model
Pydantic record for the flow_specs cache table (v1).
Module
Functions
spec_hash
def spec_hash(flow_spec_raw: dict[str, Any]) ‑> str:Return the content hash of a rendered flow spec.
Canonical JSON (sorted keys, no insignificant whitespace), so two serialisations of one spec hash alike.
Arguments
flow_spec_raw: The rendered spec, as stored on theflow_specsrow.
Returns The hex SHA-256 digest.
Classes
FlowSpecRecord
class FlowSpecRecord(**data: Any):The persisted replay material for one linked (project, datasource).
Attributes
project_id: Project the datasource is linked to.datasource_name: Datasource the project is linked to.dag_name: The FlowSpec's name, which is also the DAG and Prefect flow name. Denormalised so lineage can be read without deserialisingflow_spec_raw.flow_spec_raw: The FlowSpec exactly as the Hub sent it.origin_task_id: Task id of the triggering envelope, retained so a recovered attempt reports under the task the Hub already tracks.Nonefor the CLI path, which has no envelope.gave_up_at: When an earlier build gave the lineage up. Nothing writes it now: a lineage at its failure limit is held, not given up.Nonewhile the lineage is still allowed to recover.gave_up_reason: Support-facing explanation of why it gave up.linked_at: When this link was last recorded.tags: Arbitrary flat metadata.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Variables
- static
dag_name : str
- static
datasource_name : str
- static
flow_spec_raw : dict[str, typing.Any]
- static
gave_up_at : datetime.datetime | None
- static
gave_up_reason : str | None
- static
linked_at : datetime.datetime
- static
model_config
- static
origin_task_id : str | None
- static
project_id : str
- static
tags : dict[str, typing.Any] | None
-
gave_up : bool- Whether this lineage has been abandoned.Reads the timestamp rather than the reason, so a give-up recorded with no reason still counts.
-
inventory_count_at_last_run : int | None- How many indexed files this lineage's last completed run saw.Nonewhen no run has completed since the lineage was linked, which the growth trigger reads as "no baseline yet" and treats as due. That fails toward doing the work: the alternative — reading it as "nothing has grown" — would wedge a lineage whose every run so far has failed, leaving it to the daily cron for ever.A non-integer value reads as
Nonefor the same reason a corruptlast_rerun_atdoes: one hand-edited row should cost an extra rerun, not stall the trigger.
-
last_hold_at : datetime | None- When this lineage was last held back with nothing running for it.The scheduler's
flows.dag.lineage_facts.last_hold_atis read from the run rows, which a hold recorded by a run leaves behind. A hold the rerun check records itself (record_hold) has no run to leave one, so it lands here instead, and the facts take whichever of the two is newer.Only a hold this way of recording exists for: a run turned away by a lock still dates its own row, and that is the more precise answer.
Read with
last_rerun_at's care — an unparseable or naive stamp isNone, which costs at most one occurrence of held work rather than stalling the lineage with aTypeErrorinside the calendar.Returns: The stamp, or
Nonewhen no hold has been recorded here.
-
last_rerun_at : datetime | None- The legacy rerun stamp, for lineages whose rows do not carry one yet.The scheduler's clock is
flows.dag.lineage_facts.last_rerun_at, read from the run rows; this is its fallback for a pod upgraded between reruns, and goes withLAST_RERUN_AT_TAG.Nonewhen it has never been rerun, or when the stored value is not a parseable aware timestamp — a corrupt tag reads as "never rerun", which costs one extra rerun rather than stalling the lineage forever. A stamp with no zone is rejected for the same reason:fromisoformataccepts one, and the first comparison against an awaredatetimewould then raise inside the rerun calendar, which has no per-record guard.