Implementation:416rehman DeepZero load pipeline
| Knowledge Sources | |
|---|---|
| Domains | Pipeline_Orchestration, Configuration |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Loads, validates, and instantiates a pipeline from YAML, with environment variable expansion, processor resolution, and pipeline graph validation.
Description
The load_pipeline function is the entry point for pipeline loading. It takes a pipeline reference (bare name, directory, or file path), reads the YAML, expands environment variables, parses stage specs, resolves processor classes, and validates the pipeline graph. It returns a PipelineDefinition ready for execution.
Key operations:
- Environment variable expansion: ${VAR} expands to the env value or empty; ${VAR:-default} provides a fallback. This runs before config parsing, so empty vars don't leak as literal strings.
- Processor resolution: bare names resolve to built-in registry; dir/file.py resolves to external processors in the processors/ directory; module:Class resolves via dotted import.
- Graph validation: first stage must be IngestProcessor; subsequent stages must be Map/Reduce/BulkMap; each processor's validate() is called to check dependencies.
- Corpus scoping: PipelineDefinition.bind_corpus(target) scopes the work directory to a specific target, so different targets through the same pipeline get isolated, independently resumable run directories.
The companion validate_pipeline function runs the same loading but returns warnings instead of raising, for use by deepzero validate.
Usage
- Loading a pipeline for execution: load_pipeline("demo") or load_pipeline("./pipelines/loldrivers")
- Overriding model or work directory: load_pipeline(pipeline, model_override="openai/gpt-4o", work_dir_override="./custom_work")
- Validating without running: validate_pipeline("demo") returns a list of warnings
Code Reference
Source Location
- Repository: DeepZero
- File: src/deepzero/engine/pipeline.py
Signature
class PipelineDefinition:
name: str
description: str
model: str
settings: dict[str, Any]
knowledge: dict[str, Any]
stage_specs: list[StageSpec]
pipeline_dir: Path
raw_yaml: str
report: dict[str, Any] | None
ingest_processor: IngestProcessor | None
stages: list[tuple[StageSpec, Processor]]
@property
def work_dir(self) -> Path: ...
def bind_corpus(self, target: Path) -> None: ...
def to_global_config(self) -> GlobalConfig: ...
def load_pipeline(
pipeline_ref: str,
model_override: str | None = None,
work_dir_override: str | None = None,
) -> PipelineDefinition: ...
def validate_pipeline(pipeline_ref: str) -> list[str]: ...
Import
from deepzero.engine.pipeline import load_pipeline, validate_pipeline, PipelineDefinition
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| pipeline_ref | str | Yes | Pipeline name, directory, or YAML file path |
| model_override | None | No | Override the model field from YAML |
| work_dir_override | None | No | Override the work_dir setting |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | PipelineDefinition | Loaded and validated pipeline ready for execution |
| validate_pipeline returns | list[str] | Validation warnings (empty list = valid) |
Usage Examples
Loading and Running a Pipeline
from pathlib import Path
from deepzero.engine.pipeline import load_pipeline
# Load by name (searches pipelines/ directory)
pipeline = load_pipeline("demo")
# Load by path
pipeline = load_pipeline("./pipelines/loldrivers/pipeline.yaml")
# Override model
pipeline = load_pipeline("loldrivers", model_override="openai/gpt-4o")
# Scope to corpus before running
pipeline.bind_corpus(Path("./driver_pack"))
print(f"Work dir: {pipeline.work_dir}")
Validating Without Running
from deepzero.engine.pipeline import validate_pipeline
warnings = validate_pipeline("loldrivers")
for w in warnings:
print(w)
# "pipeline is valid - no issues found" means all good
Environment Variable Expansion
# In pipeline YAML:
# config:
# ghidra_install_dir: ${GHIDRA_INSTALL_DIR}
# java_home: ${JAVA_HOME:-/usr/lib/jvm/default}
#
# ${VAR} expands to env value or empty string
# ${VAR:-default} expands to env value or the default