FrankYang0529 commented on code in PR #68280:
URL: https://github.com/apache/airflow/pull/68280#discussion_r3381070549
##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -195,17 +199,46 @@ def dag_clear(args, *, session: Session = NEW_SESSION) ->
None:
print("Cancelled, nothing was cleared.")
return
- cleared = 0
- for run_id in run_ids:
- cleared += dag.clear(
- run_id=run_id,
- only_failed=args.only_failed,
- only_running=args.only_running,
- session=session,
- )
+ cleared = _bulk_clear_runs(
+ run_ids,
+ only_failed=args.only_failed,
+ only_running=args.only_running,
+ session=session,
+ )
print(f"Cleared {cleared} task instance(s) across {len(run_ids)} Dag
run(s).")
+def _bulk_clear_runs(
+ run_ids: list[str],
+ only_failed: bool,
+ only_running: bool,
+ session: Session,
+) -> int:
+ """Clear task instances for the given run_ids in chunks instead of one
transaction per run."""
+ from airflow.utils.state import TaskInstanceState
Review Comment:
Sorry for that. It's not a valid exception. Move import to top of file.
https://github.com/apache/airflow/blob/6132261fb49e6ffd46846b6c4cee9832fc472b96/AGENTS.md?plain=1#L137
--
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]