save/load ML models#120
Conversation
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella thanks for implementing this 👍 . The io function looks great for saving and loading ML models! We want something similar for crop models and their parameters too. I noticed issue #110 didn't have much detail, so I added some explanations and examples to give a better idea of what I had in mind. The examples are just meant to explain the concept, the actual implementation can be different. We can also chat and brainstorm this offline!
|
Thanks @SarahAlidoost, I have totally missed that part! In the new commit, I have added unified I have also added some tests for the physical model io. |
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella thanks! look great! 🥇 I left a few comments to help improve readability; we can move some parts of save_model and load_model into config.py, but we don't need to add tests for those methods in test_config.py, the existing io tests should be enough.
I also noticed that io.py is currently under ml_models. Could please you move it one level up to src/diffwofost?
Other than that, this looks great and should be ready to merge.
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella thanks for addressing the comments. Only one of the suggestions has not been addressed yet, see my comment. Do you think we can also implement the classmethod from_dict or is there any issue with that? thanks! After that, we can merge this PR.
|



This closes #110, by adding a save/load utility for the ML modules using
safetensorsMain changes:
safetensorsas a dependencydiffwofost.ml_models.iowith:save_model(model, ...)load_model(path, ...)Design choices:
save_model(model)saves to a default temp location (ignored by git)