uranusjr commented on code in PR #41803:
URL: https://github.com/apache/airflow/pull/41803#discussion_r1737868208
##########
airflow/models/xcom.py:
##########
@@ -603,62 +427,15 @@ def clear(
:param session: Database session. If not given, a new session will be
created for this function.
"""
-
- @overload
- @staticmethod
- @internal_api_call
- def clear(
- execution_date: pendulum.DateTime,
- dag_id: str,
- task_id: str,
- session: Session = NEW_SESSION,
- ) -> None:
- """
- Clear all XCom data from the database for the given task instance.
-
- :sphinx-autoapi-skip:
- """
-
- @staticmethod
- @provide_session
- @internal_api_call
- def clear(
- execution_date: pendulum.DateTime | None = None,
- dag_id: str | None = None,
- task_id: str | None = None,
- session: Session = NEW_SESSION,
- *,
- run_id: str | None = None,
- map_index: int | None = None,
- ) -> None:
- """
- Clear all XCom data from the database for the given task instance.
-
- :sphinx-autoapi-skip:
- """
- from airflow.models import DagRun
-
# Given the historic order of this function (execution_date was first
argument) to add a new optional
# param we need to add default values for everything :(
if dag_id is None:
raise TypeError("clear() missing required argument: dag_id")
if task_id is None:
raise TypeError("clear() missing required argument: task_id")
- if not exactly_one(execution_date is not None, run_id is not None):
- raise ValueError(
- f"Exactly one of run_id or execution_date must be passed. "
- f"Passed execution_date={execution_date}, run_id={run_id}"
- )
-
- if execution_date is not None:
- message = "Passing 'execution_date' to 'XCom.clear()' is
deprecated. Use 'run_id' instead."
- warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3)
- run_id = (
- session.query(DagRun.run_id)
- .filter(DagRun.dag_id == dag_id, DagRun.execution_date ==
execution_date)
- .scalar()
- )
+ if not run_id:
+ raise ValueError(f"run_id must be passed. Passed run_id={run_id}")
Review Comment:
Same here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]