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 the hashing semantics of the pyxis-enroot modifier #731

Merged
Merged
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
48 changes: 33 additions & 15 deletions var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ class PyxisEnroot(BasicModifier):

container_extension = "sqsh"

container_hash_file_extension = "sha256"

name = "pyxis-enroot"

tags("container", "slurm")

maintainers("douglasjacobsen")

mode("standard", description="Standard execution mode for pyxis-enroot")
mode(
"no_provenance",
description="Standard execution mode without provenance tracking",
)
default_mode("standard")

required_variable("container_name")
Expand All @@ -58,43 +64,43 @@ class PyxisEnroot(BasicModifier):
"container_mounts",
default="",
description="Comma delimited list of mount points for the container. Filled in by modifier",
modes=["standard"],
modes=["standard", "no_provenance"],
)

modifier_variable(
"container_env_vars",
default="",
description="Comma delimited list of environments to import into container. Filled in by modifier",
modes=["standard"],
modes=["standard", "no_provenance"],
)

modifier_variable(
"container_dir",
default="{workload_input_dir}",
description="Directory where the container sqsh will be stored",
modes=["standard"],
modes=["standard", "no_provenance"],
)

modifier_variable(
"container_extract_dir",
default="{workload_input_dir}",
description="Directory where the extracted paths will be stored",
modes=["standard"],
modes=["standard", "no_provenance"],
)

modifier_variable(
"container_path",
default="{container_dir}/{container_name}." + container_extension,
description="Full path to the container sqsh file",
modes=["standard"],
modes=["standard", "no_provenance"],
)

modifier_variable(
"container_extract_paths",
default="[]",
description="List of paths to extract from the sqsh file into the {workload_input_dir}. "
+ "Will have paths of {workload_input_dir}/enroot_extractions/{path_basename}",
modes=["standard"],
modes=["standard", "no_provenance"],
track_used=False,
)

Expand Down Expand Up @@ -191,7 +197,6 @@ def extract_names(itr, name_set=set()):
"container_mounts",
modification=prefix + exp_mount,
method="append",
separator=",",
mode=self._usage_mode,
)

Expand Down Expand Up @@ -251,10 +256,6 @@ def _extract_from_sqsh(self, workspace, app_inst=None):
)
container_path = self.expander.expand_var_name("container_path")

if not os.path.exists(container_extract_dir):
if not workspace.dry_run:
fs.mkdirp(container_extract_dir)

unsquash_args = [
"-f",
"-dest",
Expand Down Expand Up @@ -284,6 +285,9 @@ def artifact_inventory(self, workspace, app_inst=None):
container_uri = self.expander.expand_var_name("container_uri")
inventory = []

if self._usage_mode == "no_provenance":
return inventory

inventory.append(
{
"container_uri": container_uri,
Expand All @@ -292,11 +296,25 @@ 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
)

if os.path.exists(hash_file_path):
with open(hash_file_path, "r") as f:
container_hash = f.read()

else:
container_hash = hash_file(container_path)

with open(hash_file_path, "w+") as f:
f.write(container_hash)

inventory.append(
{
"container_name": container_name,
"digest": hash_file(container_path),
}
{"container_name": container_name, "digest": container_hash}
)

return inventory
Expand Down