Model Registries
Initialization of the MLflow Service.
Model registries are centralized repositories that facilitate the collaboration and management of machine learning models. They provide functionalities such as version control, metadata tracking, and storage of model artifacts, enabling data scientists to efficiently share and keep track of their models within a team or organization.
BaseModelRegistry
Bases: StackComponent
, ABC
Base class for all ZenML model registries.
Source code in src/zenml/model_registries/base_model_registry.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
config
property
Returns the config of the model registries.
Returns:
Type | Description |
---|---|
BaseModelRegistryConfig
|
The config of the model registries. |
delete_model(name)
abstractmethod
Deletes a registered model from the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the model does not exist. |
RuntimeError
|
If deletion fails. |
Source code in src/zenml/model_registries/base_model_registry.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
delete_model_version(name, version)
abstractmethod
Deletes a model version from the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
version
|
str
|
The version of the model version to delete. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
RuntimeError
|
If deletion fails. |
Source code in src/zenml/model_registries/base_model_registry.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
get_latest_model_version(name, stage=None)
Gets the latest model version for a registered model.
This method is used to get the latest model version for a registered model. If no stage is provided, the latest model version across all stages is returned. If a stage is provided, the latest model version for that stage is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
Returns:
Type | Description |
---|---|
Optional[RegistryModelVersion]
|
The latest model version. |
Source code in src/zenml/model_registries/base_model_registry.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
get_model(name)
abstractmethod
Gets a registered model from the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The registered model. |
Raises:
Type | Description |
---|---|
EntityExistsError
|
If the model does not exist. |
RuntimeError
|
If retrieval fails. |
Source code in src/zenml/model_registries/base_model_registry.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
get_model_uri_artifact_store(model_version)
abstractmethod
Gets the URI artifact store for a model version.
This method retrieves the URI of the artifact store for a specific model version. Its purpose is to ensure that the URI is in the correct format for the specific artifact store being used. This is essential for the model serving component, which relies on the URI to serve the model version. In some cases, the URI may be stored in a different format by certain model registry integrations. This method allows us to obtain the URI in the correct format, regardless of the integration being used.
Note: In some cases the URI artifact store may not be available to the user, the method should save the target model in one of the other artifact stores supported by ZenML and return the URI of that artifact store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_version
|
RegistryModelVersion
|
The model version for which to get the URI artifact store. |
required |
Returns:
Type | Description |
---|---|
str
|
The URI artifact store for the model version. |
Source code in src/zenml/model_registries/base_model_registry.py
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
get_model_version(name, version)
abstractmethod
Gets a model version for a registered model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
version
|
str
|
The version of the model version to get. |
required |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The model version. |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
RuntimeError
|
If retrieval fails. |
Source code in src/zenml/model_registries/base_model_registry.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
list_model_versions(name=None, model_source_uri=None, metadata=None, stage=None, count=None, created_after=None, created_before=None, order_by_date=None, **kwargs)
abstractmethod
Lists all model versions for a registered model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the registered model. |
None
|
model_source_uri
|
Optional[str]
|
The model source URI of the registered model. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
Metadata associated with this model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
count
|
Optional[int]
|
The number of model versions to return. |
None
|
created_after
|
Optional[datetime]
|
The timestamp after which to list model versions. |
None
|
created_before
|
Optional[datetime]
|
The timestamp before which to list model versions. |
None
|
order_by_date
|
Optional[str]
|
Whether to sort by creation time, this can be "asc" or "desc". |
None
|
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Optional[List[RegistryModelVersion]]
|
A list of model versions. |
Source code in src/zenml/model_registries/base_model_registry.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
list_models(name=None, metadata=None)
abstractmethod
Lists all registered models in the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the registered model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata associated with the registered model. |
None
|
Returns:
Type | Description |
---|---|
List[RegisteredModel]
|
A list of registered models. |
Source code in src/zenml/model_registries/base_model_registry.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
load_model_version(name, version, **kwargs)
abstractmethod
Loads a model version from the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
version
|
str
|
The version of the model version to load. |
required |
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The loaded model version. |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
RuntimeError
|
If loading fails. |
Source code in src/zenml/model_registries/base_model_registry.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
register_model(name, description=None, metadata=None)
abstractmethod
Registers a model in the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
description
|
Optional[str]
|
The description of the registered model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata associated with the registered model. |
None
|
Returns:
Type | Description |
---|---|
RegisteredModel
|
The registered model. |
Raises:
Type | Description |
---|---|
EntityExistsError
|
If a model with the same name already exists. |
RuntimeError
|
If registration fails. |
Source code in src/zenml/model_registries/base_model_registry.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
register_model_version(name, version=None, model_source_uri=None, description=None, metadata=None, **kwargs)
abstractmethod
Registers a model version in the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
model_source_uri
|
Optional[str]
|
The source URI of the model. |
None
|
version
|
Optional[str]
|
The version of the model version. |
None
|
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The metadata associated with the model version. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The registered model version. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If registration fails. |
Source code in src/zenml/model_registries/base_model_registry.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
update_model(name, description=None, metadata=None, remove_metadata=None)
abstractmethod
Updates a registered model in the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
description
|
Optional[str]
|
The description of the registered model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata associated with the registered model. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the registered model. |
None
|
Raises:
Type | Description |
---|---|
KeyError
|
If the model does not exist. |
RuntimeError
|
If update fails. |
Source code in src/zenml/model_registries/base_model_registry.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
update_model_version(name, version, description=None, metadata=None, remove_metadata=None, stage=None)
abstractmethod
Updates a model version in the model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the registered model. |
required |
version
|
str
|
The version of the model version to update. |
required |
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
Metadata associated with this model version. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The updated model version. |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
RuntimeError
|
If update fails. |
Source code in src/zenml/model_registries/base_model_registry.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
BaseModelRegistryConfig
Bases: StackComponentConfig
Base config for model registries.
Source code in src/zenml/model_registries/base_model_registry.py
171 172 |
|
BaseModelRegistryFlavor
Bases: Flavor
Base class for all ZenML model registry flavors.
Source code in src/zenml/model_registries/base_model_registry.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
|
config_class
property
Config class for this flavor.
Returns:
Type | Description |
---|---|
Type[BaseModelRegistryConfig]
|
The config class for this flavor. |
implementation_class
abstractmethod
property
Returns the implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
type
property
Type of the flavor.
Returns:
Name | Type | Description |
---|---|---|
StackComponentType |
StackComponentType
|
The type of the flavor. |