Skip to content

Context & Results

This reference covers the context object passed to plugin hooks, the storage sessions it exposes, batch inputs, and the result and metrics types. Import all symbols from firecube.ingestor.api.

Name Description
PluginContext Read-only per-run context handed to every plugin-facing hook.
StorageContext Storage sessions for an ingestion run, keyed by role.
PipelineBatch A batch of data ready for processing in the pipeline.
PipelineRunState Immutable snapshot of a pipeline run passed to lifecycle hooks.
IngestResult Final result of one ingestion run.
PipelineResult Result from a pipeline batch processing.
OutputPaths Shared outputs shape used by both batch- and run-level results.
ResultMetrics Shared metrics shape used by both batch- and run-level results.
PipelineMetrics Typed pipeline processing metrics reported in results.
StorageMetrics Typed summary of storage output produced by a run or batch.

PluginContext

firecube.ingestor.api.PluginContext

Read-only per-run context handed to every plugin-facing hook.

The engine builds one instance per run from the caller's IngestContext plus its own runtime state, and passes it to plugin hooks such as discover_source_files, get_batch_groups, and build_dataset. Plugin authors never construct it themselves.

All members are read-only. In particular, options is a detached immutable copy taken when the context is created, and attribute access outside the documented surface raises AttributeError.

Attributes

source property

source

Input data location for this run, as provided by the caller.

A local path or remote URI (e.g. the --input-data CLI option). The default discover_source_files implementation scans it for input files; plugins with custom discovery may interpret it freely.

target property

target

Output target URI for this run, or None when not provided.

Taken from the caller's IngestContext.target. The engine resolves the actual store location from it together with the configured write mode, so plugins should treat it as declarative rather than writing to it directly.

in_memory property

in_memory

Whether intermediate processing should stay in memory.

Set by the caller (e.g. the --in-memory CLI flag). When true, plugins that stage data (such as DuckDB-backed plugins) should use in-memory state instead of files under temp_root.

output_format property

output_format

Requested output format for this run, or None when unset.

One of "zarr", "parquet", or "tensogram" for the built-in templates; the CLI defaults it to "zarr".

storage property

storage

Storage sessions bound to this run, keyed by role, or None.

When output storage is bound, storage.output is the session for the run's output target. See StorageContext.

temp_root property

temp_root

Per-run workspace directory, or None when no workspace exists.

Created by the engine at run start. Materialized source files and other temporary artifacts live under this root; it may be deleted when the run finishes, so nothing durable should be stored here.

force_reingest property

force_reingest

Whether this run is allowed to overwrite existing slice data.

Engine-owned flag (e.g. --option force_reingest=true); read-only for plugins.

incremental property

incremental

Whether plugin logic should prefer incremental update behavior.

Engine-owned flag; read-only for plugins. When true, plugins that support it should update existing output instead of reprocessing from scratch.

dry_run property

dry_run

Whether side-effecting writes should be suppressed when supported.

Engine-owned flag; read-only for plugins. Plugins that honor it should skip persistent writes while still exercising the rest of their processing.

telemetry property

telemetry

Telemetry sink for this run, or None when not configured.

Plugins should record metrics and tracing spans only through this object (emit(), span()) instead of importing a telemetry backend directly.

options property

options

Plugin options for this run as an immutable mapping.

A detached copy of the caller's options (including --option CLI overrides) wrapped in types.MappingProxyType when the context is created: it cannot be mutated, and later changes to engine state are not reflected in it.

run_id property

run_id

Stable run identifier assigned by the engine for this execution.

Methods:

option

option(key, default=None)

Return a single option value with a fallback.

Parameters:

Name Type Description Default
key str

Option name as passed by the caller (e.g. via --option).

required
default Any

Value returned when the option is not set.

None

Returns:

Type Description
Any

The value from options, or default when missing.

materialize

materialize(source)

Ensure a source file is available locally and return its path.

Remote sources (e.g. S3 URIs) are downloaded into the per-run cache under temp_root; already-local paths are returned directly.

Parameters:

Name Type Description Default
source Any

A local path, URI string, or source-file object.

required

Returns:

Type Description
Path

Local filesystem path to the materialized file.

Raises:

Type Description
RuntimeError

If no materializer is configured for the run and the source cannot be resolved to an existing local file.

Examples:

Resolve discovered items before handing them to a reader that only accepts local paths:

def build_dataset(self, group, items, ctx):
    paths = [ctx.materialize(item) for item in items]
    return xr.open_mfdataset(paths, combine="by_coords")

StorageContext

firecube.ingestor.api.StorageContext dataclass

Storage sessions for an ingestion run, keyed by role.

Each field binds one storage role to a session that the engine creates from the resolved target and selected storage driver. Plugins reach it through PluginContext.storage and should treat the bound sessions as engine-owned handles: use them to inspect the product identity and perform storage operations, but do not replace or close them.

Attributes:

Name Type Description
output StorageSession | None

Session bound to the run's output target, or None when the engine has not bound output storage. The session exposes the product identity (output.product) and filesystem-level operations (exists, open, ...) routed through the selected storage driver.

Batch Input

GenericParquetIngestor and DirectZarrIngestor receive a PipelineBatch. GenericZarrIngestor receives the batch's source items directly.

firecube.ingestor.api.PipelineBatch dataclass

A batch of data ready for processing in the pipeline.

Run State

firecube.ingestor.api.PipelineRunState dataclass

Immutable snapshot of a pipeline run passed to lifecycle hooks.

Captures the planned batches, worker/batch-size configuration, timing counters, and (once available) per-batch results and aggregated totals. Instances are frozen: hooks such as on_pipeline_start observe the state but cannot mutate it.

Results

firecube.ingestor.api.IngestResult dataclass

Final result of one ingestion run.

Aggregates the run's output locations (outputs) and merged metrics (metrics) after all batches have completed. When output storage is bound, the engine additionally records the storage completion outcome (storage_result), the effective write mode (write_mode_applied), and a manifest summary (manifest) before returning the result to the caller.

Attributes

output_path property

output_path

Compatibility view of the primary output path.

Methods:

all_outputs

all_outputs()

Return the typed outputs container for compatibility callers.

firecube.ingestor.api.PipelineResult dataclass

Result from a pipeline batch processing.

Attributes

output_path property

output_path

Compatibility view of the primary output path.

firecube.ingestor.api.OutputPaths dataclass

Shared outputs shape used by both batch- and run-level results.

Methods:

get

get(key, default=None)

Return an output path by compatibility key.

keys

keys()

Return the populated output keys in insertion order.

items

items()

Return compatibility key/value pairs.

Metrics

firecube.ingestor.api.ResultMetrics dataclass

Shared metrics shape used by both batch- and run-level results.

Methods:

__post_init__

__post_init__()

Seed compatibility mapping state from typed fields when needed.

to_dict

to_dict()

Render the typed fields as a plain dict, excluding internal state.

get

get(key, default=None)

Return a compatibility-mapped metric value by key.

__getitem__

__getitem__(key)

Provide mapping-style access for compatibility code paths.

__setitem__

__setitem__(key, value)

Update a compatibility metric entry and keep typed fields in sync.

items

items()

Return compatibility key/value pairs.

values

values()

Return compatibility values.

update

update(other=None, /, **kwargs)

Update compatibility metrics from another mapping or keyword args.

setdefault

setdefault(key, default=None)

Set a compatibility metric only when missing.

keys

keys()

Return the current compatibility keys in insertion order.

__iter__

__iter__()

Iterate over compatibility metric keys.

__len__

__len__()

Return the number of populated compatibility keys.

firecube.ingestor.api.PipelineMetrics dataclass

Typed pipeline processing metrics reported in results.

Attributes:

Name Type Description
duration_pipeline_s float

Time spent in batch processing, in seconds.

rows_processed int | None

Rows read or processed, when known.

rows_ingested int | None

Rows actually written to the output, when known.

coverage list[SpanCoverage]

Span coverage entries describing which groups, arrays, and time ranges the run wrote.

duration_upload_s float

Time spent uploading staged output, in seconds.

duration_total_s float

Total wall-clock duration, in seconds.

Methods:

to_dict

to_dict()

Render pipeline metrics as a compatibility dictionary.

firecube.ingestor.api.StorageMetrics dataclass

Typed summary of storage output produced by a run or batch.

Attributes:

Name Type Description
path str | None

Output path or URI the data was written to, when known.

bytes int

Total bytes written.

files int

Number of files written.

duration_s float

Time spent writing to storage, in seconds.

Methods:

to_dict

to_dict()

Render storage metrics as a compatibility dictionary.

See Also