Skip to content

Commit

Permalink
improve functionality of hidden workflow flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Sep 12, 2024
1 parent bb13cf5 commit c565ac1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 deletions.
39 changes: 7 additions & 32 deletions CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ 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 @@ -213,6 +212,7 @@ def get_job_overrides(self, job, case):
thread_count,
ngpus_per_node,
) = env_workflow.get_job_specs(case, job)

overrides = {}

if total_tasks:
Expand Down Expand Up @@ -258,18 +258,6 @@ def make_batch_script(self, input_template, job, case, outfile=None):
subgroup=job,
overrides=overrides,
)
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(
Expand Down Expand Up @@ -509,6 +497,7 @@ def get_batch_directives(self, case, job, overrides=None, output_format="default
""" """
result = []
directive_prefix = None
self._hidden_batch_script[job] = self.hidden_status(case, job)

roots = self.get_children("batch_system")
queue = case.get_value("JOB_QUEUE", subgroup=job)
Expand Down Expand Up @@ -774,10 +763,7 @@ def submit_jobs(
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,
j, hidden=env_workflow.hidden_job(case, j)
),
)
)
Expand Down Expand Up @@ -1100,6 +1086,7 @@ def _submit_single_job(
set_continue_run=resubmit_immediate,
submit_resubmits=workflow and not resubmit_immediate,
)
env_workflow = case.get_env("workflow")
if batch_system == "lsf" and not batch_env_flag:
sequence = (
run_args,
Expand All @@ -1108,11 +1095,7 @@ def _submit_single_job(
batchredirect,
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
hidden=env_workflow.hidden_job(case, job),
),
)
elif batch_env_flag:
Expand All @@ -1125,11 +1108,7 @@ def _submit_single_job(
self._caseroot,
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
hidden=env_workflow.hidden_job(case, job),
),
),
)
Expand All @@ -1142,11 +1121,7 @@ def _submit_single_job(
self._caseroot,
get_batch_script_for_job(
job,
hidden=(
self._hidden_batch_script[job]
if job in self._hidden_batch_script
else None
),
hidden=env_workflow.hidden_job(case, job),
),
),
run_args,
Expand Down
12 changes: 12 additions & 0 deletions CIME/XML/env_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from CIME.XML.standard_module_setup import *
from CIME.XML.env_base import EnvBase
from CIME.utils import get_cime_root

import re, math

logger = logging.getLogger(__name__)
Expand All @@ -21,6 +22,7 @@ def __init__(self, case_root=None, infile="env_workflow.xml", read_only=False):
# schema = os.path.join(get_cime_root(), "CIME", "config", "xml_schemas", "env_workflow.xsd")
# TODO: define schema for this file
schema = None
self._hidden = {}
super(EnvWorkflow, self).__init__(
case_root, infile, schema=schema, read_only=read_only
)
Expand Down Expand Up @@ -89,7 +91,17 @@ def get_type_info(self, vid):
)
return type_info

def hidden_job(self, case, job):
if job not in self._hidden:
self.get_job_specs(case, job)
return self._hidden[job]

def get_job_specs(self, case, job):
hidden = self.get_value("hidden", subgroup=job)
self._hidden[job] = (hidden is None and job != "case.st_archive") or (
hidden is not None and hidden.lower() == "true"
)

task_count = case.get_resolved_value(self.get_value("task_count", subgroup=job))
tasks_per_node = case.get_resolved_value(
self.get_value("tasks_per_node", subgroup=job)
Expand Down

0 comments on commit c565ac1

Please sign in to comment.