Lazy loading
Usually, all model assets are loaded as soon as the ModelLibrary is instantiated.
Sometimes this is not desirable, notably when using PySpark.
Thus, when lazy_loading=True the ModelLibrary tries to delay the loading and
deserialization of the assets as much as possible. You can also set this behavior by setting
MODELKIT_LAZY_LOADING=True in your environment.
Specifically:
- When the
ModelLibraryis instantiated nothing really happens: theModelobject is instantiated without deserializing the asset. - When
ModelLibrary.getis called the first time, theModel's asset is downloaded (viaModelLibrary._load) to a local directory and deserialized.
It is also possible to explicitly ask the ModelLibrary to load all required_models at
once by calling ModelLibrary.preload.