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

Handle corrupted or empty global configuration file #2508

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/zenml/config/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,17 @@ def _read_config(self) -> Dict[str, Any]:
config_file = self._config_file
config_values = {}
if fileio.exists(config_file):
config_values = cast(
Dict[str, Any],
yaml_utils.read_yaml(config_file),
config_values = yaml_utils.read_yaml(config_file)

if config_values is None:
# This can happen for example if the config file is empty
config_values = {}
elif not isinstance(config_values, dict):
logger.warning(
"The global configuration file is not a valid YAML file. "
"Creating a new global configuration file."
)
config_values = {}

return config_values

Expand Down
Loading