research_helpers.build
This module covers the registry of generated artefacts and the drift checks over them. See Adding a generated table for the end-to-end workflow.
- class research_helpers.build.Kind(name, suffix, directory, label_prefix, setting, reference, block, float_is_generated, binary=False)[source]
Bases:
objectA class of generated artefact (and how the paper refers to it).
- Parameters:
- hand_written(paper)[source]
Return the floats the paper carries with no emitter behind them, keyed by label.
Where the emitter produces the float itself, any literal float is hand-written. Where it produces only the contents, a float counts as hand-written when nothing inside it is pulled in from this kind’s directory.
- class research_helpers.build.Artefact(label, emitter, description='', metadata=<factory>)[source]
Bases:
objectA registered artefact.
- class research_helpers.build.Drift(stale, missing, ungenerated)[source]
Bases:
NamedTupleThe three ways a paper and its emitters can disagree.
- class research_helpers.build.Registry(kind)[source]
Bases:
objectThe emitters for one kind of artefact and the checks over them.
- Parameters:
kind (Kind)
- register(label, *, description='', **metadata)[source]
Register the decorated function as the emitter for ‘label’.
- Parameters:
- Return type:
Callable[[TypeVar(EmitterT, bound= Callable[[], str | bytes])],TypeVar(EmitterT, bound= Callable[[], str | bytes])]- Returns:
The decorator, which returns the emitter unchanged so it stays directly callable.
- Raises:
ValueError – if the label is already registered or lacks the kind’s prefix.
- build_dir(directory=None)[source]
Return where artefacts are built, defaulting to the project’s build directory.
- install_dir(destination=None)[source]
Return where the paper reads artefacts from, defaulting to the project’s setting.
- write_all(directory=None)[source]
Build every artefact into ‘directory’, one file per label, and return the paths.
- install(destination=None, source=None)[source]
Copy built artefacts to where the paper reads them.
- Parameters:
- Return type:
- Returns:
The paths written.
- Raises:
FileNotFoundError – if an artefact has not been built.
- drift(paper=None, destination=None)[source]
Compare what the paper carries against what the emitters produce.
- Parameters:
- Return type:
- Returns:
The three ways they disagree; falsy when they do not.