Skip to content

Commit

Permalink
Improve carryover dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 committed Sep 23, 2024
1 parent 7c7a8e9 commit 4b9660f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions zppy/e3sm_diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
return existing_bundles

# --- Generate and submit e3sm_diags scripts ---
dependencies: List[str] = []
carried_over_dependencies: List[str] = []

for c in tasks:

dependencies: List[str] = carried_over_dependencies

c["scriptDir"] = scriptDir

if "ts_num_years" in c.keys():
Expand Down Expand Up @@ -237,6 +239,8 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
end_yr,
c["ts_num_years"],
)

c["dependencies"] = dependencies
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down Expand Up @@ -267,7 +271,7 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
# Note that this line should still be executed even if jobid == -1
# The later tc_analysis-using e3sm_diags tasks still depend on this task (and thus will also fail).
# Add to the dependency list
dependencies.append(statusFile)
carried_over_dependencies.append(statusFile)
else:
print("...adding to bundle '%s'" % (c["bundle"]))

Expand Down
1 change: 1 addition & 0 deletions zppy/global_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def global_time_series(config, scriptDir, existing_bundles, job_ids_file): # no
)
)

c["dependencies"] = dependencies
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down
5 changes: 3 additions & 2 deletions zppy/ilamb.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def ilamb(config, scriptDir, existing_bundles, job_ids_file):
return existing_bundles

# --- Generate and submit ilamb scripts ---
dependencies: List[str] = []

for c in tasks:

dependencies: List[str] = []

if "ts_num_years" in c.keys():
c["ts_num_years"] = int(c["ts_num_years"])

Expand Down Expand Up @@ -94,6 +94,7 @@ def ilamb(config, scriptDir, existing_bundles, job_ids_file):
f.write(template.render(**c))
makeExecutable(scriptFile)

c["dependencies"] = dependencies
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down
10 changes: 8 additions & 2 deletions zppy/mpas_analysis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pprint
from typing import List

import jinja2

Expand Down Expand Up @@ -35,10 +36,14 @@ def mpas_analysis(config, scriptDir, existing_bundles, job_ids_file):
# job should run at once. To gracefully handle this, we make each
# MAPS-Analysis task dependant on all previous ones. This may not
# be 100% fool-proof, but should be a reasonable start
dependencies = []

# Dependencies carried over from previous task.
carried_over_dependencies: List[str] = []

for c in tasks:

dependencies: List[str] = carried_over_dependencies

if config["mpas_analysis"]["shortTermArchive"]:
c["subdir_ocean"] = "/archive/ocn/hist"
c["subdir_ice"] = "/archive/ice/hist"
Expand Down Expand Up @@ -105,6 +110,7 @@ def mpas_analysis(config, scriptDir, existing_bundles, job_ids_file):
f.write(template.render(**c))
makeExecutable(scriptFile)

c["dependencies"] = dependencies
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down Expand Up @@ -133,7 +139,7 @@ def mpas_analysis(config, scriptDir, existing_bundles, job_ids_file):
# Note that this line should still be executed even if jobid == -1
# The later MPAS-Analysis tasks still depend on this task (and thus will also fail).
# Add to the dependency list
dependencies.append(statusFile)
carried_over_dependencies.append(statusFile)
else:
print("...adding to bundle '%s'" % (c["bundle"]))

Expand Down
9 changes: 7 additions & 2 deletions zppy/tc_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ def tc_analysis(config, scriptDir, existing_bundles, job_ids_file):

# There is a `GenerateConnectivityFile: error while loading shared libraries: libnetcdf.so.11: cannot open shared object file: No such file or directory` error
# when multiple year_sets are run simultaneously. Therefore, we will wait for the completion of one year_set before moving on to the next.
dependencies: List[str] = []

# Dependencies carried over from previous task.
carried_over_dependencies: List[str] = []

for c in tasks:

dependencies: List[str] = carried_over_dependencies

# Loop over year sets
year_sets = getYears(c["years"])
for s in year_sets:
Expand Down Expand Up @@ -61,6 +65,7 @@ def tc_analysis(config, scriptDir, existing_bundles, job_ids_file):
f.write(template.render(**c))
makeExecutable(scriptFile)

c["dependencies"] = dependencies
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down Expand Up @@ -88,7 +93,7 @@ def tc_analysis(config, scriptDir, existing_bundles, job_ids_file):
# Note that this line should still be executed even if jobid == -1
# The later tc_analysis tasks still depend on this task (and thus will also fail).
# Add to the dependency list
dependencies.append(statusFile)
carried_over_dependencies.append(statusFile)
else:
print("...adding to bundle '%s'" % (c["bundle"]))

Expand Down

0 comments on commit 4b9660f

Please sign in to comment.