From 8d1c0939efb141c1f11b81e7dc06ba2342031100 Mon Sep 17 00:00:00 2001 From: Douglas Jacobsen Date: Wed, 6 Dec 2023 14:54:05 -0700 Subject: [PATCH] Allow empty spack environments when constructing hash When building an experiment / workspace inventory, previously it was required that if an environment had a spack.yaml, it also created a spack.lock (or Ramble would error). This commit allows spack.yaml files that have no packages (And thus, won't concretized into a spack.lock) without throwing an error. --- lib/ramble/ramble/spack_runner.py | 2 +- .../unsetup_workspace_cannot_analyze.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ramble/ramble/spack_runner.py b/lib/ramble/ramble/spack_runner.py index 68e45ee0f..d6780860d 100644 --- a/lib/ramble/ramble/spack_runner.py +++ b/lib/ramble/ramble/spack_runner.py @@ -602,7 +602,7 @@ def inventory_hash(self, require_exist=False): contents_to_hash = None if not self.dry_run: - if not lock_exists and require_exist: + if not lock_exists and (require_exist or len(self.env_contents) == 0): logger.die( 'spack.lock file does not exist in environment ' f'{self.env_path}\n' diff --git a/lib/ramble/ramble/test/workspace_hashing/unsetup_workspace_cannot_analyze.py b/lib/ramble/ramble/test/workspace_hashing/unsetup_workspace_cannot_analyze.py index d64f8a9b7..a6cff946a 100644 --- a/lib/ramble/ramble/test/workspace_hashing/unsetup_workspace_cannot_analyze.py +++ b/lib/ramble/ramble/test/workspace_hashing/unsetup_workspace_cannot_analyze.py @@ -49,8 +49,13 @@ def test_unsetup_workspace_cannot_analyze(mutable_config, MY_VAR: 'TEST' spack: concretized: true - packages: {} - environments: {} + packages: + zlib: + spack_spec: zlib + environments: + zlib: + packages: + - zlib """ workspace_name = 'test_unsetup_workspace_cannot_analyze' with ramble.workspace.create(workspace_name) as ws: