-
Notifications
You must be signed in to change notification settings - Fork 913
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
[DRAFT] - Refactor the OmegaConfigLoader load_and_merge_dir_config method #2591
Conversation
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
Signed-off-by: Nok Chan <[email protected]>
def _build_conf_paths(self, conf_path, patterns): | ||
if not self._fs.isdir(Path(conf_path).as_posix()): | ||
raise MissingConfigException( | ||
f"Given configuration path either does not exist " | ||
f"or is not a valid directory: {conf_path}" | ||
) | ||
|
||
paths = [ | ||
Path(each) | ||
for pattern in patterns | ||
for each in self._fs.glob(Path(f"{str(conf_path)}/{pattern}").as_posix()) | ||
] | ||
deduplicated_paths = set(paths) | ||
config_files_filtered = [ | ||
path for path in deduplicated_paths if self._is_valid_config_path(path) | ||
] | ||
|
||
return config_files_filtered |
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 am happy with this as this is quite clean already
Signed-off-by: Nok Chan <[email protected]>
This is only for demonstration purpose and is not ready to be merged. |
Leave this for reference but I will close the PR to clean up tickets |
Since you're here - with #2821 in mind, please think about how to track the line number references of YAML declarations |
Description
The OCL has a big function
load_and_merge_dir_config
which does a lot of things. It makes it hard to reason about and write test for it.We can simplify the test and extend the class by breaking it down. The PR is a quick effort of #2584 @ankatiyar as we keep adding arguments to this function, making it hard to maintain. I think it's easier to have a draft PR to show what I mean, ultimately the PR should also update the test and
__getitem__
will be orchestrating the logic which simply call these functions (Not done in this draft).Development notes
It may be helpful to see each refactoring steps.
Checklist
RELEASE.md
file