Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update several object definitions to use better paths #787

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -473,12 +475,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 @@ -519,12 +517,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 @@ -574,9 +568,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 @@ -602,7 +598,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
Loading