divik.core.io
module¶
Reusable utilities for data and model I/O
-
divik.core.io.
save
(model, destination, **kwargs)[source]¶ Save model and related summaries into specified destination directory
-
divik.core.io.
saver
(fn)[source]¶ Register the function as handler for saving model and related summaries
The saver function should be reusable for different models exhibiting the required variables. Rather prefer checking the required attributes than the model class.
Examples
>>> from divik.core.io import saver >>> @saver ... def my_saver(model, destination, **kwargs): ... if not hasattr(model, 'my_custom_field_'): ... return ... if not 'my_param' in kwargs: ... return ... # custom saving logic comes here
You can also make this function configurable:
>>> import gin >>> from divik.core.io import saver >>> @saver ... @gin.configurable(allowlist=['my_param']) ... def configurable_saver(model, destination, my_param=None, **kwargs): ... if not hasattr(model, 'my_custom_field_'): ... return ... if my_param is None: ... return ... # custom saving logic comes here