mamut_routing_lib.sidecars¶
Generic sha-pinned sidecar references and benchmark-collection resolution.
A collection is a family-first benchmark tree (all problem-type variants of
one benchmark family plus their shared sidecars/ tree) marked by a
mamut-collection.json file at its root. Instance files inside a collection
reference their sidecars with paths relative to the collection root, each
paired with the sha256 of the sidecar's uncompressed canonical JSON bytes.
Every published family is a collection (mounted at benchmarks/<Family>/).
The marker's layout_version says how instance paths are shaped below the
root: 1 is the Poryos2026 shape (place, size, base instance), 2 is the shape of
the classic families (<problem>/[<subset>/]n=<N>/<file>.vrp.json).
An instance file that has no marker above it is a loose file: its sidecar
paths are relative to its own directory (:func:sidecar_base_dir).
CollectionResolutionError
¶
Bases: ValueError
Raised when a collection root or a collection-relative path cannot be resolved.
SidecarRef
¶
Bases: BaseModel
A sha-pinned reference to a sidecar file.
path is relative to the collection root (for instances inside a
collection) or to the instance directory (historic layouts).
sha256 pins the sidecar's uncompressed canonical JSON bytes, so it is
stable across .json and .json.gz storage forms.
CollectionMarker
¶
Bases: BaseModel
Content of the mamut-collection.json marker at a collection root.
format_version
class-attribute
instance-attribute
¶
validate_format
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
validate_format_version
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
validate_layout_version
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
validate_relative_sidecar_path
¶
A sidecar path must be relative, non-empty and free of parent escapes.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
load_collection_marker
¶
save_collection_marker
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
find_collection_root
¶
Walk up from start (a file or directory) to the nearest marker directory.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
require_collection_root
¶
require_collection_root(
instance_path: str | Path,
collection_root: str | Path | None = None,
) -> Path
The collection root of an instance: explicit override, else marker walk-up.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
sidecar_base_dir
¶
The directory that the sidecar paths written in an instance are relative to.
Inside a collection this is the collection root (explicit collection_root, else the
nearest mamut-collection.json walking up). A loose instance file, with no marker above
it, resolves its sidecars against its own directory.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/sidecars.py
resolve_sidecar_ref
¶
resolve_sidecar_ref(
ref: SidecarRef,
instance_path: str | Path,
collection_root: str | Path | None = None,
) -> Path
Absolute path of a collection-relative sidecar reference.