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

Make MetricsControl the standard across visualizations #4914

Merged
merged 4 commits into from
May 15, 2018

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented May 1, 2018

@GabeLoins this spreads MetricsControl across visualizations.

@gabe-lyons
Copy link

Awesome! Will take a look at this tomorrow.

superset/viz.py Outdated
for mkey in METRIC_KEYS:
val = fd.get(mkey)
if val:
print(mkey, val)

Choose a reason for hiding this comment

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

zoops

@gabe-lyons
Copy link

LGTM- yay super excited to see this happening. I think referring to metrics at the label level definitely seems better than keeping a mixed list of dicts and strings- glad to see that refactor.

@@ -202,7 +222,7 @@ def query_obj(self):
"""Building a query object"""
form_data = self.form_data
gb = form_data.get('groupby') or []
metrics = form_data.get('metrics') or []
metrics = self.all_metrics or []
Copy link
Member

@hughhhh hughhhh May 7, 2018

Choose a reason for hiding this comment

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

I don't like the pattern we currently have for returning empty arrays, i feel like we should be throwing some exceptions with the proper messaging to let the user know how that there are no metrics currently selected.

For instance if we get len(self.all_metrics) == 0 or some check we should throw a SupersetException

@GabeLoins let me know what you think

Choose a reason for hiding this comment

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

The UI does a pretty good job right now informing users that they do not have a metric selected and preventing them from issuing queries. I'm not sure what situations there could be where a user could submit a query from explore without a metric selected, but I am all for informative error messages. I still think its good to have an idea of when this could happen so the error message offers the right information. Is this if there's a bug in the UI? Or are there cases where the UI is working and someone still can press Run Query with no metric selected? See:

https://github.com/apache/incubator-superset/blob/master/superset/assets/src/explore/controls.jsx#L176

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit complex here as many controls may use MetricControl (some with non null validators, some without) and we don't want to duplicate logic. In the context above metrics may exist as a key or not exist, or have None, [] or an actual list of values OR dicts. That first step here is to remove None or key doesn't exist from the list of possibility as it should be treated the same.

There's clearly much that could be done with a stronger contract between the backend and the frontend.

superset/viz.py Outdated
@@ -43,6 +43,11 @@
config = app.config
stats_logger = config.get('STATS_LOGGER')

METRIC_KEYS = {
Copy link
Member

Choose a reason for hiding this comment

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

nit: [] over {}

@mistercrunch mistercrunch changed the title [WiP] make MetricsControl the standard across visualizations Make MetricsControl the standard across visualizations May 14, 2018
@codecov-io
Copy link

Codecov Report

Merging #4914 into master will increase coverage by 0.23%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4914      +/-   ##
==========================================
+ Coverage    77.1%   77.34%   +0.23%     
==========================================
  Files          44       44              
  Lines        8644     8664      +20     
==========================================
+ Hits         6665     6701      +36     
+ Misses       1979     1963      -16
Impacted Files Coverage Δ
superset/data/__init__.py 100% <100%> (ø) ⬆️
superset/viz.py 81.48% <96.96%> (+1.19%) ⬆️
superset/models/core.py 86.47% <0%> (-0.08%) ⬇️
superset/sql_parse.py 98.79% <0%> (-0.06%) ⬇️
superset/db_engine_specs.py 53.74% <0%> (+0.87%) ⬆️
superset/sql_lab.py 75.27% <0%> (+0.95%) ⬆️

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 7a4a89b...3d35544. Read the comment docs.

@mistercrunch
Copy link
Member Author

Addressed comments, merging

@mistercrunch mistercrunch merged commit 7b427d7 into apache:master May 15, 2018
@mistercrunch mistercrunch deleted the fix_heatmap branch May 15, 2018 17:37
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 22, 2018
* [WiP] make MetricsControl the standard across visualizations

This spreads MetricsControl across visualizations.

* Addressing comments

* Fix deepcopy issue using shallow copy

* Fix tests

(cherry picked from commit 7b427d7)
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
* [WiP] make MetricsControl the standard across visualizations

This spreads MetricsControl across visualizations.

* Addressing comments

* Fix deepcopy issue using shallow copy

* Fix tests
timifasubaa pushed a commit to timifasubaa/incubator-superset that referenced this pull request May 31, 2018
* [WiP] make MetricsControl the standard across visualizations

This spreads MetricsControl across visualizations.

* Addressing comments

* Fix deepcopy issue using shallow copy

* Fix tests
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* [WiP] make MetricsControl the standard across visualizations

This spreads MetricsControl across visualizations.

* Addressing comments

* Fix deepcopy issue using shallow copy

* Fix tests
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.26.0 labels Feb 27, 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 🚢 0.26.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants