Skip to content

Commit

Permalink
Remove requirement that suite definition file names begin with "suite…
Browse files Browse the repository at this point in the history
…_" (#569)

Remove hard-coded requirement in prebuild that suite definition file names begin with the literal
string `suite_`. Includes back-compatibility logic to allow for the previous naming convention to continue to work.
  • Loading branch information
mkavulich authored Jul 11, 2024
1 parent 0f82327 commit 3e85c68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
20 changes: 17 additions & 3 deletions scripts/ccpp_prebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def parse_arguments():
verbose = args.verbose
debug = args.debug
if args.suites:
sdfs = ['suite_{0}.xml'.format(x) for x in args.suites.split(',')]
sdfs = ['{0}.xml'.format(x) for x in args.suites.split(',')]
else:
sdfs = None
builddir = args.builddir
Expand Down Expand Up @@ -181,8 +181,22 @@ def parse_suites(suites_dir, sdfs):
logging.info('Parsing suite definition files ...')
suites = []
for sdf in sdfs:
logging.info('Parsing suite definition file {0} ...'.format(os.path.join(suites_dir, sdf)))
suite = Suite(sdf_name=os.path.join(suites_dir, sdf))
sdf_file=os.path.join(suites_dir, sdf)
if not os.path.exists(sdf_file):
# If suite file not found, check old filename convention (suite_[suitename].xml)
sdf_file_legacy=os.path.join(suites_dir, f"suite_{sdf}")
if os.path.exists(sdf_file_legacy):
logging.warning("Parsing suite definition file using legacy naming convention")
logging.warning(f"Filename {os.path.basename(sdf_file_legacy)}")
logging.warning(f"Suite name {sdf}")
sdf_file=sdf_file_legacy
else:
logging.critical(f"Suite definition file {sdf_file} not found.")
success = False
return (success, suites)

logging.info(f'Parsing suite definition file {sdf_file} ...')
suite = Suite(sdf_name=sdf_file)
success = suite.parse()
if not success:
logging.error('Parsing suite definition file {0} failed.'.format(sdf))
Expand Down
2 changes: 1 addition & 1 deletion scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
CCPP_STATIC_SUBROUTINE_NAME = 'ccpp_physics_{stage}'

# Filename pattern for suite definition files
SUITE_DEFINITION_FILENAME_PATTERN = re.compile('^suite_(.*)\.xml$')
SUITE_DEFINITION_FILENAME_PATTERN = re.compile('^(.*)\.xml$')

# Maximum number of concurrent CCPP instances per MPI task
CCPP_NUM_INSTANCES = 200
Expand Down
15 changes: 10 additions & 5 deletions scripts/mkstatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,16 @@ def parse(self, make_call_tree=False):
suite_xml = tree.getroot()
self._name = suite_xml.get('name')
# Validate name of suite in XML tag against filename; could be moved to common.py
if not (os.path.basename(self._sdf_name) == 'suite_{}.xml'.format(self._name)):
logging.critical("Invalid suite name {0} in suite definition file {1}.".format(
self._name, self._sdf_name))
success = False
return success
if not (os.path.basename(self._sdf_name) == '{}.xml'.format(self._name)):
if (os.path.basename(self._sdf_name) == 'suite_{}.xml'.format(self._name)):
logging.debug("Parsing suite using legacy naming convention")
logging.debug(f"Filename {os.path.basename(self._sdf_name)}")
logging.debug(f"Suite name {format(self._name)}")
else:
logging.critical("Invalid suite name {0} in suite definition file {1}.".format(
self._name, self._sdf_name))
success = False
return success

# Check if suite name is too long
if len(self._name) > SUITE_NAME_MAX_CHARS:
Expand Down

0 comments on commit 3e85c68

Please sign in to comment.