Skip to main content

mb.add_models(models, ...)

Adds one or more models to the model registry. The registry is updated with the new model if a an entry with that name already exists.

Parameters

  • models: Optional[Dict[str, Any]] A dictionary of { modelName: modelVariable }. The keys of the dictionary must be strings. The values are the models to store. The values are Python variables, not paths to .pkl files. Required unless using the files= parameter.
  • files: Optional[Dict[str, str]] A dictionary of { modelName: pathToModelFile }. The keys and values of the dictionary must be strings, and the values must be filepaths to local model files. Use this for file-based models instead of models=
  • metrics: Optional[str, Optional[Dict[str, Any]]] Optional, the metrics to associate with the models getting added. Like the models parameter, the metrics parameter is a dictionary of { modelName: metricsDict }. Metrics must be JSON-serializable with str values for keys.
  • serializer: Optional["cloudpickle"] Optional, specify a different serializer to use. Default value is None which uses the pickle module. This setting applies to all models in this call. Learn mode

Returns

No value is returned. A success status message is printed if the command is successful.

Examples

Adding a model

mb.add_models({ "example_model": my_model })

Adding multiple models

mb.add_models({ "example_model": my_model, "another_model": other_model })

Adding multiple model to the "finance" directory

mb.add_models({ "finance/example_model": my_model, "finance/another_model": other_model })

Adding file-based models

mb.add_models(files={ "my_model": "path/to/model.gguf" })

Adding multiple models with metrics

mb.add_models({
"example_model": my_model,
"another_model": other_model
},
metrics={
"example_model": { "precision": 0.95 },
"another_model": { "precision": 0.80 }
})

Adding multiple models with cloudpickle

mb.add_models({ "example_model": my_model, "another_model": other_model }, serializer="cloudpickle")

See also