GitHub user kokoc30 added a comment to the discussion: Timezone-aware schedule 
with @asset decorator

Yes: pass a timetable that carries the timezone as the `schedule`, rather than 
passing a plain cron string.

For example, with the Airflow 3.1.0 API:

~~~python
from airflow.sdk import asset, task
from airflow.timetables.trigger import CronTriggerTimetable


@asset(
    schedule=CronTriggerTimetable(
        "0 9 * * *",
        timezone="Europe/London",
        run_immediately=False,
    )
)
@task.bash(retries=3)
def example_asset():
    return "echo 'run'"
~~~

This interprets the cron expression as **09:00 Europe/London**, including the 
local daylight-saving offset. `run_immediately=False` makes the initial 
schedule wait for the next cron occurrence; it is also the default in 3.1.0.

The reason this works is that the [3.1.0 asset decorator 
implementation](https://github.com/apache/airflow/blob/3.1.0/task-sdk/src/airflow/sdk/definitions/asset/decorators.py)
 accepts `schedule: ScheduleArg` and forwards it to the generated Dag. That 
type includes a `Timetable`. The decorator does not expose every Dag 
constructor argument, so trying to pass `start_date` to it is a different 
issue. The timetable's explicit timezone avoids relying on that missing 
argument or the deployment's default timezone.

One semantic distinction matters: 
[`CronTriggerTimetable`](https://airflow.apache.org/docs/apache-airflow/3.1.0/authoring-and-scheduling/timetable.html#crontriggertimetable)
 triggers at the cron occurrence and has a zero-length data interval by 
default. It is appropriate for “run this producer at 09:00.” If you need a 
historical `start_date`, catchup, or specific data-interval semantics, use an 
explicit `@dag` / `DAG` definition with a task declaring the asset in 
`outlets`. The asset decorator is a shorthand for that structure.

This is checked against the versioned source and timetable documentation; I 
have not run this against your deployment.

---
Drafted-by: Codex (GPT-6) (no human review before posting)

GitHub link: 
https://github.com/apache/airflow/discussions/61940#discussioncomment-19428844

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to