Skip to content

Commit

Permalink
Fix experiment and workspace inventories
Browse files Browse the repository at this point in the history
This commit ensures experiment inventories are populated before
executing experiment phases. This allows the inventory to be populated
before writing it out to the experiment directory.
  • Loading branch information
douglasjacobsen committed Oct 16, 2024
1 parent 825c8aa commit 035f1da
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions lib/ramble/ramble/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,24 @@ def __init__(self, workspace, filters):
self.workspace.software_environments = self._software_environments
self._experiment_set = workspace.build_experiment_set()

def _construct_hash(self):
"""Hash all of the experiments, construct workspace inventory"""
def _construct_experiment_hashes(self):
"""Hash all of the experiments.
Populate the workspace inventory information with experiment hash data.
"""
for exp, app_inst, _ in self._experiment_set.all_experiments():
app_inst.populate_inventory(
self.workspace,
force_compute=self.force_inventory,
require_exist=self.require_inventory,
)

def _construct_workspace_hash(self):
"""Construct workspace inventory
Assumes experiment hashes are already constructed and populated into
the workspace.
"""
workspace_inventory = os.path.join(self.workspace.root, self.workspace.inventory_file_name)
workspace_hash_file = os.path.join(self.workspace.root, self.workspace.hash_file_name)

Expand Down Expand Up @@ -280,7 +289,8 @@ def _prepare(self):
" Make sure your workspace is setup with\n"
" ramble workspace setup"
)
super()._construct_hash()
super()._construct_experiment_hashes()
super()._construct_workspace_hash()
super()._prepare()

def _complete(self):
Expand Down Expand Up @@ -328,7 +338,8 @@ def __init__(
)

def _prepare(self):
super()._construct_hash()
super()._construct_experiment_hashes()
super()._construct_workspace_hash()
super()._prepare()

date_str = self.workspace.date_string()
Expand Down Expand Up @@ -488,20 +499,22 @@ def __init__(self, workspace, filters):
self.action_string = "Setting up"

def _prepare(self):
# Check if the selected phases require the inventory is successful
if "write_inventory" in self.filters.phases or "*" in self.filters.phases:
self.require_inventory = True

super()._prepare()
experiment_file = open(self.workspace.all_experiments_path, "w+")
shell = ramble.config.get("config:shell")
shell_path = os.path.join("/bin/", shell)
experiment_file.write(f"#!{shell_path}\n")
self.workspace.experiments_script = experiment_file

def _complete(self):
# Check if the selected phases require the inventory is successful
if "write_inventory" in self.filters.phases or "*" in self.filters.phases:
self.require_inventory = True
super()._construct_experiment_hashes()

def _complete(self):
try:
super()._construct_hash()
super()._construct_workspace_hash()
except FileNotFoundError as e:
tty.warn("Unable to construct workspace hash due to missing file")
tty.warn(e)
Expand Down

0 comments on commit 035f1da

Please sign in to comment.