Skip to content

Commit

Permalink
put SAVE_TIMING_DIR_PROJECTS in env_run.xml
Browse files Browse the repository at this point in the history
With the simplified implementation of is_save_timing_dir_project,
the dependence on config_machines.xml can be eliminated after
the case is created by putting SAVE_TIMING_DIR_PROJECTS in, and
reading it from, env_run.xml . This is more consistent with
how other parameters of this sort are handled.

[BFB]
  • Loading branch information
Patrick Worley committed Dec 7, 2017
1 parent 76c4ffa commit acdd673
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 31 deletions.
22 changes: 0 additions & 22 deletions scripts/lib/CIME/XML/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,6 @@ def is_valid_MPIlib(self, mpilib, attributes=None):
return mpilib == "mpi-serial" or \
self.get_field_from_list("MPILIBS", reqval=mpilib, attributes=attributes) is not None

def is_save_timing_dir_project(self,project):
"""
Check whether the project is permitted to archive performance data in the location specified for the current machine
>>> machobj = Machines(machine="edison")
>>> machobj.is_save_timing_dir_project("acme")
True
>>> machobj.is_save_timing_dir_project("ccsm1")
False
"""
save_timing_dir_projects = self.get_value("SAVE_TIMING_DIR_PROJECTS")
if not save_timing_dir_projects:
return False
else:
save_timing_dir_projects = save_timing_dir_projects.split(",")
for save_timing_dir_project in save_timing_dir_projects:
regex = re.compile(save_timing_dir_project)
if regex.match(project):
return True

return False

def has_batch_system(self):
"""
Return if this machine has a batch system
Expand Down
17 changes: 17 additions & 0 deletions scripts/lib/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,3 +1457,20 @@ def create_clone(self, newcase, keepexe=False, mach_dir=None, project=None,
project=project, cime_output_root=cime_output_root,
exeroot=exeroot, rundir=rundir,
user_mods_dir=user_mods_dir)

def is_save_timing_dir_project(self,project):
"""
Check whether the project is permitted to archive performance data in the location
specified for the current machine
"""
save_timing_dir_projects = self.get_value("SAVE_TIMING_DIR_PROJECTS")
if not save_timing_dir_projects:
return False
else:
save_timing_dir_projects = save_timing_dir_projects.split(",")
for save_timing_dir_project in save_timing_dir_projects:
regex = re.compile(save_timing_dir_project)
if regex.match(project):
return True

return False
15 changes: 6 additions & 9 deletions scripts/lib/CIME/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

from CIME.XML.standard_module_setup import *
from CIME.XML.machines import Machines
from CIME.utils import touch, gzip_existing_file, SharedArea, copy_umask

import tarfile, getpass, signal, glob, shutil
Expand Down Expand Up @@ -95,13 +94,11 @@ def save_build_provenance(case, lid=None):
_save_build_provenance_cesm(case, lid)

def _save_prerun_timing_acme(case, lid):
mach = case.get_value("MACH")
machobj = Machines(machine=mach)
project = case.get_value("PROJECT", subgroup="case.run")
if not machobj.is_save_timing_dir_project(project):
if not case.is_save_timing_dir_project(project):
return

timing_dir = machobj.get_value("SAVE_TIMING_DIR")
timing_dir = case.get_value("SAVE_TIMING_DIR")
if timing_dir is None or not os.path.isdir(timing_dir):
logger.warning("SAVE_TIMING_DIR {} is not valid. E3SM requires a valid SAVE_TIMING_DIR to archive timing data.".format(timing_dir))
return
Expand All @@ -123,6 +120,7 @@ def _save_prerun_timing_acme(case, lid):
logger.warning("{} cannot be created. Skipping archive of timing data and associated provenance.".format(full_timing_dir))
return

mach = case.get_value("MACH")
compiler = case.get_value("COMPILER")

# For some batch machines save queue info
Expand Down Expand Up @@ -286,16 +284,15 @@ def _save_postrun_timing_acme(case, lid):
timing_saved_file = "timing.%s.saved" % lid
touch(os.path.join(caseroot, "timing", timing_saved_file))

mach = case.get_value("MACH")
machobj = Machines(machine=mach)
project = case.get_value("PROJECT", subgroup="case.run")
if not machobj.is_save_timing_dir_project(project):
if not case.is_save_timing_dir_project(project):
return

timing_dir = machobj.get_value("SAVE_TIMING_DIR")
timing_dir = case.get_value("SAVE_TIMING_DIR")
if timing_dir is None or not os.path.isdir(timing_dir):
return

mach = case.get_value("MACH")
base_case = case.get_value("CASE")
full_timing_dir = os.path.join(timing_dir, "performance_archive", getpass.getuser(), base_case, lid)

Expand Down
18 changes: 18 additions & 0 deletions src/drivers/mct/cime_config/config_component_acme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
<desc>logical to save timing files in rundir</desc>
</entry>

<entry id="SAVE_TIMING_DIR">
<type>char</type>
<valid_values></valid_values>
<default_value>UNSET</default_value>
<group>run_flags</group>
<file>env_run.xml</file>
<desc>Where to auto archive timing data</desc>
</entry>

<entry id="SAVE_TIMING_DIR_PROJECTS">
<type>char</type>
<valid_values></valid_values>
<default_value></default_value>
<group>run_flags</group>
<file>env_run.xml</file>
<desc> A comma-separated list of projects that are allowed to auto archive timing data in SAVE_TIMING_DIR</desc>
</entry>

<entry id="TIMER_DETAIL">
<type>integer</type>
<default_value>12</default_value>
Expand Down

0 comments on commit acdd673

Please sign in to comment.