hostel-protocol-python 0.3.0__tar.gz → 0.3.2__tar.gz
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.
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/PKG-INFO +1 -1
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/pyproject.toml +1 -1
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/converter.py +19 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.github/workflows/ci.yml +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.github/workflows/publish.yml +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.gitignore +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/Makefile +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/client/__init__.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/client/client.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/__init__.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/models.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/py.typed +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/__init__.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/transport.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/zeromq.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/__init__.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_client.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_converter.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_models.py +0 -0
- {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_transport.py +0 -0
{hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/converter.py
RENAMED
|
@@ -98,6 +98,14 @@ _SUB_MSG_FIELDS: dict[type[Message], dict[str, type[Message]]] = {
|
|
|
98
98
|
task_pb2.UpdateTaskResponse: {"task": task_pb2.TaskData},
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
# Enum fields: proto class -> {field_name: {int_value: str_value}}
|
|
102
|
+
# Used to convert between proto integer enum values and Pydantic string literals.
|
|
103
|
+
_ENUM_FIELDS: dict[type[Message], dict[str, dict[int, str]]] = {
|
|
104
|
+
chat_pb2.ChatRequest: {
|
|
105
|
+
"planning_mode": {0: "react", 1: "plan_and_execute"},
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
101
109
|
# oneof groups: proto class -> {field_name: proto sub-message class}
|
|
102
110
|
_ONEOF_FIELDS: dict[type[Message], dict[str, type[Message]]] = {
|
|
103
111
|
chat_pb2.ChatMessage: {
|
|
@@ -196,6 +204,7 @@ def _pydantic_to_proto_inner(model: BaseModel, proto_cls: type[Message]) -> Mess
|
|
|
196
204
|
repeated_fields = _REPEATED_MSG_FIELDS.get(proto_cls, {})
|
|
197
205
|
sub_msg_fields = _SUB_MSG_FIELDS.get(proto_cls, {})
|
|
198
206
|
oneof_fields = _ONEOF_FIELDS.get(proto_cls, {})
|
|
207
|
+
enum_fields = _ENUM_FIELDS.get(proto_cls, {})
|
|
199
208
|
|
|
200
209
|
# Special handling for HostelMessage payload oneof
|
|
201
210
|
is_envelope = proto_cls is message_pb2.HostelMessage
|
|
@@ -252,6 +261,11 @@ def _pydantic_to_proto_inner(model: BaseModel, proto_cls: type[Message]) -> Mess
|
|
|
252
261
|
if child_pydantic_cls and isinstance(value, child_pydantic_cls):
|
|
253
262
|
getattr(proto, field_name).CopyFrom(_pydantic_to_proto_inner(value, child_proto_cls))
|
|
254
263
|
|
|
264
|
+
# Enum fields (string literal -> int)
|
|
265
|
+
elif field_name in enum_fields:
|
|
266
|
+
str_to_int = {v: k for k, v in enum_fields[field_name].items()}
|
|
267
|
+
setattr(proto, field_name, str_to_int[value])
|
|
268
|
+
|
|
255
269
|
# Scalar fields
|
|
256
270
|
else:
|
|
257
271
|
setattr(proto, field_name, value)
|
|
@@ -280,6 +294,7 @@ def _proto_to_pydantic_inner(proto: Message, pydantic_cls: type[BaseModel]) -> B
|
|
|
280
294
|
repeated_fields = _REPEATED_MSG_FIELDS.get(proto_cls, {})
|
|
281
295
|
sub_msg_fields = _SUB_MSG_FIELDS.get(proto_cls, {})
|
|
282
296
|
oneof_fields = _ONEOF_FIELDS.get(proto_cls, {})
|
|
297
|
+
enum_fields = _ENUM_FIELDS.get(proto_cls, {})
|
|
283
298
|
|
|
284
299
|
is_envelope = proto_cls is message_pb2.HostelMessage
|
|
285
300
|
|
|
@@ -361,6 +376,10 @@ def _proto_to_pydantic_inner(proto: Message, pydantic_cls: type[BaseModel]) -> B
|
|
|
361
376
|
else:
|
|
362
377
|
kwargs[field_name] = None
|
|
363
378
|
|
|
379
|
+
# Enum fields (int -> string literal)
|
|
380
|
+
elif field_name in enum_fields:
|
|
381
|
+
kwargs[field_name] = enum_fields[field_name][getattr(proto, field_name)]
|
|
382
|
+
|
|
364
383
|
# Scalar fields
|
|
365
384
|
else:
|
|
366
385
|
kwargs[field_name] = getattr(proto, field_name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/__init__.py
RENAMED
|
File without changes
|
{hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/transport.py
RENAMED
|
File without changes
|
{hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/zeromq.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|