hterik commented on code in PR #34887:
URL: https://github.com/apache/airflow/pull/34887#discussion_r1392647818
##########
airflow/www/views.py:
##########
@@ -3467,25 +3468,44 @@ def grid_data(self):
if num_runs is None:
num_runs = conf.getint("webserver",
"default_dag_run_display_number")
- try:
- base_date = timezone.parse(request.args["base_date"], strict=True)
- except (KeyError, ValueError):
- base_date = dag.get_latest_execution_date() or timezone.utcnow()
+ dagrun = None
+ if run_id:
+ with create_session() as session:
+ dagrun = dag.get_dagrun(run_id=run_id, session=session)
+ if not dagrun:
+ return {"error": f"can't find dag_run_id={run_id}"}, 404
+ base_date = dagrun.execution_date
+ else:
+ try:
+ base_date = timezone.parse(request.args["base_date"],
strict=True)
+ except (KeyError, ValueError):
+ base_date = dag.get_latest_execution_date() or
timezone.utcnow()
with create_session() as session:
query = select(DagRun).where(DagRun.dag_id == dag.dag_id,
DagRun.execution_date <= base_date)
run_type = request.args.get("run_type")
if run_type:
+ if run_id:
+ return {"error": "Can not provide filters when dag_run_id
filter is selected."}, 400
query = query.where(DagRun.run_type == run_type)
run_state = request.args.get("run_state")
if run_state:
+ if run_id:
+ return {"error": "Can not provide filters when dag_run_id
filter is selected."}, 400
query = query.where(DagRun.state == run_state)
dag_runs = wwwutils.sorted_dag_runs(
query, ordering=dag.timetable.run_ordering, limit=num_runs,
session=session
)
+ if dagrun:
+ found_requested_run_id = any(True for d in dag_runs if d.run_id ==
run_id)
Review Comment:
This query is limited to `num_runs` so it shouldn't be an issue. This is the
final response sent to UI so query must be executed anyway and if it contains
10k runs it would have other bigger issues. The check added here is more of
final assert.
The query that find the base_date based on provided run_id is run further up
on line 3474. Here it uses DB-queries instead of python.
--
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]