Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Err 2 compare two #1852

Merged
merged 3 commits into from
Aug 31, 2017
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
46 changes: 18 additions & 28 deletions scripts/lib/CIME/SystemTests/err.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,29 @@
ERR tests short term archiving and restart capabilities
"""
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.ers import ERS

import shutil, glob
from CIME.SystemTests.restart_tests import RestartTest
from CIME.case_st_archive import restore_from_archive
from CIME.utils import ls_sorted_by_mtime

logger = logging.getLogger(__name__)

class ERR(ERS):
class ERR(RestartTest):

def __init__(self, case):
def __init__(self, case): # pylint: disable=super-init-not-called
"""
initialize an object interface to the ERR system test
"""
ERS.__init__(self, case)

def run_phase(self):
first_phase = self._case.get_value("RESUBMIT") == 1

if first_phase:
self._case.set_value("DOUT_S", True)
self._case.flush()
self._ers_first_phase()
else:
dout_s_root = self._case.get_value("DOUT_S_ROOT")
rundir = self._case.get_value("RUNDIR")
case = self._case.get_value("CASE")
# First remove restart, history and rpointer files from the run directory
for item in glob.iglob(os.path.join(rundir, "{}.*".format(case))):
if not item.endswith("base"):
os.remove(item)
for item in glob.iglob(os.path.join(rundir, "rpointer.*")):
os.remove(item)
# Then replace them from the restart directory
for item in glob.iglob(os.path.join(dout_s_root,"rest","*","*")):
shutil.copy(item, rundir)
RestartTest.__init__(self, case, # pylint: disable=non-parent-init-called
separate_builds = False,
run_two_suffix = 'rest',
run_one_description = 'initial',
run_two_description = 'restart',
multisubmit = True)

self._ers_second_phase()
def _case_two_custom_prerun_action(self):
dout_s_root = self._case1.get_value("DOUT_S_ROOT")
rest_root = os.path.abspath(os.path.join(dout_s_root,"rest"))
restart_list = ls_sorted_by_mtime(rest_root)
expect(len(restart_list) >= 1, "No restart files found in {}".format(rest_root))
restore_from_archive(self._case, rest_dir=
os.path.join(rest_root, restart_list[0]))
23 changes: 9 additions & 14 deletions scripts/lib/CIME/SystemTests/erri.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ def __init__(self, case):
"""
ERR.__init__(self, case)

def run_phase(self):
first_phase = self._case.get_value("RESUBMIT") == 1

ERR.run_phase(self)

if not first_phase:
rundir = self._case.get_value("RUNDIR")
for logname_gz in glob.glob(os.path.join(rundir, '*.log*.gz')):
# gzipped logfile names are of the form $LOGNAME.gz
# Removing the last three characters restores the original name
logname = logname_gz[:-3]
with gzip.open(logname_gz, 'rb') as f_in, open(logname, 'w') as f_out:
shutil.copyfileobj(f_in, f_out)
os.remove(logname_gz)
def _case_two_custom_postrun_action(self):
rundir = self._case.get_value("RUNDIR")
for logname_gz in glob.glob(os.path.join(rundir, '*.log*.gz')):
# gzipped logfile names are of the form $LOGNAME.gz
# Removing the last three characters restores the original name
logname = logname_gz[:-3]
with gzip.open(logname_gz, 'rb') as f_in, open(logname, 'w') as f_out:
shutil.copyfileobj(f_in, f_out)
os.remove(logname_gz)
31 changes: 8 additions & 23 deletions scripts/lib/CIME/SystemTests/irt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,22 @@

"""

from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
from CIME.SystemTests.restart_tests import RestartTest
from CIME.XML.standard_module_setup import *
from CIME.case_st_archive import case_st_archive, restore_from_archive
from CIME.utils import ls_sorted_by_mtime

logger = logging.getLogger(__name__)

class IRT(SystemTestsCompareTwo):
class IRT(RestartTest):

def __init__(self, case):
SystemTestsCompareTwo.__init__(self, case,
separate_builds=False,
run_two_suffix = 'restart',
run_one_description = 'initial',
run_two_description = 'restart',
multisubmit = False)

def _case_one_setup(self):
stop_n = self._case1.get_value("STOP_N")
expect(stop_n >= 3,"STOP_N must be at least 3, STOP_N = {}".format(stop_n))

def _case_two_setup(self):
rest_n = self._case1.get_value("REST_N")
stop_n = self._case1.get_value("STOP_N")
stop_new = stop_n - rest_n
expect(stop_new > 0, "ERROR: stop_n value {:d} too short {:d} {:d}".format(stop_new,stop_n,rest_n))
# hist_n is set to the stop_n value of case1
self._case.set_value("HIST_N", stop_n)
self._case.set_value("STOP_N", stop_new)
self._case.set_value("CONTINUE_RUN",True)
self._case.set_value("REST_OPTION", "never")
RestartTest.__init__(self, case,
separate_builds=False,
run_two_suffix = 'restart',
run_one_description = 'initial',
run_two_description = 'restart',
multisubmit = False)

def _case_one_custom_postrun_action(self):
case_st_archive(self._case)
Expand Down
40 changes: 40 additions & 0 deletions scripts/lib/CIME/SystemTests/restart_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Abstract class for restart tests

"""

from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
from CIME.XML.standard_module_setup import *

logger = logging.getLogger(__name__)

class RestartTest(SystemTestsCompareTwo):

def __init__(self, case,
separate_builds,
run_two_suffix = 'restart',
run_one_description = 'initial',
run_two_description = 'restart',
multisubmit = False):
SystemTestsCompareTwo.__init__(self, case,
separate_builds,
run_two_suffix = run_two_suffix,
run_one_description = run_one_description,
run_two_description = run_two_description,
multisubmit = multisubmit)


def _case_one_setup(self):
stop_n = self._case1.get_value("STOP_N")
expect(stop_n >= 3,"STOP_N must be at least 3, STOP_N = {}".format(stop_n))

def _case_two_setup(self):
rest_n = self._case1.get_value("REST_N")
stop_n = self._case1.get_value("STOP_N")
stop_new = stop_n - rest_n
expect(stop_new > 0, "ERROR: stop_n value {:d} too short {:d} {:d}".format(stop_new,stop_n,rest_n))
# hist_n is set to the stop_n value of case1
self._case.set_value("HIST_N", stop_n)
self._case.set_value("STOP_N", stop_new)
self._case.set_value("CONTINUE_RUN",True)
self._case.set_value("REST_OPTION", "never")