You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/11 08:52:35 UTC
[GitHub] [airflow] talnagar opened a new pull request, #22900: add auto refresh to dags home page
talnagar opened a new pull request, #22900:
URL: https://github.com/apache/airflow/pull/22900
Add auto refresh functionality to the home page (dags).
closes: #22418
---
refresh every 2 seconds:
- last dag runs
- last run
- recent tasks
---
before:

after:

--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850454012
##########
airflow/www/static/js/dags.js:
##########
@@ -38,6 +39,9 @@ const dagStatsUrl = getMetaValue('dag_stats_url');
const taskStatsUrl = getMetaValue('task_stats_url');
const gridUrl = getMetaValue('grid_url');
+// auto refresh interval in milliseconds
+const refreshIntervalMs = 2000;
Review Comment:
sure. Actually I was wondering what's the best interval for update since this page can be quite heavy in some cases. what do you think?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850454147
##########
airflow/www/static/js/dags.js:
##########
@@ -351,7 +359,117 @@ function hideSvgTooltip() {
$('#svg-tooltip').css('display', 'none');
}
+function RefreshDagRunsAndTasks(selector, dagId, states) {
Review Comment:
```suggestion
function refreshDagRunsAndTasks(selector, dagId, states) {
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1098208940
@bbovenzi thanks for the review.
As suggested
- paused the refresh when the page isn't focused
- unchecked auto refresh when there are no more active runs
- I changed the css and template layout a bit so it won't break, hopefully now it looks better on all screen sizes.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1099297342
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 main or amend the last commit of the PR, and push it with --force-with-lease.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850466564
##########
airflow/www/static/js/dags.js:
##########
@@ -158,6 +162,9 @@ function lastDagRunsHandler(error, json) {
const g = d3.select(`#last-run-${safeDagId}`);
// Show last run as a link to the graph view
+ g.selectAll('a')
Review Comment:
Let's combine them at least:
```
g.selectAll('a')
.attr('href', `${graphUrl}?dag_id=${encodeURIComponent(dagId)}&execution_date=${encodeURIComponent(executionDate)}`)
.html('')
.insert(isoDateToTimeEl.bind(null, executionDate, { title: false }));```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850460158
##########
airflow/www/static/js/dags.js:
##########
@@ -158,6 +162,9 @@ function lastDagRunsHandler(error, json) {
const g = d3.select(`#last-run-${safeDagId}`);
// Show last run as a link to the graph view
+ g.selectAll('a')
Review Comment:
I think I couldn't find a way to update the date without clearing it first.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850478511
##########
airflow/www/static/js/dags.js:
##########
@@ -158,6 +162,9 @@ function lastDagRunsHandler(error, json) {
const g = d3.select(`#last-run-${safeDagId}`);
// Show last run as a link to the graph view
+ g.selectAll('a')
Review Comment:
sure.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1099278165
> Great work! I think people will be really excited to have this.
>
> But let's not merge until 2.3.0b1 is out
Thanks @bbovenzi! 😃
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1098945236
@bbovenzi for some reason I can't reproduce this break. I removed the margin now hopefully it looks ok.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850453606
##########
airflow/www/static/js/dags.js:
##########
@@ -158,6 +162,9 @@ function lastDagRunsHandler(error, json) {
const g = d3.select(`#last-run-${safeDagId}`);
// Show last run as a link to the graph view
+ g.selectAll('a')
Review Comment:
Why do are we setting the graphUrl twice?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi merged pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi merged PR #22900:
URL: https://github.com/apache/airflow/pull/22900
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850454720
##########
airflow/www/static/js/dags.js:
##########
@@ -351,7 +359,117 @@ function hideSvgTooltip() {
$('#svg-tooltip').css('display', 'none');
}
+function RefreshDagRunsAndTasks(selector, dagId, states) {
+ d3.select(`svg#${selector}-${dagId.replace(/\./g, '__dot__')}`)
+ .selectAll('circle')
+ .data(states)
+ .attr('stroke-width', (d) => {
+ if (d.count > 0) return strokeWidth;
+ return 1;
+ })
+ .attr('stroke', (d) => {
+ if (d.count > 0) return STATE_COLOR[d.state];
+
+ return 'gainsboro';
+ })
+ .attr('fill', '#fff')
+ .attr('r', diameter / 2)
+ .attr('title', (d) => d.state)
+ .on('mouseover', (d) => {
+ if (d.count > 0) {
+ d3.select(this).transition().duration(400)
+ .attr('fill', '#e2e2e2')
+ .style('stroke-width', strokeWidthHover);
+ }
+ });
+ d3.select(`svg#${selector}-${dagId.replace(/\./g, '__dot__')}`)
+ .selectAll('text')
+ .data(states)
+ .text((d) => {
+ if (d.count > 0) {
+ return d.count;
+ }
+ return '';
+ });
+}
+
+function refreshTaskStateHandler(error, ts) {
+ Object.keys(ts).forEach((dagId) => {
+ const states = ts[dagId];
+ RefreshDagRunsAndTasks('task-run', dagId, states);
Review Comment:
```suggestion
refreshDagRunsAndTasks('task-run', dagId, states);
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850456161
##########
airflow/www/static/js/dags.js:
##########
@@ -351,7 +359,117 @@ function hideSvgTooltip() {
$('#svg-tooltip').css('display', 'none');
}
+function RefreshDagRunsAndTasks(selector, dagId, states) {
+ d3.select(`svg#${selector}-${dagId.replace(/\./g, '__dot__')}`)
+ .selectAll('circle')
+ .data(states)
+ .attr('stroke-width', (d) => {
+ if (d.count > 0) return strokeWidth;
+ return 1;
+ })
+ .attr('stroke', (d) => {
+ if (d.count > 0) return STATE_COLOR[d.state];
+
+ return 'gainsboro';
+ })
+ .attr('fill', '#fff')
+ .attr('r', diameter / 2)
+ .attr('title', (d) => d.state)
+ .on('mouseover', (d) => {
+ if (d.count > 0) {
+ d3.select(this).transition().duration(400)
+ .attr('fill', '#e2e2e2')
+ .style('stroke-width', strokeWidthHover);
+ }
+ });
+ d3.select(`svg#${selector}-${dagId.replace(/\./g, '__dot__')}`)
+ .selectAll('text')
+ .data(states)
+ .text((d) => {
+ if (d.count > 0) {
+ return d.count;
+ }
+ return '';
+ });
+}
+
+function refreshTaskStateHandler(error, ts) {
+ Object.keys(ts).forEach((dagId) => {
+ const states = ts[dagId];
+ RefreshDagRunsAndTasks('task-run', dagId, states);
+ });
+}
+
+let refreshInterval;
+
+function checkActiveRuns(json) {
+ // filter latest dag runs and check if there are still running dags
+ const activeRuns = Object.keys(json).filter((dagId) => {
+ const dagRuns = json[dagId].filter((s) => s.state === 'running').filter((r) => r.count > 0);
+ return (dagRuns.length > 0);
+ });
+ if (activeRuns.length === 0) {
+ // in case there are no active runs increase the interval for auto refresh
+ $('#auto_refresh').prop('checked', false);
+ clearInterval(refreshInterval);
+ }
+}
+
+function refreshDagRuns(error, json) {
+ checkActiveRuns(json);
+ Object.keys(json).forEach((dagId) => {
+ const states = json[dagId];
+ drawDagStatsForDag(dagId, states);
+ RefreshDagRunsAndTasks('dag-run', dagId, states);
+ });
+}
+
+function handleRefresh() {
+ $('#loading-dots').css('display', 'inline-block');
+ d3.json(lastDagRunsUrl)
+ .header('X-CSRFToken', csrfToken)
+ .post(encodedDagIds, lastDagRunsHandler);
+ d3.json(dagStatsUrl)
+ .header('X-CSRFToken', csrfToken)
+ .post(encodedDagIds, refreshDagRuns);
+ d3.json(taskStatsUrl)
+ .header('X-CSRFToken', csrfToken)
+ .post(encodedDagIds, refreshTaskStateHandler);
+ setTimeout(() => {
+ $('#loading-dots').css('display', 'none');
+ }, refreshIntervalMs);
+}
Review Comment:
```suggestion
}
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1098337545
Let's still fix the margin for the switch because even with removing that classname I can run into this pretty easily:
<img width="287" alt="Screen Shot 2022-04-13 at 2 04 20 PM" src="https://user-images.githubusercontent.com/4600967/163242844-0c3933e5-90ab-4d82-96ba-4758824d8181.png">
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1114149296
@bbovenzi can this be merged now?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] talnagar commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
talnagar commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1094742010
@bbovenzi I would appreciate your feedback on this.
In addition, I didn't know whether there are any tests relevant for ui only changes such as this.
thanks.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850449914
##########
airflow/www/static/js/dags.js:
##########
@@ -38,6 +39,9 @@ const dagStatsUrl = getMetaValue('dag_stats_url');
const taskStatsUrl = getMetaValue('task_stats_url');
const gridUrl = getMetaValue('grid_url');
+// auto refresh interval in milliseconds
+const refreshIntervalMs = 2000;
Review Comment:
Lets also add a comment on how /dags autorefresh is 2x tree or graph autorefresh.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850466564
##########
airflow/www/static/js/dags.js:
##########
@@ -158,6 +162,9 @@ function lastDagRunsHandler(error, json) {
const g = d3.select(`#last-run-${safeDagId}`);
// Show last run as a link to the graph view
+ g.selectAll('a')
Review Comment:
Let's combine them at least:
```
g.selectAll('a')
.attr('href', `${graphUrl}?dag_id=${encodeURIComponent(dagId)}&execution_date=${encodeURIComponent(executionDate)}`)
.html('')
.insert(isoDateToTimeEl.bind(null, executionDate, { title: false }));
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] bbovenzi commented on a diff in pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #22900:
URL: https://github.com/apache/airflow/pull/22900#discussion_r850445726
##########
airflow/www/static/css/main.css:
##########
@@ -422,7 +422,7 @@ label[for="timezone-other"],
}
.refresh-actions > .switch-label {
- margin: 0 10px 0 20px;
+ margin: 0 10px 0 0;
Review Comment:
```suggestion
margin: 0 10px;
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] marclamberti commented on pull request #22900: add auto refresh to dags home page
Posted by GitBox <gi...@apache.org>.
marclamberti commented on PR #22900:
URL: https://github.com/apache/airflow/pull/22900#issuecomment-1159799685
OMG! this is AWESOME ❤️
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org