这是我的superser_config.py
的配置:
from superset.typing import CacheConfig
# 源数据库配置
SQLALCHEMY_DATABASE_URI = 'mysql://root:root@localhost/superset_meta?charset=utf8'
# 汉化
BABEL_DEFAULT_LOCALE = "zh"
# 缓存配置
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'localhost',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 0,
'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
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',
}
# 开启缩略图
FEATURE_FLAGS = {
"THUMBNAILS": True,
"THUMBNAILS_SQLA_LISTENERS": True,
}
# Async selenium thumbnail task will use the following user
# 缩略图配置
THUMBNAIL_CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 24 * 60 * 60 * 7,
'CACHE_KEY_PREFIX': 'thumbnail_',
'CACHE_NO_NULL_WARNING': True,
'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
# celery配置
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_PREFETCH_MULTIPLIER = 10
CELERY_ACKS_LATE = True
CELERY_CONFIG = CeleryConfig
THUMBNAIL_SELENIUM_USER = "Admin" # 指定缩略图的角色
WEBDRIVER_TYPE = "chrome"
# for older versions this was EMAIL_REPORTS_WEBDRIVER = "chrome"
WEBDRIVER_OPTION_ARGS = [
"--force-device-scale-factor=2.0",
"--high-dpi-support=2.0",
"--headless",
"--disable-gpu",
"--disable-dev-shm-usage",
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-extensions",
]
# The base URL to query for accessing the user interface
WEBDRIVER_BASEURL = "http://localhost:8001/"
而且我也已经安装了chromedriver
运行时有报错:
...
Attempting to get from cache: abbb8ea1ad9a735006f338133d6c1b64
2021-12-21 10:57:57,764:INFO:superset.utils.screenshots:Attempting to get from cache: abbb8ea1ad9a735006f338133d6c1b64
Failed at getting from cache: abbb8ea1ad9a735006f338133d6c1b64
2021-12-21 10:57:57,771:INFO:superset.utils.screenshots:Failed at getting from cache: abbb8ea1ad9a735006f338133d6c1b64
Triggering thumbnail compute (chart id: 73) ASYNC
2021-12-21 10:57:57,775:INFO:superset.charts.api:Triggering thumbnail compute (chart id: 73) ASYNC
Attempting to get from cache: b06fdc239cb339d68ce9133515e059fd
2021-12-21 10:57:57,778:INFO:superset.utils.screenshots:Attempting to get from cache: b06fdc239cb339d68ce9133515e059fd
Failed at getting from cache: b06fdc239cb339d68ce9133515e059fd
2021-12-21 10:57:57,785:INFO:superset.utils.screenshots:Failed at getting from cache: b06fdc239cb339d68ce9133515e059fd
Attempting to get from cache: 17c67c85c07197102cfd9ab7426f09d1
Attempting to get from cache: 3ecab91cd8e314c2df7a7a2adf63f1d7
Triggering thumbnail compute (chart id: 71) ASYNC
2021-12-21 10:57:57,812:INFO:superset.utils.screenshots:Attempting to get from cache: 17c67c85c07197102cfd9ab7426f09d1
Failed at getting from cache: 17c67c85c07197102cfd9ab7426f09d1
2021-12-21 10:57:57,815:INFO:superset.utils.screenshots:Attempting to get from cache: 3ecab91cd8e314c2df7a7a2adf63f1d7
Failed at getting from cache: 3ecab91cd8e314c2df7a7a2adf63f1d7
2021-12-21 10:57:57,820:INFO:superset.charts.api:Triggering thumbnail compute (chart id: 71) ASYNC
...
在我执行celery --app=superset.tasks.celery_app:app worker --pool=prefork -O fair -c 4
时,提示以下错误:
[2021-12-14 17:04:43,482: ERROR/SpawnPoolWorker-2] Process SpawnPoolWorker-2
Traceback (most recent call last):
File "D:\Anaconda3\install\envs\superset_env\Lib\site-packages\billiard\process.py", line 327, in _bootstrap
self.run()
File "D:\Anaconda3\install\envs\superset_env\Lib\site-packages\billiard\process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "D:\Anaconda3\install\envs\superset_env\Lib\site-packages\billiard\pool.py", line 289, in __call__
self.after_fork()
File "D:\Anaconda3\install\envs\superset_env\Lib\site-packages\billiard\pool.py", line 421, in after_fork
self.initializer(*self.initargs)
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\concurrency\prefork.py", line 55, in process_initializer
app.loader.init_worker()
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 114, in init_worker
self.import_default_modules()
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 109, in import_default_modules
return [self.import_task_module(m) for m in self.default_modules]
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 109, in <listcomp>
return [self.import_task_module(m) for m in self.default_modules]
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 89, in import_task_module
return self.import_from_cwd(module)
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 98, in import_from_cwd
package=package,
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\utils\imports.py", line 111, in import_from_cwd
return imp(module, package=package)
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\celery\loaders\base.py", line 92, in import_module
return importlib.import_module(module, package=package)
File "D:\Anaconda3\install\envs\superset_env\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\sql_lab.py", line 37, in <module>
from superset.db_engine_specs import BaseEngineSpec
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\db_engine_specs\__init__.py", line 43, in <module>
from superset.db_engine_specs.base import BaseEngineSpec
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\db_engine_specs\base.py", line 61, in <module>
from superset.models.sql_lab import Query
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\models\__init__.py", line 17, in <module>
from . import (
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\models\alerts.py", line 55, in <module>
class Alert(Model, AuditMixinNullable):
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\superset\models\alerts.py", line 68, in Alert
owners = relationship(security_manager.user_model, secondary=alert_owner)
File "D:\Anaconda3\install\envs\superset_env\lib\site-packages\werkzeug\local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: 'NoneType' object has no attribute 'user_model'
这是因为什么导致的错误呢?是不是哪儿我配置错误呢?是不是屏幕截图的问题呢?