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

Union of different kinds of FileModels can become slow and buggy #519

Open
priscavdsluis opened this issue Apr 11, 2023 · 0 comments
Open
Labels
type: bug Something isn't working type: enhancement Improvements to existing functionality

Comments

@priscavdsluis
Copy link
Contributor

priscavdsluis commented Apr 11, 2023

Is your feature request related to a problem? Please describe.
When we have a field with e.g. type Union[TimModel, ForcingModel] we follow the order of the declared FileModels and try to parse the data from the file and initialize the model. When this fails, the next object is tried.
This has several draw backs:

  1. Performance; especially with larger files this could build up significantly
  2. When the user refers to e.g. a tim file in the model, but there is a mistake in the file, the initialized file model will be a ForcingModel. Because of the Union type, errors are swallowed and the user remains uninformed.
  3. Sometimes the order is very finicky; some file types are very similar and the parser won't throw errors leading to the wrong FileModel.
  4. With loading a model using Recurse=False, the first FileModel will be used, since it has no data to validate, this validation will always succeed.

Describe the solution you'd like
I would like to have a smarter way to deal with FileModel unions.
Some files like the old external forcing file have a file type defined, this could potentially be used to initialize the correct FileModel.
We could also look at the extensions of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working type: enhancement Improvements to existing functionality
Projects
Status: To do
Development

No branches or pull requests

1 participant