feat(subset): subset env generator with DAG visualization
What this adds
This MR adds generate_subset.py, a tool that creates a smaller Spack environment from an existing, already-concretized environment.
Given one or more root packages, it:
- Extracts their full dependency closure (build, link, run, and test).
- Generates a self-contained
spack.yamlandspack.lockwhile preserving the originaldag_hashvalues. - Prints the dependency graph as a Unicode tree in the CI logs and can also generate Graphviz (
.dot,.svg,.png) output.
Usage
spack python generate_subset.py \
--env <concretized-spack-environment> \
--specs <packages-to-extract> \
--outdir <output-directory> \
[--dot FILE] [--tree-depth N] \
[--dot-deptypes TYPES] [--dot-dpi N] \
[--pin-deps [TYPES]] [--pin-deps-only NAMES]
Example
spack python generate_subset.py \
--env /path/to/environment \
--specs arbor neuron \
--outdir ./subset \
--dot subset.dot \
--pin-deps
Flags
| Flag | Description | Default |
|---|---|---|
--dot FILE |
Generate a Graphviz .dot file and render an .svg (and .png for graphs with ≤120 nodes). |
Disabled |
--tree-depth N |
Maximum depth of the printed dependency tree (0 = unlimited). |
4 |
--dot-deptypes TYPES |
Dependency types to include (all or link,run). |
all |
--dot-dpi N |
PNG resolution. | 150 |
--pin-deps [TYPES] |
Pin dependencies to ESD hashes using ^/<hash>. |
Off |
--pin-deps-only NAMES |
Limit --pin-deps to specific dependency names. |
Off |
How it works
The tool works with an already-concretized Spack environment. It does not run concretization itself.
It finds the selected root packages, follows all of their dependencies, and writes a new spack.lock containing only those packages. Since it copies the existing concrete specs, the original dag_hash values are preserved, allowing the subset to reuse the existing ESD binary cache.
The generated spack.yaml also keeps the original abstract specs and the site-config/ include, so re-concretizing the subset uses the same compiler, target, and variant settings as the full ESD environment.
Scaling
- Uses an iterative dependency traversal, so it works well even on large dependency graphs.
- Uses
dotwithsplines="ortho"for cleaner DAGs. - Generates PNGs only for graphs with 120 nodes or fewer. Larger graphs generate SVGs.
- Uses different edge styles for different dependency types:
- Link → solid
- Build → dotted
- Run/Test → dashed
- Build dependency pruning is based on dependency traversal instead of a hard-coded package list.
CI changes
build-spack-env-on-runner
The build job now uses the real ESD spack.yaml together with the already-concretized $SPACK_DEV_ENV.
With CONCRETIZE_ONLY=true, it:
- Concretizes the environment.
- Generates subsets for:
arborneuronnestarbor + neuronarbor + neuron --pin-deps
- Generates DAGs under
subset_dags/. - Re-concretizes each subset and reports dependency reuse.
| Subset | Reuse |
|---|---|
| neuron | 98/98 (100%) |
| nest | 130/130 (100%) |
| arbor | 98/100 (98%) |
| arbor + neuron | 106/108 (98%) |
arbor + neuron + --pin-deps
|
107/108 (99%) |
The reuse check is only for validation and cannot fail the pipeline. The production spack.yaml is left unchanged.
install-subset-on-runner
Adds a new manual CI job that installs the ESD from the read-only Harbor build cache. This verifies that the published build cache can be consumed read-only.
install_spack_env.sh
Adds a CONCRETIZE_ONLY option.
When enabled, the script stops after concretization and writing spack.lock, skipping the install step. The default behavior is unchanged.
Binary cache reuse
Generating subsets from the master concretization preserves the original dag_hash values, allowing the generated subset to reuse existing ESD binaries instead of rebuilding them.
Installing from the generated lockfile gives 100% binary cache reuse.
The reuse percentages shown during re-concretization are only a diagnostic.