Skip to content

ExternalPythonOperator got function not defined error #34460

Answered by Taragolis
yeangPan asked this question in Q&A
Discussion options

You must be logged in to vote

Did you try to import required dependency inside of python callable?

from airflow import DAG
from airflow.operators.python import ExternalPythonOperator
import pendulum


def venv_callable(module="", func=""):
    from omsmanager import run

    run(module=module, func=func)


with DAG(
    dag_id="test_dag", 
    catchup=False,
    schedule="0 0 * * *",
    start_date=pendulum.datetime(2021, 1, 1, tz="UTC")
) as dag:
    virtualenv_task = ExternalPythonOperator(
        task_id="test_task",
        queue="controller",
        python="/opt/airflow/feature/bin/python",
        python_callable=venv_callable,
        op_kwargs = {'module':'datastack','func':'deploy'},
        # requirements=…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yeangPan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants