You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/02 01:13:49 UTC

[GitHub] [superset] github-wcha opened a new issue #12878: Custom viz throwing KeyError from superset.views.base

github-wcha opened a new issue #12878:
URL: https://github.com/apache/superset/issues/12878


   A clear and concise description of what the bug is.
   
   I've been working on a custom visualisation, Traffic Lights, where I would be basically able to get a ratio and adjust the colour of the traffic light accordingly. I've tried to use a hello-world guide by [Preset](https://preset.io/blog/2020-07-02-hello-world/), but was getting bunch of errors repeatedly. Then, I've done some research and was advised to copy the folder over to the `superset-frontend/node_modules/@superset-ui/`, but the code still didn't compile. Now, I'm running off my own [npm package](https://www.npmjs.com/package/@ali.bakhodirov/plugin-chart-traffic-lights) that I'm trying to fix. I've tried to use hello-world generated by yeoman: still didn't work. And now I'm trying to use some code from existing superset-ui plugins and it has finally compiled! Yay! But when I apply the "Visualization Type", it throws `Unexpected error 'traffic_lights_total'`. The console output is the following:
   ```
   superset_app             | ERROR:superset.views.base:'traffic_lights_total'
   superset_app             | Traceback (most recent call last):
   superset_app             |   File "/app/superset/views/base.py", line 181, in wraps
   superset_app             |     return f(self, *args, **kwargs)
   superset_app             |   File "/app/superset/utils/log.py", line 164, in wrapper
   superset_app             |     value = f(*args, **kwargs)
   superset_app             |   File "/app/superset/utils/cache.py", line 172, in wrapper
   superset_app             |     response = f(*args, **kwargs)
   superset_app             |   File "/app/superset/views/utils.py", line 450, in wrapper
   superset_app             |     check_perms(*args, **kwargs)
   superset_app             |   File "/app/superset/views/utils.py", line 519, in check_datasource_perms
   superset_app             |     force=False,
   superset_app             |   File "/app/superset/views/utils.py", line 124, in get_viz
   superset_app             |     viz_obj = viz.viz_types[viz_type](
   superset_app             | KeyError: 'traffic_lights_total'
   ```
   ### Expected results
   
   I expect to apply the viz type and count the total number of entries in the dataset.
   
   ### Actual results
   
   I receive the error, `Unexpected error 'traffic_lights_total'`. The console output is the following:
   ```
   superset_app             | ERROR:superset.views.base:'traffic_lights_total'
   superset_app             | Traceback (most recent call last):
   superset_app             |   File "/app/superset/views/base.py", line 181, in wraps
   superset_app             |     return f(self, *args, **kwargs)
   superset_app             |   File "/app/superset/utils/log.py", line 164, in wrapper
   superset_app             |     value = f(*args, **kwargs)
   superset_app             |   File "/app/superset/utils/cache.py", line 172, in wrapper
   superset_app             |     response = f(*args, **kwargs)
   superset_app             |   File "/app/superset/views/utils.py", line 450, in wrapper
   superset_app             |     check_perms(*args, **kwargs)
   superset_app             |   File "/app/superset/views/utils.py", line 519, in check_datasource_perms
   superset_app             |     force=False,
   superset_app             |   File "/app/superset/views/utils.py", line 124, in get_viz
   superset_app             |     viz_obj = viz.viz_types[viz_type](
   superset_app             | KeyError: 'traffic_lights_total'
   ```
   
   #### Screenshots
   
   ![image](https://user-images.githubusercontent.com/77943875/106537363-49815800-654e-11eb-96bd-f0e8ae086a18.png)
   ![image](https://user-images.githubusercontent.com/77943875/106537439-70d82500-654e-11eb-8527-a0efa8e414f1.png)
   
   #### How to reproduce the bug
   
   1. Once you have superset up and running, edit `superset-frontend/package.json` to include a new dependency: `"@ali.bakhodirov/plugin-chart-traffic-lights": "^0.4.0"`
   ![image](https://user-images.githubusercontent.com/77943875/106537665-eba14000-654e-11eb-804d-3c298be22670.png)
   
   2. Edit `superset-frontend/src/visualizations/presets/MainPreset.js` to include the following lines:
   import { TrafficLightsChartPlugin, TrafficLightsTotalChartPlugin } from '@ali.bakhodirov/plugin-chart-traffic-lights'; at line 41 and
   ![image](https://user-images.githubusercontent.com/77943875/106537828-3e7af780-654f-11eb-8a94-071a07694946.png)
   ```
   new TrafficLightsChartPlugin().configure({ key: 'traffic_lights' }),
   new TrafficLightsTotalChartPlugin().configure({ key: 'traffic_lights_total' }),
   ``` at line 109
   ![image](https://user-images.githubusercontent.com/77943875/106537851-48045f80-654f-11eb-842e-cee97a57f778.png)
   
   3. Run `docker-compose up`
   4. Edit any chart to be a Traffic Lights viz type.
   5. See the error.
   
   ### Environment
   
   (please complete the following information):
   
   - superset version: tried both 0.999.0dev and 1.0.0
   - python version: 3.7
   - node.js version: v12.18.2
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [*] I have checked the superset logs for python stacktraces and included it here as text if there are any.
   - [*] I have reproduced the issue with at least the latest released version of superset.
   - [*] I have checked the issue tracker for the same issue and I haven't found one similar.
   
   ### Additional context
   
   Please see the initial description for more contaxt.
   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-wcha closed issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
github-wcha closed issue #12878:
URL: https://github.com/apache/superset/issues/12878


   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] suddjian commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
suddjian commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772005882


   Any chance you could point me to a github repo with your plugin code? The link on npm still points to the official superset-ui repo.


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] ktmud commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
ktmud commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772099765


   Looks like you are still using [the legacy API](https://github.com/thanksgold/plugin/blob/main/plugin-chart-traffic-lights/esm/TrafficLights/index.js#L27). We recommend creating new viz plugins using the new chart data API, which requires setting `useLegacyAPI` to `false`.
   
   You can check out the official non-legacy plugins (e.g. [plugin-chart-word-cloud](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-word-cloud/src/plugin)) for examples of how to build queries for the generic data backend API.


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-wcha commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
github-wcha commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772041413


   Thanks @suddjian for helping to resolve the error. The code for the plugin is very similar to the [big number preset chart](https://www.npmjs.com/package/@superset-ui/legacy-preset-chart-big-number) and can be found in [here](https://github.com/thanksgold/plugin/tree/main/plugin-chart-traffic-lights).


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-wcha closed issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
github-wcha closed issue #12878:
URL: https://github.com/apache/superset/issues/12878


   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-wcha commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
github-wcha commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772041413






----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] suddjian commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
suddjian commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772002875


   That sounds like a cool plugin @github-wcha! This error comes from the backend, which, if your plugin is using the v1 chart API, shouldn't have any knowledge of viz types. Let me see if I can figure out what's going on here.


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] suddjian commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
suddjian commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772002875






----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] ktmud commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
ktmud commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772099765


   Looks like you are still using [the legacy API](https://github.com/thanksgold/plugin/blob/main/plugin-chart-traffic-lights/esm/TrafficLights/index.js#L27). We recommend creating new viz plugins using the new chart data API, which requires setting `useLegacyAPI` to `false`.
   
   You can check out the official non-legacy plugins (e.g. [plugin-chart-word-cloud](https://github.com/apache-superset/superset-ui/tree/master/plugins/plugin-chart-word-cloud/src/plugin)) for examples of how to build queries for the generic data backend API.


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-wcha commented on issue #12878: Custom viz throwing KeyError from superset.views.base

Posted by GitBox <gi...@apache.org>.
github-wcha commented on issue #12878:
URL: https://github.com/apache/superset/issues/12878#issuecomment-772111908


   Hi @ktmud, indeed you were right, I was still using the legacy API. I set that to false and it works now. Thanks heaps! I really appreciate your help! 


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org