Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a816977
Adds Config class
jasonb5 Jun 14, 2022
341d3ee
Removes unused imports
jasonb5 Jun 15, 2022
fe3aa8d
Fixes black formatting
jasonb5 Jun 15, 2022
8ab2490
Fixes more black formatting
jasonb5 Jun 15, 2022
eeff346
Removes unused argument
jasonb5 Jun 15, 2022
ab26bcc
Fixes Config class to be singleton
jasonb5 Jun 15, 2022
3a7f4d5
Removes model specific provenance code, replaces with calls to handlers
jasonb5 Jun 16, 2022
66b1a2a
Fixes using classes in hooks
jasonb5 Jun 20, 2022
e036cca
Create first 3 config flags
jasonb5 Jun 21, 2022
c5297f0
Adds more config flags
jasonb5 Jun 22, 2022
46b936a
Fixes black formatting
jasonb5 Jun 22, 2022
af78b51
Removes provenance tests
jasonb5 Jun 30, 2022
d09b445
Merge branch 'master' into remove_model_specific
jasonb5 Jun 30, 2022
a8938ad
Adds additional flags
jasonb5 Jul 2, 2022
e04e839
Fixes black formatting
jasonb5 Jul 5, 2022
8253c11
Fixes clearing utils.GLOBAL, was causing issues reading cime_config f…
jasonb5 Jul 8, 2022
caddd25
Adds some filtering so tests can live in customize folder.
jasonb5 Jul 8, 2022
e70c2a7
Merge branch 'master' into remove_model_specific
jasonb5 Jul 8, 2022
b752893
Prevents overwriting loaded values with defaults.
jasonb5 Jul 8, 2022
235d9eb
Fixes loading model customized values when running tests
jasonb5 Jul 8, 2022
cdec47c
Removes member variable for Config, casued issues when cloning a case
jasonb5 Jul 9, 2022
b924191
Fixes using Config defaults when processing conditional arguments
jasonb5 Jul 9, 2022
f37028a
Fixes postrun provenance hook
jasonb5 Jul 9, 2022
906de33
Fixes black formatting
jasonb5 Jul 11, 2022
eb20855
Adds method to print rst table with variables
jasonb5 Jul 12, 2022
3539361
Adds cime-customize documentation
jasonb5 Jul 12, 2022
97337b4
Fixes broken documentation
jasonb5 Jul 12, 2022
71fb66a
Fixes black formatting and excludes processing docs/ with pre-commit.
jasonb5 Jul 13, 2022
d740104
Removes archive drv/dart config variables
jasonb5 Aug 6, 2022
a3c987e
Removes model check
jasonb5 Aug 6, 2022
63e7293
Adds driver default and choices as config variables
jasonb5 Aug 6, 2022
88f2b3d
Renames cesm_create_test_flags to create_test_flag_mode
jasonb5 Aug 6, 2022
7819db3
Groups testing config variables under 'test_mode', current options ar…
jasonb5 Aug 9, 2022
79c355a
Removes references to get_model and replaces with 'test_mode'
jasonb5 Aug 9, 2022
4a91cb6
Adds mct library path variable
jasonb5 Aug 10, 2022
78aa0c9
Merge branch 'master' into remove_model_specific
jasonb5 Aug 10, 2022
9f64b3d
Fixes model reference in create_newcase script
jasonb5 Aug 10, 2022
251113e
Fixes additional archive components
jasonb5 Aug 12, 2022
a6fd290
Fixes black formatting
jasonb5 Aug 12, 2022
dfb383c
Improves the description of CIME's customize variables
jasonb5 Aug 13, 2022
e2bf301
Fixes black formatting
jasonb5 Aug 13, 2022
860861f
Updates save_provenance tool to use new provenance hooks
jasonb5 Aug 16, 2022
e2d2f6d
Fixes docker machine recording performance archive
jasonb5 Aug 17, 2022
83163f3
Fixes run/bld directory locations
jasonb5 Aug 17, 2022
41ab0a3
Fixes variable name in entrypoint.sh
jasonb5 Aug 17, 2022
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
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ repos:
- id: check-xml
files: config/
- id: end-of-file-fixer
exclude: doc/
- id: trailing-whitespace
exclude: doc/
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand All @@ -18,6 +20,6 @@ repos:
hooks:
- id: pylint
args:
- --disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import,fixme,broad-except,bare-except,eval-used,exec-used,global-statement,logging-format-interpolation,no-name-in-module,arguments-renamed,unspecified-encoding,protected-access,import-error
- --disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import,fixme,broad-except,bare-except,eval-used,exec-used,global-statement,logging-format-interpolation,no-name-in-module,arguments-renamed,unspecified-encoding,protected-access,import-error,no-member
files: CIME
exclude: CIME/(tests|Tools|code_checker.py)
9 changes: 7 additions & 2 deletions CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
get_ts_synopsis,
generate_baseline,
)
from CIME.config import Config
from CIME.provenance import save_test_time, get_test_success
from CIME.locked_files import LOCKED_DIR, lock_file, is_locked
import CIME.build as build
Expand Down Expand Up @@ -253,7 +254,9 @@ def run(self, skip_pnl=False):
RUN_PHASE, status, comments=("time={:d}".format(int(time_taken)))
)

if get_model() == "e3sm":
config = Config.instance()

if config.verbose_run_phase:
# If run phase worked, remember the time it took in order to improve later walltime ests
baseline_root = self._case.get_value("BASELINE_ROOT")
if success:
Expand Down Expand Up @@ -320,7 +323,9 @@ def run(self, skip_pnl=False):
)
)

if get_model() == "cesm" and self._case.get_value("GENERATE_BASELINE"):
if config.baseline_store_teststatus and self._case.get_value(
"GENERATE_BASELINE"
):
baseline_dir = os.path.join(
self._case.get_value("BASELINE_ROOT"),
self._case.get_value("BASEGEN_CASE"),
Expand Down
6 changes: 4 additions & 2 deletions CIME/SystemTests/system_tests_compare_n.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.case import Case
from CIME.utils import get_model
from CIME.config import Config
from CIME.test_status import *

import shutil, os, glob
Expand Down Expand Up @@ -182,6 +182,8 @@ def build_phase(self, sharedlib_only=False, model_only=False):
# with a with statement in all the API entrances in CIME. subsequent cases were
# created via clone, not a with statement, so it's not in a writeable state,
# so we need to use a with statement here to put it in a writeable state.
config = Config.instance()

for i in range(1, self.N):
with self._cases[i]:
if self._separate_builds:
Expand All @@ -193,7 +195,7 @@ def build_phase(self, sharedlib_only=False, model_only=False):
# Although we're doing separate builds, it still makes sense
# to share the sharedlibroot area with case1 so we can reuse
# pieces of the build from there.
if get_model() != "e3sm":
if config.common_sharedlibroot:
# We need to turn off this change for E3SM because it breaks
# the MPAS build system
## TODO: ^this logic mimics what's done in SystemTestsCompareTwo
Expand Down
4 changes: 2 additions & 2 deletions CIME/SystemTests/system_tests_compare_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from CIME.XML.standard_module_setup import *
from CIME.SystemTests.system_tests_common import SystemTestsCommon
from CIME.case import Case
from CIME.utils import get_model
from CIME.config import Config
from CIME.test_status import *

import shutil, os, glob
Expand Down Expand Up @@ -217,7 +217,7 @@ def build_phase(self, sharedlib_only=False, model_only=False):
# Although we're doing separate builds, it still makes sense
# to share the sharedlibroot area with case1 so we can reuse
# pieces of the build from there.
if get_model() != "e3sm":
if Config.instance().common_sharedlibroot:
# We need to turn off this change for E3SM because it breaks
# the MPAS build system
self._case2.set_value(
Expand Down
6 changes: 5 additions & 1 deletion CIME/Tools/generate_cylc_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"""
Generates a cylc workflow file for the case. See https://cylc.github.io for details about cylc
"""
import os
import sys

from standard_script_setup import *
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))

from CIME.Tools.standard_script_setup import *

from CIME.case import Case
from CIME.utils import expect, transform_vars
Expand Down
38 changes: 34 additions & 4 deletions CIME/Tools/save_provenance
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ This tool provide command-line access to provenance-saving functionality
from standard_script_setup import *

from CIME.case import Case
from CIME.config import Config
from CIME.provenance import *
from CIME.utils import get_lids
from CIME.get_timing import get_timing

import logging

logger = logging.getLogger(__name__)

###############################################################################
def parse_command_line(args, description):
###############################################################################
Expand Down Expand Up @@ -57,31 +62,56 @@ def _main_func(description):
###############################################################################
mode, caseroot, lid = parse_command_line(sys.argv, description)
with Case(caseroot, read_only=False) as case:
srcroot = case.get_value("SRCROOT")

customize_path = os.path.join(srcroot, "cime_config", "customize")

config = Config.load(customize_path)

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)

try:
config.save_build_provenance(case, lid=lid)
except AttributeError:
logger.debug("Could not save build provenance, no handler found")
elif mode == "prerun":
expect(lid is not None, "You must provide LID for prerun mode")
save_prerun_provenance(case, lid=lid)

try:
config.save_prerun_provenance(case, lid=lid)
except AttributeError:
logger.debug("Could not save prerun provenance, no handler found")
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", "{}_timing.{}.{}.gz".format(model, caseid, lid)
)

if not os.path.exists(expected_timing_file):
get_timing(case, lid)
save_prerun_provenance(case, lid=lid)
save_postrun_provenance(case, lid=lid)

try:
config.save_prerun_provenance(case, lid=lid)
except AttributeError:
logger.debug("Could not save prerun provenance, no handler found")

try:
config.save_postrun_provenance(case, lid=lid)
except AttributeError:
logger.debug("Could not save postrun provenance, no handler found")
else:
expect(False, "Unhandled mode '{}'".format(mode))

Expand Down
6 changes: 5 additions & 1 deletion CIME/Tools/testreporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"""
Simple script to populate CESM test database with test results.
"""
import os
import sys

from standard_script_setup import *
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))

from CIME.Tools.standard_script_setup import *

from CIME.XML.env_build import EnvBuild
from CIME.XML.env_case import EnvCase
Expand Down
14 changes: 8 additions & 6 deletions CIME/XML/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""

from CIME.XML.standard_module_setup import *
from CIME.config import Config
from CIME.XML.archive_base import ArchiveBase
from CIME.XML.files import Files
from CIME.utils import expect, get_model
from copy import deepcopy

logger = logging.getLogger(__name__)
Expand All @@ -28,12 +28,14 @@ def setup(self, env_archive, components, files=None):
components_node = env_archive.make_child(
"components", attributes={"version": "2.0"}
)

arch_components = deepcopy(components)
model = get_model()
if "drv" not in arch_components and model != "ufs":
arch_components.append("drv")
if "dart" not in arch_components and model == "cesm":
arch_components.append("dart")

config = Config.instance()

for comp in config.additional_archive_components:
if comp not in arch_components:
arch_components.append(comp)

for comp in arch_components:
infile = files.get_value("ARCHIVE_SPEC_FILE", {"component": comp})
Expand Down
6 changes: 0 additions & 6 deletions CIME/XML/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import urllib.request
from CIME.XML.standard_module_setup import *
from CIME.XML.generic_xml import GenericXML
from CIME.utils import expect, get_model
import ssl

# pylint: disable=protected-access
Expand All @@ -19,11 +18,6 @@ def __init__(self):
"""
initialize an object
"""

expect(
get_model() == "cesm",
"testreport is only meant to populate the CESM test database.",
)
self.root = None

GenericXML.__init__(
Expand Down
5 changes: 3 additions & 2 deletions CIME/bless_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from CIME.utils import (
run_cmd,
get_scripts_root,
get_model,
EnvironmentContext,
parse_test_name,
)
from CIME.config import Config
from CIME.test_status import *
from CIME.hist_utils import generate_baseline, compare_baseline
from CIME.case import Case
Expand Down Expand Up @@ -36,10 +36,11 @@ def bless_namelists(
if not report_only and (
force or input("Update namelists (y/n)? ").upper() in ["Y", "YES"]
):
config = Config.instance()

create_test_gen_args = " -g {} ".format(
baseline_name
if get_model() == "cesm"
if config.create_test_flag_mode == "cesm"
else " -g -b {} ".format(baseline_name)
)
if new_test_root is not None:
Expand Down
22 changes: 14 additions & 8 deletions CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
get_logging_options,
import_from_file,
)
from CIME.provenance import save_build_provenance as save_build_provenance_sub
from CIME.config import Config
from CIME.locked_files import lock_file, unlock_file
from CIME.XML.files import Files

logger = logging.getLogger(__name__)

config = Config.instance()

_CMD_ARGS_FOR_BUILD = (
"CASEROOT",
"CASETOOLS",
Expand Down Expand Up @@ -283,7 +285,7 @@ def uses_kokkos(case):
cam_target = case.get_value("CAM_TARGET")
# atm_comp = case.get_value("COMP_ATM") # scream does not use the shared kokkoslib for now

return get_model() == "e3sm" and cam_target in (
return config.use_kokkos and cam_target in (
"preqx_kokkos",
"theta-l",
"theta-l_kokkos",
Expand Down Expand Up @@ -323,7 +325,7 @@ def _build_model(
# special case for clm
# clm 4_5 and newer is a shared (as in sharedlibs, shared by all tests) library
# (but not in E3SM) and should be built in build_libraries
if get_model() != "e3sm" and comp == "clm":
if config.shared_clm_component and comp == "clm":
continue
else:
logger.info(" - Building {} Library ".format(model))
Expand Down Expand Up @@ -379,7 +381,7 @@ def _build_model(
file_build = os.path.join(exeroot, "{}.bldlog.{}".format(cime_model, lid))

ufs_driver = os.environ.get("UFS_DRIVER")
if cime_model == "ufs" and ufs_driver == "nems":
if config.ufs_alternative_config and ufs_driver == "nems":
config_dir = os.path.join(
cimeroot, os.pardir, "src", "model", "NEMS", "cime", "cime_config"
)
Expand Down Expand Up @@ -813,7 +815,7 @@ def _build_libraries(
logger.warning(line)

# clm not a shared lib for E3SM
if get_model() != "e3sm" and (buildlist is None or "lnd" in buildlist):
if config.shared_clm_component and (buildlist is None or "lnd" in buildlist):
comp_lnd = case.get_value("COMP_LND")
if comp_lnd == "clm":
logging.info(" - Building clm library ")
Expand Down Expand Up @@ -888,7 +890,7 @@ def _build_model_thread(
libroot=libroot,
bldroot=bldroot,
)
if get_model() != "ufs":
if config.enable_smp:
compile_cmd = "SMP={} {}".format(stringify_bool(smp), compile_cmd)

if is_python_executable(cmd):
Expand Down Expand Up @@ -1104,6 +1106,7 @@ def _case_build_impl(
os.environ["BUILD_THREADED"] = stringify_bool(build_threaded)
cime_model = get_model()

# TODO need some other method than a flag.
if cime_model == "e3sm" and mach == "titan" and compiler == "pgiacc":
case.set_value("CAM_TARGET", "preqx_acc")

Expand Down Expand Up @@ -1175,7 +1178,7 @@ def _case_build_impl(
)

if not sharedlib_only:
if get_model() == "e3sm":
if config.build_model_use_cmake:
logs.extend(
_build_model_cmake(
exeroot,
Expand Down Expand Up @@ -1242,7 +1245,10 @@ def post_build(case, logs, build_complete=False, save_build_provenance=True):
os.environ["LID"] if "LID" in os.environ else get_timestamp("%y%m%d-%H%M%S")
)
if save_build_provenance:
save_build_provenance_sub(case, lid=lid)
try:
Config.instance().save_build_provenance(case, lid=lid)
except AttributeError:
logger.debug("No handler for save_build_provenance was found")
# Set XML to indicate build complete
case.set_value("BUILD_COMPLETE", True)
case.set_value("BUILD_STATUS", 0)
Expand Down
Loading