-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Auto refresh on Tree View #15474
Auto refresh on Tree View #15474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
airflow/www/views.py
Outdated
@@ -459,6 +459,97 @@ def add_user_permissions_to_dag(sender, template, context, **extra): # noqa pyl | |||
context['dag'] = dag | |||
|
|||
|
|||
def get_tree_data(dag_runs, dag, base_date): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
airflow/www/views.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
airflow/www/views.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
} |
airflow/www/views.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_data
endpoint to ping for updates every 3 secondsrunning
dag 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.