Skip to content

Commit

Permalink
chore: ensure pre-commit is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical committed Nov 25, 2022
1 parent 7617a2a commit 030a311
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 53 deletions.
15 changes: 9 additions & 6 deletions src/isolate/backends/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,20 @@ def create(self) -> List[EnvironmentDefinition]:
for env in self.target_environments:
if not env.get("kind") or not env.get("configuration"):
raise RuntimeError(f"`kind` or `configuration` key missing in: {env}")
envs.append(EnvironmentDefinition(
kind=env["kind"],
configuration=interface.to_struct(env["configuration"])))
envs.append(
EnvironmentDefinition(
kind=env["kind"],
configuration=interface.to_struct(env["configuration"]),
)
)
return envs

def exists(self) -> bool:
return False

def open_connection(
self,
connection_key: List[EnvironmentDefinition],
self,
connection_key: List[EnvironmentDefinition],
) -> IsolateServerConnection:
return IsolateServerConnection(self, self.host, connection_key)

Expand Down Expand Up @@ -100,7 +103,7 @@ def run(
method=self.environment.settings.serialization_method,
was_it_raised=False,
),
environments=self.definitions
environments=self.definitions,
)

return_value = []
Expand Down
5 changes: 1 addition & 4 deletions src/isolate/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ def wrap(

# TODO: We should think of a way to set multiple environment definitions

target_list = [{
"kind": kind,
"configuration": definition
}]
target_list = [{"kind": kind, "configuration": definition}]

# Create a remote environment.
return BoxedEnvironment(
Expand Down
25 changes: 14 additions & 11 deletions src/isolate/server/definitions/server_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions src/isolate/server/definitions/server_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,29 @@ class BoundFunction(google.protobuf.message.Message):
ENVIRONMENTS_FIELD_NUMBER: builtins.int
FUNCTION_FIELD_NUMBER: builtins.int
@property
def environments(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___EnvironmentDefinition]: ...
def environments(
self,
) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[
global___EnvironmentDefinition
]: ...
@property
def function(self) -> common_pb2.SerializedObject: ...
def __init__(
self,
*,
environments: collections.abc.Iterable[global___EnvironmentDefinition] | None = ...,
environments: collections.abc.Iterable[global___EnvironmentDefinition]
| None = ...,
function: common_pb2.SerializedObject | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["function", b"function"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["environments", b"environments", "function", b"function"]) -> None: ...
def HasField(
self, field_name: typing_extensions.Literal["function", b"function"]
) -> builtins.bool: ...
def ClearField(
self,
field_name: typing_extensions.Literal[
"environments", b"environments", "function", b"function"
],
) -> None: ...

global___BoundFunction = BoundFunction

Expand All @@ -56,7 +68,14 @@ class EnvironmentDefinition(google.protobuf.message.Message):
kind: builtins.str = ...,
configuration: google.protobuf.struct_pb2.Struct | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["configuration", b"configuration"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["configuration", b"configuration", "kind", b"kind"]) -> None: ...
def HasField(
self, field_name: typing_extensions.Literal["configuration", b"configuration"]
) -> builtins.bool: ...
def ClearField(
self,
field_name: typing_extensions.Literal[
"configuration", b"configuration", "kind", b"kind"
],
) -> None: ...

global___EnvironmentDefinition = EnvironmentDefinition
63 changes: 38 additions & 25 deletions src/isolate/server/definitions/server_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def __init__(self, channel):
channel: A grpc.Channel.
"""
self.Run = channel.unary_stream(
'/Isolate/Run',
request_serializer=server__pb2.BoundFunction.SerializeToString,
response_deserializer=common__pb2.PartialRunResult.FromString,
)
"/Isolate/Run",
request_serializer=server__pb2.BoundFunction.SerializeToString,
response_deserializer=common__pb2.PartialRunResult.FromString,
)


class IsolateServicer(object):
Expand All @@ -30,40 +30,53 @@ def Run(self, request, context):
and the result originating from that function.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")


def add_IsolateServicer_to_server(servicer, server):
rpc_method_handlers = {
'Run': grpc.unary_stream_rpc_method_handler(
servicer.Run,
request_deserializer=server__pb2.BoundFunction.FromString,
response_serializer=common__pb2.PartialRunResult.SerializeToString,
),
"Run": grpc.unary_stream_rpc_method_handler(
servicer.Run,
request_deserializer=server__pb2.BoundFunction.FromString,
response_serializer=common__pb2.PartialRunResult.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'Isolate', rpc_method_handlers)
"Isolate", rpc_method_handlers
)
server.add_generic_rpc_handlers((generic_handler,))


# This class is part of an EXPERIMENTAL API.
# This class is part of an EXPERIMENTAL API.
class Isolate(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def Run(request,
def Run(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_stream(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/Isolate/Run',
"/Isolate/Run",
server__pb2.BoundFunction.SerializeToString,
common__pb2.PartialRunResult.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
)
4 changes: 3 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ def test_server_multiple_envs(
requirements.append(f"{REPO_DIR}[grpc]")

env_definition = define_environment("virtualenv", requirements=requirements)
xtra_env_definition = define_environment("virtualenv", requirements=xtra_requirements)
xtra_env_definition = define_environment(
"virtualenv", requirements=xtra_requirements
)
request = definitions.BoundFunction(
function=to_serialized_object(
partial(
Expand Down

0 comments on commit 030a311

Please sign in to comment.