feat(be/cfg): replace deprecated imp.load_source with importlib.util (#30390)

This commit is contained in:
Đỗ Trọng Hải 2024-10-04 04:58:32 +07:00 committed by GitHub
parent 6217cb636f
commit 2aa9348759
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -25,7 +25,6 @@ at the end of this file.
# pylint: disable=too-many-lines
from __future__ import annotations
import imp # pylint: disable=deprecated-module
import importlib.util
import json
import logging
@ -1885,7 +1884,9 @@ if CONFIG_PATH_ENV_VAR in os.environ:
cfg_path = os.environ[CONFIG_PATH_ENV_VAR]
try:
module = sys.modules[__name__]
override_conf = imp.load_source("superset_config", cfg_path)
spec = importlib.util.spec_from_file_location("superset_config", cfg_path)
override_conf = importlib.util.module_from_spec(spec)
spec.loader.exec_module(override_conf)
for key in dir(override_conf):
if key.isupper():
setattr(module, key, getattr(override_conf, key))