Skip to content

Commit

Permalink
feat: make logging labels updatable for submit tasks (#153)
Browse files Browse the repository at this point in the history
* new proto metadata for tasks

* adapt the server
  • Loading branch information
chamini2 authored Sep 18, 2024
1 parent 5aaf154 commit 509b139
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 75 deletions.
18 changes: 10 additions & 8 deletions src/isolate/connections/grpc/definitions/agent_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import builtins
from isolate.connections.grpc.definitions import common_pb2
import google.protobuf.descriptor
import google.protobuf.message
import typing
import sys

if sys.version_info >= (3, 8):
import typing as typing_extensions
else:
import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing.final
@typing_extensions.final
class FunctionCall(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -20,23 +24,21 @@ class FunctionCall(google.protobuf.message.Message):
@property
def function(self) -> common_pb2.SerializedObject:
"""The function to execute and return the results to."""

@property
def setup_func(self) -> common_pb2.SerializedObject:
"""Optionally the setup function which will be passed
as the first argument to the given function. This
has to be an idempotent step since the result for
this executable will be cached.
"""

def __init__(
self,
*,
function: common_pb2.SerializedObject | None = ...,
setup_func: common_pb2.SerializedObject | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["_setup_func", b"_setup_func", "function", b"function", "setup_func", b"setup_func"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["_setup_func", b"_setup_func", "function", b"function", "setup_func", b"setup_func"]) -> None: ...
def WhichOneof(self, oneof_group: typing.Literal["_setup_func", b"_setup_func"]) -> typing.Literal["setup_func"] | None: ...
def HasField(self, field_name: typing_extensions.Literal["_setup_func", b"_setup_func", "function", b"function", "setup_func", b"setup_func"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_setup_func", b"_setup_func", "function", b"function", "setup_func", b"setup_func"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["_setup_func", b"_setup_func"]) -> typing_extensions.Literal["setup_func"] | None: ...

global___FunctionCall = FunctionCall
25 changes: 11 additions & 14 deletions src/isolate/connections/grpc/definitions/common_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import builtins
import collections.abc
import google.protobuf.descriptor
Expand Down Expand Up @@ -62,7 +61,7 @@ STDOUT: LogLevel.ValueType # 5
STDERR: LogLevel.ValueType # 6
global___LogLevel = LogLevel

@typing.final
@typing_extensions.final
class SerializedObject(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand Down Expand Up @@ -90,13 +89,13 @@ class SerializedObject(google.protobuf.message.Message):
was_it_raised: builtins.bool = ...,
stringized_traceback: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["_stringized_traceback", b"_stringized_traceback", "stringized_traceback", b"stringized_traceback"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["_stringized_traceback", b"_stringized_traceback", "definition", b"definition", "method", b"method", "stringized_traceback", b"stringized_traceback", "was_it_raised", b"was_it_raised"]) -> None: ...
def WhichOneof(self, oneof_group: typing.Literal["_stringized_traceback", b"_stringized_traceback"]) -> typing.Literal["stringized_traceback"] | None: ...
def HasField(self, field_name: typing_extensions.Literal["_stringized_traceback", b"_stringized_traceback", "stringized_traceback", b"stringized_traceback"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_stringized_traceback", b"_stringized_traceback", "definition", b"definition", "method", b"method", "stringized_traceback", b"stringized_traceback", "was_it_raised", b"was_it_raised"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["_stringized_traceback", b"_stringized_traceback"]) -> typing_extensions.Literal["stringized_traceback"] | None: ...

global___SerializedObject = SerializedObject

@typing.final
@typing_extensions.final
class PartialRunResult(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -110,25 +109,23 @@ class PartialRunResult(google.protobuf.message.Message):
"""A list of logs collected during this partial execution. It does
not include old logs.
"""

@property
def result(self) -> global___SerializedObject:
"""The result of the run, if it is complete."""

def __init__(
self,
*,
is_complete: builtins.bool = ...,
logs: collections.abc.Iterable[global___Log] | None = ...,
result: global___SerializedObject | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["_result", b"_result", "result", b"result"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["_result", b"_result", "is_complete", b"is_complete", "logs", b"logs", "result", b"result"]) -> None: ...
def WhichOneof(self, oneof_group: typing.Literal["_result", b"_result"]) -> typing.Literal["result"] | None: ...
def HasField(self, field_name: typing_extensions.Literal["_result", b"_result", "result", b"result"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_result", b"_result", "is_complete", b"is_complete", "logs", b"logs", "result", b"result"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["_result", b"_result"]) -> typing_extensions.Literal["result"] | None: ...

global___PartialRunResult = PartialRunResult

@typing.final
@typing_extensions.final
class Log(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -149,7 +146,7 @@ class Log(google.protobuf.message.Message):
level: global___LogLevel.ValueType = ...,
timestamp: google.protobuf.timestamp_pb2.Timestamp | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["timestamp", b"timestamp"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["level", b"level", "message", b"message", "source", b"source", "timestamp", b"timestamp"]) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["timestamp", b"timestamp"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["level", b"level", "message", b"message", "source", b"source", "timestamp", b"timestamp"]) -> None: ...

global___Log = Log
18 changes: 18 additions & 0 deletions src/isolate/server/definitions/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ service Isolate {
// Submit a function to be run without waiting for results.
rpc Submit (SubmitRequest) returns (SubmitResponse) {}

// Set the metadata for a task.
rpc SetMetadata (SetMetadataRequest) returns (SetMetadataResponse) {}

// List running tasks
rpc List (ListRequest) returns (ListResponse) {}

Expand All @@ -36,12 +39,27 @@ message EnvironmentDefinition {
message SubmitRequest {
// The function to run.
BoundFunction function = 1;
// Task metadata.
TaskMetadata metadata = 2;
}

message TaskMetadata {
// Labels to attach to the logs.
map<string, string> logger_labels = 1;
}

message SubmitResponse {
string task_id = 1;
}

message SetMetadataRequest{
string task_id = 1;
TaskMetadata metadata = 2;
}

message SetMetadataResponse {
}

message ListRequest {
}

Expand Down
42 changes: 26 additions & 16 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.

Loading

0 comments on commit 509b139

Please sign in to comment.