Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import superset_config #15444

Merged
merged 2 commits into from
Jun 29, 2021
Merged

Conversation

villebro
Copy link
Member

@villebro villebro commented Jun 29, 2021

SUMMARY

A recent PR #15405 replaced the use of the deprecated imp.load_source with importlib.load_module, which caused the following error on some deployments:

Failed to import config for SUPERSET_CONFIG_PATH=/Users/ville/superset/superset_config.py
Traceback (most recent call last):
  File "/Users/ville/src/superset/superset/app.py", line 80, in load_override_config
    override_conf = importlib.import_module("superset_config", cfg_path)
  File "/Users/ville/.pyenv/versions/3.8-dev/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'superset_config'
Failed to create app
Traceback (most recent call last):
  File "/Users/ville/src/superset/superset/app.py", line 40, in create_app
    config = init_config()
  File "/Users/ville/src/superset/superset/app.py", line 56, in init_config
    override_conf = convert_to_dict(load_override_config())
  File "/Users/ville/src/superset/superset/app.py", line 80, in load_override_config
    override_conf = importlib.import_module("superset_config", cfg_path)
  File "/Users/ville/.pyenv/versions/3.8-dev/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'superset_config'
Traceback (most recent call last):
  File "/Users/ville/src/superset/venv/bin/superset", line 11, in <module>
    load_entry_point('apache-superset', 'console_scripts', 'superset')()
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/flask/cli.py", line 425, in decorator
    with __ctx.ensure_object(ScriptInfo).load_app().app_context():
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/flask/cli.py", line 381, in load_app
    app = call_factory(self, self.create_app)
  File "/Users/ville/src/superset/venv/lib/python3.8/site-packages/flask/cli.py", line 119, in call_factory
    return app_factory()
  File "/Users/ville/src/superset/superset/app.py", line 51, in create_app
    raise ex
  File "/Users/ville/src/superset/superset/app.py", line 40, in create_app
    config = init_config()
  File "/Users/ville/src/superset/superset/app.py", line 56, in init_config
    override_conf = convert_to_dict(load_override_config())
  File "/Users/ville/src/superset/superset/app.py", line 80, in load_override_config
    override_conf = importlib.import_module("superset_config", cfg_path)
  File "/Users/ville/.pyenv/versions/3.8-dev/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'superset_config'

A similar change was done on Airflow last year: apache/airflow#7099 , which is based on the official documentation found here: https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Jun 29, 2021

Codecov Report

Merging #15444 (ccad28a) into master (ed6d10e) will decrease coverage by 0.23%.
The diff coverage is 25.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15444      +/-   ##
==========================================
- Coverage   77.21%   76.98%   -0.24%     
==========================================
  Files         975      975              
  Lines       50662    50668       +6     
  Branches     6228     6228              
==========================================
- Hits        39120    39005     -115     
- Misses      11331    11452     +121     
  Partials      211      211              
Flag Coverage Δ
hive ?
mysql 81.71% <25.00%> (-0.02%) ⬇️
postgres 81.73% <25.00%> (-0.02%) ⬇️
presto ?
python 81.82% <25.00%> (-0.46%) ⬇️
sqlite 81.35% <25.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/app.py 63.49% <25.00%> (-4.93%) ⬇️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.20% <0.00%> (-17.21%) ⬇️
superset/db_engine_specs/presto.py 83.36% <0.00%> (-6.53%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/connectors/sqla/models.py 88.22% <0.00%> (-1.65%) ⬇️
superset/db_engine_specs/base.py 87.97% <0.00%> (-0.41%) ⬇️
superset/models/core.py 89.76% <0.00%> (-0.27%) ⬇️
superset/utils/core.py 88.97% <0.00%> (-0.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed6d10e...ccad28a. Read the comment docs.

@villebro villebro merged commit f33a0e1 into apache:master Jun 29, 2021
@villebro villebro deleted the villebro/load-source branch June 29, 2021 10:30
betodealmeida added a commit to betodealmeida/incubator-superset that referenced this pull request Jul 6, 2021
betodealmeida added a commit that referenced this pull request Jul 6, 2021
graceguo-supercat pushed a commit to airbnb/superset-fork that referenced this pull request Jul 6, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* fix: import superset_config

* make module name constant
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* fix: import superset_config

* make module name constant
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* fix: import superset_config

* make module name constant
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants