You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "wyc990122 (via GitHub)" <gi...@apache.org> on 2023/02/03 08:48:05 UTC

[GitHub] [superset] wyc990122 opened a new issue, #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container

wyc990122 opened a new issue, #22977:
URL: https://github.com/apache/superset/issues/22977

   A clear and concise description of what the bug is.
   I have runned the integration tests shell scripts/run.sh in the docker container. When it ran the "superset db upgrade" command, the ImportError hits. Here is the log:
   ```
   Traceback (most recent call last):
     File "/usr/local/bin/superset", line 33, in <module>
       sys.exit(load_entry_point('apache-superset', 'console_scripts', 'superset')())
     File "/usr/local/bin/superset", line 25, in importlib_load_entry_point
       return next(matches).load()
     File "/usr/local/lib/python3.8/importlib/metadata.py", line 77, in load
       module = import_module(match.group('module'))
     File "/usr/local/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 975, in _find_and_load_unlocked
     File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
     File "<frozen importlib._bootstrap_external>", line 843, in exec_module
     File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
     File "/app/superset/cli/main.py", line 27, in <module>
       from superset import app, appbuilder, cli, security_manager
   ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py)
   ```
   #### How to reproduce the bug
   
   1. Some secondary development for superset, and I have copied them to the right position in the docker container.
   2. run 'ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]' command, and  'run source /app/superset/run.sh' in the docker-entrypoint.sh
   3. In run.sh,I change the DB configurations to my local server, including DB_NAME,DB_USER,DB_PASSWORD
   4. Then the error occurs.
   
   ### Expected results
   
   run.sh can be runned correctly
   ### Actual results
   ```
     File "/app/superset/cli/main.py", line 27, in <module>
       from superset import app, appbuilder, cli, security_manager
   ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py)
   ```
   
   #### Screenshots
   
   If applicable, add screenshots to help explain your problem.
   ![image](https://user-images.githubusercontent.com/65800480/216553647-685b6317-e02e-4a8c-8139-8ca359e5776e.png)
   
   
   ### Environment
   
   (please complete the following information):
   
   - browser type and version:
   - superset version: 2.0.0
   - python version: 3.8
   - node.js version: unknown
   - any feature flags active:
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [✔] I have checked the superset logs for python stacktraces and included it here as text if there are any.
   - [❌] I have reproduced the issue with at least the latest released version of superset.(didn't try on 2.0.1 superset)
   - [✔] I have checked the issue tracker for the same issue and I haven't found one similar.
   
   ### Additional context
   
   Add any other context about the problem here.
   


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] wyc990122 commented on issue #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container

Posted by "wyc990122 (via GitHub)" <gi...@apache.org>.
wyc990122 commented on issue #22977:
URL: https://github.com/apache/superset/issues/22977#issuecomment-1512469715

   The probem is expired.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] wyc990122 closed issue #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container

Posted by "wyc990122 (via GitHub)" <gi...@apache.org>.
wyc990122 closed issue #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container
URL: https://github.com/apache/superset/issues/22977


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] wyc990122 commented on issue #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container

Posted by "wyc990122 (via GitHub)" <gi...@apache.org>.
wyc990122 commented on issue #22977:
URL: https://github.com/apache/superset/issues/22977#issuecomment-1415401374

   Besides,I also tried another superset version 1.3.0 integration tests,and i got the similar ImportError result:
   ```
   2023-02-03 16:58:12 | Traceback (most recent call last):
     | 2023-02-03 16:58:12 | File "/usr/local/bin/superset", line 33, in <module>
     | 2023-02-03 16:58:12 | sys.exit(load_entry_point('apache-superset', 'console_scripts', 'superset')())
     | 2023-02-03 16:58:12 | File "/usr/local/bin/superset", line 25, in importlib_load_entry_point
     | 2023-02-03 16:58:12 | return next(matches).load()
     | 2023-02-03 16:58:12 | File "/usr/local/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 105, in load
     | 2023-02-03 16:58:12 | module = import_module(match.group('module'))
     | 2023-02-03 16:58:12 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
     | 2023-02-03 16:58:12 | return _bootstrap._gcd_import(name[level:], package, level)
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
     | 2023-02-03 16:58:12 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
     | 2023-02-03 16:58:12 | File "/app/superset/__init__.py", line 20, in <module>
     | 2023-02-03 16:58:12 | from flask_appbuilder import AppBuilder, SQLA
     | 2023-02-03 16:58:12 | File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/__init__.py", line 5, in <module>
     | 2023-02-03 16:58:12 | from .api import ModelRestApi  # noqa: F401
     | 2023-02-03 16:58:12 | File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/api/__init__.py", line 6, in <module>
     | 2023-02-03 16:58:12 | from typing import Callable, Dict, List, Optional, Set
     | 2023-02-03 16:58:12 | File "/app/superset/typing.py", line 19, in <module>
     | 2023-02-03 16:58:12 | from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
     | 2023-02-03 16:58:12 | ImportError: cannot import name 'Any' from 'typing' (/app/superset/typing.py)
   ```
   It shows the similar ImportError, so I don't know if I run the run.sh by the wrong way.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] wyc990122 commented on issue #22977: ImportError: cannot import name 'appbuilder' from 'superset' (/app/superset/__init__.py) when running run.sh in the docker container

Posted by "wyc990122 (via GitHub)" <gi...@apache.org>.
wyc990122 commented on issue #22977:
URL: https://github.com/apache/superset/issues/22977#issuecomment-1415417804

   here are the contents of Dockerfile, docker-entrypoint.sh and run.sh:
   Dockerfile
   ```
   # Production Stage
   FROM apache/superset:2.0.0
   WORKDIR /app
   # 以下为COPY二次开发代码到docker容器替换源码文件的命令,请严格按照文件排列顺序复制,以防遗漏或重复
   # 如果删除某个文件后,请注意回到Dockerfile中删除对应文件的COPY语句
   # 复制superset文件夹下内容:
   COPY superset/charts/commands/data.py /app/superset/charts/commands/
   COPY superset/charts/api.py /app/superset/charts/
   COPY superset/cli/main.py app/superset/cli/
   COPY superset/common/query_context.py /app/superset/common/
   COPY superset/connectors/connector_registry.py /app/superset/connectors/
   COPY superset/utils/core.py /app/superset/utils/
   COPY superset/utils/log.py /app/superset/utils/
   COPY superset/utils/pandas_postprocessing.py /app/superset/utils/
   COPY superset/views/chart/views.py /app/superset/views/chart/
   COPY superset/views/utils.py /app/superset/views/
   COPY superset/build_ptr_table_name.py /app/superset/
   COPY superset/config.py /app/pythonpath/
   COPY superset/extensions.py /app/superset/
   COPY superset/generate_filter_time_range.py /app/superset/
   COPY superset/superset_config.py /app/pythonpath/
   COPY superset/viz.py /app/superset/
   COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
   
   COPY requirements.txt /tmp/requirements.txt
   COPY requirements/base.txt /tmp/base.txt
   COPY requirements/docker.txt /tmp/docker.txt
   COPY requirements/integration.txt /tmp/integration.txt
   COPY requirements/development.txt /tmp/development.txt
   #COPY requirements/original_development.txt /tmp/original_development.txt
   COPY requirements/testing.txt /tmp/testing.txt
   COPY scripts/tests/run.sh /app/superset/
   COPY SysPath.py /app/
   COPY tests /app/superset
   
   # 执行其他命令
   # 安装依赖
   
   RUN pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir  pip==21.0.1
   RUN pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/development.txt \
   #&& pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/original_development.txt \
   && pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/base.txt \
   && pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/docker.txt \
   && pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/integration.txt \
   && pip install  --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir -r /tmp/testing.txt \
   && pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  --no-cache-dir apache-superset==2.0.0
   # 对前端文件解压
   # RUN unzip -o /app/superset/assets.zip -d /app/superset/static
   # 执行docker-entrypoint.sh文件
   USER root
   RUN chmod +x /usr/bin/docker-entrypoint.sh \
   && chmod +x /app/superset/run.sh
   USER superset
   ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
   ```
   docker-entrypoint.sh:
   ```
   #!/bin/bash
   set -eo pipefail
   
   if [ "${#}" -ne 0 ]; then
       exec "${@}"
   else
       export PYTHONPATH=/app/superset/
       source /app/superset/run.sh
   fi
   ```
   scripts/run.sh
   ```
   #!/usr/bin/env bash
   set -e
   
   #
   # Reset test DATABASE
   #
   function reset_db() {
     echo --------------------
     echo Reseting test DB
     echo --------------------
     docker-compose stop superset-tests-worker superset || true
     # shellcheck disable=SC2034
     RESET_DB_CMD="mysql \"mysql://${DB_USER}:${DB_PASSWORD}@{host}:3306\" <<-EOF
       DROP DATABASE IF EXISTS ${DB_NAME};
       CREATE DATABASE ${DB_NAME};
       \\c ${DB_NAME}
       DROP SCHEMA IF EXISTS sqllab_test_db;
       CREATE SCHEMA sqllab_test_db;
       DROP SCHEMA IF EXISTS admin_database;
       CREATE SCHEMA admin_database;
   EOF
   "
     docker exec -i superset_db bash -c "${RESET_DB_CMD}"
     docker-compose start superset-tests-worker superset
   }
   
   #
   # Run init test procedures
   #
   function test_init() {
     echo --------------------
     echo Upgrading
     echo --------------------
     superset db upgrade
     echo --------------------
     echo Superset init
     echo --------------------
     superset init
   }
   
   #
   # Init global vars
   #
   DB_NAME="superset_2.0_upgrade_test"
   DB_USER="root"
   DB_PASSWORD="{password}"
   export SUPERSET__SQLALCHEMY_DATABASE_URI=${SUPERSET__SQLALCHEMY_DATABASE_URI:-mysql://"${DB_USER}":"${DB_PASSWORD}"@172.29.155.152:3306/"${DB_NAME}"}
   export PYTHONPATH=/app/superset
   echo $PYTHONPATH
   export SUPERSET_CONFIG=tests.integration_tests.superset_test_config
   echo '成功配置SUPERSET_CONFIG'
   
   RUN_INIT=1
   RUN_RESET_DB=1
   RUN_TESTS=1
   TEST_MODULE="tests.integration_tests"
   
   PARAMS=""
   while (( "$#" )); do
     case "$1" in
       --help)
         echo Switches:
         echo --no-init : Will not, reset the test DB, superset init and load examples
         echo --no-reset-db: Will not reset the test DB
         echo --no-tests: Will not run any test, by default reset the DB, superset init and load_examples
         echo --reset-db: Just resets the test DB, will not run any test
         echo --module: Run a specific test module: --module tests/charts/api_tests.py for example
         exit 0
         ;;
       --no-init)
         RUN_INIT=0
         RUN_RESET_DB=0
         shift 1
         ;;
       --no-reset-db)
         RUN_RESET_DB=0
         shift 1
         ;;
       --no-tests)
         RUN_TESTS=0
         shift 1
         ;;
       --reset-db)
         RUN_TESTS=0
         RUN_INIT=0
         shift 1
         ;;
       --module)
         TEST_MODULE=$2
         shift 2
         ;;
       --) # end argument parsing
         shift
         break
         ;;
       --*) # unsupported flags
         echo "Error: Unsupported flag $1" >&2
         exit 1
         ;;
       *) # preserve positional arguments
         PARAMS="$PARAMS $1"
         shift
         ;;
     esac
   done
   
   echo ------------------------------------
   echo DB_URI="${SUPERSET__SQLALCHEMY_DATABASE_URI}"
   echo Superset config module="${SUPERSET_CONFIG}"
   echo Run init procedures=$RUN_INIT
   echo Run reset DB=$RUN_RESET_DB
   echo Test to run:"${TEST_MODULE}"
   echo ------------------------------------
   
   
   if [ $RUN_RESET_DB -eq 1 ]
   then
     reset_db
   fi
   
   if [ $RUN_INIT -eq 1 ]
   then
     #  PATH="$PATH":/app/superset/tests/integration_tests/superset_test_config
   #  echo "$PATH"
     # shellcheck disable=SC2046
     # shellcheck disable=SC2006
     # shellcheck disable=SC2034
     PATH="$PATH":/app/superset
     PATH="$PATH":/usr/bin
     test_init
   fi
   
   if [ $RUN_TESTS -eq 1 ]
   then
     pytest --durations=0 --maxfail=1 "${TEST_MODULE}"
   fi
   
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org