-
Notifications
You must be signed in to change notification settings - Fork 3
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
Broker class and necessary configuration #16
Conversation
@@ -4,13 +4,15 @@ | |||
|
|||
from functools import cache | |||
from pathlib import Path | |||
|
|||
import os | |||
from pydantic import BaseModel, ConfigDict, DirectoryPath | |||
from pydantic_settings import BaseSettings | |||
|
|||
|
|||
DEFAULT_CONFIG_FILE = _config_file = "/etc/webhook-to-fedora-messaging/webhook-to-fedora-messaging.cfg" |
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 see that you are using the INI-styled configuration here. Could you please include a default configuration with placeholder values for folks to get started with?
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, @abompard should we stick to an INI-styled configuration or use a more profound TOML-styled configuration? I am fine with either but I wanted to hear your opinion on this.
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.
We shouldn't use pydantic anyway, because Flask has its own configuration system.
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.
Yeah, I got bamboozled seeing all the Pydantic stuff here and assumed that it was used here.
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 see that you are using the INI-styled configuration here. Could you please include a default configuration with placeholder values for folks to get started with?
Default configuration for constants as a different file? Or should this one stay the same and just an example config as a different file?
@brngylni Please refer to #2 (comment) for how commit messages should be written. |
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.
@abompard, this is not in @brngylni's changes but can we please use context-aware modules for storing configuration instead of global variables?
Take for instance, the section https://github.com/fedora-infra/webhook-to-fedora-messaging/pull/16/files#diff-00c1df60e290e533baec34ac9f6abd4db0fa8b99f04485315dff43023f8049b6R44-R47, could simply be a module-wide variable that can be referenced and changed throughout the project with the use of the following.
In the configuration initialization module named something.py
,
from webhook_to_fedora_messaging import config
config.some_variable = "SOMETHING"
In the configuration using module named something_else.py
,
from webhook_to_fedora_messaging import config
def do_something() -> str:
return config.some_variable
As long as we do not import the variable like the following cases.
In the configuration initialization module named something.py
,
from webhook_to_fedora_messaging.config import some_variable
some_variable = "SOMETHING"
In the configuration using module named something_else.py
,
from webhook_to_fedora_messaging.config import some_variable
def do_something() -> str:
return some_variable
We should be able to ensure that the variable is not instantiated with the default value and that the variable retains the value set to it during the runtime.
I can switch the structure to this if you both agreed on this @abompard @gridhead |
Regarding to #14 @abompard