Auto refresh on Tree View - #15474
Conversation
ashb
left a comment
There was a problem hiding this comment.
There's probably too much duplication between this new method and the existing tree view that we should pull out in to a function and call from both places.
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
…flow into refresh-tree-view
| context['dag'] = dag | ||
|
|
||
|
|
||
| def get_tree_data(dag_runs, dag, base_date): |
There was a problem hiding this comment.
| def get_tree_data(dag_runs, dag, base_date): | |
| def get_tree_data(dag_runs: Iterable[DagRun], dag: DAG, base_date: DateTime): |
(I think those types should be in scope and correct)
|
The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*. |
|
The Workflow run is cancelling this PR. Building image for the PR has been cancelled |
|
Good catch. I added a min-width to the refresh actions so there is always space for the loading dots. |
uranusjr
left a comment
There was a problem hiding this comment.
Some coding style suggestions that might help get rid of pylint’s too-many-locals warning as well (no idea how many is too many). Nothing logical incorrect from what I can tell.
| dates = sorted(dag_runs.keys()) | ||
| max_date = max(dates) if dates else None | ||
| min_date = min(dates) if dates else None |
There was a problem hiding this comment.
| dates = sorted(dag_runs.keys()) | |
| max_date = max(dates) if dates else None | |
| min_date = min(dates) if dates else None | |
| max_date = max(dag_runs, default=None) | |
| min_date = min(dag_runs, default=None) |
| tis = dag.get_task_instances(start_date=min_date, end_date=base_date) | ||
| task_instances: Dict[Tuple[str, datetime], models.TaskInstance] = {} | ||
| for ti in tis: | ||
| task_instances[(ti.task_id, ti.execution_date)] = ti |
There was a problem hiding this comment.
| tis = dag.get_task_instances(start_date=min_date, end_date=base_date) | |
| task_instances: Dict[Tuple[str, datetime], models.TaskInstance] = {} | |
| for ti in tis: | |
| task_instances[(ti.task_id, ti.execution_date)] = ti | |
| task_instances = { | |
| (ti.task_id, ti.execution_date): ti | |
| for ti in dag.get_task_instances(start_date=min_date, end_date=base_date) | |
| } |
| if base_date: | ||
| base_date = timezone.parse(base_date) | ||
| else: | ||
| base_date = dag.get_latest_execution_date() or timezone.utcnow() |
There was a problem hiding this comment.
| if base_date: | |
| base_date = timezone.parse(base_date) | |
| else: | |
| base_date = dag.get_latest_execution_date() or timezone.utcnow() | |
| try: | |
| base_date = timezone.parse(request.args["base_date"]) | |
| except (KeyError, ValueError): | |
| base_date = dag.get_latest_execution_date() or timezone.utcnow() |
and remove the base_date line above. There’s a similar one in the other view as well.
ryanahamilton
left a comment
There was a problem hiding this comment.
I did a bunch of local testing on this—it works great and I think people are really going to love it!
|
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease. |
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>

Auto-refresh on Graph View was a very popular feature when 2.0.0 was released. This PR adds auto-refresh for Tree View.
tree_dataendpoint to ping for updates every 3 secondsrunningdag runs^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.