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

[BUG]: .env file is being ignored #609

Closed
1 task done
njbrake opened this issue Jan 13, 2025 · 2 comments · Fixed by #614
Closed
1 task done

[BUG]: .env file is being ignored #609

njbrake opened this issue Jan 13, 2025 · 2 comments · Fixed by #614
Labels
bug Something isn't working

Comments

@njbrake
Copy link
Contributor

njbrake commented Jan 13, 2025

Description

When I run make local-up the backend errors out due to a pydantic validation error.

backend-1                   | RAY_DASHBOARD_PORT
backend-1                   |   Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='${RAY_DASHBOARD_PORT:-8265}', input_type=str]

Reproduction

git checkout main && git pull
docker system prune -af # maybe you don't need this, I'm a scorched earth kinda guy
rm .env # to force a new env to be made from the .env.example file
make local-up

Relevant log output

backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/main.py", line 11, in <module>
backend-1                   |     from backend.api.router import api_router
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/api/router.py", line 3, in <module>
backend-1                   |     from backend.api.routes import (
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/api/routes/completions.py", line 4, in <module>
backend-1                   |     from backend.api.deps import MistralCompletionServiceDep, OpenAICompletionServiceDep
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/api/deps.py", line 11, in <module>
backend-1                   |     from backend.db import session_manager
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/db.py", line 8, in <module>
backend-1                   |     from backend.settings import settings
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/backend/settings.py", line 173, in <module>
backend-1                   |     settings = BackendSettings()
backend-1                   |                ^^^^^^^^^^^^^^^^^
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/.venv/lib/python3.11/site-packages/pydantic_settings/main.py", line 84, in __init__
backend-1                   |     super().__init__(
backend-1                   |   File "/mzai/lumigator/python/mzai/backend/.venv/lib/python3.11/site-packages/pydantic/main.py", line 212, in __init__
backend-1                   |     validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
backend-1                   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1                   | pydantic_core._pydantic_core.ValidationError: 1 validation error for BackendSettings
backend-1                   | RAY_DASHBOARD_PORT
backend-1                   |   Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='${RAY_DASHBOARD_PORT:-8265}', input_type=str]
backend-1                   |     For further information visit https://errors.pydantic.dev/2.9/v/int_parsing
localstack-1                | 2025-01-13T13:49:40.941  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS s3.CreateBucket => 200

Expected behavior

I would expect it to not have a validation error.

System Info

Macos 15.2
commit 7917bd4

Have you searched for similar issues before submitting this one?

  • Yes, I have searched for similar issues
@njbrake njbrake added the bug Something isn't working label Jan 13, 2025
@njbrake njbrake changed the title [BUG]: Pydantic Validation error of RAY_DASHBOARD_PORT [BUG]: .env file is being ignored Jan 13, 2025
@njbrake
Copy link
Contributor Author

njbrake commented Jan 13, 2025

After investigation: #595 removed the sourcing of the .env file, which means that the bash terminal running the docker compose commands has not loaded the contents of the .env (unless the user had manually sourced the .env before running).

Tested by having this in my .env file:

BRAKE=2
S3_BUCKET=${S3_BUCKET:-lumigator-storage}

then run make local-up

then run docker exec -it lumigator-backend-1 bash in a separate terminal.

Logs:

root@4056acfdd462:/mzai/lumigator/python/mzai/backend# echo $BRAKE

root@4056acfdd462:/mzai/lumigator/python/mzai/backend# echo $S3_BUCKET
lumigator-storage
root@4056acfdd462:/mzai/lumigator/python/mzai/backend# 

@javiermtorres
Copy link
Contributor

I included the .env directly in the Makefile, without noticing that some vars had bash-specific syntax afaict :-/
Some of the keys were included, but others were interpreted in very strange ways and kept present but empty, which messed up with e.g. AWS credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants