k4bench.provenance.stack¶
k4bench.provenance.stack ¶
Read a Key4hep release's git provenance off CVMFS.
Spack records the exact upstream commit of every package it builds from git, in three independent places that this module reads in order of preference:
{release}/.spack-db/index.json— the install database, one file for the whole stack (spec.parameters.commit).- the install directory name,
{release}/{pkg}/{commit}_{version}-{hash}— used when the database is unreadable or its schema moved. Coarser (no dependency info) but essentially immune to schema churn. {install}/.spack/repos/**/packages/{pkg}/package.py— the recipe Spack ships beside each install, whosegit =attribute is the upstream URL. Every git-built package in the stack carries one, including the ones from Spack's own builtin repo (those nest one level deeper, underrepos/spack_repo/builtin/).
Nothing here raises: provenance is metadata about a benchmark, and a stack this module cannot parse must degrade to an empty record rather than fail the benchmark that produced the measurements.
RepoRef
dataclass
¶
A package's upstream repository, parsed far enough to build links.
find_release_root ¶
Return the release root for a $KEY4HEP_STACK path, or None.
$KEY4HEP_STACK points at the stack's own setup.sh, several levels
below the release root::
/cvmfs/sw-nightlies.hsf.org/key4hep/releases/{date}/{platform}
└── key4hep-stack/{version}/setup.sh ← $KEY4HEP_STACK
We walk up looking for the .spack-db the caller actually needs, rather
than matching the releases/{date}/{platform} layout with a regex: the
walk tests for the artifact itself, so it keeps working if upstream renests
the tree, and it fails loudly (None) instead of silently returning a
plausible-looking wrong directory.
Source code in k4bench/provenance/stack.py
parse_repo ¶
parse_repo(url: str | None) -> RepoRef | None
Parse a recipe's git URL, or None if we cannot build links for it.
Recognizes GitHub and GitLab (including the self-hosted gitlab.cern.ch
and gitlab.desy.de instances two Key4hep packages live on). An
unrecognized forge returns None: the package keeps its commit, but
guessing a URL layout would produce links that quietly 404.
Source code in k4bench/provenance/stack.py
read_stack_packages ¶
Return {package: {"commit", "version", "repo_url"}} for a release.
Only packages Spack built from git are included — a release-tarball install
has no upstream commit, so it can never be the subject of a blame window.
repo_url is the recipe's URL verbatim (None when the recipe is
missing); use :func:github_slug to normalize it.
Returns {} rather than raising when release_root cannot be read at
all, so a caller can record "no provenance" and carry on.