-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Add run_on_latest_version support for backfill and clear operations #52177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4d9ebcc
65e5db1
2d825ef
065300b
2e43d42
c8a95a9
07c9384
400b7a7
92f5776
f068789
2c7f12e
71ec6c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
from airflow.api_fastapi.execution_api.datamodels.dagrun import DagRunStateResponse, TriggerDAGRunPayload | ||
from airflow.exceptions import DagRunAlreadyExists | ||
from airflow.models.dag import DagModel | ||
from airflow.models.dagbag import DagBag | ||
from airflow.models.dagrun import DagRun | ||
from airflow.utils.types import DagRunTriggeredByType | ||
|
||
|
@@ -122,9 +121,20 @@ def clear_dag_run( | |
"message": f"DAG with dag_id: '{dag_id}' has import errors and cannot be triggered", | ||
}, | ||
) | ||
from airflow.jobs.scheduler_job_runner import SchedulerDagBag | ||
|
||
dag_run = session.scalar(select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == run_id)) | ||
dag_bag = SchedulerDagBag() | ||
jason810496 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given we did There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's because the circular import error as mentioned in #52177 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This endpoint don't also have dagbag dependency. If you scroll down, you can see usage of DagBag before the change |
||
dag = dag_bag.get_dag(dag_run=dag_run, session=session) | ||
if not dag: | ||
raise HTTPException( | ||
status.HTTP_404_NOT_FOUND, | ||
detail={ | ||
"reason": "Not Found", | ||
"message": f"DAG with dag_id: '{dag_id}' was not found in the DagBag", | ||
}, | ||
) | ||
|
||
dag_bag = DagBag(dag_folder=dm.fileloc, read_dags_from_db=True) | ||
dag = dag_bag.get_dag(dag_id) | ||
dag.clear(run_id=run_id) | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.