-
Notifications
You must be signed in to change notification settings - Fork 338
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
No Singleton: Configuration
#2541
Conversation
7b7586a
to
f4c11fd
Compare
2b34389
to
227e61d
Compare
03b57cd
to
a74fc0b
Compare
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.
Thanks! Just a few questions
std::string m_name; | ||
std::string m_group = "Default"; | ||
std::string m_description = "No description provided"; | ||
std::string m_long_description = ""; | ||
Configuration* m_config = nullptr; |
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 the mechanism 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.
See:
- https://github.com/mamba-org/mamba/pull/2541/files#diff-ec708ed47303bbb952a95a186b9463393bdddf3762aa7fbade9f5c21114cc632L662
- https://github.com/mamba-org/mamba/pull/2541/files#diff-ec708ed47303bbb952a95a186b9463393bdddf3762aa7fbade9f5c21114cc632L793
My understanding of the original code is that Configurables in a Configuration can be manipulated before Configuration::load()
is done and in that case Configurable::value()
can throw an exception if called before Configuration::load()
. This is not ideal but I didnt want to change the logic and Configurable was accessing Configuration through the singleton accessor, so removing it lead to Configurable needing to be able to check that the Configuration is or not in the loading phase. The only way I found was adding the pointer to the Configuration once the Configurable is stored in the Configuration (because it could be created before that point).
When we rewrite Configuration itself to be as discussed last live meeting (real fields, no magically casting dynamic fields), this issue can be completely removed by having 2 types of configurations: one that is being set and one "locked".
@@ -149,10 +137,13 @@ namespace mamba | |||
virtual YAML::Node yaml_value() const = 0; | |||
virtual void dump_json(nlohmann::json& node, const std::string& name) const = 0; | |||
|
|||
bool is_config_loading() const; |
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 does that do?
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.
See my last comment.
@@ -54,9 +56,9 @@ namespace mamba | |||
|
|||
void create_empty_target(const fs::u8path& prefix); | |||
|
|||
void file_specs_hook(std::vector<std::string>& file_specs); | |||
void file_specs_hook(std::vector<std::string>& file_specs, Configuration& config); |
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.
Nitpicking: config should be the first argument to be consistent with other functions in this file.
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.
Ah yes nice catch, will fix
7dc940b
to
2c5c753
Compare
2c5c753
to
7df49ef
Compare
No description provided.