# MAGIC %md ## Delete `Version 1` of the power forecasting model # MAGIC # MAGIC You can also use the MLflow UI or MLflow API to delete model versions. **Model version deletion is permanent and cannot be undone.** # MAGIC # MAGIC The following cells provide a reference for deleting `Version 1` of the power forecasting model using the MLflow API. See the documentation for how to delete a model version using the UI. # COMMAND ---------- # MAGIC %md ### Delete `Version 1` using the MLflow API # MAGIC # MAGIC The following cell permanently deletes `Version 1` of the power forecasting model. # COMMAND ---------- client.delete_model_version( name=model_name, version=1, ) # COMMAND ---------- # MAGIC %md ## Delete the power forecasting model # MAGIC # MAGIC If you want to delete an entire registered model, including all of its model versions, you can use the `MlflowClient.delete_registered_model()` to do so. This action cannot be undone. You must first transition all model version stages to **None** or **Archived**. # MAGIC # MAGIC **Warning: The following cell permanently deletes the power forecasting model, including all of its versions.** # COMMAND ---------- client.transition_model_version_stage( name=model_name, version=2,
# MAGIC %md ### Cleanup # COMMAND ---------- # delete AML webservice svc.delete() # loop over registered models in MLflow models = client.search_model_versions("name='{}'".format(model_name)) for model in models: try: # set model stage to Archive client.transition_model_version_stage(name=model_name, version=model.version, stage='Archived') except: pass # delete version of model client.delete_model_version(model_name, model.version) # delete model client.delete_registered_model(model_name) # COMMAND ---------- # MAGIC %md-sandbox # MAGIC © 2020 Databricks, Inc. All rights reserved.<br/> # MAGIC Apache, Apache Spark, Spark and the Spark logo are trademarks of the <a href="http://www.apache.org/">Apache Software Foundation</a>.<br/> # MAGIC <br/> # MAGIC <a href="https://databricks.com/privacy-policy">Privacy Policy</a> | <a href="https://databricks.com/terms-of-use">Terms of Use</a> | <a href="http://help.databricks.com/">Support</a>
# MAGIC %md # MAGIC ### Delete Registered Models # COMMAND ---------- from mlflow.tracking.client import MlflowClient client = MlflowClient() modelName = "Titanic-Model__" + userName models = client.search_model_versions("name='{}'".format(modelName)) # loop over registered models for i in range(len(models)): try: # set model stage to Archive client.transition_model_version_stage(name=modelName, version=models[i].version, stage='Archived') except: pass # delete version of model client.delete_model_version(modelName, models[i].version) # delete model client.delete_registered_model(modelName) # COMMAND ---------- # MAGIC %md-sandbox # MAGIC © 2020 Databricks, Inc. All rights reserved.<br/> # MAGIC Apache, Apache Spark, Spark and the Spark logo are trademarks of the <a href="http://www.apache.org/">Apache Software Foundation</a>.<br/> # MAGIC <br/> # MAGIC <a href="https://databricks.com/privacy-policy">Privacy Policy</a> | <a href="https://databricks.com/terms-of-use">Terms of Use</a> | <a href="http://help.databricks.com/">Support</a>