Hvitgar commented on issue #15118:
URL: https://github.com/apache/superset/issues/15118#issuecomment-910199827
Solving this requires multiple steps. First, you have to adjust several
values in your superset_config.py:
Enable the following feature flags if you want to see thumbnails for your
dashboards:
```python
FEATURE_FLAGS = {
"THUMBNAILS": True,
"THUMBNAILS_SQLA_LISTENERS": True,
}
```
provide valid cache configs for `CACHE_CONFIG`, `DATA_CACHE_CONFIG` and
`THUMBNAIL_CACHE_CONFIG`, for testing purpose a local FileSystemCache is
sufficient:
```python
CACHE_CONFIG = {
'CACHE_TYPE': 'FileSystemCache',
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24,
'CACHE_THRESHOLD': CACHE_THRESHOLD, # integer, limit of items in the
cache
'CACHE_DIR': BASE_CACHE_DIR, # the directory where the cache should be
stored
}
```
additionally, configure the `RESULTS_BACKEND` (once again, for testing
FileSystemCache is sufficient):
```python
from cachelib.file import FileSystemCache
import os
RESULTS_BACKEND = FileSystemCache(
cache_dir=os.path.join(BASE_CACHE_DIR, 'results/'),
threshold=CACHE_THRESHOLD,
default_timeout=CACHE_DEFAULT_TIMEOUT
)
```
Next, you need to provide a celery config (the one below is copied from the
[official superset
documentation](https://superset.apache.org/docs/installation/async-queries-celery)
without any modifications):
```python
class CeleryConfig(object):
BROKER_URL = 'redis://localhost:6379/0'
CELERY_IMPORTS = (
'superset.sql_lab',
'superset.tasks',
'superset.tasks.thumbnails'
)
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERYD_LOG_LEVEL = 'DEBUG'
CELERYD_PREFETCH_MULTIPLIER = 10
CELERY_ACKS_LATE = True
CELERY_ANNOTATIONS = {
'sql_lab.get_sql_results': {
'rate_limit': '100/s',
},
'email_reports.send': {
'rate_limit': '1/s',
'time_limit': 120,
'soft_time_limit': 150,
'ignore_result': True,
},
}
CELERY_CONFIG = CeleryConfig
```
last steps in the `superset_config.py`:
```python
WEBDRIVER_TYPE = "firefox"
WEBDRIVER_BASEURL = "http://localhost:8088" # or whatever URL your superset
instance is running on, the webdriver will use this URL to connect to superset
in order to take a screenshot
THUMBNAIL_SELENIUM_USER = "admin" # any user with permissions to view all
charts is sufficient
```
now, in your superset environment, make sure you have a redis server running
and listening on port 6379 (otherwise, adjust the redis port in the settings
above). Also, you will need firefox and geckodriver.
Make sure that your redis server can write data to the disk by connecting to
it via `redis-cli` and running the following two commands:
```bash
CONFIG SET dir /app/superset_home/redis # where the database will be
stored, the directory must exist
CONFIG SET dbfilename redis.rdb # or any other filename
```
Start celery using `celery --app=superset.tasks.celery_app:app worker
--pool=prefork -O fair -c 4`
Now, you should be able to take screenshots and see thumbnails of your
dashboards
Note: I am not sure whether all settings are actually needed, this is just
the setup that worked for me.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]