Skip to content

Builds and bundles

Build, load, and validate active project build bundles.

ProjectBuilder

Build project artifacts without retaining per-build mutable state.

root instance-attribute

root = pathlib.Path(project_root).resolve()

build

build(*, python_spec: str | None = None, json_spec: JsonSourceInput = None, yaml_spec: YamlSourceInput = None, features: FeatureSelection = None, code: CodeSettings | None = None) -> models.BuildBundle

Build and publish a spec, execution plan, and Explorer snapshot.

Parameters:

Name Type Description Default
python_spec str | None

Optional module:attribute containing a Python Spec.

None
json_spec JsonSourceInput

Optional explicit spec JSON path, relative to the project root unless absolute.

None
yaml_spec YamlSourceInput

Optional YAML file or directory, relative to the project root unless absolute.

None
features FeatureSelection

Optional output features to compile with their dependencies.

None
code CodeSettings | None

Project code settings. If absent, the language comes from the packager or defaults to Python, the runtime definition is discovered, and the source path defaults to src.

None

Returns:

Type Description
BuildBundle

The validated newly published bundle.

Raises:

Type Description
BuildLockError

Another builder or active bundle reader holds the lock.

ProjectBuildError

Loading, compilation, generation, or publication fails.

BundleStore

Load saved and staged bundles for a fixed project root.

root instance-attribute

root = pathlib.Path(project_root).resolve()

read_explorer_snapshot

read_explorer_snapshot() -> bytes

Read the snapshot without validating execution artifacts or requiring write access.

load

load(*, validate: bool = True) -> models.BuildBundle

Load the active build, releasing its reader lock before returning.

Parameters:

Name Type Description Default
validate bool

Run Spec semantic checks. Artifact and plan checks always run.

True

Returns:

Type Description
BuildBundle

A validated bundle containing the saved Spec, plan, and artifact paths.

Raises:

Type Description
BuildError

The bundle is missing, incomplete, or invalid.

read

read(*, validate: bool = True) -> typing.Generator[models.BuildBundle]

Load the active build while holding a reader lock.

Parameters:

Name Type Description Default
validate bool

Run Spec semantic checks. All other bundle checks always run.

True

Yields:

Type Description
Generator[BuildBundle]

The loaded bundle, protected by the reader lock for the context lifetime.

load_at

load_at(bundle_root: Path, *, validate: bool = True, log_structure: bool = True) -> models.BuildBundle

Load a saved or staged bundle while the caller holds its project lock.

Parameters:

Name Type Description Default
bundle_root Path

Directory containing the saved bundle.

required
validate bool

Run Spec semantic checks. Structural and artifact checks always run.

True
log_structure bool

Emit Spec structural validation debug messages.

True

Returns:

Type Description
BuildBundle

The validated bundle at the supplied directory.

Raises:

Type Description
BuildError

The bundle is missing, incomplete, or invalid.

BuildBundle dataclass

Validated artifacts, execution plan, and portable code for one active build.

project_root instance-attribute

project_root: Path

root instance-attribute

root: Path

manifest instance-attribute

manifest: BuildManifest

spec_path instance-attribute

spec_path: Path

spec_definition instance-attribute

spec_definition: Spec

execution_plan_path instance-attribute

execution_plan_path: Path

execution_plan instance-attribute

execution_plan: ExecutionPlan

source_path class-attribute instance-attribute

source_path: Path | None = None

requirements_file class-attribute instance-attribute

requirements_file: Path | None = None

explorer_path class-attribute instance-attribute

explorer_path: Path | None = None

build

build(project_root: str | Path = defaults.DEFAULT_PROJECT_ROOT, python_spec: str | None = None, json_spec: JsonSourceInput = None, features: FeatureSelection = None, *, code: CodeSettings | None = None, yaml_spec: YamlSourceInput = None) -> models.BuildBundle

Build and publish project artifacts through a root-bound builder.

Parameters:

Name Type Description Default
project_root str | Path

Project directory, defaulting to the current directory.

DEFAULT_PROJECT_ROOT
python_spec str | None

Optional module:attribute containing a Python Spec.

None
json_spec JsonSourceInput

Optional explicit spec JSON path, relative to the project root unless absolute.

None
yaml_spec YamlSourceInput

Optional YAML file or directory, relative to the project root unless absolute.

None
features FeatureSelection

Optional output features to compile with their dependencies.

None
code CodeSettings | None

Project code settings. If absent, the language comes from the packager or defaults to Python, the runtime definition is discovered, and the source path defaults to src.

None

Returns:

Type Description
BuildBundle

The validated newly published bundle.

Raises:

Type Description
BuildLockError

Another builder or active bundle reader holds the lock.

ProjectBuildError

Loading, compilation, generation, or publication fails.

load_build_bundle

load_build_bundle(project_root: str | Path, *, validate: bool = True) -> models.BuildBundle

Load the active build through a root-bound bundle store.

Parameters:

Name Type Description Default
project_root str | Path

Root directory of the analytics project.

required
validate bool

Run Spec semantic checks. Artifact and plan checks always run.

True

Returns:

Type Description
BuildBundle

The validated saved build bundle.

Raises:

Type Description
BuildError

The bundle is missing, incomplete, or invalid.

read_build_bundle

read_build_bundle(project_root: str | Path, *, validate: bool = True) -> contextlib.AbstractContextManager[models.BuildBundle]

Return a context manager holding a reader lock on the active build.

Parameters:

Name Type Description Default
project_root str | Path

Root directory of the analytics project.

required
validate bool

Run Spec semantic checks. All other bundle checks always run.

True

Returns:

Type Description
AbstractContextManager[BuildBundle]

A context manager yielding the validated saved build bundle.