I have a packaged DAG where I store my module in sub-folder.
I'm using PythonVirtualenvOperator and want to access this module from the virtual env.
The folder system -
dags/
packaged_dag.zip/
dag.py
package/
my_module.py
__init__.py
dag.py
from airflow.operators.python_operator import PythonVirtualenvOperator
def my_function(**kwargs):
from package import my_module
with models.DAG(
default_args=default_dag_args) as dag:
virtualenv_task = PythonVirtualenvOperator(
task_id="virtualenv_python",
python_callable=my_function,
system_site_packages=True,
dag=dag,
)
For this I will get package module not found.
If I'll move the import to the main dag file (like with PythonVirtualenvOperator) - it will work fine but I want the file from the virtualenv.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…