Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/generated/test_bundles_chrysalis.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[default]
case = v2.LR.historical_0201
constraint = ""
environment_commands = "source /lcrc/soft/climate/e3sm-unified/test_e3sm_unified_1.8.0rc6_chrysalis.sh"
environment_commands = "source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh"
input = "/lcrc/group/e3sm/ac.forsyth2/E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "/home/ac.zender/data/maps/map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[default]
case = v2.LR.historical_0201
constraint = ""
environment_commands = "source /lcrc/soft/climate/e3sm-unified/test_e3sm_unified_1.8.0rc6_chrysalis.sh"
environment_commands = "source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh"
input = "/lcrc/group/e3sm/ac.forsyth2//E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "/home/ac.zender/data/maps/map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@ def generate_cfgs(unified_testing=False):


if __name__ == "__main__":
generate_cfgs(True)
generate_cfgs()
20 changes: 12 additions & 8 deletions zppy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def main(): # noqa: C901
username = os.environ.get("USER")
output = output.replace("$USER", username)
scriptDir = os.path.join(output, "post/scripts")
job_ids_file = os.path.join(scriptDir, "jobids.txt")
try:
os.makedirs(scriptDir)
except OSError as exc:
Expand Down Expand Up @@ -134,28 +135,30 @@ def main(): # noqa: C901
existing_bundles = predefined_bundles(config, scriptDir, existing_bundles)

# climo tasks
existing_bundles = climo(config, scriptDir, existing_bundles)
existing_bundles = climo(config, scriptDir, existing_bundles, job_ids_file)

# time series tasks
existing_bundles = ts(config, scriptDir, existing_bundles)
existing_bundles = ts(config, scriptDir, existing_bundles, job_ids_file)

# tc_analysis tasks
existing_bundles = tc_analysis(config, scriptDir, existing_bundles)
existing_bundles = tc_analysis(config, scriptDir, existing_bundles, job_ids_file)

# e3sm_diags tasks
existing_bundles = e3sm_diags(config, scriptDir, existing_bundles)
existing_bundles = e3sm_diags(config, scriptDir, existing_bundles, job_ids_file)

# amwg tasks
existing_bundles = amwg(config, scriptDir, existing_bundles)
existing_bundles = amwg(config, scriptDir, existing_bundles, job_ids_file)

# mpas_analysis tasks
existing_bundles = mpas_analysis(config, scriptDir, existing_bundles)
existing_bundles = mpas_analysis(config, scriptDir, existing_bundles, job_ids_file)

# global time series tasks
existing_bundles = global_time_series(config, scriptDir, existing_bundles)
existing_bundles = global_time_series(
config, scriptDir, existing_bundles, job_ids_file
)

# ilamb tasks
existing_bundles = ilamb(config, scriptDir, existing_bundles)
existing_bundles = ilamb(config, scriptDir, existing_bundles, job_ids_file)

# Submit bundle jobs
for b in existing_bundles:
Expand All @@ -169,6 +172,7 @@ def main(): # noqa: C901
b.bundle_file,
b.bundle_status,
b.export,
job_ids_file,
dependFiles=b.dependencies_external,
)

Expand Down
8 changes: 6 additions & 2 deletions zppy/amwg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# -----------------------------------------------------------------------------
def amwg(config, scriptDir, existing_bundles):
def amwg(config, scriptDir, existing_bundles, job_ids_file):

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -79,7 +79,11 @@ def amwg(config, scriptDir, existing_bundles):
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)
else:
print("...adding to bundle '%s'" % (c["bundle"]))
Expand Down
4 changes: 2 additions & 2 deletions zppy/climo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# -----------------------------------------------------------------------------
def climo(config, scriptDir, existing_bundles):
def climo(config, scriptDir, existing_bundles, job_ids_file):

# --- Initialize jinja2 template engine ---
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -95,7 +95,7 @@ def climo(config, scriptDir, existing_bundles):
if not c["dry_run"]:
if c["bundle"] == "":
# Submit job
submitScript(scriptFile, statusFile, export)
submitScript(scriptFile, statusFile, export, job_ids_file)
else:
print("...adding to bundle '%s'" % (c["bundle"]))

Expand Down
8 changes: 6 additions & 2 deletions zppy/e3sm_diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -----------------------------------------------------------------------------
# FIXME: C901 'e3sm_diags' is too complex (20)
def e3sm_diags(config, scriptDir, existing_bundles): # noqa: C901
def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -214,7 +214,11 @@ def e3sm_diags(config, scriptDir, existing_bundles): # noqa: C901
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)

# Due to a `socket.gaierror: [Errno -2] Name or service not known` error when running e3sm_diags with tc_analysis
Expand Down
8 changes: 6 additions & 2 deletions zppy/global_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# -----------------------------------------------------------------------------
def global_time_series(config, scriptDir, existing_bundles):
def global_time_series(config, scriptDir, existing_bundles, job_ids_file):

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -124,7 +124,11 @@ def global_time_series(config, scriptDir, existing_bundles):
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)
else:
print("...adding to bundle '%s'" % (c["bundle"]))
Expand Down
8 changes: 6 additions & 2 deletions zppy/ilamb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# -----------------------------------------------------------------------------
def ilamb(config, scriptDir, existing_bundles):
def ilamb(config, scriptDir, existing_bundles, job_ids_file):

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -118,7 +118,11 @@ def ilamb(config, scriptDir, existing_bundles):
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)
else:
print("...adding to bundle '%s'" % (c["bundle"]))
Expand Down
8 changes: 6 additions & 2 deletions zppy/mpas_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# -----------------------------------------------------------------------------
def mpas_analysis(config, scriptDir, existing_bundles):
def mpas_analysis(config, scriptDir, existing_bundles, job_ids_file):

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -123,7 +123,11 @@ def mpas_analysis(config, scriptDir, existing_bundles):
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)

# Note that this line should still be executed even if jobid == -1
Expand Down
8 changes: 6 additions & 2 deletions zppy/tc_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


# -----------------------------------------------------------------------------
def tc_analysis(config, scriptDir, existing_bundles):
def tc_analysis(config, scriptDir, existing_bundles, job_ids_file):

# Initialize jinja2 template engine
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -78,7 +78,11 @@ def tc_analysis(config, scriptDir, existing_bundles):
if c["bundle"] == "":
# Submit job
submitScript(
scriptFile, statusFile, export, dependFiles=dependencies
scriptFile,
statusFile,
export,
job_ids_file,
dependFiles=dependencies,
)

# Note that this line should still be executed even if jobid == -1
Expand Down
4 changes: 2 additions & 2 deletions zppy/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


# -----------------------------------------------------------------------------
def ts(config, scriptDir, existing_bundles):
def ts(config, scriptDir, existing_bundles, job_ids_file):

# --- Initialize jinja2 template engine ---
templateLoader = jinja2.FileSystemLoader(
Expand Down Expand Up @@ -108,7 +108,7 @@ def ts(config, scriptDir, existing_bundles):
if not c["dry_run"]:
if c["bundle"] == "":
# Submit job
submitScript(scriptFile, statusFile, export)
submitScript(scriptFile, statusFile, export, job_ids_file)
else:
print("...adding to bundle '%s'" % (c["bundle"]))

Expand Down
7 changes: 6 additions & 1 deletion zppy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def getComponent(input_files):


# -----------------------------------------------------------------------------
def submitScript(scriptFile, statusFile, export, dependFiles=[]):
def submitScript(scriptFile, statusFile, export, job_ids_file, dependFiles=[]):

# id of submitted job, or -1 if not submitted
jobid = None
Expand Down Expand Up @@ -209,6 +209,11 @@ def submitScript(scriptFile, statusFile, export, dependFiles=[]):
print(stderr)
raise RuntimeError(error_str)
jobid = int(out.split()[-1])
with open(job_ids_file, "a") as j:
# To include the scriptFile, use this line:
# j.write(f"{scriptFile}: {jobid}\n")
# To cancel all jobs associated with this zppy run, use `xargs scancel < jobids.txt`.
j.write(f"{jobid}\n")

# Small pause to avoid overloading queueing system
time.sleep(0.2)
Expand Down