diff --git a/apps/step-function.json.j2 b/apps/step-function.json.j2 index 173d3acbf..f7937bb12 100644 --- a/apps/step-function.json.j2 +++ b/apps/step-function.json.j2 @@ -169,7 +169,7 @@ { "Variable": "$.job_type", "StringEquals": "{{ job_type }}", - "Next": "{{ job_spec['tasks'][0]['name'] }}" + "Next": "{{ job_spec['tasks'][0]['name'] }}{% if 'run_if' in job_spec['tasks'][0] %}_CHOICE{% endif %}" }{% if not loop.last %},{% endif %} {% endfor %} ], @@ -177,6 +177,20 @@ }, {% for job_type, job_spec in job_types.items() %} {% for task in job_spec['tasks'] %} + {% if 'run_if' in task %} + "{{ task['name'] }}_CHOICE": { + "Type": "Choice", + "Choices": [ + { + {% for key, value in task['run_if'].items() %} + "{{ key }}": {{ json.dumps(value) }}, + {% endfor %} + "Next": "{{ task['name'] }}" + } + ], + "Default": "{% if not loop.last %}{{ loop.nextitem['name'] }}{% if 'run_if' in loop.nextitem %}_CHOICE{% endif %}{% else %}GET_FILES{% endif %}" + }, + {% endif %} "{{ task['name'] }}": { "Type": "Task", "Resource": "arn:aws:states:::batch:submitJob.sync", @@ -193,7 +207,7 @@ } }, "ResultPath": "$.results.processing_results.step_{{ loop.index0 }}", - "Next": "{% if not loop.last %}{{ loop.nextitem['name'] }}{% else %}GET_FILES{% endif %}", + "Next": "{% if not loop.last %}{{ loop.nextitem['name'] }}{% if 'run_if' in loop.nextitem %}_CHOICE{% endif %}{% else %}GET_FILES{% endif %}", "Retry": [ { "ErrorEquals": [ diff --git a/job_spec/INSAR_ISCE.yml b/job_spec/INSAR_ISCE.yml index 818c0028a..d19542956 100644 --- a/job_spec/INSAR_ISCE.yml +++ b/job_spec/INSAR_ISCE.yml @@ -56,6 +56,13 @@ INSAR_ISCE: vcpu: 1 memory: 7500 - name: TROPOSPHERE + run_if: + And: + - Variable: $.job_parameters.tropospheric_model + IsPresent: true + - Not: + Variable: $.job_parameters.tropospheric_model + StringEquals: None image: ghcr.io/dbekaert/raider command: - ++process @@ -68,4 +75,4 @@ INSAR_ISCE: - Ref::tropospheric_model timeout: 10800 vcpu: 1 - memory: 7500 \ No newline at end of file + memory: 7500