diff --git a/var/ramble/repos/builtin/applications/py-nemo/application.py b/var/ramble/repos/builtin/applications/py-nemo/application.py index 2be38ad8d..633d34f28 100644 --- a/var/ramble/repos/builtin/applications/py-nemo/application.py +++ b/var/ramble/repos/builtin/applications/py-nemo/application.py @@ -16,6 +16,8 @@ import ramble.util.yaml_generation +from spack.util.path import canonicalize_path + class PyNemo(ExecutableApplication): """A scalable generative AI framework built for researchers and @@ -481,12 +483,8 @@ def _ingest_default_configs(self, workspace, app_inst): not defined in the input ramble.yaml or workload definition.""" base_config = get_file_path( - os.path.abspath( - os.path.expandvars( - os.path.expanduser( - self.expander.expand_var_name("nemo_base_config") - ) - ) + canonicalize_path( + self.expander.expand_var_name("nemo_base_config") ), workspace, ) @@ -527,12 +525,8 @@ def _ingest_default_configs(self, workspace, app_inst): def _write_config(self, workspace, app_inst): base_config = get_file_path( - os.path.abspath( - os.path.expandvars( - os.path.expanduser( - self.expander.expand_var_name("nemo_base_config") - ) - ) + canonicalize_path( + self.expander.expand_var_name("nemo_base_config") ), workspace, ) @@ -582,9 +576,11 @@ def _write_config(self, workspace, app_inst): config_data, var_name ) - config_path = os.path.join( - self.expander.expand_var("{nemo_generated_config_path}"), - self.expander.expand_var("{nemo_generated_config_name}"), + config_path = canonicalize_path( + os.path.join( + self.expander.expand_var("{nemo_generated_config_path}"), + self.expander.expand_var("{nemo_generated_config_name}"), + ) ) # Ensure all instances of ${data_dir} are replaced correctly @@ -610,7 +606,7 @@ def _write_config(self, workspace, app_inst): def _preprocess_log(self, workspace, app_inst): log_file = get_file_path( - os.path.abspath(self.expander.expand_var_name("log_file")), + canonicalize_path(self.expander.expand_var_name("log_file")), workspace, ) diff --git a/var/ramble/repos/builtin/modifiers/apptainer/modifier.py b/var/ramble/repos/builtin/modifiers/apptainer/modifier.py index de853858a..3594d47bc 100644 --- a/var/ramble/repos/builtin/modifiers/apptainer/modifier.py +++ b/var/ramble/repos/builtin/modifiers/apptainer/modifier.py @@ -11,6 +11,7 @@ from ramble.modkit import * from ramble.util.hashing import hash_string +from spack.util.path import canonicalize_path import llnl.util.filesystem as fs @@ -231,8 +232,12 @@ def _pull_sif(self, workspace, app_inst=None): uri = self.expander.expand_var_name("container_uri") - container_dir = self.expander.expand_var_name("container_dir") - container_path = self.expander.expand_var_name("container_path") + container_dir = canonicalize_path( + self.expander.expand_var_name("container_dir") + ) + container_path = canonicalize_path( + self.expander.expand_var_name("container_path") + ) pull_args = ["pull", container_path, uri] @@ -261,7 +266,9 @@ def artifact_inventory(self, workspace, app_inst=None): id_regex = re.compile(r"\s*ID:\s*(?P\S+)") container_name = self.expander.expand_var_name("container_name") container_uri = self.expander.expand_var_name("container_uri") - container_path = self.expander.expand_var_name("container_path") + container_path = canonicalize_path( + self.expander.expand_var_name("container_path") + ) header_args = ["sif", "header", container_path] inventory = [] diff --git a/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py b/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py index cb1d0378e..c1fec7ffc 100644 --- a/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py +++ b/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py @@ -10,6 +10,7 @@ from ramble.modkit import * from ramble.util.hashing import hash_file, hash_string +from spack.util.path import canonicalize_path import llnl.util.filesystem as fs @@ -218,8 +219,12 @@ def _import_sqsh(self, workspace, app_inst=None): uri = self.expander.expand_var_name("container_uri") - container_dir = self.expander.expand_var_name("container_dir") - container_path = self.expander.expand_var_name("container_path") + container_dir = canonicalize_path( + self.expander.expand_var_name("container_dir") + ) + container_path = canonicalize_path( + self.expander.expand_var_name("container_path") + ) import_args = ["import", "-o", container_path, "--", uri] @@ -264,7 +269,9 @@ def _extract_from_sqsh(self, workspace, app_inst=None): ] for extract_path in extract_paths: - expanded_path = self.expander.expand_var(extract_path) + expanded_path = canonicalize_path( + self.expander.expand_var(extract_path) + ) self.unsquashfs_runner.execute( self.unsquashfs_runner.command, unsquash_args + [expanded_path], @@ -281,7 +288,9 @@ def artifact_inventory(self, workspace, app_inst=None): (dict): Artifact inventory for container attributes """ container_name = self.expander.expand_var_name("container_name") - container_path = self.expander.expand_var_name("container_path") + container_path = canonicalize_path( + self.expander.expand_var_name("container_path") + ) container_uri = self.expander.expand_var_name("container_uri") inventory = [] @@ -298,9 +307,7 @@ def artifact_inventory(self, workspace, app_inst=None): if os.path.isfile(container_path): hash_file_path = ( - self.expander.expand_var_name("container_path") - + "." - + self.container_hash_file_extension + container_path + "." + self.container_hash_file_extension ) if os.path.exists(hash_file_path):