mlflow-model-registry-inventory(Python)

Loading...

Inventory workspace model registry entities

This notebook uses the model registry REST API to copy all registered model and model version metadata into Delta tables. You can use then use the Delta tables to understand your model registry entities and select entities to delete.

      Registered models

      The following code lists all registered models in a workspace and copies their metadata into a Delta table.

      Model versions

      The following code lists the latest 1000 model versions of each registered model in a workspace and copies their metadata into a Delta table.

      Note: The search_model_versions REST API does not support pagination, nor does it support filtering based on the version column. To list all model versions under a registered model, Databricks recommends listing model versions 10,000 at a time in order of descending version, deleting versions you no longer need, and then repeating the process as necessary until you are under the limit.

      search_params = {
              "filter": f"name = 'too_many_model_versions'",
              "max_results": 10000,
              "order_by": ["version DESC"]
      }
      

      Delete unused entities

      Now, run SQL queries on the registered model and model version metadata you've stored in Delta Tables. Use SQL queries to identify and delete unused entities.