Skip to content

Commit

Permalink
Fix templates so they work with new StrictUndefined setting for rende…
Browse files Browse the repository at this point in the history
…ring

In some cases, we want template rendering to fail if a variable is not defined.  In other cases, we want to check for definition, and if it's not defined, proceed without executing a certain part of the template.  Specifying the latter as {% if key is defined %} rather than {% if key %}  allows us to do that.
  • Loading branch information
shreyb committed Jun 28, 2022
1 parent cae6d90 commit f6fbb3d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions templates/dag/dag.dag.condor.sub
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ environment = _CONDOR_SCHEDD_ADDRESS_FILE=/var/lib/condor/spool/.schedd_address
x509userproxy = {{proxy}}
{{lines|join("\n+")}}

{% if subgroup %}
{% if subgroup is defined %}
+AccountingGroup = "group_{{group}}.{{subgroup}}.{{user}}"
{% else %}
+AccountingGroup = "group_{{group}}.{{user}}"
Expand All @@ -37,7 +37,7 @@ x509userproxy = {{proxy}}
+Jobsub_Group="{{group}}"
+JobsubJobId="$(CLUSTER).$(PROCESS)@{{schedd}}"

{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
use_oauth_services = {{group}}_{{role}}
{% else %}
use_oauth_services = {{group}}
Expand Down
2 changes: 1 addition & 1 deletion templates/dag/dagman_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# condor wants to copy in the condor_dagman executable, but we
# want it to run the local one, so we give it this one...

{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
export BEARER_TOKEN_FILE=$_CONDOR_CREDS/{{group}}_{{role}}.use
{% else %}
export BEARER_TOKEN_FILE=$_CONDOR_CREDS/{{group}}.use
Expand Down
16 changes: 8 additions & 8 deletions templates/dataset_dag/dagbegin.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by jobsub_lite
# {%if debug%}debug{%endif%}
# {%if debug is defined%}debug{%endif%}
universe = vanilla
executable = sambegin.sh
arguments =
Expand All @@ -19,10 +19,10 @@ transfer_error = True
transfer_executable= True
when_to_transfer_output = ON_EXIT_OR_EVICT
transfer_output_files = .empty_file
{%if cpu %}request_cpus = {{cpu}}{%endif%}
{%if memory %}request_memory = {{memory}}{%endif%}
{%if disk %}request_disk = {{disk}}KB{%endif%}
{%if OS %}+DesiredOS={{OS}}{%endif%}
{%if cpu is defined %}request_cpus = {{cpu}}{%endif%}
{%if memory is defined %}request_memory = {{memory}}{%endif%}
{%if disk is defined %}request_disk = {{disk}}KB{%endif%}
{%if OS is defined %}+DesiredOS={{OS}}{%endif%}
+JobsubClientDN="{{clientdn}}"
+JobsubClientIpAddress="{{ipaddr}}"
+Owner="{{user}}"
Expand All @@ -35,19 +35,19 @@ notify_user = {{email_to}}
+Jobsub_Group="{{group}}"
+JobsubJobId="$(CLUSTER).$(PROCESS)@{{schedd}}"
+Drain = False
{%if blacklist %}
{%if blacklist is defined %}
+Blacklist_Sites = "{{blacklist}}"
{% endif %}
+GeneratedBy ="{{version}} {{schedd}}"
{{resource_provides_quoted|join("\n+DESIRED_")}}
{{lines|join("\n+")}}
requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))) {%if append_condor_requirements %} && {{append_condor_requirements}} {%endif%}
requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))) {%if append_condor_requirements is defined %} && {{append_condor_requirements}} {%endif%}

{% if no_singularity is false %}
+SingularityImage="{{singularity_image}}"
{% endif %}

{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
use_oauth_services = {{group}}_{{role}}
{% else %}
use_oauth_services = {{group}}
Expand Down
16 changes: 8 additions & 8 deletions templates/dataset_dag/dagend.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by jobsub_lite
# {%if debug%}debug{%endif%}
# {%if debug is defined %}debug{%endif%}
universe = vanilla
executable = samend.sh
arguments =
Expand All @@ -20,10 +20,10 @@ transfer_error = True
transfer_executable= True
transfer_output_files=.empty_file
when_to_transfer_output = ON_EXIT_OR_EVICT
{%if cpu %}request_cpus = {{cpu}}{%endif%}
{%if memory %}request_memory = {{memory}}{%endif%}
{%if disk %}request_disk = {{disk}}KB{%endif%}
{%if OS %}+DesiredOS={{OS}}{%endif%}
{%if cpu is defined %}request_cpus = {{cpu}}{%endif%}
{%if memory is defined %}request_memory = {{memory}}{%endif%}
{%if disk is defined %}request_disk = {{disk}}KB{%endif%}
{%if OS is defined %}+DesiredOS={{OS}}{%endif%}
+JobsubClientDN="{{clientdn}}"
+JobsubClientIpAddress="{{ipaddr}}"
+Owner="{{user}}"
Expand All @@ -36,19 +36,19 @@ notify_user = {{email_to}}
+Jobsub_Group="{{group}}"
+JobsubJobId="$(CLUSTER).$(PROCESS)@{{schedd}}"
+Drain = False
{%if blacklist %}
{%if blacklist is defined%}
+Blacklist_Sites = "{{blacklist}}"
{% endif %}
+GeneratedBy ="{{version}} {{schedd}}"
{{resource_provides_quoted|join("\n+DESIRED_")}}
{{lines|join("\n+")}}
requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))) {%if append_condor_requirements %} && {{append_condor_requirements}} {%endif%}
requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))) {%if append_condor_requirements is defined%} && {{append_condor_requirements}} {%endif%}

{% if no_singularity is false %}
+SingularityImage="{{singularity_image}}"
{% endif %}

{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
use_oauth_services = {{group}}_{{role}}
{% else %}
use_oauth_services = {{group}}
Expand Down
20 changes: 10 additions & 10 deletions templates/simple/simple.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# generated by jobsub_lite
# {%if debug%}debug{%endif%}
# {%if debug is defined %}debug{%endif%}
universe = vanilla
executable = {{script_name|default('simple.sh')}}
arguments = {{exe_arguments|join(" ")}}
Expand All @@ -18,10 +18,10 @@ transfer_executable= True
transfer_input_files = {{executable|basename}}
when_to_transfer_output = ON_EXIT_OR_EVICT
transfer_output_files = .empty_file
{%if cpu %}request_cpus = {{cpu}}{%endif%}
{%if memory %}request_memory = {{memory}}{%endif%}
{%if disk %}request_disk = {{disk}}KB{%endif%}
{%if OS %}+DesiredOS={{OS}}{%endif%}
{%if cpu is defined %}request_cpus = {{cpu}}{%endif%}
{%if memory is defined %}request_memory = {{memory}}{%endif%}
{%if disk is defined %}request_disk = {{disk}}KB{%endif%}
{%if OS is defined %}+DesiredOS={{OS}}{%endif%}
+JobsubClientDN="{{clientdn}}"
+JobsubClientIpAddress="{{ipaddr}}"
+Owner="{{user}}"
Expand All @@ -31,7 +31,7 @@ transfer_output_files = .empty_file
+JOB_EXPECTED_MAX_LIFETIME = {{expected_lifetime}}
notify_user = {{email_to}}

{% if subgroup %}
{% if subgroup is defined %}
+AccountingGroup = "group_{{group}}.{{subgroup}}.{{user}}"
{% else %}
+AccountingGroup = "group_{{group}}.{{user}}"
Expand All @@ -41,16 +41,16 @@ notify_user = {{email_to}}
+JobsubJobId="$(CLUSTER).$(PROCESS)@{{schedd}}"
+Drain = False

{% if site and site != 'LOCAL' %}
{% if site is defined and site != 'LOCAL' %}
+DESIRED_SITES = "{{site}}"
{% endif %}
{%if blacklist %}
{%if blacklist is defined %}
+Blacklist_Sites = "{{blacklist}}"
{% endif %}
+GeneratedBy ="{{version}} {{schedd}}"
{{resource_provides_quoted|join("\n+DESIRED_")}}
{{lines|join("\n+")}}
requirements = {%if overwrite_requirements %}{{overwrite_requirements}}{%else%}target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))){%endif%}{%if append_condor_requirements %} && {{append_condor_requirements}} {%endif%}
requirements = {%if overwrite_requirements is defined %}{{overwrite_requirements}}{%else%}target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && (isUndefined(DesiredOS) || stringListsIntersect(toUpper(DesiredOS),IFOS_installed)) && (stringListsIntersect(toUpper(target.HAS_usage_model), toUpper(my.DESIRED_usage_model))){%endif%}{%if append_condor_requirements is defined %} && {{append_condor_requirements}} {%endif%}

{% if no_singularity is false %}
+SingularityImage="{{singularity_image}}"
Expand All @@ -63,7 +63,7 @@ requirements = {%if overwrite_requirements %}{{overwrite_requirements}}{%else%}
#
#
#
{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
use_oauth_services = {{group}}_{{role}}
{% else %}
use_oauth_services = {{group}}
Expand Down
4 changes: 2 additions & 2 deletions templates/simple/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

umask 002

{% if role and role != 'Analysis' %}
{% if role is defined and role != 'Analysis' %}
export BEARER_TOKEN_FILE=$PWD/.condor_creds/{{group}}_{{role}}.use
{% else %}
export BEARER_TOKEN_FILE=$PWD/.condor_creds/{{group}}.use
Expand Down Expand Up @@ -320,7 +320,7 @@ ${JSB_TMP}/ifdh.sh log poms_data=$poms_data
echo `date` $JOBSUBJOBID BEGIN EXECUTION $JOBSUB_EXE_SCRIPT {{exe_arguments|join(" ")}} >&2
echo `date` $JOBSUBJOBID BEGIN EXECUTION $JOBSUB_EXE_SCRIPT {{exe_arguments|join(" ")}}

{%if timeout%} timeout {{timeout}} {%endif%} $JOBSUB_EXE_SCRIPT {{exe_arguments|join(" ")}}
{%if timeout is defined %} timeout {{timeout}} {%endif%} $JOBSUB_EXE_SCRIPT {{exe_arguments|join(" ")}}
JOB_RET_STATUS=$?

# copy out -d directories
Expand Down

0 comments on commit f6fbb3d

Please sign in to comment.