Skip to content

Commit

Permalink
change pod object attribute multi_case_dict to multicase_dict and upd…
Browse files Browse the repository at this point in the history
…ate definitions and refs in pod_setup and output_manager (NOAA-GFDL#632)
  • Loading branch information
wrongkindofdoctor authored Jul 21, 2024
1 parent 769d57d commit 5fa7a81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/output_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ def html_templating_dict(pod) -> dict:
d[attr] = str(pod.pod_settings.get(attr, ""))
if not any(d[attr]):
d[attr] = str(getattr(pod, attr, ""))
if len(pod.multi_case_dict['CASE_LIST']) > 1: # multi-case PODs
if len(pod.multicase_dict) > 1: # multi-case PODs
case_number = 1
for case_name, case_dict in pod.multi_case_dict['CASE_LIST'].items():
for case_name, case_dict in pod.multicase_dict.items():
case_str = f'CASE_{case_number}'
d[case_str] = case_name
case_number += 1
for att_name, att in case_dict.items():
d[att_name] = att
else: # single-case PODs
for case_name, case_dict in pod.multi_case_dict['CASE_LIST'].items():
for case_name, case_dict in pod.multicase_dict.items():
for att_name, att in case_dict.items():
d[att_name] = att
return d
Expand Down Expand Up @@ -81,7 +81,7 @@ def write_data_log_file(self):
str_1 = f"POD {self.obj.name}"
elif isinstance(self, HTMLOutputManager):
str_1 = ""
for case_name in self.obj.multi_case_dict['CASE_LIST'].keys():
for case_name in self.obj.multicase_dict.keys():
str_1 += f"case {case_name} \n"
else:
raise AssertionError("self is not an instance of HTMLPodOutputManager or HTMLOutputManager")
Expand Down Expand Up @@ -311,7 +311,7 @@ def __init__(self, pod, config):
else:
self.overwrite = False
self.file_overwrite = self.overwrite # overwrite both config and .tar
if hasattr(config, 'make_multicase_figure_html'):
if config.get('make_multicase_figure_html', False):
self.multi_case_figure = config['make_multicase_figure_html']
else:
self.multi_case_figure = False
Expand Down Expand Up @@ -461,8 +461,8 @@ def make_html(self, html_file_name: str, cleanup=True):
util.append_html_template(self.CASE_TEMP_HTML, dest, {})
with io.open(dest, 'a', encoding='utf-8') as f:
if self.multi_case_figure:
self.generate_html_file_case_loop(self.obj.multi_case_dict['CASE_LIST'], template_dict, f)
self.append_case_info_html(self.obj.multi_case_dict['CASE_LIST'], f)
self.generate_html_file_case_loop(self.obj.multicase_dict, template_dict, f)
self.append_case_info_html(self.obj.multicase_dict, f)
f.close()
util.append_html_template(
self.html_src_file('mdtf_footer.html'), dest, template_dict
Expand Down
3 changes: 2 additions & 1 deletion src/pod_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PodObject(util.MDTFObjectBase, util.PODLoggerMixin, PodBaseClass):
pod_data = dict()
pod_vars = dict()
pod_settings = dict()
multi_case_dict = dict() # populated with case_info entries in enviroment_manager
multicase_dict = dict() # populated with case_info entries in enviroment_manager
overwrite: bool = False
# explict 'program' attribute in settings
_interpreters = dict
Expand Down Expand Up @@ -76,6 +76,7 @@ def __init__(self, name: str, runtime_config: util.NameSpace):
env=self.pod_env_vars,
new_work_dir=False)
self.paths.setup_pod_paths(self.name)
self.multicase_dict = runtime_config.case_list
util.MDTFObjectBase.__init__(self, name=self.name, _parent=None)

# Explicitly invoke MDTFObjectBase post_init and init methods so that _id and other inherited
Expand Down

0 comments on commit 5fa7a81

Please sign in to comment.