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

OmegaConfigLoader should not throw MissingConfigException when the file is empty #2566

Closed
noklam opened this issue May 5, 2023 · 0 comments · Fixed by #2584
Closed

OmegaConfigLoader should not throw MissingConfigException when the file is empty #2566

noklam opened this issue May 5, 2023 · 0 comments · Fixed by #2584
Assignees

Comments

@noklam
Copy link
Contributor

noklam commented May 5, 2023

Description

Related #2556

Currently, if you have an empty configuration file with OmegaConfigLoader, you will get this error which isn't very accurate.

This draft PR is just a starting point, it's expected to be picked up by someone and worked on it further.

if not config:
raise MissingConfigException(
f"No files of YAML or JSON format found in {base_path} or {env_path} matching"
f" the glob pattern(s): {[*self.config_patterns[key]]}"
)
return config

This is due to the fact that we always return an empty dictionary when we load the configuration. In other words, we cannot distinguish between an empty file and a missing file.

if not aggregate_config:
return {}

We should take this as an opportunity to refactor and simplify these conditions. Bottom line we should have a better error message to handle empty configuration properly.

Context

How has this bug affected you? What were you trying to accomplish?
I was confused with the error because I have the config file. Initially I thought my configuration is not in the right place or I didn't config the config_patterns properly. The config file is actually read but the error is confusing.

Expected Result

Tell us what should happen.
It should return an empty dictionary {} instead of getting error.

Actual Result

Tell us what happens instead.
MissingConfigException is thrown.

-- If you received an error, place it here.
-- Separate them if you have more than one.
@noklam noklam moved this to In Progress in Kedro Framework May 15, 2023
@noklam noklam moved this from In Progress to To Do in Kedro Framework May 15, 2023
@ankatiyar ankatiyar self-assigned this May 15, 2023
@ankatiyar ankatiyar moved this from To Do to In Progress in Kedro Framework May 15, 2023
@jmholzer jmholzer moved this from In Progress to In Review in Kedro Framework May 16, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Kedro Framework May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants