Make autoloading more robust to bad yaml files #114
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having an incorrect yaml file in the default paths (root dir and config dir)
can cause the plugin to crash completely. I ran into this in #104, which was
particularly bad because the plugin wrote the inconsistent file in the first
place. However, there's many reasons why bad yaml might exist in the
default directories, including:
versions)
Non-yaml files are already ignored, so I don't think it's a big difference if
we also ignore invalid yaml files. Until we provide utilities to clean up the
directories, I think robustness to bad input is very important.
In this PR, if we encounter any error while loading all models from given
directories, we ignore the error and move on to the next file.