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 2020/04/01 10:53:41 UTC

[GitHub] [airflow] ashb opened a new pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

ashb opened a new pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043
 
 
   They had _similar_ info, but they weren't identical and should have
   been.
   
   To not include the 250kb of moment-timezone in more than one Webpack
   output bundle I changed how that is imported/handled. There may be a
   better way of doing this in webpack, but I couldn't find it, and this
   isn't horrible.
   
   
   #### Graph TI:
   
   **Before:**
   ![before_graph_ti](https://user-images.githubusercontent.com/34150/78129100-f4952280-740e-11ea-9898-df4317f8df0f.png)
   
   **After:**
   ![after_graph_ti](https://user-images.githubusercontent.com/34150/78129054-df1ff880-740e-11ea-8197-28648f2eb52c.png)
   
   (i.e. unchanged)
   
   #### Tree TI:
   **Before:**
   ![before_tree_ti](https://user-images.githubusercontent.com/34150/78129105-f6f77c80-740e-11ea-87fd-4353bf2edf5d.png)
   
   **After:**
   ![after_tree_ti](https://user-images.githubusercontent.com/34150/78129225-260dee00-740f-11ea-9e8d-2115244ea531.png)
   
   #### Tree DagRun
   
   **Before**: BROKEN ON MASTER -- no tooltip was displayed! Oops.
   
   **After:**
   ![after_tree_dagrun](https://user-images.githubusercontent.com/34150/78129055-dfb88f00-740e-11ea-9a8e-3d74ebd213cf.png)
   
   
   
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [ ] Description above provides context of the change
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [ ] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [ ] Relevant documentation is updated including usage instructions.
   - [ ] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#discussion_r401643962
 
 

 ##########
 File path: airflow/www/static/js/task-instances.js
 ##########
 @@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global window, dagTZ, moment, convertSecsToHumanReadable */
+
+// We don't re-import moment again, otherwise webpack will include it twice in the bundle!
+import { defaultFormat, formatDateTime } from './datetime-utils';
+import { escapeHtml } from './base';
+
+function makeDateTimeHTML(start, end) {
+  return (
+    `Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
+  )
+}
+
+function generateTooltipDateTimes(startDate, endDate, dagTZ) {
+  const tzFormat = 'z (Z)';
+  const localTZ = moment.tz.guess();
+  startDate = moment.utc(startDate);
+  endDate = moment.utc(endDate);
+  dagTZ = dagTZ.toUpperCase();
+
+  // Generate UTC Start and End Date
+  if (!startDate) {
+    return '<br><em>Not yet started</em>';
+  }
+
+  // Generate UTC Start and End Date
+  let tooltipHTML = `<br><strong>UTC:</strong><br>`;
+  tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
+
+  // Generate User's Local Start and End Date
+  tooltipHTML += `<br><strong>Local: ${moment.tz(localTZ).format(tzFormat)}</strong><br>`;
+  tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
+
+  // Generate DAG's Start and End Date
+  if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
+    tooltipHTML += `<br><strong>DAG's TZ: ${moment.tz(dagTZ).format(tzFormat)}</strong><br>`;
+    tooltipHTML += makeDateTimeHTML(startDate.tz(dagTZ), endDate.tz(dagTZ));
+  }
+
+  return tooltipHTML;
+}
+
+export default function tiTooltip(ti) {
+  let tt = '';
+  if(ti.task_id !== undefined) {
+    tt += `Task_id: ${escapeHtml(ti.task_id)}<br>`;
+  }
+  tt += `Run: ${formatDateTime(ti.execution_date)}<br>`;
+  if(ti.run_id !== undefined) {
+    tt += `run_id: <nobr>${escapeHtml(ti.run_id)}</nobr><br>`;
 
 Review comment:
   I'll make it `Run Id` to match how we show the column in Browse -> Dag Runs.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#discussion_r401535492
 
 

 ##########
 File path: airflow/www/static/js/graph.js
 ##########
 @@ -16,8 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { generateTooltipDateTime, converAndFormatUTC, secondsToString } from './datetime-utils';
-import { escapeHtml } from './base';
+// global tiTooltip, taskTip
 
 Review comment:
   Global as it's included in another file that is sourced.
   
   If I used a normal import webpack would include it in two files.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb edited a comment on issue #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb edited a comment on issue #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#issuecomment-607183252
 
 
   Whops, just notcied the `Local: UTC` that should just be `UTC`. Updated code and screenshots

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb merged pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb merged pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] BasPH commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
BasPH commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#discussion_r401608848
 
 

 ##########
 File path: airflow/www/static/js/task-instances.js
 ##########
 @@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global window, dagTZ, moment, convertSecsToHumanReadable */
+
+// We don't re-import moment again, otherwise webpack will include it twice in the bundle!
+import { defaultFormat, formatDateTime } from './datetime-utils';
+import { escapeHtml } from './base';
+
+function makeDateTimeHTML(start, end) {
+  return (
+    `Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
+  )
+}
+
+function generateTooltipDateTimes(startDate, endDate, dagTZ) {
+  const tzFormat = 'z (Z)';
+  const localTZ = moment.tz.guess();
+  startDate = moment.utc(startDate);
+  endDate = moment.utc(endDate);
+  dagTZ = dagTZ.toUpperCase();
+
+  // Generate UTC Start and End Date
+  if (!startDate) {
+    return '<br><em>Not yet started</em>';
+  }
+
+  // Generate UTC Start and End Date
+  let tooltipHTML = `<br><strong>UTC:</strong><br>`;
+  tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
+
+  // Generate User's Local Start and End Date
+  tooltipHTML += `<br><strong>Local: ${moment.tz(localTZ).format(tzFormat)}</strong><br>`;
+  tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
+
+  // Generate DAG's Start and End Date
+  if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
+    tooltipHTML += `<br><strong>DAG's TZ: ${moment.tz(dagTZ).format(tzFormat)}</strong><br>`;
+    tooltipHTML += makeDateTimeHTML(startDate.tz(dagTZ), endDate.tz(dagTZ));
+  }
+
+  return tooltipHTML;
+}
+
+export default function tiTooltip(ti) {
+  let tt = '';
+  if(ti.task_id !== undefined) {
+    tt += `Task_id: ${escapeHtml(ti.task_id)}<br>`;
+  }
+  tt += `Run: ${formatDateTime(ti.execution_date)}<br>`;
+  if(ti.run_id !== undefined) {
+    tt += `run_id: <nobr>${escapeHtml(ti.run_id)}</nobr><br>`;
 
 Review comment:
   For consistency sake, let's start with capital.
   ```suggestion
       tt += `Run_id: <nobr>${escapeHtml(ti.run_id)}</nobr><br>`;
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on issue #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb commented on issue #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#issuecomment-607183252
 
 
   Whops, just notcied the `Local: UTC` that should just be `UTC`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #8043: Use same tooltip for Graph and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#discussion_r401535087
 
 

 ##########
 File path: airflow/www/static/js/datetime-utils.js
 ##########
 @@ -16,41 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-export const moment = require('moment-timezone');
+
+/* global moment */
 export const defaultFormat = 'YYYY-MM-DD, HH:mm:ss';
 export const defaultFormatWithTZ = 'YYYY-MM-DD, HH:mm:ss z';
 
 
-const makeDateTimeHTML = (start, end) => {
-  return (
-    `Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
-  )
-};
-
-export const generateTooltipDateTime = (startDate, endDate, dagTZ) => {
-  const tzFormat = 'z (Z)';
-  const localTZ = moment.tz.guess();
-  startDate = moment.utc(startDate);
-  endDate = moment.utc(endDate);
-  dagTZ = dagTZ.toUpperCase();
-
-  // Generate UTC Start and End Date
-  let tooltipHTML = '<br><strong>UTC</strong><br>';
-  tooltipHTML += makeDateTimeHTML(startDate, endDate);
-
-  // Generate User's Local Start and End Date
-  tooltipHTML += `<br><strong>Local: ${moment.tz(localTZ).format(tzFormat)}</strong><br>`;
-  tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
-
-  // Generate DAG's Start and End Date
-  if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
-    tooltipHTML += `<br><strong>DAG's TZ: ${moment.tz(dagTZ).format(tzFormat)}</strong><br>`;
-    tooltipHTML += makeDateTimeHTML(startDate.tz(dagTZ), endDate.tz(dagTZ));
-  }
-
-  return tooltipHTML
-};
-
 
 Review comment:
   I moved these fns in to a new "task-instances.js" as they are specific to there, and not general "datetime" utils.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services