From 3420c27e1960a296c3c7b64d275884ee1a124e70 Mon Sep 17 00:00:00 2001 From: Lin Guo Date: Thu, 23 Jan 2025 22:41:58 -0800 Subject: [PATCH] Archive templates rendered via `register_template` --- lib/ramble/ramble/application.py | 6 ++++++ lib/ramble/ramble/test/end_to_end/test_template.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/ramble/ramble/application.py b/lib/ramble/ramble/application.py index 050156f42..e18637908 100644 --- a/lib/ramble/ramble/application.py +++ b/lib/ramble/ramble/application.py @@ -1573,6 +1573,12 @@ def _archive_experiments(self, workspace, app_inst=None): if os.path.exists(src): shutil.copy(src, archive_experiment_dir) + # Copy all rendered templates generated by `register_template` + for _, tpl_config in self._object_templates(workspace): + src_path = tpl_config["dest_path"] + if os.path.exists(src_path): + shutil.copy(src_path, archive_experiment_dir) + # Copy all figure of merit files criteria_list = workspace.success_list analysis_files, _, _ = self._analysis_dicts(criteria_list) diff --git a/lib/ramble/ramble/test/end_to_end/test_template.py b/lib/ramble/ramble/test/end_to_end/test_template.py index c7305e0bf..db94d5176 100644 --- a/lib/ramble/ramble/test/end_to_end/test_template.py +++ b/lib/ramble/ramble/test/end_to_end/test_template.py @@ -68,6 +68,15 @@ def test_template(): assert os.path.isfile(script3_path) assert os.path.isfile(script4_path) + # Test template archival + workspace("archive", global_args=["-w", workspace_name]) + exp_archive_path = os.path.join( + ws.latest_archive_path, "experiments", "template", "test_template", "test" + ) + files = os.listdir(exp_archive_path) + assert "bar.sh" in files + assert "script.sh" in files + def test_template_inherited(): test_config = """