Skip to content

Commit

Permalink
create input file with empty string if input value_from_service fails…
Browse files Browse the repository at this point in the history
… to return a result for a given source and is not required
  • Loading branch information
nathandf committed Jan 5, 2024
1 parent 60e8c50 commit 9c69b54
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/engine/src/core/tasks/TaskInputFileStagingService.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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":
Expand All @@ -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)

Expand Down

0 comments on commit 9c69b54

Please sign in to comment.