-
Notifications
You must be signed in to change notification settings - Fork 6
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
Declarative approach to settings #234
Conversation
SKernchen
commented
Nov 15, 2023
- Declarative approach to settings #219
- Adapt Tutorials
This is required as Pydantic uses this style for their doc strings.
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.
One minor change.
Co-authored-by: Michael Meinel <michael.meinel@dlr.de>
Co-authored-by: David Pape <d.pape@hzdr.de>
Similiarly to the Then you can instantiate the settings like this: settings = HermesSettings() at the end of (I'm not sure if we can go this route with the plan of plugins being able to configure their own settings.) |
I can already skip the model_validate by using the json in the Settings class which uses the HermesSettings. Still defining the Source and automatically reading the Toml could be better for usage. |
You call |
After reviewing the code, some general remarks here: praise: Worked better than I expected according to your reports. Also your code is well structured and your names seem well chosen. :) opinion: I think it is not required / advisible to try to keep the exiting code working with declarative model.
We could discuss whether it would be good to have both options available for transition but I'd prefer to break and repair instead of maintaining deprecated stuff. We could also change your hint: I suppose you are using an automatic code formatter? You should definately extend the allowed line length to 120 chars. This will make the code a bit more readable at some places... (This is also the value we are using in our liniting). |
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.
note: Not working yet, hence no approval.
I added some inline hints and also some general thoughts about the implementation.
I think the way forward here is to implement / adapt all the plugins that access configuration values (i.e., get rid of all the get
calls).
Then we can in parallel further refactor the class-based plugin API (i.e., no central settings.py
collecting all models anymore) and implement the CLI switch.
Maybe a litte co-programming could help with pushing this forward... ;)
This is required as Pydantic uses this style for their doc strings.
Co-authored-by: Michael Meinel <michael.meinel@dlr.de>
Co-authored-by: David Pape <d.pape@hzdr.de>
Config is not in Context rigth now, maybe @sdruskat attempt for changing to argparse can help there |
This starts to feel a really bad, actually. lots of stuff to fix up later. But I'm taking the full responsibility!
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.
There are still several places where the hermes.logger
module is used. However, the config should be accessible using the ctx
object (which is already part of the refactoring strategy).
There is still one place... a hack that is required to introduce the new interface while not having the front-end refactored yet.
This happens when there is no configuration file given and no `hermes.toml` available in the current directory.