-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fal-ai/add-server
feat: Add isolate server
- Loading branch information
Showing
23 changed files
with
1,165 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
cloudpickle>=2.2.0 | ||
dill>=0.3.5.1 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,21 @@ authors = ["Features & Labels <[email protected]>"] | |
|
||
[tool.poetry.dependencies] | ||
python = ">=3.7" | ||
virtualenv = "^20" | ||
cloudpickle = "^2.2.0" | ||
importlib-metadata = "^5.0.0" | ||
virtualenv = ">=20.4" | ||
importlib-metadata = ">=4.4" | ||
flask = { version = "*", optional = true } | ||
marshmallow = { version = "*", optional = true } | ||
|
||
[tool.poetry.extras] | ||
server = ["flask", "marshmallow"] | ||
|
||
[tool.poetry.plugins."isolate.backends"] | ||
"virtualenv" = "isolate.backends.virtual_env:VirtualPythonEnvironment" | ||
"conda" = "isolate.backends.conda:CondaEnvironment" | ||
"local" = "isolate.backends.local:LocalPythonEnvironment" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
requires = ["poetry-core>=1.1.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.isort] | ||
|
@@ -20,7 +29,3 @@ force_grid_wrap=0 | |
include_trailing_comma=true | ||
multi_line_output=3 | ||
use_parentheses=true | ||
|
||
[tool.poetry.plugins."isolate.backends"] | ||
"virtualenv" = "isolate.backends.virtual_env:VirtualPythonEnvironment" | ||
"conda" = "isolate.backends.conda:CondaEnvironment" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from isolate.managed import EnvironmentManager | ||
from isolate.registry import prepare_environment | ||
|
||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from isolate.backends.connections.ipc import ( | ||
DualPythonIPC, | ||
ExtendedPythonIPC, | ||
IsolatedProcessConnection, | ||
PythonIPC, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from isolate.backends.connections.ipc._base import ( | ||
DualPythonIPC, | ||
ExtendedPythonIPC, | ||
IsolatedProcessConnection, | ||
PythonIPC, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import Any, ClassVar, Dict | ||
|
||
from isolate.backends import BaseEnvironment | ||
from isolate.backends.common import sha256_digest_of | ||
from isolate.backends.connections import PythonIPC | ||
from isolate.backends.context import GLOBAL_CONTEXT, ContextType | ||
|
||
|
||
@dataclass | ||
class LocalPythonEnvironment(BaseEnvironment[Path]): | ||
BACKEND_NAME: ClassVar[str] = "local" | ||
|
||
@classmethod | ||
def from_config( | ||
cls, | ||
config: Dict[str, Any], | ||
context: ContextType = GLOBAL_CONTEXT, | ||
) -> BaseEnvironment: | ||
environment = cls() | ||
environment.set_context(context) | ||
return environment | ||
|
||
@property | ||
def key(self) -> str: | ||
return sha256_digest_of(sys.exec_prefix) | ||
|
||
def create(self) -> Path: | ||
return Path(sys.exec_prefix) | ||
|
||
def destroy(self, connection_key: Path) -> None: | ||
raise NotImplementedError("LocalPythonEnvironment cannot be destroyed") | ||
|
||
def exists(self) -> bool: | ||
return True | ||
|
||
def open_connection(self, connection_key: Path) -> PythonIPC: | ||
return PythonIPC(self, connection_key) |
Oops, something went wrong.