Skip to content

Commit

Permalink
Remove deprecations in airflow.models.dagrun (#41778)
Browse files Browse the repository at this point in the history
* Remove deprecations in airflow.models.dagrun

* Update newsfragments/41778.significant.rst

Co-authored-by: Jarek Potiuk <[email protected]>

---------

Co-authored-by: Jarek Potiuk <[email protected]>
  • Loading branch information
jscheffl and potiuk authored Aug 27, 2024
1 parent dc12ad1 commit 748a48a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
37 changes: 1 addition & 36 deletions airflow/models/dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import itertools
import os
import warnings
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, NamedTuple, Sequence, TypeVar, overload

Expand Down Expand Up @@ -51,7 +50,7 @@
from airflow.api_internal.internal_api_call import internal_api_call
from airflow.callbacks.callback_requests import DagCallbackRequest
from airflow.configuration import conf as airflow_conf
from airflow.exceptions import AirflowException, RemovedInAirflow3Warning, TaskNotFound
from airflow.exceptions import AirflowException, TaskNotFound
from airflow.listeners.listener import get_listener_manager
from airflow.models import Log
from airflow.models.abstractoperator import NotMapped
Expand Down Expand Up @@ -1500,31 +1499,6 @@ def _revise_map_indexes_if_mapped(self, task: Operator, *, session: Session) ->
session.flush()
yield ti

@staticmethod
def get_run(session: Session, dag_id: str, execution_date: datetime) -> DagRun | None:
"""
Get a single DAG Run.
:meta private:
:param session: Sqlalchemy ORM Session
:param dag_id: DAG ID
:param execution_date: execution date
:return: DagRun corresponding to the given dag_id and execution date
if one exists. None otherwise.
"""
warnings.warn(
"This method is deprecated. Please use SQLAlchemy directly",
RemovedInAirflow3Warning,
stacklevel=2,
)
return session.scalar(
select(DagRun).where(
DagRun.dag_id == dag_id,
DagRun.external_trigger == False, # noqa: E712
DagRun.execution_date == execution_date,
)
)

@property
def is_backfill(self) -> bool:
return self.run_type == DagRunType.BACKFILL_JOB
Expand Down Expand Up @@ -1668,15 +1642,6 @@ def _get_log_template(
)
return template

@provide_session
def get_log_filename_template(self, *, session: Session = NEW_SESSION) -> str:
warnings.warn(
"This method is deprecated. Please use get_log_template instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
return self.get_log_template(session=session).filename

@staticmethod
def _get_partial_task_ids(dag: DAG | None) -> list[str] | None:
return dag.task_ids if dag and dag.partial else None
Expand Down
4 changes: 4 additions & 0 deletions newsfragments/41778.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Removed a set of deprecations in from ``airflow.models.dagrun``.

- Removed deprecated method ``DagRun.get_run()``. Instead you should use standard Sqlalchemy DagRun model retrieval.
- Removed deprecated method ``DagRun.get_log_filename_template()``. Please use ``get_log_template()`` instead.

0 comments on commit 748a48a

Please sign in to comment.