From 119989c5fa8407a45993ef70940725ae9670f1d9 Mon Sep 17 00:00:00 2001 From: Douglas Jacobsen Date: Fri, 4 Oct 2024 20:35:16 -0600 Subject: [PATCH] Allow force writing workspace config files This commit allows the _write_config method in workspaces to force writing the workspace config. This gets around a problem where reading with _read_config causes _write_config to think the file has already been written as is. --- lib/ramble/ramble/cmd/workspace.py | 2 +- lib/ramble/ramble/workspace/workspace.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ramble/ramble/cmd/workspace.py b/lib/ramble/ramble/cmd/workspace.py index 865f8420b..83ccd6610 100644 --- a/lib/ramble/ramble/cmd/workspace.py +++ b/lib/ramble/ramble/cmd/workspace.py @@ -341,7 +341,7 @@ def _workspace_create( if config: with open(config) as f: workspace._read_config("workspace", f) - workspace._write_config("workspace") + workspace._write_config("workspace", force=True) if template_execute: with open(template_execute) as f: diff --git a/lib/ramble/ramble/workspace/workspace.py b/lib/ramble/ramble/workspace/workspace.py index 33ca92cf0..7abd8067b 100644 --- a/lib/ramble/ramble/workspace/workspace.py +++ b/lib/ramble/ramble/workspace/workspace.py @@ -680,14 +680,14 @@ def write(self, software_dir=None, inputs_dir=None): self._write_templates() - def _write_config(self, section): + def _write_config(self, section, force=False): """Update YAML config file for this workspace, based on changes and write it""" config = self.config_sections[section] changed = not yaml_equivalent(config["raw_yaml"], config["yaml"]) written = os.path.exists(config["path"]) - if changed or not written: + if changed or not written or force: config["raw_yaml"] = copy.deepcopy(config["yaml"]) with fs.write_tmp_and_move(config["path"]) as f: _write_yaml(config["yaml"], f, config["schema"])