Skip to content

Commit

Permalink
Merge pull request #787 from douglasjacobsen/object-path-canonicaliza…
Browse files Browse the repository at this point in the history
…tion

Update several object definitions to use better paths
  • Loading branch information
linsword13 authored Dec 5, 2024
2 parents 1737954 + 47df7fa commit 3c7a864
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
28 changes: 12 additions & 16 deletions var/ramble/repos/builtin/applications/py-nemo/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Expand All @@ -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,
)

Expand Down
13 changes: 10 additions & 3 deletions var/ramble/repos/builtin/modifiers/apptainer/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -261,7 +266,9 @@ def artifact_inventory(self, workspace, app_inst=None):
id_regex = re.compile(r"\s*ID:\s*(?P<id>\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 = []
Expand Down
21 changes: 14 additions & 7 deletions var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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],
Expand All @@ -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 = []

Expand All @@ -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):
Expand Down

0 comments on commit 3c7a864

Please sign in to comment.