Skip to content

Commit

Permalink
Merge pull request #4677 from jedwards4b/make_hidden_status_of_batch_…
Browse files Browse the repository at this point in the history
…xml_var

make the hidden status of batch jobs xml dependent
  • Loading branch information
jedwards4b authored Sep 10, 2024
2 parents 95c5196 + a86c8f3 commit bb13cf5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 10 deletions.
1 change: 0 additions & 1 deletion CIME/Tools/xmlchange
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ from standard_script_setup import *
from CIME.utils import (
expect,
convert_to_type,
get_batch_script_for_job,
Timeout,
)
from CIME.status import append_case_status
Expand Down
72 changes: 67 additions & 5 deletions CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, case_root=None, infile="env_batch.xml", read_only=False):
initialize an object interface to file env_batch.xml in the case directory
"""
self._batchtype = None
self._hidden_batch_script = {}
# This arbitrary setting should always be overwritten
self._default_walltime = "00:20:00"
schema = os.path.join(utils.get_schema_path(), "env_batch.xsd")
Expand Down Expand Up @@ -257,7 +258,31 @@ def make_batch_script(self, input_template, job, case, outfile=None):
subgroup=job,
overrides=overrides,
)
output_name = get_batch_script_for_job(job) if outfile is None else outfile
env_workflow = case.get_env("workflow")

hidden = env_workflow.get_value("hidden", subgroup=job)
# case.st_archive is not hidden for backward compatibility
if (
(job != "case.st_archive" and hidden is None)
or hidden == "True"
or hidden == "true"
):
self._hidden_batch_script[job] = True
else:
self._hidden_batch_script[job] = False

output_name = (
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
)
if outfile is None
else outfile
)
logger.info("Creating file {}".format(output_name))
with open(output_name, "w") as fd:
fd.write(output_text)
Expand Down Expand Up @@ -745,7 +770,17 @@ def submit_jobs(
alljobs = [
j
for j in alljobs
if os.path.isfile(os.path.join(self._caseroot, get_batch_script_for_job(j)))
if os.path.isfile(
os.path.join(
self._caseroot,
get_batch_script_for_job(
j,
hidden=self._hidden_batch_script[j]
if j in self._hidden_batch_script
else None,
),
)
)
]

startindex = 0
Expand Down Expand Up @@ -1071,22 +1106,49 @@ def _submit_single_job(
batchsubmit,
submitargs,
batchredirect,
get_batch_script_for_job(job),
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
),
)
elif batch_env_flag:
sequence = (
batchsubmit,
submitargs,
run_args,
batchredirect,
os.path.join(self._caseroot, get_batch_script_for_job(job)),
os.path.join(
self._caseroot,
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
),
),
)
else:
sequence = (
batchsubmit,
submitargs,
batchredirect,
os.path.join(self._caseroot, get_batch_script_for_job(job)),
os.path.join(
self._caseroot,
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
),
),
run_args,
)

Expand Down
2 changes: 2 additions & 0 deletions CIME/data/config/xml_schemas/config_workflow.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<!-- simple elements -->
<xs:element name="template" type="xs:anyURI"/>
<xs:element name="hidden" type="xs:string"/>
<xs:element name="task_count" type="xs:string"/>
<xs:element name="tasks_per_node" type="xs:string"/>
<xs:element name="walltime" type="xs:string"/>
Expand Down Expand Up @@ -57,6 +58,7 @@
<xs:complexType>
<xs:sequence>
<xs:element ref="template"/>
<xs:element ref="hidden" minOccurs="0"/>
<xs:element minOccurs="0" ref="dependency"/>
<xs:element ref="prereq"/>
<xs:element ref="runtime_parameters" minOccurs="0" maxOccurs="unbounded"/>
Expand Down
3 changes: 2 additions & 1 deletion CIME/tests/test_sys_cime_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ def test_self_build_cprnc(self):
)

self.run_cmd_assert_result(
"./xmlchange CCSM_CPRNC=this_is_a_broken_cprnc", from_dir=casedir
"./xmlchange CCSM_CPRNC=this_is_a_broken_cprnc --file env_test.xml",
from_dir=casedir,
)
self.run_cmd_assert_result("./case.build", from_dir=casedir)
self.run_cmd_assert_result("./case.submit", from_dir=casedir)
Expand Down
2 changes: 1 addition & 1 deletion CIME/tests/test_sys_create_newcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_a_createnewcase(self):
# on systems (like github workflow) that do not have batch, set this for the next test
if batch_system == "none":
self.run_cmd_assert_result(
'./xmlchange --subgroup case.run BATCH_COMMAND_FLAGS="-q \$JOB_QUEUE"',
r'./xmlchange --subgroup case.run BATCH_COMMAND_FLAGS="-q \$JOB_QUEUE"',
from_dir=testdir,
)

Expand Down
7 changes: 5 additions & 2 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2530,8 +2530,11 @@ def run_bld_cmd_ensure_logging(cmd, arg_logger, from_dir=None, timeout=None):
expect(stat == 0, filter_unicode(errput))


def get_batch_script_for_job(job):
return job if "st_archive" in job else "." + job
def get_batch_script_for_job(job, hidden=None):
# this if statement is for backward compatibility
if hidden is None:
hidden = job != "case.st_archive"
return "." + job if hidden else job


def string_in_list(_string, _list):
Expand Down

0 comments on commit bb13cf5

Please sign in to comment.