From 9c69b549b8f5134f9b1eafbe4eb39986d653cf47 Mon Sep 17 00:00:00 2001 From: Nathan Freeman Date: Fri, 5 Jan 2024 16:28:07 -0600 Subject: [PATCH] create input file with empty string if input value_from_service fails to return a result for a given source and is not required --- .../src/core/tasks/TaskInputFileStagingService.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/engine/src/core/tasks/TaskInputFileStagingService.py b/src/engine/src/core/tasks/TaskInputFileStagingService.py index e1a79a1c..f5a65b9c 100644 --- a/src/engine/src/core/tasks/TaskInputFileStagingService.py +++ b/src/engine/src/core/tasks/TaskInputFileStagingService.py @@ -19,7 +19,8 @@ def __init__( value_from_service: ValueFromService ): self._value_from_service = value_from_service - + + # TODO Improve error handling below. Catch specific errors from the value from service def stage(self, task: Task): """Iterates over all of the items in the task input dictionary, fetches the values from their sources, then creates the files in the task's @@ -28,7 +29,8 @@ def stage(self, task: Task): if input_.value != None: self._create_input_(task, input_id, input_.value) continue - + + value = None value_from = input_.value_from key = list(value_from.keys())[0] # NOTE Should only have 1 key if key == "task_output": @@ -38,21 +40,24 @@ def stage(self, task: Task): _id=value_from[key].output_id ) except Exception as e: - raise TaskInputStagingError(f"No output found for task '{value_from[key].task_id}' with output id of '{value_from[key].output_id}' | {e}") + if input_.required: + raise TaskInputStagingError(f"No output found for task '{value_from[key].task_id}' with output id of '{value_from[key].output_id}' | {e}") if key == "args": try: value = self._value_from_service.get_arg_value_by_key( value_from[key] ) except Exception as e: - raise TaskInputStagingError(f"Error attempting to fetch value from args at key '{value_from[key]}' | {e}") + if input_.required: + raise TaskInputStagingError(f"Error attempting to fetch value from args at key '{value_from[key]}' | {e}") if key == "env": try: value = self._value_from_service.get_env_value_by_key( value_from[key] ) except Exception as e: - raise TaskInputStagingError(f"Error attempting to fetch value from env at key '{value_from[key]}' | {e}") + if input_.required: + raise TaskInputStagingError(f"Error attempting to fetch value from env at key '{value_from[key]}' | {e}") self._create_input_(task, input_id, value)