Skip to content

'NoneType' object has no attribute 'refresh_from_task' Error when manually running task instance #19477

Closed

Description

@potiuk

Discussed in #19366

Originally posted by a-pertsev November 2, 2021

Apache Airflow version

2.2.1 (latest released)

Operating System

Ubuntu 20.04 LTS

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==2.3.0
apache-airflow-providers-apache-cassandra==2.1.0
apache-airflow-providers-ftp==2.0.1
apache-airflow-providers-google==6.0.0
apache-airflow-providers-http==2.0.1
apache-airflow-providers-imap==2.0.1
apache-airflow-providers-jdbc==2.0.1
apache-airflow-providers-mysql==2.1.1
apache-airflow-providers-postgres==2.3.0
apache-airflow-providers-presto==2.0.1
apache-airflow-providers-slack==4.1.0
apache-airflow-providers-sqlite==2.0.1

Deployment

Virtualenv installation

Deployment details

No response

What happened

Got error when manually run newly created task in already finished dag run (in UI).

What you expected to happen

"Run" button should work without exceptions.

How to reproduce

  1. Define a dag with some tasks.
  2. Create dag run (manually or by schedule)
  3. Add new task into dag, deploy code
  4. Select new task in UI and press "Run" button

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. potiuk commented on Nov 8, 2021

    @potiuk
    MemberAuthor

    Copied from discussion:
    here is some code examples:

    from datetime import datetime
    
    from airflow.operators.python_operator import PythonOperator
    from airflow import DAG
    
    with DAG('a_dag',  schedule_interval=None, default_args={'start_date': datetime(2018, 1, 1, 0, 0, 0)}) as dag:
        def success(*args, **kwargs):
            print('ok')
    
        some_task = PythonOperator(task_id='some_tasks', python_callable=success)
    

    and with new task

    from datetime import datetime
    
    from airflow.operators.python_operator import PythonOperator
    from airflow import DAG
    
    with DAG('a_dag',  schedule_interval=None, default_args={'start_date': datetime(2018, 1, 1, 0, 0, 0)}) as dag:
        def success(*args, **kwargs):
            print('ok')
    
        some_task = PythonOperator(task_id='some_tasks', python_callable=success)
        new_task = PythonOperator(task_id='new_task', python_callable=success)
    and steps to reproduce:
    
    1. Define "a_dag" with "some_tasks".
    2. Create dag run (manually or by schedule)
    3. Add "new_task" into dag, deploy code
    4. Select "new_task" in UI and press "Run" button
  2. potiuk commented on Nov 8, 2021

    @potiuk
    MemberAuthor
  3. added a commit that references this issue on Nov 8, 2021
    cb77afe
  4. added a commit that references this issue on Nov 8, 2021
    51d61a9
  5. a-pertsev commented on Nov 11, 2021

    @a-pertsev

    @potiuk as i can see in #19478, attempt of running newly created task will cause redirect with error message.
    In previous versions airflow was creating and running new task instance - imho it is more preferable behaviour, beacause it is what user expects airflow to do

  6. potiuk commented on Nov 11, 2021

    @potiuk
    MemberAuthor

    I am afraid it is not possible now because of how DAG serializatiion works (and I think this is correct behaviour to be honest). But you can raise a feature request for that (with justification etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions