-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New command-line access to provenance capabilities
1) New save_provenance tool. Allows use to execute provenance capabilities from command-line and independent from running the case. 1.a) Allows users to decide to save timing info after a run without having to rerun. 2) Move getTiming implementation to a library so it does not have to be invoked via shell command line. 3) Encapsulate provenance-related code in it's own library: provenance.py 4) Improve quality of save-timing regression test 5) Add regression test for save_provenance 6) Simplify get_timing call from case_run
- Loading branch information
Showing
10 changed files
with
958 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
This tool provide command-line access to provenance-saving functionality | ||
""" | ||
|
||
from standard_script_setup import * | ||
|
||
from CIME.case import Case | ||
from CIME.provenance import * | ||
from CIME.utils import get_lids | ||
from CIME.get_timing import get_timing | ||
|
||
############################################################################### | ||
def parse_command_line(args, description): | ||
############################################################################### | ||
parser = argparse.ArgumentParser( | ||
usage="""\n%s <MODE> [<casedir>] [--verbose] | ||
OR | ||
%s --help | ||
OR | ||
%s --test | ||
\033[1mEXAMPLES:\033[0m | ||
\033[1;32m# Save run (timing) provenance for current case \033[0m | ||
> %s postrun | ||
""" % ((os.path.basename(args[0]), ) * 4), | ||
description=description, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
) | ||
|
||
CIME.utils.setup_standard_logging_options(parser) | ||
|
||
parser.add_argument("mode", choices=("build", "prerun", "postrun"), | ||
help="Phase for which to save provenance. " | ||
"prerun is mostly for infrastructure testing; " | ||
"it does not make sense to store this information manually otherwise") | ||
|
||
parser.add_argument("caseroot", nargs="?", default=os.getcwd(), | ||
help="Case directory") | ||
|
||
parser.add_argument("-l", "--lid", | ||
help="Force system to save provenance with this LID") | ||
|
||
args = parser.parse_args(args[1:]) | ||
|
||
CIME.utils.handle_standard_logging_options(args) | ||
|
||
return args.mode, args.caseroot, args.lid | ||
|
||
############################################################################### | ||
def _main_func(description): | ||
############################################################################### | ||
mode, caseroot, lid = parse_command_line(sys.argv, description) | ||
with Case(caseroot, read_only=False) as case: | ||
if mode == "build": | ||
expect(False, "Saving build provenance manually is not currently supported " | ||
"but it should already always be happening automatically") | ||
save_build_provenance(case, lid=lid) | ||
elif mode == "prerun": | ||
expect(lid is not None, "You must provide LID for prerun mode") | ||
save_prerun_provenance(case, lid=lid) | ||
elif mode == "postrun": | ||
expect(lid is None, "Please allow me to autodetect LID") | ||
model = case.get_value("MODEL") | ||
caseid = case.get_value("CASE") | ||
case.set_value("SAVE_TIMING", True) | ||
lids = get_lids(case) | ||
for lid in lids: | ||
# call get_timing if needed | ||
expected_timing_file = os.path.join(caseroot, "timing", "%s_timing.%s.%s.gz" % (model, caseid, lid)) | ||
if (not os.path.exists(expected_timing_file)): | ||
get_timing(case, lid) | ||
save_postrun_provenance(case, lid=lid) | ||
else: | ||
expect(False, "Unhandled mode '%s'" % mode) | ||
|
||
if __name__ == "__main__": | ||
_main_func(__doc__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.