Skip to content

Commit

Permalink
fix(jobs): handle optional null artifact inputs
Browse files Browse the repository at this point in the history
Artifact inputs can be optional and null. If this is the case we should not populate default
arguments with them.

re pollination/pollination-server#146
  • Loading branch information
AntoineDao committed Jun 3, 2021
1 parent 17f972c commit 61c2fbf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
9 changes: 6 additions & 3 deletions queenbee/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ def populate_default_arguments(self, inputs: List[DAGInputs]):
found_argument = True

if not found_argument and not recipe_input.required:
if recipe_input.is_artifact:
argument = None
if recipe_input.is_artifact and \
recipe_input.default is not None:
argument = JobPathArgument(
name=recipe_input.name,
source=recipe_input.default,
)
else:
elif recipe_input.is_parameter:
argument = JobArgument(
name=recipe_input.name,
value=recipe_input.default,
)
combination.append(argument)
if argument is not None:
combination.append(argument)

def validate_arguments(self, inputs: List[DAGInputs]):
errors = []
Expand Down
17 changes: 15 additions & 2 deletions tests/job/job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def optional_artifact_input():
)


@pytest.fixture
def optional_artifact_input_with_no_default():
return DAGPathInput(
name='optional-artifact-input-no-default',
required=False,
)


@pytest.fixture
def required_artifact_input():
return DAGPathInput(
Expand All @@ -47,8 +55,13 @@ def required_inputs(required_parameter_input, required_artifact_input):


@pytest.fixture
def optional_inputs(optional_parameter_input, optional_artifact_input):
return [optional_parameter_input, optional_artifact_input]
def optional_inputs(optional_parameter_input, optional_artifact_input,
optional_artifact_input_with_no_default):
return [
optional_parameter_input,
optional_artifact_input,
optional_artifact_input_with_no_default
]


@pytest.fixture
Expand Down

0 comments on commit 61c2fbf

Please sign in to comment.