---
name: dazflow
description: >
  A time-series modelling workflow whose every step returns tables, figures and findings ready for a model document. Use when writing Python code that uses the dazflow package.
license: MIT
compatibility: Requires Python >=3.12.
---

# dazflow

A time-series modelling workflow whose every step returns tables, figures and findings ready for a model document.

## Installation

```bash
pip install dazflow
```

## API overview

### Core: data and configuration

The dataset that passes between steps, configuration, and the registries every component joins.

- `ENTRY_POINT_GROUP`: str(object='') -> str
- `FINGERPRINT_FORMAT`: str(object='') -> str
- `STEP_NUMBERS`: dict() -> new empty dictionary
- `Config`: Base class of every configuration: YAML on disk, JSON Schema for tools
- `Dataset`: A frame of series with their metadata, scenarios and a log of changes
- `LogEntry`: One change made to the data, with its reason and what it touched
- `Registry`: Components of one kind, looked up by the key configuration names them by
- `SeriesMeta`: Metadata of one series (one column of `Dataset.frame`)

### Dataset Methods

Methods for the Dataset class

- `Dataset.__setattr__`
- `Dataset.frame`
- `Dataset.series`
- `Dataset.scenarios`
- `Dataset.severity`
- `Dataset.log`
- `Dataset.columns`
- `Dataset.is_panel`
- `Dataset.segments`
- `Dataset.targets`
- `Dataset.drivers`
- `Dataset.fingerprint`
- `Dataset.__repr__`
- `Dataset.with_frame`
- `Dataset.with_series`
- `Dataset.with_scenarios`
- `Dataset.with_log`
- `Dataset.select`

### Registry Methods

Methods for the Registry class

- `Registry.kind`
- `Registry.protocol`
- `Registry.register`
- `Registry.add`
- `Registry.get`
- `Registry.keys`
- `Registry.__contains__`
- `Registry.__iter__`
- `Registry.__len__`
- `Registry.__repr__`

### Core: results, gates and findings

What every step returns: its checks, gate, overrides and finding.

- `Check`: One test: `observed <op> threshold` passes
- `Comparison`
- `Finding`: One or two sentences stating a step's result
- `Gate`: The checks that end a step. It passes when every check passes or is overridden
- `Override`: Accepts a failed check, with the reason written in configuration
- `StepResult`: The shared fields of a step's result; each step subclasses it with typed values

### Core: artefacts

Tables and figures as data, with stable identifiers.

- `Artefact`: Runtime representation of an annotated type
- `ArtefactIds`: The identifiers of one step's artefacts, fixed by name, not by creation order
- `Column`: One table column: its key, its plain-language label, its unit and the kind of value
- `Figure`: A chart for a document, as data: x values, layers, labelled axes, a caption and a source
- `Layer`: One thing drawn on a figure, against the figure's shared x values
- `Source`: Where an artefact's numbers come from: the run, the data and the date
- `Table`: A table for a document: labelled columns, rows of plain values, a caption and a source

### Core: errors

Every error dazflow raises is a `DazflowError`.

- `ArtefactError`: A `Table`, `Figure`, `Source`, `Section`, `Document` or artefact identifier is not valid
- `BuildError`: Candidate models cannot be built as configured (unknown drivers or forms, no data)
- `CheckError`: A data-quality check cannot be evaluated as configured, such as a downturn that cannot be read
- `CleanError`: The clean step cannot treat the data as configured, such as a treatment naming an unknown period
- `ConfigError`: A configuration could not be read, parsed or validated
- `DatasetError`: A `Dataset` or its metadata is not valid
- `DazflowError`: Base class of every error raised by dazflow
- `DiagnoseError`: The chosen model cannot be diagnosed as configured (no model, a back-test, a break)
- `DuplicateKeyError`: A key is already taken in a registry
- `EvaluationError`: A splitter, metric or rolling-origin evaluation cannot run as configured
- `ExploreError`: The explore step cannot profile, test or screen the series as configured
- `FindingError`: A `Finding` template could not be filled with its values
- `ForecastError`: The chosen model cannot be forecast as configured (scenarios, horizon or correction)
- `GateError`: A `Check`, `Gate` or `Override` is not valid, such as an override without a reason
- `IngestError`: The ingest step cannot put its inputs on one calendar as configured
- `MissingExtraError`: An optional package is not installed; `extra` names the ``dazflow`` extra that has it
- `ModelError`: A model form cannot be fitted, predicted or refitted as asked, such as missing values or drivers
- `PipelineError`: A pipeline cannot be built or run as configured, such as an unknown step or order
- `PluginError`: A `dazflow.plugins` entry point failed to load
- `ProjectError`: A project folder cannot be created, read or written, or its run record is missing
- `ReaderError`: Data could not be read, or its dates could not be put on a calendar
- `RecordError`: A run record cannot be read, is of another schema version, or does not match its data
- `RegistryError`: A component could not be registered or looked up
- `RenderError`: An artefact could not be rendered in the format asked for
- `ReportError`: A report cannot be built as configured, such as from something that is not a run record
- `ResultError`: A `StepResult` is not valid or could not be rebuilt from its dictionary
- `SelectError`: Candidates cannot be ranked or chosen as configured (benchmark, choice or scenarios)
- `TransformError`: A transform could not be applied or inverted, such as the log of a value that is not positive
- `UnknownKeyError`: No component is registered under the key; `known` lists the keys that are

### Readers

Read input files and frames into a dataset's calendar.

- `readers.FREQUENCIES`
- `readers.ReadSpec`
- `readers.Reader`
- `readers.ScenarioInput`
- `readers.from_frame`
- `readers.get`
- `readers.read`
- `readers.read_scenarios`
- `readers.register`
- `readers.registry`
- `readers.require`
- `readers.scenario_cover`

### Quality checks

The checks clean runs; register your own the same way.

- `checks.CheckConfig`
- `checks.Context`
- `checks.Downturn`
- `checks.Level`
- `checks.Outcome`
- `checks.QualityCheck`
- `checks.Test`
- `checks.Units`
- `checks.evaluate`
- `checks.get`
- `checks.outlier_scores`
- `checks.register`
- `checks.registry`

### Transforms

Named, invertible transforms recorded as text.

- `transforms.Transform`
- `transforms.TransformSpec`
- `transforms.apply`
- `transforms.consumed`
- `transforms.forward`
- `transforms.get`
- `transforms.inverse`
- `transforms.parse`
- `transforms.register`
- `transforms.registry`

### Model forms

The model forms, the protocol a new form follows, and the stored model record.

- `models.DEFAULT_LEVELS`
- `models.RECORD_FORMAT`
- `models.TREND`
- `models.Design`
- `models.Fitted`
- `models.FittedModel`
- `models.Forecast`
- `models.Model`
- `models.ModelForm`
- `models.ModelRecord`
- `models.ModelSpec`
- `models.Sample`
- `models.fingerprint`
- `models.get`
- `models.newey_west_lags`
- `models.refit`
- `models.register`
- `models.registry`
- `models.season_length`

### Evaluation

Rolling-origin evaluation: splitters, metrics and scores.

- `evaluation.DEFAULT_METRICS`
- `evaluation.MAE`
- `evaluation.MASE`
- `evaluation.RMSE`
- `evaluation.Coverage`
- `evaluation.Evaluation`
- `evaluation.EvaluationRow`
- `evaluation.Expanding`
- `evaluation.Fold`
- `evaluation.Metric`
- `evaluation.Rolling`
- `evaluation.Score`
- `evaluation.Splitter`
- `evaluation.evaluate`
- `evaluation.metrics`
- `evaluation.splitters`

### Rendering

House-style tables, figures and Word documents.

- `render.HOUSE_MPLSTYLE`
- `render.SUFFIXES`
- `render.Captions`
- `render.Dates`
- `render.Document`
- `render.Figures`
- `render.Fonts`
- `render.Mark`
- `render.Marks`
- `render.Numbers`
- `render.Page`
- `render.Renderable`
- `render.Renderer`
- `render.Section`
- `render.Style`
- `render.Word`
- `render.caption_text`
- `render.finding_text`
- `render.format_cell`
- `render.format_date`
- `render.format_number`
- `render.load_style`
- `render.render`
- `render.renderers`
- `render.source_text`
- `render.to_great_table`
- `render.write`

### Steps

The step registry and the protocol a step follows.

- `steps.Step`
- `steps.registry`

### Step: ingest

Read the inputs and put every series on one calendar.

- `ingest.IDS`
- `ingest.IngestConfig`
- `ingest.IngestResult`
- `ingest.Input`
- `ingest.SeriesSpec`
- `ingest.run`

### Step: clean

Data-quality checks, configured treatments and their log.

- `clean.IDS`
- `clean.CleanConfig`
- `clean.CleanResult`
- `clean.Exclude`
- `clean.Fill`
- `clean.Interpolate`
- `clean.Replace`
- `clean.Treatment`
- `clean.TreatmentRecord`
- `clean.Winsorise`
- `clean.run`

### Step: explore

Each series alone, each driver against the target.

- `explore.IDS`
- `explore.ExploreConfig`
- `explore.ExploreResult`
- `explore.Integration`
- `explore.LagProfile`
- `explore.Level`
- `explore.Profile`
- `explore.ProfileConfig`
- `explore.Screen`
- `explore.StationarityConfig`
- `explore.UnitRoot`
- `explore.driver_checks`
- `explore.integration_order`
- `explore.lag_search`
- `explore.newey_west_lags`
- `explore.profile`
- `explore.run`
- `explore.says_stationary`
- `explore.screen`
- `explore.unit_root`

### Step: build

Candidate models within the declared signs and exclusions.

- `build.IDS`
- `build.BuildConfig`
- `build.BuildResult`
- `build.Candidate`
- `build.Coefficient`
- `build.FormSpec`
- `build.combinations`
- `build.run`
- `build.stepwise`
- `build.vif`

### Step: select

Rank the candidates out of sample and propose a default.

- `select.IDS`
- `select.CandidateEvaluation`
- `select.Choice`
- `select.ConfidenceSet`
- `select.MCSConfig`
- `select.OrderingConfig`
- `select.Ranked`
- `select.RuleRow`
- `select.ScenarioForecast`
- `select.SelectConfig`
- `select.SelectResult`
- `select.confidence_set`
- `select.default_rule`
- `select.order_check`
- `select.out_of_order`
- `select.read_scenarios`
- `select.run`

### Step: forecast

The chosen model projected under every scenario.

- `forecast.IDS`
- `forecast.AnchorConfig`
- `forecast.BackTransform`
- `forecast.ForecastConfig`
- `forecast.ForecastResult`
- `forecast.ReversionConfig`
- `forecast.ScenarioPath`
- `forecast.SimulationConfig`
- `forecast.adjustment`
- `forecast.back_transform`
- `forecast.revert`
- `forecast.run`

### Step: diagnose

The chosen model tested against its assumptions and against history.

- `diagnose.IDS`
- `diagnose.Anomaly`
- `diagnose.AnomalyConfig`
- `diagnose.BacktestConfig`
- `diagnose.ChowConfig`
- `diagnose.ChowTest`
- `diagnose.Cusum`
- `diagnose.CusumConfig`
- `diagnose.DiagnoseConfig`
- `diagnose.DiagnoseResult`
- `diagnose.Diagnostic`
- `diagnose.LagTest`
- `diagnose.PValueTest`
- `diagnose.ResetConfig`
- `diagnose.Rolling`
- `diagnose.RollingConfig`
- `diagnose.Sensitivity`
- `diagnose.SensitivityConfig`
- `diagnose.anomalies`
- `diagnose.chow`
- `diagnose.default_lags`
- `diagnose.residual_tests`
- `diagnose.run`

### Step: report

The run as a model document, built from the run record alone.

- `report.IDS`
- `report.TITLES`
- `report.ReplayTolerance`
- `report.ReportConfig`
- `report.ReportResult`
- `report.replay_script`
- `report.run`

### Pipeline, record and replay

Run steps in order, keep the run record, and replay it.

- `pipeline.ATOL`
- `pipeline.DEFAULT_STEPS`
- `pipeline.RECORD_KIND`
- `pipeline.RTOL`
- `pipeline.SCHEMA_VERSION`
- `pipeline.Adapter`
- `pipeline.DatasetRecord`
- `pipeline.Difference`
- `pipeline.Environment`
- `pipeline.InputRecord`
- `pipeline.Pipeline`
- `pipeline.Replay`
- `pipeline.Run`
- `pipeline.RunInfo`
- `pipeline.RunRecord`
- `pipeline.StepInputs`
- `pipeline.adapters`
- `pipeline.compare`
- `pipeline.compare_records`
- `pipeline.default_adapter`
- `pipeline.environment`
- `pipeline.file_sha256`
- `pipeline.register_adapter`
- `pipeline.replay`

### Project folder

A project on disk: its configuration, datasets and reports.

- `project.DATASET_FORMAT`
- `project.PROJECT_FILE`
- `project.RECORD_PATH`
- `project.Project`
- `project.ProjectConfig`
- `project.commented_yaml`
- `project.init`
- `project.load`
- `project.read_dataset`
- `project.schema_path`
- `project.write_dataset`

### Testing

The contract suites every component passes.

- `testing.ComponentContract`
- `testing.ModelContract`
- `testing.sample_series`

## Resources

- [Full documentation](https://pedrobtz.github.io/py-dazflow/)
- [llms.txt](llms.txt) — Indexed API reference for LLMs
- [llms-full.txt](llms-full.txt) — Comprehensive documentation for LLMs
