From 43e96958491c72208a9de1e95fc5d46fcd3c9a6f Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 30 May 2025 16:26:33 -0300 Subject: [PATCH] SIENTIAPDE-1030 Refactor path priority handling in predictions_batch function --- orchestrator/activities/formatters.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/orchestrator/activities/formatters.py b/orchestrator/activities/formatters.py index 4317834..9d4ceb1 100644 --- a/orchestrator/activities/formatters.py +++ b/orchestrator/activities/formatters.py @@ -74,6 +74,19 @@ def overlap_filter_config(base_filter_config: dict[str, Any], config: dict[str, return base_filter_config +def process_path_priority(path_priority: list[str]): + for priority in path_priority[:]: + if priority not in ["STOP", "CONTINUE", "REPEAT"]: + path_priority.remove(priority) + + if len(path_priority) != 3: + for priority in ["STOP", "CONTINUE", "REPEAT"]: + if priority not in path_priority: + path_priority.append(priority) + + return path_priority + + def predictions_batch(config: dict[str, Any]): tags = {} for tag in config['write_tags']: @@ -92,16 +105,8 @@ def predictions_batch(config: dict[str, Any]): "data_type": tag.get('data_type', 'float'), } - path_priority = config.get('path_priority', ["STOP", "CONTINUE", "REPEAT"]) - - for priority in path_priority[:]: - if priority not in ["STOP", "CONTINUE", "REPEAT"]: - path_priority.remove(priority) - - if len(path_priority) != 3: - for priority in ["STOP", "CONTINUE", "REPEAT"]: - if priority not in path_priority: - path_priority.append(priority) + path_priority = process_path_priority(config.get( + 'path_priority', ["STOP", "CONTINUE", "REPEAT"])) return { **common_config(config),