MCPcopy Index your code
hub / github.com/feast-dev/feast / _patch_proto_json_encoding

Function _patch_proto_json_encoding

sdk/python/feast/proto_json.py:20–33  ·  view source on GitHub ↗

Patch Protobuf JSON Encoder / Decoder for a desired Protobuf type with to_json & from_json methods.

(
    proto_type: Type[ProtoMessage],
    to_json_object: Callable[[_Printer, ProtoMessage], JsonObject],
    from_json_object: Callable[[_Parser, JsonObject, ProtoMessage], None],
)

Source from the content-addressed store, hash-verified

18
19
20def _patch_proto_json_encoding(
21 proto_type: Type[ProtoMessage],
22 to_json_object: Callable[[_Printer, ProtoMessage], JsonObject],
23 from_json_object: Callable[[_Parser, JsonObject, ProtoMessage], None],
24) -> None:
25 """Patch Protobuf JSON Encoder / Decoder for a desired Protobuf type with to_json & from_json methods."""
26 to_json_fn_name = "_" + uuid.uuid4().hex
27 from_json_fn_name = "_" + uuid.uuid4().hex
28 setattr(_Printer, to_json_fn_name, to_json_object)
29 setattr(_Parser, from_json_fn_name, from_json_object)
30 _WKTJSONMETHODS[proto_type.DESCRIPTOR.full_name] = [
31 to_json_fn_name,
32 from_json_fn_name,
33 ]
34
35
36def _patch_feast_value_json_encoding():

Calls

no outgoing calls

Tested by

no test coverage detected