Akash Srivastava
Akash Srivastava

Reputation: 23

Airflow None Schedule is not working. Tasks are still running automatically

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': ['[email protected]'],
'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:

Upvotes: 0

Views: 399

Answers (1)

Bas Harenslak
Bas Harenslak

Reputation: 3064

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,
)

Upvotes: 1

Related Questions