Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

noklam
Copy link
Contributor

@noklam noklam commented May 18, 2023

NOTE: Kedro datasets are moving from kedro.extras.datasets to a separate kedro-datasets package in
kedro-plugins repository. Any changes to the dataset implementations
should be done by opening a pull request in that repository.

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

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes

@noklam noklam requested a review from idanov as a code owner May 18, 2023 16:07
@noklam noklam changed the title Refactor the OmegaConfigLoader load_and_merge_from_dir method Refactor the OmegaConfigLoader load_and_merge_dir_config method May 18, 2023
Comment on lines +296 to +313
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
Copy link
Contributor Author

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

@noklam noklam changed the title Refactor the OmegaConfigLoader load_and_merge_dir_config method [DRAFT] - Refactor the OmegaConfigLoader load_and_merge_dir_config method Jun 9, 2023
@noklam
Copy link
Contributor Author

noklam commented Jun 9, 2023

This is only for demonstration purpose and is not ready to be merged.

@noklam
Copy link
Contributor Author

noklam commented Sep 4, 2023

Leave this for reference but I will close the PR to clean up tickets

@noklam noklam closed this Sep 4, 2023
@datajoely
Copy link
Contributor

datajoely commented Sep 4, 2023

Since you're here - with #2821 in mind, please think about how to track the line number references of YAML declarations

@merelcht merelcht deleted the feat/refactor-ocl branch September 28, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants