Airflow - Python file NOT in the same DAG folder

后端 未结 4 803
抹茶落季
抹茶落季 2021-02-05 06:14

I am trying to use Airflow to execute a simple task python.

from __future__ import print_function
from airflow.operators.python_operator import PythonOperator
f         


        
4条回答
  •  醉酒成梦
    2021-02-05 06:45

    For your first question, it is possible.

    And I guess you should create an empty file named __init__.py under the same directory with SimplePython.py (It is worker directory in your case). By doing that worker directory will be regarded as a python module.

    Then in your DAG definition, try from worker.SimplePython import print_context.

    In you case, I guess it would be better if you write a plugin for airflow, because you might want to upgrade airflow core project without removing your customized functions.

提交回复
热议问题