Skip to main content

hydra_steps()

Get a check collection as a Steps object.

Usage

Source

hydra_steps(
    name,
    vars=None,
    config_dir=None,
    allow_python=False,
)

A check collection is an option of the pointblank/checks config group: a YAML file with a list of validation steps, in a project’s own directory or in the config tree of an installed package. This gets the steps of one collection for use in a validation that’s written in Python, where they’re added with Validate.add_steps().

The arguments of each step are used as they’re written in the collection, as they are for the steps of a Contract, so the python: blocks of a collection aren’t run.

Parameters

name: str

The collection, as it’s selected in a defaults: list (e.g., "ids" or "acme/emails").

vars: Mapping[str, Any] | None = None

Values for the ${vars.<name>} interpolations in the collection.

config_dir: str | Path | None = None

A directory to add to the search path.

allow_python: bool = False
Whether to make the mappings with a _target_ key into the Python objects they describe (such as a custom check that a package provides). Without this, a collection with a _target_ raises an error. Only set it for collections that you trust.

Returns

Steps
The steps of the collection.

Raises

ImportError

If neither hydra-core nor lerna is installed.

YAMLValidationError
If there’s no such collection, or it has an interpolation with no value.

Examples

Let’s write a check collection to a temporary directory. The column it checks is left as a variable.

import pointblank as pb
import tempfile
from pathlib import Path

config_dir = Path(tempfile.mkdtemp())
(config_dir / "pointblank" / "checks").mkdir(parents=True)

(config_dir / "pointblank" / "checks" / "ids.yaml").write_text('''
# @package checks.ids
steps:
- col_vals_not_null:
    columns: ${vars.id_column}
- rows_distinct:
    columns_subset: ${vars.id_column}
''')

id_checks = pb.hydra_steps("ids", vars={"id_column": "a"}, config_dir=config_dir)
id_checks
Steps — 2 steps
1.col_vals_not_null(columns='a')
2.rows_distinct(columns_subset='a')

The steps can be added to any validation, alongside steps that are written in Python:

(
    pb.Validate(data=pb.load_dataset("small_table"))
    .add_steps(id_checks)
    .col_vals_gt(columns="d", value=100)
    .interrogate()
)
Pointblank Validation
2026-12-04|20:52:35
Polars
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_not_null
col_vals_not_null()
a — ✓ 13 13
1.00
0
0.00
— — — —
#4CA64C66 2
rows_distinct
rows_distinct()
a — ✓ 13 4
0.31
9
0.69
— — —
#4CA64C 3
col_vals_gt
col_vals_gt()
d 100 ✓ 13 13
1.00
0
0.00
— — — —

The two steps of the collection come first in the validation, followed by the step that’s written in Python.