|
15 | 15 | """Client and server classes corresponding to protobuf-defined services.""" |
16 | 16 | import grpc |
17 | 17 |
|
18 | | -from jetstream.core.proto import jetstream_pb2 as jetstream_dot_core_dot_proto_dot_jetstream__pb2 |
| 18 | +from jetstream.core.proto import jetstream_pb2 as jetstream__pb2 |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class OrchestratorStub(object): |
22 | | - """TODO: Merge this with main JetStream core once we settle on an API.""" |
| 22 | + """TODO: Merge this with main JetStream core once we settle on an API. |
23 | 23 |
|
24 | | - def __init__(self, channel): |
25 | | - """Constructor. |
26 | | -
|
27 | | - Args: |
28 | | - channel: A grpc.Channel. |
29 | 24 | """ |
30 | | - self.Decode = channel.unary_stream( |
31 | | - "/jetstream_proto.Orchestrator/Decode", |
32 | | - request_serializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeRequest.SerializeToString, |
33 | | - response_deserializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeResponse.FromString, |
34 | | - ) |
35 | | - self.HealthCheck = channel.unary_unary( |
36 | | - "/jetstream_proto.Orchestrator/HealthCheck", |
37 | | - request_serializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckRequest.SerializeToString, |
38 | | - response_deserializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckResponse.FromString, |
39 | | - ) |
| 25 | + |
| 26 | + def __init__(self, channel): |
| 27 | + """Constructor. |
| 28 | +
|
| 29 | + Args: |
| 30 | + channel: A grpc.Channel. |
| 31 | + """ |
| 32 | + self.Decode = channel.unary_stream( |
| 33 | + '/jetstream_proto.Orchestrator/Decode', |
| 34 | + request_serializer=jetstream__pb2.DecodeRequest.SerializeToString, |
| 35 | + response_deserializer=jetstream__pb2.DecodeResponse.FromString, |
| 36 | + ) |
| 37 | + self.HealthCheck = channel.unary_unary( |
| 38 | + '/jetstream_proto.Orchestrator/HealthCheck', |
| 39 | + request_serializer=jetstream__pb2.HealthCheckRequest.SerializeToString, |
| 40 | + response_deserializer=jetstream__pb2.HealthCheckResponse.FromString, |
| 41 | + ) |
40 | 42 |
|
41 | 43 |
|
42 | 44 | class OrchestratorServicer(object): |
43 | | - """TODO: Merge this with main JetStream core once we settle on an API.""" |
| 45 | + """TODO: Merge this with main JetStream core once we settle on an API. |
44 | 46 |
|
45 | | - def Decode(self, request, context): |
46 | | - """Query LLM to generate text or tokens.""" |
47 | | - context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
48 | | - context.set_details("Method not implemented!") |
49 | | - raise NotImplementedError("Method not implemented!") |
| 47 | + """ |
50 | 48 |
|
51 | | - def HealthCheck(self, request, context): |
52 | | - """Checks if the model server is live.""" |
53 | | - context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
54 | | - context.set_details("Method not implemented!") |
55 | | - raise NotImplementedError("Method not implemented!") |
| 49 | + def Decode(self, request, context): |
| 50 | + """Query LLM to generate text or tokens. |
| 51 | + """ |
| 52 | + context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 53 | + context.set_details('Method not implemented!') |
| 54 | + raise NotImplementedError('Method not implemented!') |
| 55 | + |
| 56 | + def HealthCheck(self, request, context): |
| 57 | + """Checks if the model server is live. |
| 58 | + """ |
| 59 | + context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 60 | + context.set_details('Method not implemented!') |
| 61 | + raise NotImplementedError('Method not implemented!') |
56 | 62 |
|
57 | 63 |
|
58 | 64 | def add_OrchestratorServicer_to_server(servicer, server): |
59 | | - rpc_method_handlers = { |
60 | | - "Decode": grpc.unary_stream_rpc_method_handler( |
61 | | - servicer.Decode, |
62 | | - request_deserializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeRequest.FromString, |
63 | | - response_serializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeResponse.SerializeToString, |
64 | | - ), |
65 | | - "HealthCheck": grpc.unary_unary_rpc_method_handler( |
66 | | - servicer.HealthCheck, |
67 | | - request_deserializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckRequest.FromString, |
68 | | - response_serializer=jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckResponse.SerializeToString, |
69 | | - ), |
70 | | - } |
71 | | - generic_handler = grpc.method_handlers_generic_handler( |
72 | | - "jetstream_proto.Orchestrator", rpc_method_handlers |
73 | | - ) |
74 | | - server.add_generic_rpc_handlers((generic_handler,)) |
75 | | - |
76 | | - |
77 | | -# This class is part of an EXPERIMENTAL API. |
| 65 | + rpc_method_handlers = { |
| 66 | + 'Decode': grpc.unary_stream_rpc_method_handler( |
| 67 | + servicer.Decode, |
| 68 | + request_deserializer=jetstream__pb2.DecodeRequest.FromString, |
| 69 | + response_serializer=jetstream__pb2.DecodeResponse.SerializeToString, |
| 70 | + ), |
| 71 | + 'HealthCheck': grpc.unary_unary_rpc_method_handler( |
| 72 | + servicer.HealthCheck, |
| 73 | + request_deserializer=jetstream__pb2.HealthCheckRequest.FromString, |
| 74 | + response_serializer=jetstream__pb2.HealthCheckResponse.SerializeToString, |
| 75 | + ), |
| 76 | + } |
| 77 | + generic_handler = grpc.method_handlers_generic_handler( |
| 78 | + 'jetstream_proto.Orchestrator', rpc_method_handlers) |
| 79 | + server.add_generic_rpc_handlers((generic_handler,)) |
| 80 | + |
| 81 | + |
| 82 | + # This class is part of an EXPERIMENTAL API. |
78 | 83 | class Orchestrator(object): |
79 | | - """TODO: Merge this with main JetStream core once we settle on an API.""" |
80 | | - |
81 | | - @staticmethod |
82 | | - def Decode( |
83 | | - request, |
84 | | - target, |
85 | | - options=(), |
86 | | - channel_credentials=None, |
87 | | - call_credentials=None, |
88 | | - insecure=False, |
89 | | - compression=None, |
90 | | - wait_for_ready=None, |
91 | | - timeout=None, |
92 | | - metadata=None, |
93 | | - ): |
94 | | - return grpc.experimental.unary_stream( |
95 | | - request, |
96 | | - target, |
97 | | - "/jetstream_proto.Orchestrator/Decode", |
98 | | - jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeRequest.SerializeToString, |
99 | | - jetstream_dot_core_dot_proto_dot_jetstream__pb2.DecodeResponse.FromString, |
100 | | - options, |
101 | | - channel_credentials, |
102 | | - insecure, |
103 | | - call_credentials, |
104 | | - compression, |
105 | | - wait_for_ready, |
106 | | - timeout, |
107 | | - metadata, |
108 | | - ) |
109 | | - |
110 | | - @staticmethod |
111 | | - def HealthCheck( |
112 | | - request, |
113 | | - target, |
114 | | - options=(), |
115 | | - channel_credentials=None, |
116 | | - call_credentials=None, |
117 | | - insecure=False, |
118 | | - compression=None, |
119 | | - wait_for_ready=None, |
120 | | - timeout=None, |
121 | | - metadata=None, |
122 | | - ): |
123 | | - return grpc.experimental.unary_unary( |
124 | | - request, |
125 | | - target, |
126 | | - "/jetstream_proto.Orchestrator/HealthCheck", |
127 | | - jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckRequest.SerializeToString, |
128 | | - jetstream_dot_core_dot_proto_dot_jetstream__pb2.HealthCheckResponse.FromString, |
129 | | - options, |
130 | | - channel_credentials, |
131 | | - insecure, |
132 | | - call_credentials, |
133 | | - compression, |
134 | | - wait_for_ready, |
135 | | - timeout, |
136 | | - metadata, |
137 | | - ) |
| 84 | + """TODO: Merge this with main JetStream core once we settle on an API. |
| 85 | +
|
| 86 | + """ |
138 | 87 |
|
| 88 | + @staticmethod |
| 89 | + def Decode(request, |
| 90 | + target, |
| 91 | + options=(), |
| 92 | + channel_credentials=None, |
| 93 | + call_credentials=None, |
| 94 | + insecure=False, |
| 95 | + compression=None, |
| 96 | + wait_for_ready=None, |
| 97 | + timeout=None, |
| 98 | + metadata=None): |
| 99 | + return grpc.experimental.unary_stream(request, target, '/jetstream_proto.Orchestrator/Decode', |
| 100 | + jetstream__pb2.DecodeRequest.SerializeToString, |
| 101 | + jetstream__pb2.DecodeResponse.FromString, |
| 102 | + options, channel_credentials, |
| 103 | + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) |
| 104 | + |
| 105 | + @staticmethod |
| 106 | + def HealthCheck(request, |
| 107 | + target, |
| 108 | + options=(), |
| 109 | + channel_credentials=None, |
| 110 | + call_credentials=None, |
| 111 | + insecure=False, |
| 112 | + compression=None, |
| 113 | + wait_for_ready=None, |
| 114 | + timeout=None, |
| 115 | + metadata=None): |
| 116 | + return grpc.experimental.unary_unary(request, target, '/jetstream_proto.Orchestrator/HealthCheck', |
| 117 | + jetstream__pb2.HealthCheckRequest.SerializeToString, |
| 118 | + jetstream__pb2.HealthCheckResponse.FromString, |
| 119 | + options, channel_credentials, |
| 120 | + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) |
0 commit comments