使用 CLI 导入 Apache Superset 问题

问题描述 投票:0回答:1

我正在使用 docker image 运行 apache superset 实例,UI 工作正常,我已成功创建数据源和仪表板,然后将其导出为 zip 文件。 我的问题是每当我尝试使用 superset cli 导入仪表板(或数据库)时

superset import-dashboards -p myDashboard.zip
我遇到以下异常

root@5be86760ec2a:/app# superset import-dashboards -p dash1.zip
Loaded your LOCAL configuration at [/app/docker/pythonpath_dev/superset_config.py]
logging was configured successfully
2023-10-23 08:39:13,044:INFO:superset.utils.logging_configurator:logging was configured successfully
2023-10-23 08:39:13,048:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
We haven't found any Content Security Policy (CSP) defined in the configurations. Please make sure to configure CSP using the TALISMAN_ENABLED and TALISMAN_CONFIG keys or any other external software. Failing to configure CSP have serious security implications. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more information. You can disable this warning using the CONTENT_SECURITY_POLICY_WARNING key.
2023-10-23 08:39:13,050:WARNING:superset.initialization:We haven't found any Content Security Policy (CSP) defined in the configurations. Please make sure to configure CSP using the TALISMAN_ENABLED and TALISMAN_CONFIG keys or any other external software. Failing to configure CSP have serious security implications. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more information. You can disable this warning using the CONTENT_SECURITY_POLICY_WARNING key.
/usr/local/lib/python3.9/site-packages/flask_limiter/extension.py:293: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
  warnings.warn(
/app/superset/commands/importers/v1/utils.py:113: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, password in db.session.query(Database.uuid, Database.password).all()
/app/superset/commands/importers/v1/utils.py:118: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, password in db.session.query(SSHTunnel.uuid, SSHTunnel.password).all()
/app/superset/commands/importers/v1/utils.py:123: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, private_key in db.session.query(
/app/superset/commands/importers/v1/utils.py:130: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, private_key_password in db.session.query(
Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
2023-10-23 08:39:14,571:ERROR:superset.dashboards.commands.importers.dispatcher:Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
There was an error when importing the dashboards(s), please check the exception traceback in the log
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/cli/importexport.py", line 161, in import_dashboards
    ImportDashboardsCommand(contents, overwrite=True).run()
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
2023-10-23 08:39:14,576:ERROR:superset.cli.importexport:There was an error when importing the dashboards(s), please check the exception traceback in the log
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/cli/importexport.py", line 161, in import_dashboards
    ImportDashboardsCommand(contents, overwrite=True).run()
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason

尝试导入数据源时发生同样的问题

我尝试使用超集 UI 导入完全相同的文件,效果很好。 还尝试通过提供实际的数据库密码来更改导出文件中的数据库网址,仍然相同。

apache-superset
1个回答
0
投票

有同样的问题。您可以为导入过程指定用户,如下所示。这解决了我的问题:

superset import-dashboards -p dashboards.zip -u admin

我还在 CLI 帮助中发现了这一点。当然只有在我启动并运行之后 🤦u200d♂️:

Usage: superset import-dashboards [OPTIONS]

  Import dashboards from ZIP file

Options:
  -p, --path TEXT      Path to a single ZIP file
  -u, --username TEXT  Specify the user name to assign dashboards to
  --help               Show this message and exit.
© www.soinside.com 2019 - 2024. All rights reserved.