isolate 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isolate/__init__.py +3 -0
- isolate/_isolate_version.py +34 -0
- isolate/_version.py +6 -0
- isolate/backends/__init__.py +2 -0
- isolate/backends/_base.py +132 -0
- isolate/backends/common.py +259 -0
- isolate/backends/conda.py +215 -0
- isolate/backends/container.py +64 -0
- isolate/backends/local.py +46 -0
- isolate/backends/pyenv.py +143 -0
- isolate/backends/remote.py +141 -0
- isolate/backends/settings.py +121 -0
- isolate/backends/virtualenv.py +204 -0
- isolate/common/__init__.py +0 -0
- isolate/common/timestamp.py +15 -0
- isolate/connections/__init__.py +21 -0
- isolate/connections/_local/__init__.py +2 -0
- isolate/connections/_local/_base.py +190 -0
- isolate/connections/_local/agent_startup.py +53 -0
- isolate/connections/common.py +121 -0
- isolate/connections/grpc/__init__.py +1 -0
- isolate/connections/grpc/_base.py +175 -0
- isolate/connections/grpc/agent.py +284 -0
- isolate/connections/grpc/configuration.py +23 -0
- isolate/connections/grpc/definitions/__init__.py +11 -0
- isolate/connections/grpc/definitions/agent.proto +18 -0
- isolate/connections/grpc/definitions/agent_pb2.py +29 -0
- isolate/connections/grpc/definitions/agent_pb2.pyi +44 -0
- isolate/connections/grpc/definitions/agent_pb2_grpc.py +68 -0
- isolate/connections/grpc/definitions/common.proto +49 -0
- isolate/connections/grpc/definitions/common_pb2.py +35 -0
- isolate/connections/grpc/definitions/common_pb2.pyi +152 -0
- isolate/connections/grpc/definitions/common_pb2_grpc.py +4 -0
- isolate/connections/grpc/interface.py +71 -0
- isolate/connections/ipc/__init__.py +5 -0
- isolate/connections/ipc/_base.py +225 -0
- isolate/connections/ipc/agent.py +205 -0
- isolate/logger.py +53 -0
- isolate/logs.py +76 -0
- isolate/py.typed +0 -0
- isolate/registry.py +53 -0
- isolate/server/__init__.py +1 -0
- isolate/server/definitions/__init__.py +13 -0
- isolate/server/definitions/server.proto +80 -0
- isolate/server/definitions/server_pb2.py +56 -0
- isolate/server/definitions/server_pb2.pyi +241 -0
- isolate/server/definitions/server_pb2_grpc.py +205 -0
- isolate/server/health/__init__.py +11 -0
- isolate/server/health/health.proto +23 -0
- isolate/server/health/health_pb2.py +32 -0
- isolate/server/health/health_pb2.pyi +66 -0
- isolate/server/health/health_pb2_grpc.py +99 -0
- isolate/server/health_server.py +40 -0
- isolate/server/interface.py +27 -0
- isolate/server/server.py +735 -0
- isolate-0.22.0.dist-info/METADATA +88 -0
- isolate-0.22.0.dist-info/RECORD +61 -0
- isolate-0.22.0.dist-info/WHEEL +5 -0
- isolate-0.22.0.dist-info/entry_points.txt +7 -0
- isolate-0.22.0.dist-info/licenses/LICENSE +201 -0
- isolate-0.22.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import AsyncIterator
|
|
4
|
+
|
|
5
|
+
from grpc.aio import ServicerContext
|
|
6
|
+
|
|
7
|
+
from isolate.server import health
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class HealthServicer(health.HealthServicer):
|
|
12
|
+
def __post_init__(self):
|
|
13
|
+
self._state = {
|
|
14
|
+
# Empty refers to the whole server
|
|
15
|
+
"": health.HealthCheckResponse.ServingStatus.SERVING,
|
|
16
|
+
"isolate": health.HealthCheckResponse.ServingStatus.SERVING,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def _get_status(
|
|
20
|
+
self, service: str
|
|
21
|
+
) -> health.HealthCheckResponse.ServingStatus.ValueType:
|
|
22
|
+
status = self._state.get(
|
|
23
|
+
service,
|
|
24
|
+
health.HealthCheckResponse.ServingStatus.SERVICE_UNKNOWN,
|
|
25
|
+
)
|
|
26
|
+
return status
|
|
27
|
+
|
|
28
|
+
def Check(
|
|
29
|
+
self, request: health.HealthCheckRequest, context: ServicerContext
|
|
30
|
+
) -> health.HealthCheckResponse:
|
|
31
|
+
return health.HealthCheckResponse(status=self._get_status(request.service))
|
|
32
|
+
|
|
33
|
+
async def Watch(
|
|
34
|
+
self,
|
|
35
|
+
request: health.HealthCheckRequest,
|
|
36
|
+
context: ServicerContext,
|
|
37
|
+
) -> AsyncIterator[health.HealthCheckResponse]:
|
|
38
|
+
while True:
|
|
39
|
+
yield health.HealthCheckResponse(status=self._get_status(request.service))
|
|
40
|
+
await asyncio.sleep(2)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
from isolate.backends import BaseEnvironment
|
|
4
|
+
from isolate.connections.grpc.interface import (
|
|
5
|
+
from_grpc,
|
|
6
|
+
to_grpc,
|
|
7
|
+
to_serialized_object,
|
|
8
|
+
)
|
|
9
|
+
from isolate.server import definitions
|
|
10
|
+
|
|
11
|
+
__all__ = ["from_grpc", "to_grpc", "to_serialized_object", "to_struct"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@from_grpc.register
|
|
15
|
+
def _(message: definitions.EnvironmentDefinition) -> BaseEnvironment:
|
|
16
|
+
from isolate import prepare_environment
|
|
17
|
+
|
|
18
|
+
return prepare_environment(
|
|
19
|
+
message.kind,
|
|
20
|
+
**definitions.struct_to_dict(message.configuration),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def to_struct(data: Dict[str, Any]) -> definitions.Struct:
|
|
25
|
+
struct = definitions.Struct()
|
|
26
|
+
struct.update(data)
|
|
27
|
+
return struct
|