Sinaptik-AI / pandas-ai

Chat with your database (SQL, CSV, pandas, polars, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.
https://pandas-ai.com
Other
13.05k stars 1.26k forks source link

docker compose up error 16/10/2024 #1395

Closed johnfelipe closed 5 days ago

johnfelipe commented 5 days ago

System Info

latest ubuntu 22 3.11

🐛 Describe the bug

felipe@grupovanti:~/pandas-ai$ docker compose up
WARN[0000] The "cxwR1S88WmYVOw0BFpo4vuJ0Od5zrNXevkZcFt65wf5eTdMbGFMr6" variable is not set. Defaulting to a blank string.
[+] Running 9/9
 ✔ postgresql Pulled                                                       9.6s
   ✔ df9b9388f04a Pull complete                                            1.6s
   ✔ 7902437d3a12 Pull complete                                            1.6s
   ✔ 709e2267bc98 Pull complete                                            1.6s
   ✔ 10c5a0a9c34e Pull complete                                            6.4s
   ✔ b46af7f38693 Pull complete                                            6.4s
   ✔ 65aa0c237f80 Pull complete                                            6.4s
   ✔ f6493ce74812 Pull complete                                            6.4s
   ✔ eaac3b44f9d0 Pull complete                                            6.4s
[+] Running 4/3
 ✔ Network pandas-ai_pandabi-network  Created                              0.1s
 ✔ Container pandas-ai-postgresql-1   Created                              0.3s
 ✔ Container pandabi-frontend         Crea...                              0.3s
 ✔ Container pandabi-backend          Creat...                             0.0s
Attaching to pandabi-backend, pandabi-frontend, postgresql-1
postgresql-1      | The files belonging to this database system will be owned by user "postgres".
postgresql-1      | This user must also own the server process.
postgresql-1      |
postgresql-1      | The database cluster will be initialized with locale "en_US.utf8".
postgresql-1      | The default database encoding has accordingly been set to "UTF8".
postgresql-1      | The default text search configuration will be set to "english".
postgresql-1      |
postgresql-1      | Data page checksums are disabled.
postgresql-1      |
postgresql-1      | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgresql-1      | creating subdirectories ... ok
postgresql-1      | selecting dynamic shared memory implementation ... posix
postgresql-1      | selecting default max_connections ... 100
postgresql-1      | selecting default shared_buffers ... 128MB
postgresql-1      | selecting default time zone ... UTC
postgresql-1      | creating configuration files ... ok
postgresql-1      | running bootstrap script ... ok
postgresql-1      | sh: locale: not found
postgresql-1      | 2024-10-16 12:01:14.361 UTC [31] WARNING:  no usable system locales were found
pandabi-backend   | startup.sh: line 6: log: command not found
pandabi-frontend  |
pandabi-frontend  | > client@0.1.0 start
pandabi-frontend  | > next start
pandabi-frontend  |
pandabi-frontend  |  ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
postgresql-1      | performing post-bootstrap initialization ... ok
postgresql-1      | initdb: warning: enabling "trust" authentication for local connections
postgresql-1      | You can change this by editing pg_hba.conf or using the option -A, or
postgresql-1      | --auth-local and --auth-host, the next time you run initdb.
postgresql-1      | syncing data to disk ... ok
postgresql-1      |
postgresql-1      |
postgresql-1      | Success. You can now start the database server using:
postgresql-1      |
postgresql-1      |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgresql-1      |
postgresql-1      | waiting for server to start....2024-10-16 12:01:15.285 UTC [37] LOG:  starting PostgreSQL 14.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027, 64-bit
postgresql-1      | 2024-10-16 12:01:15.287 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql-1      | 2024-10-16 12:01:15.289 UTC [38] LOG:  database system was shut down at 2024-10-16 12:01:15 UTC
postgresql-1      | 2024-10-16 12:01:15.293 UTC [37] LOG:  database system is ready to accept connections
postgresql-1      |  done
postgresql-1      | server started
pandabi-frontend  |   ▲ Next.js 14.2.3
pandabi-frontend  |   - Local:        http://localhost:3000
pandabi-frontend  |
pandabi-frontend  |  ✓ Starting...
postgresql-1      | CREATE DATABASE
postgresql-1      |
postgresql-1      |
postgresql-1      | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgresql-1      |
postgresql-1      | waiting for server to shut down....2024-10-16 12:01:15.459 UTC [37] LOG:  received fast shutdown request
postgresql-1      | 2024-10-16 12:01:15.460 UTC [37] LOG:  aborting any active transactions
postgresql-1      | 2024-10-16 12:01:15.462 UTC [37] LOG:  background worker "logical replication launcher" (PID 44) exited with exit code 1
postgresql-1      | 2024-10-16 12:01:15.463 UTC [39] LOG:  shutting down
postgresql-1      | 2024-10-16 12:01:15.470 UTC [37] LOG:  database system is shut down
postgresql-1      |  done
postgresql-1      | server stopped
postgresql-1      |
postgresql-1      | PostgreSQL init process complete; ready for start up.
postgresql-1      |
postgresql-1      | 2024-10-16 12:01:15.581 UTC [1] LOG:  starting PostgreSQL 14.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027, 64-bit
postgresql-1      | 2024-10-16 12:01:15.581 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgresql-1      | 2024-10-16 12:01:15.581 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgresql-1      | 2024-10-16 12:01:15.583 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql-1      | 2024-10-16 12:01:15.586 UTC [51] LOG:  database system was shut down at 2024-10-16 12:01:15 UTC
postgresql-1      | 2024-10-16 12:01:15.589 UTC [1] LOG:  database system is ready to accept connections
pandabi-frontend  |  ✓ Ready in 735ms
pandabi-backend   | Resolving dependencies...
pandabi-backend   | Warning: The locked version 3.9.1 for matplotlib is a yanked version. Reason for being yanked: The Windows wheels, under some conditions, caused segfaults in unrelated user code.  Due to this we deleted the Windows wheels to prevent these segfaults, however this caused greater disruption as pip then began to try (and fail) to build 3.9.1 from the sdist on Windows which impacted far more users.  Yanking the whole release is the only tool available to eliminate these failures without changes to on the user side.  The sdist, OSX wheel, and manylinux wheels are all functional and there are no critical bugs in the release.   Downstream packagers should not yank their builds of Matplotlib 3.9.1.  See https://github.com/matplotlib/matplotlib/issues/28551 for details.
pandabi-backend   | poetry install
pandabi-backend   | Installing dependencies from lock file
pandabi-backend   |
pandabi-backend   | No dependencies to install or update
pandabi-backend   |
pandabi-backend   | Installing the current project: pandasai-server (0.1.0)
pandabi-backend   |
pandabi-backend   | Warning: The current project could not be installed: No file/folder found for package pandasai-server
pandabi-backend   | If you do not want to install the current project use --no-root.
pandabi-backend   | If you want to use Poetry only for dependency management but not for packaging, you can disable package mode by setting package-mode = false in your pyproject.toml file.
pandabi-backend   | In a future version of Poetry this warning will become an error!
pandabi-backend   | wait-for-it.sh: 4: shift: can't shift that many
pandabi-backend   | export DEBUG='1'
pandabi-backend   | export ENVIRONMENT='development'
pandabi-backend   | export GPG_KEY='A035C8C19219BA821ECEA86B64E628F8D684696D'
pandabi-backend   | export HOME='/root'
pandabi-backend   | export HOSTNAME='3f7bba63a62a'
pandabi-backend   | export LANG='C.UTF-8'
pandabi-backend   | export MAKEFLAGS=''
pandabi-backend   | export MAKELEVEL='1'
pandabi-backend   | export MFLAGS=''
pandabi-backend   | export PANDASAI_API_KEY='$2a$10$cxwR1S88WmYVOw0BFpo4vuJ0Od5zrNXevkZcFt65wf5eTdMbGFMr6'
pandabi-backend   | export PATH='/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/bin:/root/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
pandabi-backend   | export POSTGRES_URL='postgresql+asyncpg://pandasai:password123@postgresql:5432/pandasai-db'
pandabi-backend   | export PS1='(pandasai-server-py3.11) '
pandabi-backend   | export PWD='/app'
pandabi-backend   | export PYTHON_VERSION='3.11.10'
pandabi-backend   | export SHLVL='1'
pandabi-backend   | export SHOW_SQL_ALCHEMY_QUERIES='0'
pandabi-backend   | export TEST_POSTGRES_URL='postgresql+asyncpg://pandasai:password123@postgresql:5432/pandasai-db'
pandabi-backend   | export VIRTUAL_ENV='/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11'
pandabi-backend   | export VIRTUAL_ENV_PROMPT='pandasai-server-py3.11'
pandabi-backend   | export _='/usr/bin/make'
pandabi-backend   | poetry run alembic upgrade head
pandabi-backend   | Traceback (most recent call last):
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/bin/alembic", line 8, in <module>
pandabi-backend   |     sys.exit(main())
pandabi-backend   |              ^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/config.py", line 636, in main
pandabi-backend   |     CommandLine(prog=prog).main(argv=argv)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/config.py", line 626, in main
pandabi-backend   |     self.run_cmd(cfg, options)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/config.py", line 603, in run_cmd
pandabi-backend   |     fn(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/command.py", line 406, in upgrade
pandabi-backend   |     script.run_env()
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/script/base.py", line 582, in run_env
pandabi-backend   |     util.load_python_file(self.dir, "env.py")
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
pandabi-backend   |     module = load_module_py(module_id, path)
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
pandabi-backend   |     spec.loader.exec_module(module)  # type: ignore
pandabi-backend   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
pandabi-backend   |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
pandabi-backend   |   File "/app/migrations/env.py", line 10, in <module>
pandabi-backend   |     from app.models import Base
pandabi-backend   | ModuleNotFoundError: No module named 'app'
pandabi-backend   | make: *** [Makefile:52: migrate] Error 1
pandabi-backend   | export DEBUG='1'
pandabi-backend   | export ENVIRONMENT='development'
pandabi-backend   | export GPG_KEY='A035C8C19219BA821ECEA86B64E628F8D684696D'
pandabi-backend   | export HOME='/root'
pandabi-backend   | export HOSTNAME='3f7bba63a62a'
pandabi-backend   | export LANG='C.UTF-8'
pandabi-backend   | export MAKEFLAGS=''
pandabi-backend   | export MAKELEVEL='1'
pandabi-backend   | export MFLAGS=''
pandabi-backend   | export PANDASAI_API_KEY='$2a$10$cxwR1S88WmYVOw0BFpo4vuJ0Od5zrNXevkZcFt65wf5eTdMbGFMr6'
pandabi-backend   | export PATH='/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/bin:/root/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
pandabi-backend   | export POSTGRES_URL='postgresql+asyncpg://pandasai:password123@postgresql:5432/pandasai-db'
pandabi-backend   | export PS1='(pandasai-server-py3.11) '
pandabi-backend   | export PWD='/app'
pandabi-backend   | export PYTHON_VERSION='3.11.10'
pandabi-backend   | export SHLVL='1'
pandabi-backend   | export SHOW_SQL_ALCHEMY_QUERIES='0'
pandabi-backend   | export TEST_POSTGRES_URL='postgresql+asyncpg://pandasai:password123@postgresql:5432/pandasai-db'
pandabi-backend   | export VIRTUAL_ENV='/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11'
pandabi-backend   | export VIRTUAL_ENV_PROMPT='pandasai-server-py3.11'
pandabi-backend   | export _='/usr/bin/make'
pandabi-backend   | poetry run python main.py
pandabi-backend   | INFO:     Will watch for changes in these directories: ['/app']
pandabi-backend   | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
pandabi-backend   | INFO:     Started reloader process [57] using StatReload
pandabi-backend   | INFO:     Started server process [61]
pandabi-backend   | INFO:     Waiting for application startup.
pandabi-backend   | 2024-10-16 12:01:26,475 INFO sqlalchemy.engine.Engine select pg_catalog.version()
pandabi-backend   | 2024-10-16 12:01:26,475 INFO sqlalchemy.engine.Engine [raw sql] ()
pandabi-backend   | 2024-10-16 12:01:26,478 INFO sqlalchemy.engine.Engine select current_schema()
pandabi-backend   | 2024-10-16 12:01:26,478 INFO sqlalchemy.engine.Engine [raw sql] ()
pandabi-backend   | 2024-10-16 12:01:26,479 INFO sqlalchemy.engine.Engine show standard_conforming_strings
pandabi-backend   | 2024-10-16 12:01:26,479 INFO sqlalchemy.engine.Engine [raw sql] ()
pandabi-backend   | 2024-10-16 12:01:26,481 INFO sqlalchemy.engine.Engine BEGIN (implicit)
pandabi-backend   | 2024-10-16 12:01:26,488 INFO sqlalchemy.engine.Engine SELECT anon_1.id, anon_1.email, anon_1.first_name, anon_1.created_at, anon_1.password, anon_1.verified, anon_1.last_name, anon_1.features, organization_1.id AS id_1, organization_1.name, organization_1.url, organization_1.is_default, organization_1.settings, organization_membership_1.id AS id_2, organization_membership_1.user_id, organization_membership_1.organization_id, organization_membership_1.role, organization_membership_1.verified AS verified_1
pandabi-backend   | FROM (SELECT "user".id AS id, "user".email AS email, "user".first_name AS first_name, "user".created_at AS created_at, "user".password AS password, "user".verified AS verified, "user".last_name AS last_name, "user".features AS features
pandabi-backend   | FROM "user"
pandabi-backend   |  LIMIT $1::INTEGER OFFSET $2::INTEGER) AS anon_1 LEFT OUTER JOIN organization_membership AS organization_membership_1 ON anon_1.id = organization_membership_1.user_id LEFT OUTER JOIN organization AS organization_1 ON organization_1.id = organization_membership_1.organization_id
pandabi-backend   | 2024-10-16 12:01:26,488 INFO sqlalchemy.engine.Engine [generated in 0.00023s] (1, 0)
postgresql-1      | 2024-10-16 12:01:26.489 UTC [58] ERROR:  relation "user" does not exist at character 700
postgresql-1      | 2024-10-16 12:01:26.489 UTC [58] STATEMENT:  SELECT anon_1.id, anon_1.email, anon_1.first_name, anon_1.created_at, anon_1.password, anon_1.verified, anon_1.last_name, anon_1.features, organization_1.id AS id_1, organization_1.name, organization_1.url, organization_1.is_default, organization_1.settings, organization_membership_1.id AS id_2, organization_membership_1.user_id, organization_membership_1.organization_id, organization_membership_1.role, organization_membership_1.verified AS verified_1
postgresql-1      |     FROM (SELECT "user".id AS id, "user".email AS email, "user".first_name AS first_name, "user".created_at AS created_at, "user".password AS password, "user".verified AS verified, "user".last_name AS last_name, "user".features AS features
postgresql-1      |     FROM "user"
postgresql-1      |      LIMIT $1::INTEGER OFFSET $2::INTEGER) AS anon_1 LEFT OUTER JOIN organization_membership AS organization_membership_1 ON anon_1.id = organization_membership_1.user_id LEFT OUTER JOIN organization AS organization_1 ON organization_1.id = organization_membership_1.organization_id
pandabi-backend   | 2024-10-16 12:01:26,490 INFO sqlalchemy.engine.Engine ROLLBACK
pandabi-backend   | ERROR:    Traceback (most recent call last):
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 514, in _prepare_and_execute
pandabi-backend   |     prepared_stmt, attributes = await adapt_connection._prepare(
pandabi-backend   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 760, in _prepare
pandabi-backend   |     prepared_stmt = await self._connection.prepare(
pandabi-backend   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/asyncpg/connection.py", line 636, in prepare
pandabi-backend   |     return await self._prepare(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/asyncpg/connection.py", line 654, in _prepare
pandabi-backend   |     stmt = await self._get_statement(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/asyncpg/connection.py", line 433, in _get_statement
pandabi-backend   |     statement = await self._protocol.prepare(
pandabi-backend   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "asyncpg/protocol/protocol.pyx", line 166, in prepare
pandabi-backend   | asyncpg.exceptions.UndefinedTableError: relation "user" does not exist
pandabi-backend   |
pandabi-backend   | The above exception was the direct cause of the following exception:
pandabi-backend   |
pandabi-backend   | Traceback (most recent call last):
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
pandabi-backend   |     self.dialect.do_execute(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute
pandabi-backend   |     cursor.execute(statement, parameters)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 572, in execute
pandabi-backend   |     self._adapt_connection.await_(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 132, in await_only
pandabi-backend   |     return current.parent.switch(awaitable)  # type: ignore[no-any-return,attr-defined] # noqa: E501
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 196, in greenlet_spawn
pandabi-backend   |     value = await result
pandabi-backend   |             ^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 550, in _prepare_and_execute
pandabi-backend   |     self._handle_exception(error)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 501, in _handle_exception
pandabi-backend   |     self._adapt_connection._handle_exception(error)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 784, in _handle_exception
pandabi-backend   |     raise translated_error from error
pandabi-backend   | sqlalchemy.dialects.postgresql.asyncpg.AsyncAdapt_asyncpg_dbapi.ProgrammingError: <class 'asyncpg.exceptions.UndefinedTableError'>: relation "user" does not exist
pandabi-backend   |
pandabi-backend   | The above exception was the direct cause of the following exception:
pandabi-backend   |
pandabi-backend   | Traceback (most recent call last):
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 671, in lifespan
pandabi-backend   |     async with self.lifespan_context(app):
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 566, in __aenter__
pandabi-backend   |     await self._router.startup()
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 648, in startup
pandabi-backend   |     await handler()
pandabi-backend   |   File "/app/core/server.py", line 145, in on_startup
pandabi-backend   |     await init_database()
pandabi-backend   |   File "/app/core/server.py", line 113, in init_database
pandabi-backend   |     user = await init_user()
pandabi-backend   |            ^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/core/server.py", line 81, in init_user
pandabi-backend   |     await controller.create_default_user()
pandabi-backend   |   File "/app/core/database/transactional.py", line 40, in decorator
pandabi-backend   |     raise exception
pandabi-backend   |   File "/app/core/database/transactional.py", line 27, in decorator
pandabi-backend   |     result = await self._run_required_new(
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/core/database/transactional.py", line 53, in _run_required_new
pandabi-backend   |     result = await function(*args, **kwargs)
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/app/controllers/user.py", line 21, in create_default_user
pandabi-backend   |     users = await self.get_all(limit=1, join_={"memberships"})
pandabi-backend   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/core/controller/base.py", line 69, in get_all
pandabi-backend   |     response = await self.repository.get_all(skip, limit, join_)
pandabi-backend   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/core/repository/base.py", line 48, in get_all
pandabi-backend   |     return await self._all_unique(query)
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/app/core/repository/base.py", line 124, in _all_unique
pandabi-backend   |     result = await self.session.execute(query)
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/scoping.py", line 589, in execute
pandabi-backend   |     return await self._proxied.execute(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/session.py", line 461, in execute
pandabi-backend   |     result = await greenlet_spawn(
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 201, in greenlet_spawn
pandabi-backend   |     result = context.throw(*sys.exc_info())
pandabi-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2351, in execute
pandabi-backend   |     return self._execute_internal(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2236, in _execute_internal
pandabi-backend   |     result: Result[Any] = compile_state_cls.orm_execute_statement(
pandabi-backend   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
pandabi-backend   |     result = conn.execute(
pandabi-backend   |              ^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
pandabi-backend   |     return meth(
pandabi-backend   |            ^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
pandabi-backend   |     return connection._execute_clauseelement(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
pandabi-backend   |     ret = self._execute_context(
pandabi-backend   |           ^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
pandabi-backend   |     return self._exec_single_context(
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
pandabi-backend   |     self._handle_dbapi_exception(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2353, in _handle_dbapi_exception
pandabi-backend   |     raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
pandabi-backend   |     self.dialect.do_execute(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute
pandabi-backend   |     cursor.execute(statement, parameters)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 572, in execute
pandabi-backend   |     self._adapt_connection.await_(
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 132, in await_only
pandabi-backend   |     return current.parent.switch(awaitable)  # type: ignore[no-any-return,attr-defined] # noqa: E501
pandabi-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 196, in greenlet_spawn
pandabi-backend   |     value = await result
pandabi-backend   |             ^^^^^^^^^^^^
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 550, in _prepare_and_execute
pandabi-backend   |     self._handle_exception(error)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 501, in _handle_exception
pandabi-backend   |     self._adapt_connection._handle_exception(error)
pandabi-backend   |   File "/root/.cache/pypoetry/virtualenvs/pandasai-server-9TtSrW0h-py3.11/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 784, in _handle_exception
pandabi-backend   |     raise translated_error from error
pandabi-backend   | sqlalchemy.exc.ProgrammingError: (sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.UndefinedTableError'>: relation "user" does not exist
pandabi-backend   | [SQL: SELECT anon_1.id, anon_1.email, anon_1.first_name, anon_1.created_at, anon_1.password, anon_1.verified, anon_1.last_name, anon_1.features, organization_1.id AS id_1, organization_1.name, organization_1.url, organization_1.is_default, organization_1.settings, organization_membership_1.id AS id_2, organization_membership_1.user_id, organization_membership_1.organization_id, organization_membership_1.role, organization_membership_1.verified AS verified_1
pandabi-backend   | FROM (SELECT "user".id AS id, "user".email AS email, "user".first_name AS first_name, "user".created_at AS created_at, "user".password AS password, "user".verified AS verified, "user".last_name AS last_name, "user".features AS features
pandabi-backend   | FROM "user"
pandabi-backend   |  LIMIT $1::INTEGER OFFSET $2::INTEGER) AS anon_1 LEFT OUTER JOIN organization_membership AS organization_membership_1 ON anon_1.id = organization_membership_1.user_id LEFT OUTER JOIN organization AS organization_1 ON organization_1.id = organization_membership_1.organization_id]
pandabi-backend   | [parameters: (1, 0)]
pandabi-backend   | (Background on this error at: https://sqlalche.me/e/20/f405)
pandabi-backend   |
pandabi-backend   | ERROR:    Application startup failed. Exiting.
dosubot[bot] commented 5 days ago

The error you're encountering is due to a missing module and a missing database table. Here are the steps to resolve these issues:

  1. ModuleNotFoundError: No module named 'app':

    • Ensure that the app directory is correctly placed in your project structure. It should be in the root of your project or the path should be correctly set in your environment. The app module is expected to contain subdirectories like controllers, models, and repositories [1].
  2. UndefinedTableError: relation "user" does not exist:

    • This error indicates that the user table does not exist in your database. You need to run the database migrations to create the necessary tables.
    • Use the migrate target in your Makefile to apply migrations. This can be done by running make migrate in your terminal. This command will execute poetry run alembic upgrade head, which applies all pending migrations [2].
  3. Check Environment Variables:

    • The warning about the unset variable cxwR1S88WmYVOw0BFpo4vuJ0Od5zrNXevkZcFt65wf5eTdMbGFMr6 suggests that an environment variable is missing. Ensure all required environment variables are set in your .env file or environment.
  4. Check Docker Configuration:

    • Ensure your docker-compose.yml is correctly configured and that all services are defined properly. The docker-compose.yml should define services for the backend, frontend, and PostgreSQL database [3].

By addressing these issues, you should be able to resolve the errors and successfully start your application.

To continue talking to Dosu, mention @dosu.

johnfelipe commented 5 days ago

Basado en la estructura de directorios que has proporcionado, aquí tienes el código corregido para el archivo env.py ubicado en /server/migrations/env.py:

import asyncio
import os
import sys
from logging.config import fileConfig

from alembic import context
from sqlalchemy import pool
from sqlalchemy.ext.asyncio import create_async_engine
from dotenv import load_dotenv

# Añadir el directorio raíz del proyecto al sys.path
server_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
root_dir = os.path.abspath(os.path.join(server_dir, '..'))
sys.path.insert(0, server_dir)
sys.path.insert(0, root_dir)

# Cargar variables de entorno
load_dotenv(os.path.join(server_dir, '.env'))

# Importar después de haber añadido los directorios al sys.path
from app.models import Base
from core.config import config as app_config

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
    fileConfig(config.config_file_name)

print(f"Server directory: {server_dir}")
print(f"Root directory: {root_dir}")

target_metadata = Base.metadata

def run_migrations_offline():
    """Run migrations in 'offline' mode."""
    context.configure(
        url=app_config.POSTGRES_URL,
        target_metadata=target_metadata,
        literal_binds=True,
        dialect_opts={"paramstyle": "named"},
    )

    with context.begin_transaction():
        context.run_migrations()

def do_run_migrations(connection):
    context.configure(connection=connection, target_metadata=target_metadata)

    with context.begin_transaction():
        context.run_migrations()

async def run_migrations_online():
    """Run migrations in 'online' mode."""
    connectable = create_async_engine(app_config.POSTGRES_URL, poolclass=pool.NullPool)

    async with connectable.connect() as connection:
        await connection.run_sync(do_run_migrations)

    await connectable.dispose()

if context.is_offline_mode():
    run_migrations_offline()
else:
    asyncio.run(run_migrations_online())

Los cambios principales son:

  1. Ajustar la forma en que se añaden los directorios al sys.path para asegurar que tanto el directorio server como el directorio raíz del proyecto estén incluidos.
  2. Cargar las variables de entorno desde el archivo .env en el directorio server.
  3. Importar Base y config después de haber modificado el sys.path.
  4. Añadir impresiones de los directorios para ayudar con la depuración.

Asegúrate de que:

  1. El archivo .env esté en el directorio server y contenga la variable POSTGRES_URL con la URL de conexión correcta a tu base de datos PostgreSQL.
  2. Las dependencias necesarias (alembic, sqlalchemy, asyncpg, etc.) estén instaladas en tu entorno virtual.

Después de hacer estos cambios, intenta ejecutar las migraciones nuevamente:

poetry run alembic upgrade head
Muhammad-Adam1 commented 9 hours ago

getting same error on windows 11 by following step-by-step tutorial on Getting started with the Platform ,

after runnig the command : docker-compose up check out the output error in this file error.txt