airflow.example_dags.plugins.custom_partition_timetable
Classes
A schedulable timetable whose partition key is decided at task runtime. |
|
Class used to define AirflowPlugin. |
Module Contents
- class airflow.example_dags.plugins.custom_partition_timetable.ScheduledRuntimePartitionTimetable(cron, *, timezone, interval=datetime.timedelta(), run_immediately=False)[source]
Bases:
airflow.timetables.trigger.CronTriggerTimetableA schedulable timetable whose partition key is decided at task runtime.
Runs fire on the given cron cadence, exactly like an ordinary
CronTriggerTimetable. The partition key, however, is not derived from the schedule: it is set while the producing task runs — typically after the task checks whether the period’s source data has arrived — by callingoutlet_events[self].add_partitions(...).This uses runtime partitioning on a regular cron schedule: the timetable stays schedulable (
can_be_scheduledisTrue) yet setspartitioned_at_runtime = Trueso the partition key is deferred to task runtime. It differs fromPartitionedAtRuntime(which also defers the key to runtime but never schedules a run on its own) and fromCronPartitionTimetable(which works out the partition key from the cadence ahead of the run).partitionedstaysFalse: no partition key is worked out ahead of the run.Registering it via the
AirflowPlugin.timetablesregistry makes it usable by Dag authors without modifying core Airflow.- partitioned_at_runtime = True[source]
Whether this timetable defers partition selection to task runtime.
True for
PartitionedAtRuntime; downstream code can branch on this flag instead of usingisinstance.