9

I create experiments in my workspace using the python sdk (azureml-sdk). I now have a lot of 'test' experiments littering our workspace. How can I delete individual experiments either through the api or on the portal. I know I can delete the whole workspace but there are some good experiments we don't want to delete

https://learn.microsoft.com/en-us/azure/machine-learning/service/how-to-export-delete-data#delete-visual-interface-assets suggests it is possible but my workspace view does not look anything like what is shown there

mike
  • 113
  • 1
  • 6

5 Answers5

9

Experiment deletion is a common request and we in Azure ML team are working on it. Unfortunately it's not supported quite yet.

1

Starting from 2021-08-24 Azure ML Workspace release you can delete the experiment - but only by clicking in UI (Select Experiment in Experiments view -> 'Delete')

Watch out - deleting the experiment will delete all the underlying runs - and deleting a run will delete the child runs, run metrics, metadata, outputs, logs and working directories!

Only for experiments without any underlying runs you can use Python SDK (azureml-core==1.34.0) - Experiment class delete static method, example:

from azureml.core import Workspace, Experiment

aml_workspace = Workspace.from_config()
experiment_id = Experiment(aml_workspace, '<experiment_name>').id

Experiment.delete(aml_workspace, experiment_id)

If an experiment has runs you will get an error:

CloudError: Azure Error: UserError
Message: Only empty Experiments can be deleted. This experiment contains run(s)

I hope Azure ML team gets this functionality to Python SDK soon!

Also on a sad note - would be great if you optimize the deletion - for now it seems like extremely slow (implementation) synchronous (need async as well) call...

  • I only see the Archive Experiment option in the UI on the Experiments page - no Delete option – Mark Z. Jan 03 '22 at 06:18
  • 1
    Nvm - just quick clarification; I only see the Archive Experiment option in the UI on the main Experiments page (where you can see all of them and multi-select) - the Delete option is in a single Experiment view so have to click on one from that page to be taken to it. – Mark Z. Jan 03 '22 at 06:25
0

You can delete your experiment with the following code:

# Declare your experiment
from azureml.core import Experiment
experiment = Experiment(workspace=ws, name="<your_experiment>")
# Delete the experiment
experiment.archive()
# Now check the list of experiments on your AML wokrspace and see that it was deleted
Grover
  • 11
  • 2
    is archive the same thing as delete? – Anders Swanson Aug 12 '20 at 23:35
  • 2
    Nope, you can still see it if you toggle "view archived experiments" in your Experiments overview. However, it does not appear in the normal view anymore. – karu Oct 13 '20 at 14:08
  • This has a serious drawback: it still blocks you the name, can't reuse it: `MlflowException: Cannot set a deleted experiment 'digits_recognition_mlflow' as the active experiment. You can restore the experiment, or permanently delete the experiment to create a new one.` – Maciej Skorski Sep 27 '22 at 07:13
0

This issue is still opened at the moment. What I have figure out to avoid many experiments in workspace is run locally in Python SDK and after upload output files to the run's outputs folder when the run completes.

You can define it as:

run.upload_file(name='outputs/sample.csv', path_or_stream='./sample.csv')
0

Follow the two steps:

1.Delete experiment's child jobs in Azure Studio, here is how: List item

2.Delete the (empty) experiment with Python API, here is how:

from azureml.core import Workspace, Experiment, Run
# choose the workspace and experiment
ws = Workspace.from_config()
exp_name = 'digits_recognition'
# ... delete first experiment's child jobs in Azure Studio
exp = Experiment(ws,exp_name)
Experiment.delete(ws,exp.id)

Note: for a more fine-grained control over deletions, use Azure CLI.

Maciej Skorski
  • 2,303
  • 6
  • 14