Changeset View
Changeset View
Standalone View
Standalone View
docs/content/concepts/partitions-schedules-sensors/partitions.mdx
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
def weekday_partition_selector( | def weekday_partition_selector( | ||||
ctx: ScheduleEvaluationContext, partition_set: PartitionSetDefinition | ctx: ScheduleEvaluationContext, partition_set: PartitionSetDefinition | ||||
) -> Union[Partition, List[Partition]]: | ) -> Union[Partition, List[Partition]]: | ||||
"""Maps a schedule execution time to the corresponding partition or list of partitions that | """Maps a schedule execution time to the corresponding partition or list of partitions that | ||||
should be executed at that time""" | should be executed at that time""" | ||||
partitions = partition_set.get_partitions(ctx.scheduled_execution_time) | partitions = partition_set.get_partitions(ctx.scheduled_execution_time) | ||||
weekday = ctx.scheduled_execution_time.weekday() if ctx.scheduled_execution_time else 0 | weekday = ( | ||||
ctx.scheduled_execution_time.weekday() | |||||
if ctx.scheduled_execution_time | |||||
else 0 | |||||
) | |||||
return partitions[weekday] | return partitions[weekday] | ||||
my_schedule = weekday_partition_set.create_schedule_definition( | my_schedule = weekday_partition_set.create_schedule_definition( | ||||
"my_schedule", | "my_schedule", | ||||
"5 0 * * *", | "5 0 * * *", | ||||
partition_selector=weekday_partition_selector, | partition_selector=weekday_partition_selector, | ||||
execution_timezone="US/Eastern", | execution_timezone="US/Eastern", | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |