0

I have an airflow dag which i don't want to schedule. I'm using schedule_interval:None in my dag file but the dag is still running automatically once it is deployed. Airflow version used: 2.1.0

Airflow Screenshot Attached. enter image description here I'm using the following python code in my dag file.

import os
import sys
import logging
import croniter
import datetime
from datetime import timedelta
from airflow import DAG
from airflow.operators.python_operator import PythonOperator



default_args = {
'owner': 'test-owner',
'depends_on_past': True,
'start_date': '2021-11-14',
'email': ['test.owner@gmail.com'],
'email_on_failure': True,
'email_on_retry': True,
'retries': 1,
'retry_delay': timedelta(minutes=5),
'schedule_interval':None,
 }

 dag = DAG(
'test-dag',
default_args=default_args,
description='test description'
)

def test_task(ds, **kwargs):
    print(kwargs)
    print(ds)


task = PythonOperator(
    task_id="test_task",
    provide_context=True,
    python_callable=test_task,
    op_kwargs={"image": "value"},
    dag=dag,
)

Also I have setup airflow env variables to the following:

  • AIRFLOW__CORE__LOAD_EXAMPLES: "False"
  • AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: 30
  • AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: "False"

1 Answers1

1

You've set schedule_interval in the default_args, which propagates the given dict as arguments to all operators in the DAG. However, schedule_interval is an argument on DAG, so you must set it there:

 dag = DAG(
'test-dag',
default_args=default_args,
description='test description',
schedule_interval=None,
)
Bas Harenslak
  • 2,591
  • 14
  • 14