Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty jinja block #458

Merged
merged 14 commits into from
Feb 26, 2021
2 changes: 2 additions & 0 deletions flow/templates/base_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cd {{ project.config.project_dir }}
{% for operation in operations %}

# {{ "%s"|format(operation) }}
{% block pre_operation scoped %}
{% endblock %}
{{ operation.cmd }}{{ cmd_suffix }}
{% if operation.eligible_operations|length > 0 %}
# Eligible to run:
Expand Down
33 changes: 8 additions & 25 deletions flow/templates/stampede2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,17 @@ export LAUNCHER_JOB_FILE={{ launcher_file }}
$LAUNCHER_DIR/paramrun
rm {{ launcher_file }}
{% else %}
{% set cmd_suffix = cmd_suffix|default('') ~ (' &' if parallel else '') %}
{% for operation in operations %}

# {{ "%s"|format(operation) }}
{{ "_FLOW_STAMPEDE_OFFSET_=%d "|format(operation.directives['nranks']|return_and_increment) }}{{ operation.cmd }}{{ cmd_suffix }}
{% if operation.eligible_operations|length > 0 %}
# Eligible to run:
{% for run_op in operation.eligible_operations %}
{# The split/join handles multi-line cmd operations. #}
# {{ "\n# ".join(run_op.cmd.strip().split("\n")) }}
{% endfor %}
{% endif %}
{% if operation.operations_with_unmet_preconditions|length > 0 %}
# Operations with unmet preconditions:
{% for run_op in operation.operations_with_unmet_preconditions %}
# {{ "\n# ".join(run_op.cmd.strip().split("\n")) }}
{% endfor %}
{% endif %}
{% if operation.operations_with_met_postconditions|length > 0 %}
# Operations with all postconditions met:
{% for run_op in operation.operations_with_met_postconditions %}
# {{ "\n# ".join(run_op.cmd.strip().split("\n")) }}
{% endfor %}
{% endif %}
{% endfor %}
{# Only the pre_operation block is overridden, all other behavior is inherited from base_script.sh #}
{{ super () -}}
{# We need to reset the environment's base offset in between script generation for separate bundles. #}
{# Since Jinja's bytecode optimizes out calls to filters with a constant argument, we are forced to #}
{# rerun this function on the environment's base offset at the end of each run to return the offset to 0. #}
{{ "%d"|format(environment.base_offset)|decrement_offset }}
{% endif %}
{% endblock %}

{# This override needs to happen outside the body block above, otherwise jinja2 doesn't seem to #}
{# respect block scope and the operations variable is left undefined. #}
{% block pre_operation %}
export _FLOW_STAMPEDE_OFFSET_={{ "%d"|format(operation.directives['nranks']|return_and_increment) }}
{% endblock %}
Binary file modified tests/template_reference_data.tar.gz
Binary file not shown.