Skip to content

Commit

Permalink
Merge pull request #12 from fal-ai/revert-renaming
Browse files Browse the repository at this point in the history
Revert "insulate -> isolate" renaming
  • Loading branch information
isidentical authored Oct 10, 2022
2 parents 03b86fa + eaa7597 commit d195cdc
Show file tree
Hide file tree
Showing 27 changed files with 86 additions and 83 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Insulate
# Isolate

> :warning: **Insulate** is still very young, and none of the APIs should be considered stable.
> :warning: **Isolate** is still very young, and none of the APIs should be considered stable.
Run any Python function, with any dependencies, in any machine you want. Insulate offers a
Run any Python function, with any dependencies, in any machine you want. Isolate offers a
pluggable end-to-end solution for building, managing, and using isolated environments (virtualenv,
conda, and possibly more).

Expand Down Expand Up @@ -30,6 +30,6 @@ rest of your code running in a different machine).
However, unlike "virtual environment" concept, each of the projects that tried to tackle
this problem lacked a universal interface which one can simply define a set of requirements
(this might be dependencies, size of the machine that is needed to run it, or something completely
different) and can change it without any loss. Insulate is working towards a future where this
different) and can change it without any loss. Isolate is working towards a future where this
transititon is as seamless as the transition from your local environment to the remote
environment.
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "insulate"
version = "0.1.1"
name = "isolate"
version = "0.1.0"
readme = "README.md"
description = "Managed isolated environments for Python"
authors = ["Features & Labels <hello@fal.ai>"]
Expand All @@ -15,10 +15,10 @@ marshmallow = { version = "*", optional = true }
[tool.poetry.extras]
server = ["flask", "marshmallow"]

[tool.poetry.plugins."insulate.backends"]
"virtualenv" = "insulate.backends.virtual_env:VirtualPythonEnvironment"
"conda" = "insulate.backends.conda:CondaEnvironment"
"local" = "insulate.backends.local:LocalPythonEnvironment"
[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.1.0"]
Expand Down
3 changes: 0 additions & 3 deletions src/insulate/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion src/insulate/backends/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion src/insulate/server/__init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions src/isolate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from isolate.registry import prepare_environment

__version__ = "0.1.0"
1 change: 1 addition & 0 deletions src/isolate/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from isolate.backends._base import *
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
TypeVar,
)

from insulate.backends.context import (
from isolate.backends.context import (
GLOBAL_CONTEXT,
ContextType,
Log,
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions src/insulate/backends/conda.py → src/isolate/backends/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
from pathlib import Path
from typing import Any, ClassVar, Dict, List

from insulate.backends import BaseEnvironment, EnvironmentCreationError
from insulate.backends.common import (
from isolate.backends import BaseEnvironment, EnvironmentCreationError
from isolate.backends.common import (
cache_static,
logged_io,
rmdir_on_fail,
sha256_digest_of,
)
from insulate.backends.connections import PythonIPC
from insulate.backends.context import GLOBAL_CONTEXT, ContextType
from isolate.backends.connections import PythonIPC
from isolate.backends.context import GLOBAL_CONTEXT, ContextType

# Specify the path where the conda binary might reside in (or
# mamba, if it is the preferred one).
_CONDA_COMMAND = os.environ.get("CONDA_EXE", "conda")
_INSULATE_CONDA_HOME = os.getenv("INSULATE_CONDA_HOME")
_ISOLATE_CONDA_HOME = os.getenv("ISOLATE_CONDA_HOME")


@dataclass
Expand Down Expand Up @@ -91,14 +91,14 @@ def open_connection(self, connection_key: Path) -> PythonIPC:

@cache_static
def _get_conda_executable() -> Path:
for path in [_INSULATE_CONDA_HOME, None]:
for path in [_ISOLATE_CONDA_HOME, None]:
conda_path = shutil.which(_CONDA_COMMAND, path=path)
if conda_path is not None:
return Path(conda_path)
else:
# TODO: we should probably show some instructions on how you
# can install conda here.
raise FileNotFoundError(
"Could not find conda executable. If conda executable is not available by default, "
"please point insulate to the path where conda binary is available 'INSULATE_CONDA_HOME'."
"Could not find conda executable. If conda executable is not available by default, please point isolate "
" to the path where conda binary is available 'ISOLATE_CONDA_HOME'."
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from insulate.backends.connections.ipc import (
from isolate.backends.connections.ipc import (
ExtendedPythonIPC,
IsolatedProcessConnection,
PythonIPC,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from insulate.backends.connections.ipc._base import (
from isolate.backends.connections.ipc._base import (
ExtendedPythonIPC,
IsolatedProcessConnection,
PythonIPC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
from pathlib import Path
from typing import Any, ContextManager, Dict, Iterator, List, Tuple, Union

from insulate.backends import (
from isolate.backends import (
BasicCallable,
CallResultType,
EnvironmentConnection,
UserException,
)
from insulate.backends.common import (
from isolate.backends.common import (
get_executable_path,
logged_io,
python_path_for,
)
from insulate.backends.connections.ipc import agent
from insulate.backends.context import LogLevel, LogSource
from isolate.backends.connections.ipc import agent
from isolate.backends.context import LogLevel, LogSource


class _MultiFormatListener(Listener):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file defines an "insulate" agent for inter-process communication over
# This file defines an "isolate" agent for inter-process communication over
# sockets. It is spawned by the controller process with a single argument (a
# base64 encoded server address) and expected to go through the following procedures:
# 1. Decode the given address
Expand Down Expand Up @@ -72,7 +72,7 @@ def child_connection(
)


IS_DEBUG_MODE = os.getenv("INSULATE_ENABLE_DEBUGGING") == "1"
IS_DEBUG_MODE = os.getenv("ISOLATE_ENABLE_DEBUGGING") == "1"
DEBUG_TIMEOUT = 60 * 15


Expand All @@ -86,7 +86,7 @@ def run_client(
# so we want to have a smooth way into the process and see
# what is really going on in the case of errors.
#
# For using the debug mode, you first need to set INSULATE_ENABLE_DEBUGGING
# For using the debug mode, you first need to set ISOLATE_ENABLE_DEBUGGING
# environment variable to "1" from your controller process. This will
# make the isolated process hang at the initialization, and make it print
# the instructions to connect to the controller process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from platformdirs import user_cache_dir

if TYPE_CHECKING:
from insulate.backends import BaseEnvironment
from isolate.backends import BaseEnvironment


class LogSource(str, Enum):
Expand Down Expand Up @@ -97,7 +97,7 @@ def serialization_backend_name(self) -> str:
GLOBAL_CONTEXT = ContextType(
_Context(
_base_cache_dir=Path(
user_cache_dir("insulate", "insulate"),
user_cache_dir("isolate", "isolate"),
)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from pathlib import Path
from typing import Any, ClassVar, Dict

from insulate.backends import BaseEnvironment
from insulate.backends.common import sha256_digest_of
from insulate.backends.connections import PythonIPC
from insulate.backends.context import GLOBAL_CONTEXT, ContextType
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Union

from insulate.backends import BaseEnvironment, EnvironmentCreationError
from insulate.backends.common import (
from isolate.backends import BaseEnvironment, EnvironmentCreationError
from isolate.backends.common import (
get_executable_path,
logged_io,
rmdir_on_fail,
sha256_digest_of,
)
from insulate.backends.connections import PythonIPC
from insulate.backends.context import GLOBAL_CONTEXT, ContextType
from isolate.backends.connections import PythonIPC
from isolate.backends.context import GLOBAL_CONTEXT, ContextType


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions src/insulate/registry.py → src/isolate/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import importlib_metadata

if TYPE_CHECKING:
from insulate.backends import BaseEnvironment
from isolate.backends import BaseEnvironment

# Any new environments can register themselves during package installation
# time by simply adding an entry point to the `insulate.environment` group.
_ENTRY_POINT = "insulate.backends"
# time by simply adding an entry point to the `isolate.environment` group.
_ENTRY_POINT = "isolate.backends"


_ENVIRONMENT_REGISTRY: Dict[str, Type["BaseEnvironment"]] = {}
Expand All @@ -33,7 +33,7 @@ def prepare_environment(
**kwargs: Any,
) -> BaseEnvironment:
"""Get the environment for the given `kind` with the given `config`."""
from insulate.backends.context import GLOBAL_CONTEXT
from isolate.backends.context import GLOBAL_CONTEXT

registered_env_cls = _ENVIRONMENT_REGISTRY.get(kind)
if not registered_env_cls:
Expand Down
1 change: 1 addition & 0 deletions src/isolate/server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from isolate.server._server import app
File renamed without changes.
14 changes: 7 additions & 7 deletions src/insulate/server/_runs.py → src/isolate/server/_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
from pathlib import Path
from typing import Any, List, Optional

from insulate.backends import (
from isolate.backends import (
BaseEnvironment,
EnvironmentCreationError,
UserException,
)
from insulate.backends.common import run_serialized
from insulate.backends.connections import ExtendedPythonIPC
from insulate.backends.context import Log, LogLevel, LogSource
from isolate.backends.common import run_serialized
from isolate.backends.connections import ExtendedPythonIPC
from isolate.backends.context import Log, LogLevel, LogSource

# TODO: This is currently a server-level setting, but if it makes sense
# we can add it as a configuration variable to venv/conda etc (all the
# environments that use Python IPC).
INHERIT_FROM_LOCAL = os.getenv("INSULATE_INHERIT_FROM_LOCAL") == "1"
INHERIT_FROM_LOCAL = os.getenv("ISOLATE_INHERIT_FROM_LOCAL") == "1"


@dataclass
Expand Down Expand Up @@ -53,7 +53,7 @@ def run_serialized_function_in_env(

# Probably something wrong with the environment definition (e.g
# pip installing something that is not on PyPI), so we don't need
# to crash the whole application insulate server.
# to crash the whole application isolate server.
return None

inherit_from = []
Expand All @@ -62,7 +62,7 @@ def run_serialized_function_in_env(
# sysconfig, but Debian is a notorious outlier so it should be noted
# that this won't work with 'system Python' on debian based systems.
#
# You can still inherit from a venv you activated to run the insulate
# You can still inherit from a venv you activated to run the isolate
# server though (even on debian). Always use virtual environments.
local_env = Path(sys.exec_prefix)
inherit_from.append(local_env)
Expand Down
12 changes: 6 additions & 6 deletions src/insulate/server/_server.py → src/isolate/server/_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

from flask import Flask, request

from insulate import prepare_environment
from insulate.backends import BaseEnvironment
from insulate.backends.context import GLOBAL_CONTEXT
from insulate.server._models import (
from isolate import prepare_environment
from isolate.backends import BaseEnvironment
from isolate.backends.context import GLOBAL_CONTEXT
from isolate.server._models import (
Environment,
EnvironmentRun,
StatusRequest,
with_schema,
)
from insulate.server._runs import RunInfo, run_serialized_function_in_env
from insulate.server._utils import (
from isolate.server._runs import RunInfo, run_serialized_function_in_env
from isolate.server._utils import (
error,
load_token,
success,
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import pytest

from insulate.backends import BaseEnvironment, EnvironmentCreationError
from insulate.backends.common import get_executable_path, sha256_digest_of
from insulate.backends.conda import CondaEnvironment, _get_conda_executable
from insulate.backends.context import _Context
from insulate.backends.local import LocalPythonEnvironment
from insulate.backends.virtual_env import VirtualPythonEnvironment
from isolate.backends import BaseEnvironment, EnvironmentCreationError
from isolate.backends.common import get_executable_path, sha256_digest_of
from isolate.backends.conda import CondaEnvironment, _get_conda_executable
from isolate.backends.context import _Context
from isolate.backends.local import LocalPythonEnvironment
from isolate.backends.virtual_env import VirtualPythonEnvironment


class GenericCreationTests:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import pytest

from insulate.backends import BaseEnvironment, UserException
from insulate.backends.connections import ExtendedPythonIPC, PythonIPC
from insulate.backends.context import _Context
from insulate.backends.virtual_env import VirtualPythonEnvironment
from isolate.backends import BaseEnvironment, UserException
from isolate.backends.connections import ExtendedPythonIPC, PythonIPC
from isolate.backends.context import _Context
from isolate.backends.virtual_env import VirtualPythonEnvironment


class FakeEnvironment(BaseEnvironment):
Expand Down
10 changes: 5 additions & 5 deletions tests/test_insulate.py → tests/test_isolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import pytest

from insulate import prepare_environment
from isolate import prepare_environment


@pytest.fixture
def fresh_registry(monkeypatch):
"""Temporarily clear the environment registry for this test. Also restores
back to the initial state once the test is executed."""
monkeypatch.setattr("insulate.registry._ENVIRONMENT_REGISTRY", {})
monkeypatch.setattr("isolate.registry._ENVIRONMENT_REGISTRY", {})


def test_unknown_environment(fresh_registry):
Expand All @@ -23,14 +23,14 @@ def test_environment_discovery(fresh_registry):

from importlib_metadata import EntryPoint, EntryPoints

from insulate.registry import _ENTRY_POINT, _reload_registry
from isolate.registry import _ENTRY_POINT, _reload_registry

fake_ep = create_autospec(
EntryPoint,
)
fake_ep.name = "fake"
fake_ep.value = "insulate.backends._base.BaseEnvironment"
fake_ep.group = "insulate.environments"
fake_ep.value = "isolate.backends._base.BaseEnvironment"
fake_ep.group = "isolate.environments"

with patch("importlib_metadata.entry_points", return_value=EntryPoints([fake_ep])):
_reload_registry()
Expand Down
Loading

0 comments on commit d195cdc

Please sign in to comment.