Skip to content

Commit

Permalink
Avoid __getitem__ calls on a PrefectFuture or State in checking…
Browse files Browse the repository at this point in the history
… `Flow` parameter serialization (#14900)
  • Loading branch information
Andrew-S-Rosen authored Aug 13, 2024
1 parent aad6693 commit 007cb64
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/prefect/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,17 @@ def serialize_parameters(self, parameters: Dict[str, Any]) -> Dict[str, Any]:
# do not serialize the bound self object
if self.ismethod and value is self.fn.__prefect_self__:
continue
if isinstance(value, (PrefectFuture, State)):
# Don't call jsonable_encoder() on a PrefectFuture or State to
# avoid triggering a __getitem__ call
serialized_parameters[key] = f"<{type(value).__name__}>"
continue
try:
serialized_parameters[key] = jsonable_encoder(value)
except (TypeError, ValueError):
logger.debug(
f"Parameter {key!r} for flow {self.name!r} is of unserializable "
f"type {type(value).__name__!r} and will not be stored "
f"Parameter {key!r} for flow {self.name!r} is unserializable. "
f"Type {type(value).__name__!r} and will not be stored "
"in the backend."
)
serialized_parameters[key] = f"<{type(value).__name__}>"
Expand Down

0 comments on commit 007cb64

Please sign in to comment.