From e7621922975b16d624cc563dbf58d57d555c24f1 Mon Sep 17 00:00:00 2001 From: Sakari Ikonen Date: Mon, 27 Jan 2025 15:17:50 +0200 Subject: [PATCH] json serialize the ancestry metadata --- metaflow/client/core.py | 5 +++-- metaflow/task.py | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/metaflow/client/core.py b/metaflow/client/core.py index 410965cfbc5..a39f2f58286 100644 --- a/metaflow/client/core.py +++ b/metaflow/client/core.py @@ -1224,10 +1224,11 @@ def _get_metadata_query_vals( def _get_related_tasks(self, is_ancestor: bool) -> Dict[str, List[str]]: flow_id, run_id, _, _ = self.path_components metadata_dict = self.metadata_dict + # The specific values in the metadata are json serialized strings, so we need to load them before use. steps = ( - metadata_dict.get("previous-steps") + json.loads(metadata_dict.get("previous-steps")) if is_ancestor - else metadata_dict.get("successor-steps") + else json.loads(metadata_dict.get("successor-steps")) ) if not steps: diff --git a/metaflow/task.py b/metaflow/task.py index d2396ede928..7e61d64702c 100644 --- a/metaflow/task.py +++ b/metaflow/task.py @@ -523,19 +523,19 @@ def run_step( [ MetaDatum( field="foreach-indices", - value=foreach_indices, + value=json.dumps(foreach_indices), type="foreach-indices", tags=metadata_tags, ), MetaDatum( field="foreach-indices-truncated", - value=foreach_indices_truncated, + value=json.dumps(foreach_indices_truncated), type="foreach-indices-truncated", tags=metadata_tags, ), MetaDatum( field="foreach-step-names", - value=foreach_step_names, + value=json.dumps(foreach_step_names), type="foreach-step-names", tags=metadata_tags, ), @@ -783,13 +783,13 @@ def run_step( ), MetaDatum( field="previous-steps", - value=previous_steps, + value=json.dumps(previous_steps), type="previous-steps", tags=metadata_tags, ), MetaDatum( field="successor-steps", - value=successor_steps, + value=json.dumps(successor_steps), type="successor-steps", tags=metadata_tags, ),