From 7b893ad59717f09443248310d972fb92116ea49f Mon Sep 17 00:00:00 2001 From: Deepak K <89829542+Deepak-Kesavan@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:07:47 +0530 Subject: [PATCH] [FIX] Structure tool metrics error fix (#906) Handled case where metrics is missing in the output Co-authored-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> --- tools/structure/src/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/structure/src/main.py b/tools/structure/src/main.py index 6d1b16287..e9c671ea1 100644 --- a/tools/structure/src/main.py +++ b/tools/structure/src/main.py @@ -253,7 +253,7 @@ def run( structured_output_dict[SettingsKeys.METADATA] = metadata structured_output = json.dumps(structured_output_dict) - metrics = structured_output_dict[SettingsKeys.METRICS] + metrics = structured_output_dict.get(SettingsKeys.METRICS, {}) new_metrics = {} if tool_settings[SettingsKeys.ENABLE_SINGLE_PASS_EXTRACTION]: new_metrics = { @@ -267,7 +267,8 @@ def run( for key in set(metrics) | set(index_metrics) # Union of keys from both dictionaries } - structured_output_dict[SettingsKeys.METRICS] = new_metrics + if new_metrics: + structured_output_dict[SettingsKeys.METRICS] = new_metrics # Update GUI output_log = ( f"## Result\n**NOTE:** In case of a deployed pipeline, the result would "