Skip to content

Remove airflow.models reference in asset decorator #46927

@uranusjr

Description

@uranusjr

Body

def create_dag(self, *, dag_id: str) -> DAG:
from airflow.models.dag import DAG # TODO: Use the SDK DAG when it works.
return DAG(
dag_id=dag_id,
schedule=self.schedule,
is_paused_upon_creation=self.is_paused_upon_creation,
catchup=False,
dag_display_name=self.display_name or dag_id,
description=self.description,
params=self.params,
on_success_callback=self.on_success_callback,
on_failure_callback=self.on_failure_callback,
auto_register=True,
)

Currently I get an error if this is switched to use DAG from SDK

airflow/dag_processing/collection.py:337: in update_dag_parsing_results_in_db
    DAG.bulk_write_to_db(bundle_name, bundle_version, dags, session=session)
airflow/utils/session.py:98: in wrapper
    return func(*args, **kwargs)
airflow/models/dag.py:1879: in bulk_write_to_db
    dag_op.update_dags(orm_dags, session=session)
airflow/dag_processing/collection.py:430: in update_dags
    dm.default_view = dag.default_view or conf.get("webserver", "dag_default_view").lower()
AttributeError: 'DAG' object has no attribute 'default_view'

The default_view concept should go away at some point (since the old UI itself is out the way out), but I’m not sure why using the SDK DAG directly does not result in an error. Need to investigate and find a solution.

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Metadata

Metadata

Assignees

Labels

area:data-aware-schedulingassets, datasets, AIP-48kind:metaHigh-level information important to the communitypriority:mediumBug that should be fixed before next release but would not block a release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions