-
Apache Airflow version2.2.3 (latest released) What happenedI wrote a custom Timetable following the example.
What you expected to happenThe DAG should import successfully in all contexts. How to reproduceI eventually realized that the problem only arises when the Timetable is imported relative to a directory that is not the Steps to reproduce:
Operating SystemCentOS 7.4 Versions of Apache Airflow ProvidersN/A DeploymentOther Deployment detailsCurrently testing with Anything elsePossibly related to #19869. Are you willing to submit PR?
Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Thanks for opening your first issue here! Be sure to follow the issue template! |
Beta Was this translation helpful? Give feedback.
-
I think sample code is wrong. Asterisk (*) is missing in https://airflow.apache.org/docs/apache-airflow/stable/howto/timetable.html#define-scheduling-logic https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/timetables/base/index.html#airflow.timetables.base.Timetable.infer_manual_data_interval |
Beta Was this translation helpful? Give feedback.
-
The asterisk is optional in this case. It means As for the absolute import issue, unfortunately this is a (somewhat obsecure and annoying) problem in Python. If you add a directory in $ tree
.
`-- plugins
|-- __init__.py
`-- mod.py
$ cat plugins/mod.py
class A:
pass
$ PYTHONPATH=plugins python -q # Simulate how Airflow loads the plugin directory.
>>> from plugins.mod import A as AFromAbsolute
>>> from mod import A as AFromPlugin
>>> AFromAbsolute == AFromPlugin
False And since timetable is loaded from plugin, you must import relative to the plugin directory, or somewhere that’s not related to the plugin directory hierarchy, such as |
Beta Was this translation helpful? Give feedback.
-
I am trying the workday example plugin given example directory, when i try import it i get an error.
any suggestion to reslove it? |
Beta Was this translation helpful? Give feedback.
-
Converting that to a discussion - I guess there was some configuraiton issue (and I if I understand well it's been solved by restarting). |
Beta Was this translation helpful? Give feedback.
The asterisk is optional in this case. It means
run_after
can only be called as a keyword argument, while the example code allows the caller to use it as either positional or keyword. But since the function is always only called with keyword arguments in Airflow, both syntax will work. The example code is not wrong.As for the absolute import issue, unfortunately this is a (somewhat obsecure and annoying) problem in Python. If you add a directory in
sys.path
via multiple paths, names imported from differentsys.path
items have different identities.