Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions scripts/metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def read_new_metadata(filename, module_name, table_name, scheme_name = None, sub
container = encode_container(module_name, metadata_section.title)

# Add to dependencies
if new_metadata_header.relative_path:
dependencies += [ os.path.join(new_metadata_header.relative_path, x) for x in new_metadata_header.dependencies]
if new_metadata_header.dependencies_path:
dependencies += [ os.path.join(new_metadata_header.dependencies_path, x) for x in new_metadata_header.dependencies]
else:
dependencies += new_metadata_header.dependencies
else:
Expand All @@ -150,8 +150,8 @@ def read_new_metadata(filename, module_name, table_name, scheme_name = None, sub
container = encode_container(module_name, scheme_name, table_name)

# Add to dependencies
if new_metadata_header.relative_path:
dependencies += [ os.path.join(new_metadata_header.relative_path, x) for x in new_metadata_header.dependencies]
if new_metadata_header.dependencies_path:
dependencies += [ os.path.join(new_metadata_header.dependencies_path, x) for x in new_metadata_header.dependencies]
else:
dependencies += new_metadata_header.dependencies

Expand Down
24 changes: 12 additions & 12 deletions scripts/metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
[ccpp-table-properties]
name = <name>
type = scheme
relative_path = <relative path>
dependencies_path = <relative path>
dependencies = <dependencies>
module = <module name> # only needed if module name differs from filename
source_path = <relative source directory of Fortran source (if different)>
Expand Down Expand Up @@ -358,12 +358,12 @@ class MetadataTable():
__table_start = re.compile(r"(?i)\s*\[\s*ccpp-table-properties\s*\]")

def __init__(self, run_env, table_name_in=None, table_type_in=None,
dependencies=None, relative_path=None, source_path=None,
dependencies=None, dependencies_path=None, source_path=None,
known_ddts=None, var_dict=None, module=None, parse_object=None,
skip_ddt_check=False):
"""Initialize a MetadataTable, either with a name, <table_name_in>, and
type, <table_type_in>, or with information from a file (<parse_object>).
if <parse_object> is None, <dependencies>, <relative_path>, and
if <parse_object> is None, <dependencies>, <dependencies_path>, and
are <source_path> are also stored.
If <var_dict> and / or module are passed (not allowed with
<parse_object), then a single MetadataSection is added with
Expand All @@ -373,7 +373,7 @@ def __init__(self, run_env, table_name_in=None, table_type_in=None,
self.__dependencies = dependencies
self.__fortran_src_path = source_path
self.__module_name = module
self.__relative_path = relative_path
self.__dependencies_path = dependencies_path
self.__sections = []
self.__run_env = run_env
if parse_object is None:
Expand Down Expand Up @@ -419,8 +419,8 @@ def __init__(self, run_env, table_name_in=None, table_type_in=None,
perr = "dependencies not allowed as argument when reading file"
raise ParseInternalError(perr)
# end if
if relative_path:
perr = "relative_path not allowed as argument when reading file"
if dependencies_path:
perr = "dependencies_path not allowed as argument when reading file"
raise ParseInternalError(perr)
# end if
if var_dict is not None: # i.e., not even an empty dict
Expand All @@ -441,8 +441,8 @@ def __init__(self, run_env, table_name_in=None, table_type_in=None,
self.__init_from_file(known_ddts, self.__run_env, skip_ddt_check=skip_ddt_check)
# Set absolute path for all dependencies
path = os.path.dirname(self.__pobj.filename)
if self.relative_path:
path = os.path.join(path, self.relative_path)
if self.dependencies_path:
path = os.path.join(path, self.dependencies_path)
# end if
for ind, dep in enumerate(self.__dependencies):
self.__dependencies[ind] = os.path.abspath(os.path.join(path, dep))
Expand Down Expand Up @@ -505,8 +505,8 @@ def __init_from_file(self, known_ddts, run_env, skip_ddt_check=False):
# end if
elif key == 'module_name':
self.__module_name = value
elif key == 'relative_path':
self.__relative_path = value
elif key == 'dependencies_path':
self.__dependencies_path = value
elif key == 'source_path':
self.__fortran_src_path = os.path.join(my_dirname, value)
else:
Expand Down Expand Up @@ -592,9 +592,9 @@ def module_name(self):
return self.__module_name

@property
def relative_path(self):
def dependencies_path(self):
"""Return the relative path for the table's dependencies"""
return self.__relative_path
return self.__dependencies_path

@property
def fortran_source_path(self):
Expand Down
2 changes: 1 addition & 1 deletion test/capgen_test/temp_adjust.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = temp_adjust
type = scheme
dependencies = qux.F90
relative_path = adjust
dependencies_path = adjust
[ccpp-arg-table]
name = temp_adjust_register
type = scheme
Expand Down
2 changes: 1 addition & 1 deletion test/ddthost_test/temp_adjust.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = temp_adjust
type = scheme
dependencies = qux.F90
relative_path = adjust
dependencies_path = adjust
[ccpp-arg-table]
name = temp_adjust_run
type = scheme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[ccpp-table-properties]
name = test_host
type = host
relative_path = ../../ccpp/physics/physics
dependencies_path = ../../ccpp/physics/physics
dependencies = machine.F,physcons.F90,,
dependencies = GFDL_parse_tracers.F90,,rte-rrtmgp/rrtmgp/mo_gas_optics_rrtmgp.F90

Expand Down
16 changes: 8 additions & 8 deletions test/unit_tests/test_metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_good_host_file(self):
# size of returned list equals number of headers in the test file
# ccpp-table-properties name is 'test_host'
dependencies = result[0].dependencies
rel_path = result[0].relative_path
rel_path = result[0].dependencies_path
self.assertFalse('' in dependencies)
self.assertEqual(len(dependencies), 0)
self.assertIsNone(rel_path)
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_no_table_type(self):
with self.assertRaises(Exception) as context:
MetadataTable(self._DUMMY_RUN_ENV, table_name_in="something",
table_type_in=None, dependencies=None,
relative_path=None, known_ddts=None, var_dict=None,
dependencies_path=None, known_ddts=None, var_dict=None,
module=None, parse_object=None)

#print("The exception is", context.exception)
Expand All @@ -273,7 +273,7 @@ def test_bad_header_type(self):
with self.assertRaises(Exception) as context:
MetadataTable(self._DUMMY_RUN_ENV, table_name_in="something",
table_type_in="banana", dependencies=None,
relative_path=None, known_ddts=None, var_dict=None,
dependencies_path=None, known_ddts=None, var_dict=None,
module=None, parse_object=None)

#print("The exception is", context.exception)
Expand All @@ -285,7 +285,7 @@ def test_no_module(self):
with self.assertRaises(Exception) as context:
MetadataTable(self._DUMMY_RUN_ENV, table_name_in=None,
table_type_in=None, dependencies=None,
relative_path=None, known_ddts=None, var_dict=None,
dependencies_path=None, known_ddts=None, var_dict=None,
module=None, parse_object=None)

#print("The exception is", context.exception)
Expand Down Expand Up @@ -358,17 +358,17 @@ def test_missing_table_properties(self):
emsg = "Invalid CCPP metadata line, '[ccpp-arg-table]', at "
self.assertTrue(emsg in str(context.exception))

def test_dependencies_rel_path(self):
"""Test that relative_path and dependencies from ccpp-table-properties are read in correctly"""
def test_dependencies_path(self):
"""Test that dependencies_path and dependencies from ccpp-table-properties are read in correctly"""
known_ddts = list()
filename = os.path.join(SAMPLE_FILES_DIR,
"test_dependencies_rel_path.meta")
"test_dependencies_path.meta")

result = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

dependencies = result[0].dependencies
rel_path = result[0].relative_path
rel_path = result[0].dependencies_path
titles = [elem.table_name for elem in result]

self.assertEqual(len(dependencies), 4)
Expand Down
2 changes: 1 addition & 1 deletion test_prebuild/test_track_variables/scheme_2.meta
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[ccpp-table-properties]
name = scheme_2
type = scheme
relative_path = ../../
dependencies_path = ../../
dependencies = hooks/machine.F

########################################################################
Expand Down
6 changes: 3 additions & 3 deletions test_prebuild/unit_tests/test_metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[ccpp-table-properties]
name = <name>
type = scheme
relative_path = path
dependencies_path = path
dependencies = a.f,b.f

[ccpp-arg-table]
Expand Down Expand Up @@ -44,8 +44,8 @@ def test_MetadataTable_parse_table(tmpdir):
metadata_header = metadata_headers[0]
assert metadata_header.table_name == "<name>"
assert metadata_header.table_type == "scheme"
assert metadata_header.relative_path == "path"
assert metadata_header.dependencies == [os.path.join(tmpdir, metadata_header.relative_path,"a.f"), os.path.join(tmpdir, metadata_header.relative_path,"b.f")]
assert metadata_header.dependencies_path == "path"
assert metadata_header.dependencies == [os.path.join(tmpdir, metadata_header.dependencies_path,"a.f"), os.path.join(tmpdir, metadata_header.dependencies_path,"b.f")]

# check metadata section
assert len(metadata_header.sections()) == 1
Expand Down