Skip to content
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

feat: add warning metadata to tables and metrics #13606

Merged

Conversation

etr2460
Copy link
Member

@etr2460 etr2460 commented Mar 12, 2021

SUMMARY

Similar to the need for certifying metrics and tables, often data should have warnings attached. This provides support for arbitrary warning markdown text to be provided for a metric or table

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2021-03-17 at 10 33 39 AM
Screen Shot 2021-03-17 at 10 33 31 AM
Screen Shot 2021-03-17 at 10 33 23 AM

Screen Shot 2021-03-17 at 10 35 55 AM
Screen Shot 2021-03-17 at 10 35 48 AM
Screen Shot 2021-03-17 at 9 52 19 AM

TEST PLAN

Verify the icon is displayed whenever the deprecated_at param is set. Also add unit tests

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

to: @graceguo-supercat @ktmud @junlincc (could you tag the appropriate engineers from Preset here?)

@etr2460
Copy link
Member Author

etr2460 commented Mar 12, 2021

/testenv up

@github-actions
Copy link
Contributor

@etr2460 Ephemeral environment creation is currently limited to committers.

@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch 4 times, most recently from db80bab to aeb83f3 Compare March 13, 2021 02:22
@etr2460 etr2460 marked this pull request as ready for review March 13, 2021 02:33
@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from aeb83f3 to 8302744 Compare March 13, 2021 02:43
@@ -482,7 +496,7 @@ class SqlaTable( # pylint: disable=too-many-public-methods,too-many-instance-at
"fetch_values_predicate",
"extra",
]
update_from_object_fields = [f for f in export_fields if not f == "database_id"]
update_from_object_fields = [f for f in export_fields if f != "database_id"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran into this while debugging and got really confused. this seems clearer

@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #13606 (9318fd6) into master (abf2c87) will increase coverage by 0.14%.
The diff coverage is 65.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13606      +/-   ##
==========================================
+ Coverage   77.10%   77.25%   +0.14%     
==========================================
  Files         921      922       +1     
  Lines       46745    46798      +53     
  Branches     5733     5746      +13     
==========================================
+ Hits        36043    36152     +109     
+ Misses      10567    10510      -57     
- Partials      135      136       +1     
Flag Coverage Δ
cypress 56.57% <17.64%> (-0.04%) ⬇️
javascript 63.16% <60.00%> (+<0.01%) ⬆️
mysql 80.56% <100.00%> (+<0.01%) ⬆️
postgres 80.61% <100.00%> (?)
presto 80.28% <100.00%> (?)
python 80.84% <100.00%> (+0.28%) ⬆️
sqlite 80.23% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ontend/src/components/CertifiedIconWithTooltip.tsx 54.54% <0.00%> (-5.46%) ⬇️
...c/dashboard/components/gridComponents/Markdown.jsx 90.90% <ø> (+0.52%) ⬆️
...erset-frontend/src/datasource/DatasourceEditor.jsx 65.82% <0.00%> (-0.57%) ⬇️
superset/connectors/sqla/views.py 62.43% <ø> (-0.31%) ⬇️
...ontend/src/views/CRUD/data/dataset/DatasetList.tsx 69.93% <16.66%> (-0.69%) ⬇️
...perset-frontend/src/datasource/DatasourceModal.tsx 72.58% <57.14%> (+0.91%) ⬆️
...et-frontend/src/components/TableSelector/index.tsx 84.92% <66.66%> (-0.45%) ⬇️
...frontend/src/components/WarningIconWithTooltip.tsx 88.88% <88.88%> (ø)
.../explore/components/controls/DatasourceControl.jsx 67.10% <100.00%> (+2.81%) ⬆️
superset/connectors/sqla/models.py 90.55% <100.00%> (+0.92%) ⬆️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abf2c87...9318fd6. Read the comment docs.

@ktmud
Copy link
Member

ktmud commented Mar 14, 2021

/testenv up

@github-actions
Copy link
Contributor

@ktmud Ephemeral environment creation is currently limited to committers.

@ktmud
Copy link
Member

ktmud commented Mar 14, 2021

@robdiciuccio it seems there's something wrong with the committer detection logic in the Ephemeral environment workflow.

@robdiciuccio
Copy link
Member

@ktmud yep, turns out your Apache org membership needs to be public to work correctly. There's another possible code fix, but this should hopefully unblock for now.

@etr2460
Copy link
Member Author

etr2460 commented Mar 14, 2021

/testenv up

@github-actions
Copy link
Contributor

@etr2460 Ephemeral environment spinning up at http://54.68.109.205:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the idea! One small question/comment

Comment on lines 933 to 920
<Field
label={t('Deprecation link')}
fieldKey="deprecation_link"
description={t(
'A link with more details regarding the deprecation of this metric',
)}
control={
<TextControl
controlId="deprecation_link"
placeholder="https://www.example.com"
/>
}
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a freetext description field would be more convenient for most orgs. Instead of having a dedicated link field, could we have a general description field in which one can paste links if needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion, how would you recommend structuring a description field like that? Ideally, we could provide the capability for someone to embed a link and make it clickable/open in a new tab. Would rendering arbitrary markdown be a bad idea?

Copy link
Member

@villebro villebro Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be ok supporting the same markdown allowances we support on the dashboard markdown component:
image
image

I might be oversimplifying, but I'd be happy with just a simple freetext field that's then rendered as markdown (not sure if there's a simple way of forcing a new tab, but I suppose it should be doable).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think forcing a new tab in markdown is possible unless you use html a tags. i can play around a bit with supporting markdown descriptions. it's a bit less structured (which i'm not sure if that's good or bad).

For context, in internal use, the learn more link typically goes to a google doc or something else with lots of detailed, freeform content. So we made the choice in other products to just link out to there instead of making people write more context/details in product

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can allow both the free-text markdown and the "Learn more" link, if it's not too much work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this, and making the following change seems to send the links to _blank:
image

diff --git a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
index b071a9982..5b30cd400 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
@@ -286,6 +286,7 @@ class Markdown extends React.PureComponent {
             isValidNode: node => node.type !== 'script',
           }),
         ]}
+        linkTarget="_blank"
       />
     );
   }

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature!

Would it make sense to extend this to more than Deprecation? E.g. It could also be used as a general warning for things like delayed data and suggesting an alternative field:

  • "This data has been delayed for x hours. We are working on addressing this issue".
  • "This field is for advanced use only. Please use "xxx_xxx" for simpler categorization."

"is_certified",
"certified_by",
"certification_details",
"deprecated_at",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be nice to have deprecated_by field as well to have point of contact

@etr2460
Copy link
Member Author

etr2460 commented Mar 16, 2021

A bunch of good suggestions here, thanks for the comments!

I think if we're going to provide the flexibility of free text, then we should let the user add whatever content they want there (links, POCs, descriptions, replacements, etc.) and not worry about structuring it more.

However, making this a generic warning might be even better. If we want to take the flexible route, then we could get rid of the deprecated_at field too and just rely on everything to be provided in markdown. Then it's just one simple field that anyone could use for whatever purpose. Super extensible for other users, and would serve the deprecation use case.

I'm going to simplify and move forward with a generic warning_markdown field that can be added to a metric or dataset. Will tag y'all when that's ready

@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from 8302744 to 3c7995f Compare March 16, 2021 04:00
@etr2460
Copy link
Member Author

etr2460 commented Mar 16, 2021

/testenv up

@github-actions
Copy link
Contributor

@etr2460 Ephemeral environment spinning up at http://54.184.90.208:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from 3c7995f to f8a15af Compare March 16, 2021 04:28
@etr2460
Copy link
Member Author

etr2460 commented Mar 16, 2021

Here's the new user experience with markdown:
Screen Shot 2021-03-15 at 9 21 33 PM
Screen Shot 2021-03-15 at 9 23 39 PM
Screen Shot 2021-03-15 at 9 25 25 PM

@etr2460 etr2460 changed the title feat: add deprecation metadata to tables and metrics feat: add warning metadata to tables and metrics Mar 16, 2021
@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from f8a15af to fb91c83 Compare March 16, 2021 06:03
Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Code LGTM, tested it locally and found a couple of UX issues:

  1. Is the extra bottom padding intentional?
    Screen Shot 2021-03-16 at 10 31 35 AM

  2. Just remembered we already have warning_text for metrics, can we maybe migrate it to the same extra.warning_markdown field?

    Screen Shot 2021-03-16 at 10 32 39 AM
  3. The icon for metric warning markdown does not show up in any of the Dataset panel, Select options, or selected options. Maybe we should add all of them in a separate PR and only do datasource warning in this PR.

    It does show up, however, in the Datasource editor modal.
    Screen Shot 2021-03-16 at 10 34 54 AM

    BTW, there are like 3 different warning icons in this screen. Should we consolidate and make them more consistent?


Not related to this PR, but I think we also need some UI adjustment in the datasource editor modal:

image

  1. Move "extra" to "Advanced"
  2. Make the AceEditor for extra taller and resizable
  3. Move the two column layout to be two rows with Basic options on top and Advanced in the bottom.
  4. Add two column layout within the Basic and Advanced container

cc @junlincc @mihir174

@etr2460
Copy link
Member Author

etr2460 commented Mar 16, 2021

Here are the follow ups i'll make here:

  • Use the yellow caution triangle icon for this to be consistent with other warning icons
  • Update the metrics to pull either warning_markdown or warning_text (to maintain backwards compatibility)
  • Add in a superset-ui PR and dep here which adds the same caution icon for all metric locations

Here's what i'll do in future PRs:

  • DB migration to drop the warning_text from the metric model/table
  • Update superset-ui to not pull the warning_text anymore

@junlincc
Copy link
Member

junlincc commented Mar 17, 2021

@ktmud

  • Move "extra" to "Advanced"
    Definitely!
  • Make the AceEditor for extra taller and resizable
    Make sense
    -Move the two column layout to be two rows with Basic options on top and Advanced in the bottom.
    -Add two column layout within the Basic and Advanced container
    Good idea! We probably need more exploration than simply changing the layout.

@etr2460 Thank you, Erik, for opening this PR and adjusting the UI element for consistency. Really appreciate it!
Term Data entity is not being used anywhere, should we change it?

@etr2460
Copy link
Member Author

etr2460 commented Mar 17, 2021

Term Data entity is not being used anywhere, should we change it?

@junlincc That's part of the user provided string, and isn't actually in the code anywhere. FWIW, we use data entity internally to refer to any of our data objects; it's basically a catch all term to include tables, metrics, columns, datasources, datasets, etc. But since we have no need for that in superset yet, it won't be added

@etr2460
Copy link
Member Author

etr2460 commented Mar 17, 2021

I've made the changes mentioned above, but it won't build until apache-superset/superset-ui#1011 is merged and we have a new superset-ui version

@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch 3 times, most recently from b89012d to c8993ac Compare March 17, 2021 21:12
@etr2460
Copy link
Member Author

etr2460 commented Mar 17, 2021

@ktmud i think this is ready to go now

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you also add a screenshot of how the icon looks like in the "SAVED" tab of metrics select popover (if it does appear there)?

@etr2460
Copy link
Member Author

etr2460 commented Mar 17, 2021

Could you also add a screenshot of how the icon looks like in the "SAVED" tab of metrics select popover (if it does appear there)

@ktmud

image

@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from c8993ac to c124618 Compare March 17, 2021 23:46
@etr2460 etr2460 force-pushed the erik-ritter--metric-and-table-deprecation branch from c124618 to 9318fd6 Compare March 18, 2021 01:49
@etr2460 etr2460 merged commit 64785c2 into apache:master Mar 18, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants