Moving env vars to environment.py - #872
Open
vvedenskaya wants to merge 6 commits into
Open
Conversation
WillNilges
reviewed
Mar 26, 2025
WillNilges
left a comment
Collaborator
There was a problem hiding this comment.
This is definitely on the right track, thanks so much for working on this!!!
| from meshapi.util.constants import DEFAULT_EXTERNAL_API_TIMEOUT_SECONDS | ||
|
|
||
| PELIAS_ADDRESS_PARSER_URL = os.environ.get("PELIAS_ADDRESS_PARSER_URL", "http://localhost:6800/parser/parse") | ||
| PELIAS_ADDRESS_PARSER_URL = environm |
Collaborator
There was a problem hiding this comment.
You should be able to do something like this:
Suggested change
| PELIAS_ADDRESS_PARSER_URL = environm | |
| from environment import PELIAS_ADDRESS_PARSER_URL |
| from celery.signals import beat_init, worker_ready, worker_shutdown | ||
| from datadog import initialize, statsd | ||
| from dotenv import load_dotenv | ||
| import environment |
Collaborator
There was a problem hiding this comment.
Consider only importing what you need.
Suggested change
| import environment | |
| from environment import CELERY_BROKER |
Collaborator
There was a problem hiding this comment.
Radical! Thanks for including where the env vars are from, too 😄
WillNilges
reviewed
Mar 28, 2025
WillNilges
reviewed
Mar 28, 2025
|
|
||
| # Use the docker-hosted Redis container as the backend for Celery | ||
| app = Celery("meshdb", broker=os.environ.get("CELERY_BROKER", "redis://localhost:6379/0")) | ||
| app = Celery("meshdb", broker= environment.CELERY_BROKER) |
Collaborator
There was a problem hiding this comment.
You should just be able to refer to this by the environment name, since you're importing it directly.
Suggested change
| app = Celery("meshdb", broker= environment.CELERY_BROKER) | |
| app = Celery("meshdb", broker=CELERY_BROKER) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Created environment.py in src/meshdb, collected os.environ variables there, and started importing the file