-
Notifications
You must be signed in to change notification settings - Fork 905
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
Refactor OmegaConfigLoader
#4100
Conversation
…un env is also set Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
# Conflicts: # tests/config/test_omegaconf_config.py
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.
Thank you, @merelcht, changes looks good to me.
Left one non-blocking suggestion.
key: str, | ||
env_path: str, | ||
) -> Any: | ||
merging_strategy = self.merge_strategy.get(key, "destructive") |
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.
Shall we go even further and move merging strategies outside to the Enum
and create a mapping of symbolic names to the implementations? Then all the possible values and implementations will be in one place, so it's easier to navigate and compare them, and additionally, we will get rid if else
logic when applying a merging strategy.
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.
Some clarification on the above comment.
I was thinking of something like that:
class MergingStrategies(Enum):
FIRST = "first"
SECOND = "second"
def first_strat():
pass
def second_strat():
pass
merging_strategies_map = {
MergingStrategies.FIRST: first_strat,
MergingStrategies.SECOND: second_strat,
}
Usage:
first = strategies_map[MergingStrategies.FIRST]()
second = strategies_map[MergingStrategies("second")]()
Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
Signed-off-by: Merel Theisen <49397448+merelcht@users.noreply.github.com>
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.
Thank you, @merelcht, all clear! ✨
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.
Looks good! 💯
Description
The methods in
OmegaConfigLoader
are big and getting more complicated each time we make a change.Development notes
I simplified things by:
_initialise_filesystem_and_protocol
base
anddefault_run_env
config into a separate function_merge_configs
Developer Certificate of Origin
We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a
Signed-off-by
line in the commit message. See our wiki for guidance.If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.
Checklist
RELEASE.md
file