-
Notifications
You must be signed in to change notification settings - Fork 0
issue #75: first draft #78
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing a unit test.
|
||
|
||
DynamicSettings = create_dynamic_settings("env.yaml") | ||
settings = DynamicSettings(_env_file=".env") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we misunderstood each other. the .env should remain :
ENVIRONMENT_VARIABLE_NAME=ENVIRONMENT_VARIABLE_VALUE
Only the validation specification (env.yaml) should be in yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. This needs both .env and env.yaml to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work when they are no .env and we are setting instead environment variables through docker run (or equivalent container runner)?
If this is a draft, you should "Convert to draft". |
|
||
|
||
DynamicSettings = create_dynamic_settings("env.yaml") | ||
settings = DynamicSettings(_env_file=".env") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work when they are no .env and we are setting instead environment variables through docker run (or equivalent container runner)?
|
||
MEMBRANE_SERVER_PRIVATE_KEY: | ||
type: FileStr | ||
|
||
MEMBRANE_SENDER_EMAIL: | ||
type: EmailStr | ||
field_info: | ||
default: null | ||
pattern: ^[a-zA-Z0-9._+]+@(?:gc\.ca|canada\.ca|inspection\.gc\.ca)$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- what is I wanted to link to the RFC document URL detailing what makes an email valid in this env.yaml?
- seems to me we should be configuring MEMBRANE_ALLOWED_EMAIL_DOMAINS instead and internally creating that regexp pattern
@k-allagbe get this functionality into its own repo as there are more work to be done here. |
|
I see you have this issue pending: |
The PR is here: ai-cfia/obol#2 |
#75
issue75-declarative-env-var-validation
This solution uses Pydantic and Pydantic-Settings for the handling of the validations and nice exceptions.
The dynamic_env_validator.py ensures we can create a vlidation model (DynamicSettings) from a yaml file (env.yaml).
When the DynamicSettings is instantiated with the .env file, it validates the env vars.