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
31 changes: 4 additions & 27 deletions flow/templates/stampede2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
{% endif %}
{% endblock %}

{% block body %}
bdice marked this conversation as resolved.
Show resolved Hide resolved
{% if ns.use_launcher %}
{% if parallel %}
{{("Bundled submission without MPI on Stampede2 is using launcher; the --parallel option is therefore ignored.")|print_warning}}
Expand All @@ -55,34 +54,12 @@ 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 #}
{% block pre_operation %}
bdice marked this conversation as resolved.
Show resolved Hide resolved
export _FLOW_STAMPEDE_OFFSET_={{ "%d"|format(operation.directives['nranks']|return_and_increment) }}
{% endblock %}
{# 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 %}