[
https://issues.apache.org/jira/browse/AIRFLOW-4982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16888087#comment-16888087
]
Ryan Pennell commented on AIRFLOW-4982:
---------------------------------------
Could you clarify what you mean by "in my source tree"? If you are referring
to installed in $AIRFLOW_HOME/plugins or equivalent, this example is not placed
there and can be reproduced when myplugin.py is a packaged and solely installed
via "pip install" through a virtual environment.
The circular dependency can be seen in airflow/plugins_manager.py
load_entrypoint_plugins and is_valid_plugin. It comes from the fact that there
is no way to load plugins via an entry point without inheriting from
AirflowPlugin, but there's no way inherit from AirflogPlugin without first
importing it and thus loading the entry points.
> New entry_point load causes circular dependency
> -----------------------------------------------
>
> Key: AIRFLOW-4982
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4982
> Project: Apache Airflow
> Issue Type: Bug
> Components: plugins
> Affects Versions: 1.10.3
> Reporter: Ryan Pennell
> Priority: Minor
>
> I believe there is a bug with the current method used to load airflow plugins
> with setuptools entry_points.
> When creating a plugin, the current recommended method is (in myplugin.py):
> {code:python}
> from airflow.plugin_manager import AirflowPlugin
> class MyCustomPlugin(AirflowPlugin):
> name='myplugin'
> hooks = []
> {code}
> Also in plugins manager (~line 149) is the code to load the entry point.
> Unless I'm missing something, doesn't this lead to a circular load? If I try
> to use import airflow.operators.myplugin, the entry point will be loaded. So
> the entry point loads myplugin.py, which imports airflow.plugin_manager
> because it needs to inherit from AirflowPlugin. But when myplugin.py imports
> plugin_manager, it tries to load the entry points again. An because it
> hasn't completed the import of AirflowPlugin, the class MyCustomPlugin does
> not exists yet, so the import fails.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)