Skip to content

Commit

Permalink
all lines
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda committed Dec 12, 2024
1 parent 7d940a4 commit a031f82
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,28 +438,36 @@ def _msgpack_default(obj: Any) -> Union[str, msgpack.ExtType]:
def _msgpack_ext_hook(code: int, data: bytes) -> Any:
if code == EXT_CONSTRUCTOR_SINGLE_ARG:
try:
tup = msgpack.unpackb(data, ext_hook=_msgpack_ext_hook)
tup = msgpack.unpackb(
data, ext_hook=_msgpack_ext_hook, strict_map_key=False
)
# module, name, arg
return getattr(importlib.import_module(tup[0]), tup[1])(tup[2])
except Exception:
return
elif code == EXT_CONSTRUCTOR_POS_ARGS:
try:
tup = msgpack.unpackb(data, ext_hook=_msgpack_ext_hook)
tup = msgpack.unpackb(
data, ext_hook=_msgpack_ext_hook, strict_map_key=False
)
# module, name, args
return getattr(importlib.import_module(tup[0]), tup[1])(*tup[2])
except Exception:
return
elif code == EXT_CONSTRUCTOR_KW_ARGS:
try:
tup = msgpack.unpackb(data, ext_hook=_msgpack_ext_hook)
tup = msgpack.unpackb(
data, ext_hook=_msgpack_ext_hook, strict_map_key=False
)
# module, name, args
return getattr(importlib.import_module(tup[0]), tup[1])(**tup[2])
except Exception:
return
elif code == EXT_METHOD_SINGLE_ARG:
try:
tup = msgpack.unpackb(data, ext_hook=_msgpack_ext_hook)
tup = msgpack.unpackb(
data, ext_hook=_msgpack_ext_hook, strict_map_key=False
)
# module, name, arg, method
return getattr(getattr(importlib.import_module(tup[0]), tup[1]), tup[3])(
tup[2]
Expand Down

0 comments on commit a031f82

Please sign in to comment.