Skip to content

Commit 7ec109a

Browse files
authored
Metadata Creation Uses spack --config-scope Scopes (#357)
* Update get_data_from_deployment script to take in `spack --config-scope` argument, updated usages * Bounds checking for non-custom-scope builds * Update print statement * Raise spacks own error for failing to find a configuration scope
1 parent f9c72b6 commit 7ec109a

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

.github/workflows/deploy-2-start.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ jobs:
8282
run: |
8383
echo "spack=$(jq --compact-output --raw-output '.spack' ./config/versions.json)" >> $GITHUB_OUTPUT
8484
echo "packages=$(jq --compact-output --raw-output '."access-spack-packages"' ./config/versions.json)" >> $GITHUB_OUTPUT
85-
echo "custom-scopes=$(jq --compact-output --raw-output '."custom-scopes" // [] | join(" ")' ./config/versions.json)" >> $GITHUB_OUTPUT
85+
echo "custom-scopes-space-separated=$(jq --compact-output --raw-output '."custom-scopes" // [] | join(" ")' ./config/versions.json)" >> $GITHUB_OUTPUT
86+
echo "custom-scopes-comma-separated=$(jq --compact-output --raw-output '."custom-scopes" // [] | join(",")' ./config/versions.json)" >> $GITHUB_OUTPUT
87+
8688
8789
- name: Get ${{ inputs.deployment-target }} ${{ inputs.deployment-type }} Remote Paths
8890
id: path
@@ -181,7 +183,7 @@ jobs:
181183
- name: Deploy to ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}
182184
id: deploy
183185
env:
184-
SCOPES: ${{ steps.versions.outputs.custom-scopes }}
186+
SCOPES: ${{ steps.versions.outputs.custom-scopes-space-separated }}
185187
SCOPES_PATH: ${{ steps.path.outputs.spack-config }}/custom/cd
186188
# ssh into deployment environment, create and activate the env, install the spack manifest.
187189
run: |
@@ -243,6 +245,7 @@ jobs:
243245
--environment ${{ steps.path.outputs.spack-environment }} \
244246
--deployment-name ${{ inputs.expected-root-spec-name }} \
245247
--packages ${{ steps.config-packages.outputs.packages-for-provenance }} \
248+
--config-scopes ${{ steps.versions.outputs.custom-scopes-comma-separated }} \
246249
--output ${{ steps.path.outputs.spack-environment }}
247250
EOT
248251

scripts/release_provenance/get_data_from_deployment.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@
99
from typing import Any, List, Dict
1010

1111
import spack.environment
12+
import spack.error
1213
import spack.cmd
14+
import spack.config
15+
import spack.paths
1316
import spack.spec
1417
import spack.repo
18+
import spack.main
1519

1620

1721
def main():
1822
args = parse_args(sys.argv[1:])
1923
packages: List[str] = args.packages.split(",")
24+
config_scopes: List[str] = args.config_scopes.split(",") if args.config_scopes else []
2025
output_path = Path(args.output)
2126

27+
# Custom scopes added via spack --config-scope for install need to be added back here
28+
# so we can find those packages!
29+
add_custom_spack_config_scopes(config_scopes)
30+
2231
# Activate the spack environment so we can get relevant specs for this deployment
2332
spack_env = activate_spack_environment(args.environment)
2433

@@ -50,6 +59,26 @@ def main():
5059
with open(output_path / "build-db-pkgs.json", 'w') as f:
5160
json.dump(packages_metadata, f)
5261

62+
def add_custom_spack_config_scopes(config_scopes: List[str]) -> None:
63+
"""
64+
Adds paths to custom spack config scopes to the command_line scope so we can find binaries for
65+
certain environments that use custom installation directories.
66+
67+
:param config_scopes: Names of custom scopes from spack-configs custom/cd directory.
68+
:type config_scopes: List[str]
69+
"""
70+
spack_config_custom_scopes_path: Path = Path(spack.paths.spack_root).parent / "spack-config" / "custom" / "cd"
71+
72+
config_scope_paths: List[str] = [str(spack_config_custom_scopes_path / s) for s in config_scopes]
73+
74+
print(f"Attempting to load custom scopes: {config_scope_paths}")
75+
76+
try:
77+
spack.main.add_command_line_scopes(spack.config.CONFIG, config_scope_paths)
78+
except spack.error.ConfigError:
79+
print(f"Failed to find valid config scope in paths {config_scope_paths}.")
80+
raise
81+
5382
def activate_spack_environment(spack_env_path: str) -> spack.environment.Environment:
5483
spack_env = spack.environment.Environment(spack_env_path)
5584

@@ -144,6 +173,13 @@ def parse_args(args: List[str]) -> argparse.Namespace:
144173
help="Comma-separated list of packages to extract build metadata for",
145174
)
146175

176+
parser.add_argument(
177+
"--config-scopes",
178+
type=str,
179+
required=False,
180+
help="Comma-separated list of custom spack config scopes defined in spack-configs custom/cd directory"
181+
)
182+
147183
## Args dealing with outputs
148184
parser.add_argument(
149185
"--output",

0 commit comments

Comments
 (0)