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/06/18 21:09:47 UTC

[GitHub] [superset] shawnzhu opened a new issue #15258: documented data cache config doesn't work with flask-caching v1.9.0

shawnzhu opened a new issue #15258:
URL: https://github.com/apache/superset/issues/15258


   I've following the guide [here}(https://superset.apache.org/docs/installation/cache) to setup Redis as data cache with superset from master branch. 
   
   ### Expected results
   
   Superset should work as it was without data cache configuration.
   
   ### Actual results
   
   None of the chart works in any dashboards. While if clicking _Force Refresh_ option of a chart then it works again but still doesn't work when refreshing the whole dashboard.
   
   #### Screenshots
   
   ![Screenshot from 2021-06-18 10-56-22](https://user-images.githubusercontent.com/1059372/122580950-83965680-d024-11eb-8158-6744458c3880.png)
   
   #### How to reproduce the bug
   
   1. Go to any dashboard
   2. See error message `'Flask' object has no attribute 'get'`
   
   ### Environment
   
   (please complete the following information):
   
   - superset version: `Version: 0.999.0dev`
   - python version: `3.7.9`
   
   the stacktrace from webserver log:
   
   ```
   10.0.2.100 - - [18/Jun/2021:13:42:00 +0000] "POST /api/v1/chart/data?form_data=%7B%22slice_id%22%3A62%7D&dashboard_id=2 HTTP/1.1" 500 236 "http://localhost:8088/superset/dashboard/births/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
   'Flask' object has no attribute 'get'
   Traceback (most recent call last):
     File "/app/superset/views/base.py", line 204, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/utils/log.py", line 228, in wrapper
       value = f(*args, **kwargs)
     File "/app/superset/utils/cache.py", line 159, in wrapper
       return f(*args, **kwargs)
     File "/app/superset/views/utils.py", line 470, in wrapper
       return f(*args, **kwargs)
     File "/app/superset/views/core.py", line 634, in explore_json
       return self.generate_json(viz_obj, response_type)
     File "/app/superset/views/core.py", line 454, in generate_json
       payload = viz_obj.get_payload()
     File "/app/superset/viz.py", line 450, in get_payload
       payload = self.get_df_payload(query_obj)
     File "/app/superset/viz.py", line 500, in get_df_payload
       cache_value = cache_manager.data_cache.get(cache_key)
     File "/usr/local/lib/python3.7/site-packages/flask_caching/__init__.py", line 248, in get
       return self.cache.get(*args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_caching/backends/rediscache.py", line 114, in get
       self._read_clients.get(self._get_prefix() + key)
   AttributeError: 'Flask' object has no attribute 'get'
   ```
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't found one similar.
   
   ### Additional context
   
   Add any other context about the problem 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] shawnzhu commented on issue #15258: documented data cache config doesn't work with flask-caching v1.9.0

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


   I've tried below config stanza with flask-caching 1.9.0 directly and it could reproduce a similar stacktrack:
   
   ```
   DATA_CACHE_CONFIG = {
       'CACHE_TYPE': 'redis',
       'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24, # 1 day default (in secs)
       'CACHE_KEY_PREFIX': 'superset_results',
       'CACHE_REDIS_URL': 'redis://localhost:6379/0',
   }
   ```
   
   ```Python
   >>> from flask import Flask
   Cache
   
   app = Flask(__name__)>>> from flask_caching import Cache
   >>> 
   >>> app = Flask(__name__)
   >>> import superset_config
   >>> cache = Cache(app, config=superset_config.DATA_CACHE_CONFIG)
   >>> cache.get('foo')
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/local/lib/python3.7/site-packages/flask_caching/__init__.py", line 248, in get
       return self.cache.get(*args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_caching/backends/rediscache.py", line 114, in get
       self._read_clients.get(self._get_prefix() + key)
   AttributeError: 'Flask' object has no attribute 'get'
   ```
   
   However, the same code works with Flask-caching 1.10.1. So I dig more then realized the config attribute `CACHE_REDIS_URL` + `'CACHE_TYPE': 'redis'` is not supported in Flask-Caching until 1.10.0. So the above stacktrace is expected outcome by following this constructor: https://github.com/sh4nks/flask-caching/blob/cb6a7a3d61057b07ebdc7a58359b41257fe0af93/flask_caching/backends/rediscache.py#L42-L68
   
   Where the parameter `host` is actually the Flask app object.
   
   ## Suggested Fix
   
   Upgrade Flask-Caching to 1.10.0 or later


-- 
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] zhaoyongjie closed issue #15258: documented data cache config doesn't work with flask-caching v1.9.0

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


   


-- 
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: notifications-unsubscribe@superset.apache.org

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] shawnzhu edited a comment on issue #15258: documented data cache config doesn't work with flask-caching v1.9.0

Posted by GitBox <gi...@apache.org>.
shawnzhu edited a comment on issue #15258:
URL: https://github.com/apache/superset/issues/15258#issuecomment-864112590


   I've tried below config stanza with flask-caching 1.9.0 directly w/o superset and it could reproduce a similar stacktrack:
   
   ```
   DATA_CACHE_CONFIG = {
       'CACHE_TYPE': 'redis',
       'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24, # 1 day default (in secs)
       'CACHE_KEY_PREFIX': 'superset_results',
       'CACHE_REDIS_URL': 'redis://localhost:6379/0',
   }
   ```
   
   ```Python
   >>> from flask import Flask
   Cache
   
   app = Flask(__name__)>>> from flask_caching import Cache
   >>> 
   >>> app = Flask(__name__)
   >>> import superset_config
   >>> cache = Cache(app, config=superset_config.DATA_CACHE_CONFIG)
   >>> cache.get('foo')
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/local/lib/python3.7/site-packages/flask_caching/__init__.py", line 248, in get
       return self.cache.get(*args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_caching/backends/rediscache.py", line 114, in get
       self._read_clients.get(self._get_prefix() + key)
   AttributeError: 'Flask' object has no attribute 'get'
   ```
   
   However, the same code works with Flask-caching 1.10.1. So I dig more then realized the config attribute `CACHE_REDIS_URL` + `'CACHE_TYPE': 'redis'` is not supported in Flask-Caching until 1.10.0. So the above stacktrace is expected outcome by following this constructor: https://github.com/sh4nks/flask-caching/blob/cb6a7a3d61057b07ebdc7a58359b41257fe0af93/flask_caching/backends/rediscache.py#L42-L68
   
   Where the parameter `host` is actually the Flask app object.
   
   ## Suggested Fix
   
   Upgrade Flask-Caching to 1.10.0 or later


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