JSON Schema oil type improvements#59
Conversation
9d557bd to
315fa48
Compare
- create an `enums` subpackage that exports everything `enums.py` module did - original contentes of `enums.py` get split into multiple smaller files though
- make it's value a simple string (matching the name) - no more tuple - get rid of the pydantic field "before" validator (used to map from id to a tuple) - adapt usage to the new enum value - also add a `oneOf` list to `json_schema_extra` so that it's part of the schema by default - remove the (now redundant) `ModifyOilTypeJsonSchema` - fix a typo so that Pydantic actually validates default values - update tests
- `create_ocean_model_simulation` returns a model not model instance
- export the module with opendrift models from the package root - this way they can be easily imported from PTM when used as a library
- a little tangential refactor - use "early return" style (or rater `continue`) to reduce indentation in `_update_od_config_from_this_config` - also iterate over key, val - also use `x.y` instead of `getattr(x, y)` where possible
9a3e88d to
7a35db4
Compare
|
Ok I've checked a bunch of stuff and it looks good but I have a question: what should a user do if they know the name of the oil type they want to use but not the id? |
Well, previously they would need to provide the ID or both ID and name, However, still not a bad question - I think they'd have to look it up. Either, online through the database or using the library's models or enums. That made me check and I think I should update this line in the docs: particle-tracking-manager/docs/tutorial.md Line 226 in 80bd630 That should still work but now it will only have the IDs not the tuple. Alternatively, we could point them to
|
|
I don’t think PTM needs to accept oil type by name but I do think it would be good to explain how to get it. Two ways:
What do you think about this? |
- add a dict for name to ID mapping - add notes to the `docs/tutorial.md` about the oil types
What
Mainly refactors related to the oil type:
enumsfile to a few smaller onesOilTypeEnumvalues (and names) to be just IDs_update_od_config_from_this_configbody to reduce indentationWhy
To have oil type enum-label pairs in the JSON schema and make oil type parameter easier to use.
All the tests passed and if I remember correctly, I successfully ran a simulation after the last commit too.
Note: once #54 is merged, I'll change the PR target to
main(this branch is already based on the kerchunk fixes).