You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "darkag (via GitHub)" <gi...@apache.org> on 2026/02/05 15:03:45 UTC
[I] Best Practice for using variable in timetable seems obsolet [airflow]
darkag opened a new issue, #61497:
URL: https://github.com/apache/airflow/issues/61497
### What do you see as an issue?
hello, it seems that the example provided in this page [https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html#timetables ](https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html#timetables )
is not valid anymore, not only it doesn't works but it also seems to crash dag processor
<img width="585" height="72" alt="Image" src="https://github.com/user-attachments/assets/315c8bde-8989-48dc-b9d3-10165c8e7bec" />
### Solving the problem
If this example is not valid it should be removed (and maybe dag processor should not crash and provide import issue on UI)
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Best Practice for using variable in timetable seems obsolet [airflow]
Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on issue #61497:
URL: https://github.com/apache/airflow/issues/61497#issuecomment-3854492932
@darkag - can you share a snip of the code that you're authoring that's causing this exception?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Best Practice for using variable in timetable seems obsolet [airflow]
Posted by "darkag (via GitHub)" <gi...@apache.org>.
darkag commented on issue #61497:
URL: https://github.com/apache/airflow/issues/61497#issuecomment-3854771440
sure, here is the timetable code
```python
# plugins/special_days_timetable.py
from datetime import timedelta
from airflow.sdk import Variable
import pendulum
from airflow.plugins_manager import AirflowPlugin
from airflow.timetables.base import Timetable, DagRunInfo, DataInterval, TimeRestriction
from pendulum import DateTime
from typing import Optional
class SpecialDaysTimetable(Timetable):
def __init__(self, tz: str = "Europe/Paris"):
self._tz = pendulum.timezone(tz)
self.is_special_date = Variable.get("is_special", "False") == "True"
@property
def summary(self) -> str:
return f"Special date"
# --- Timetable API ---
def infer_manual_data_interval(self, run_after: DateTime) -> DataInterval:
# intervalle de 30 minutes se terminant à run_after
start = run_after.in_timezone(self._tz) - timedelta(minutes=30)
return DataInterval(start=start, end=run_after.in_timezone(self._tz))
def next_dagrun_info(
self,
*,
last_automated_data_interval: Optional[DataInterval],
restriction: TimeRestriction,
) -> Optional[DagRunInfo]:
return None
class SpecialDaysTimetablePlugin(AirflowPlugin):
name = "special_days_timetable_plugin"
timetables = [SpecialDaysTimetable]
```
and the dag using it
```
import pendulum
from datetime import timedelta, datetime
from airflow.decorators import dag,task
from special_days_timetable import SpecialDaysTimetable
local_tz = pendulum.timezone("Europe/Paris")
default_args = {
'owner': 'cineentrees',
'depends_on_past': False,
'email_on_failure': True,
'email_on_retry': False,
'retries': 0,
'retry_delay': timedelta(minutes=1),
}
@dag(
dag_id="test_of_special_days",
default_args=default_args,
schedule=SpecialDaysTimetable(),
start_date=datetime(2023,1,1, 4, tzinfo=local_tz),
max_active_runs=1,
catchup=False,
dagrun_timeout=timedelta(minutes=10),
)
def run_dag():
@task()
def first_task():
pass
first_task()
run_dag()
```
everything is ok if I replace `self.is_special_date = Variable.get("is_special", "False") == "True"` by `self.is_special_date = False`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Best Practice for using variable in timetable seems obsolete [airflow]
Posted by "shashbha14 (via GitHub)" <gi...@apache.org>.
shashbha14 commented on issue #61497:
URL: https://github.com/apache/airflow/issues/61497#issuecomment-3906855676
I would like to work on this issue. Please assign me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Best Practice for using variable in timetable seems obsolete [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb closed issue #61497: Best Practice for using variable in timetable seems obsolete
URL: https://github.com/apache/airflow/issues/61497
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Best Practice for using variable in timetable seems obsolete [airflow]
Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on issue #61497:
URL: https://github.com/apache/airflow/issues/61497#issuecomment-3908345545
@shashbha14, looks like a PR has already been created for this issue. Feel free to find another issue to contribute to!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org