Skip to content

k4bench.artifacts

k4bench.artifacts

File names of the artifacts one benchmark run directory holds.

A run directory (logs/<geometry>/ locally, {detector}/{platform}/{stack}/ {sample}/{date}/ on EOS) holds its run-wide files and, per benchmark configuration label, one file per artifact kind::

run_info.json
machine_info.json
marlin_processors.xml.gz    k4run only, when the job ran Marlin processors
event_source.json.gz        what went into the events, when it could be read
{label}_results.csv
{label}_events.json
{label}_regions.json        ddsim only
{label}_components.json     k4run only
{label}_joboptions.opts     k4run only
{label}_dataflow.json       k4run only
{label}_heap.json           k4run only, from the memory pass
{label}_event_size.json     when the job wrote output files
{label}.log
{label}_warm-up.log         k4run only, when the warm-up failed
{label}_heap.log            k4run only, when the memory pass failed

These names are part of the on-disk data contract: the benchmark writes them, and the loaders, the regression report, the dashboard and the blame tooling read them back from years of stored runs. Like :mod:k4bench.labels this is a leaf module, so every layer can share the one spelling without importing the others.

label_path

label_path(run_dir: Path, label: str, suffix: str) -> Path

Path of label's artifact with suffix inside run_dir.

Source code in k4bench/artifacts.py
def label_path(run_dir: Path, label: str, suffix: str) -> Path:
    """Path of *label*'s artifact with *suffix* inside *run_dir*."""
    return run_dir / f"{label}{suffix}"

matching

matching(names: Iterable[str], patterns: Iterable[str]) -> list[str]

The names of names that any of patterns matches, in order.

A pattern is a file name, or a shell-style pattern over one (:func:fnmatch.fnmatchcase): f"*{EVENTS_SUFFIX}" is every label's events. A run's file names are matched rather than spelled out because its labels are known only from its listing.

Source code in k4bench/artifacts.py
def matching(names: Iterable[str], patterns: Iterable[str]) -> list[str]:
    """The names of *names* that any of *patterns* matches, in order.

    A pattern is a file name, or a shell-style pattern over one
    (:func:`fnmatch.fnmatchcase`): ``f"*{EVENTS_SUFFIX}"`` is every label's
    events. A run's file names are matched rather than spelled out because
    its labels are known only from its listing.
    """
    patterns = tuple(patterns)
    return [name for name in names if any(fnmatchcase(name, p) for p in patterns)]

labelled_files

labelled_files(run_dir: Path, suffix: str) -> list[tuple[Path, str]]

Every (path, label) in run_dir whose name ends in suffix, sorted by path.

Source code in k4bench/artifacts.py
def labelled_files(run_dir: Path, suffix: str) -> list[tuple[Path, str]]:
    """Every ``(path, label)`` in *run_dir* whose name ends in *suffix*,
    sorted by path."""
    return [
        (path, path.name[: -len(suffix)])
        for path in sorted(run_dir.glob(f"*{suffix}"))
    ]