cohere-toolkit icon indicating copy to clipboard operation
cohere-toolkit copied to clipboard

Throwing error when run `make migrate` for the first time.

Open iFurySt opened this issue 10 months ago • 4 comments

What is the issue?

the error logs:

(cohere-toolkit) ➜  cohere-toolkit git:(main) make migrate
docker compose run --build backend alembic -c src/backend/alembic.ini upgrade head
WARN[0000] The "NEXT_PUBLIC_API_HOSTNAME" variable is not set. Defaulting to a blank string. 
WARN[0000] /Users/ifuryst/projects/ai/cohere-toolkit/docker-compose.yml: `version` is obsolete 
[+] Creating 1/0
 ✔ Container cohere-toolkit-db-1  Running                                                                                                                    0.0s 
[+] Building 7.9s (12/12) FINISHED                                                                                            docker-container:xenodochial_wilson
 => [backend internal] load build definition from Dockerfile                                                                                                 0.0s
 => => transferring dockerfile: 1.16kB                                                                                                                       0.0s
 => [backend internal] load metadata for docker.io/library/python:3.11                                                                                       1.3s
 => [backend internal] load .dockerignore                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                              0.0s
 => [backend 1/6] FROM docker.io/library/python:3.11@sha256:e453eb723bc8ecac7a797498f9a5915d13e567620d48dcd3568750bac3b59f31                                 0.0s
 => => resolve docker.io/library/python:3.11@sha256:e453eb723bc8ecac7a797498f9a5915d13e567620d48dcd3568750bac3b59f31                                         0.0s
 => [backend internal] load build context                                                                                                                    0.0s
 => => transferring context: 13.49kB                                                                                                                         0.0s
 => CACHED [backend 2/6] WORKDIR /workspace                                                                                                                  0.0s
 => CACHED [backend 3/6] COPY pyproject.toml poetry.lock ./                                                                                                  0.0s
 => CACHED [backend 4/6] RUN pip install --no-cache-dir poetry==1.6.1 &&   poetry install                                                                    0.0s
 => CACHED [backend 5/6] COPY src/backend/ src/backend/                                                                                                      0.0s
 => CACHED [backend 6/6] COPY .en[v] .env                                                                                                                    0.0s
 => [backend] exporting to docker image format                                                                                                               6.5s
 => => exporting layers                                                                                                                                      0.0s
 => => exporting manifest sha256:6c850bff9065e54db15bcb778ae3e50244523e9427c13ec32d8ef0f02ebee2aa                                                            0.0s
 => => exporting config sha256:1cabb0196a31aaf589436f856b77564862794efce4312b9c692f654a91cbc757                                                              0.0s
 => => sending tarball                                                                                                                                       6.5s
 => [backend] importing to docker                                                                                                                            0.0s
Traceback (most recent call last):
  File "/workspace/.venv/bin/alembic", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/config.py", line 641, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/config.py", line 631, in main
    self.run_cmd(cfg, options)
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/config.py", line 608, in run_cmd
    fn(
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/command.py", line 403, in upgrade
    script.run_env()
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/./src/backend/alembic/env.py", line 9, in <module>
    from backend.models import *
  File "/workspace/src/backend/models/__init__.py", line 4, in <module>
    from backend.models.database import *
  File "/workspace/src/backend/models/database.py", line 11, in <module>
    SQLALCHEMY_DATABASE_URL = os.environ["DATABASE_URL"]
                              ~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "<frozen os>", line 679, in __getitem__
KeyError: 'DATABASE_URL'
make: *** [migrate] Error 1

i runed by this order:

poetry install
poetry run black .
poetry run isort .
make migrate

and i tried to reset the db:

make reset-db
make migrate

it also throws the error

Additional information

Python 3.11.9 MacOS Sonoma 14.4.1

Docker info

Client:
 Version:    26.0.0
 Context:    desktop-linux

...

Server:
 Containers: 6
  Running: 2
  Paused: 0
  Stopped: 4
 Images: 13
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false

...

iFurySt avatar Apr 26 '24 05:04 iFurySt

image

it seems i need to run the make setup or make first-run first. but i can't choose a local deployment.

iFurySt avatar Apr 26 '24 05:04 iFurySt

You need to setup a .env file first, either manually or through the CLI setup

tianjing-li avatar Apr 26 '24 17:04 tianjing-li

@iFurySt can I clarify what you mean, as in when selecting a deployment in the CLI from make setup, it doesn't seem to go to the next step?

tianjing-li avatar Apr 26 '24 17:04 tianjing-li

This option is selecting the model you would like to power the chatbot, otherwise you won't be able to chat. When you select a model option, enter the keys, and run makedev, it will run locally. We'll update the language in the CLI to make that more clear, thanks for flagging!

elaineg avatar Apr 26 '24 17:04 elaineg