Unable to Delete Multiple Runs Simultaneously

Hi Eyal,

Thank you for reaching out again and for your patience as we work to resolve the issue you’ve been experiencing with deleting multiple experiments simultaneously. I understand your frustration and the urgency of this matter.

Firstly, I want to apologize for the delay in providing a resolution. Your feedback is important to us, and I assure you that we are committed to resolving this as quickly as possible.

Secondly, I do want to note that the error *errors.errorString: driver: bad connection you’re encountering upon deleting runs in bulk is a potential locking issue in our DB (MySQL). This might take a bit more time to resolve on or end. However, there is a potential workaround you can use on your end via our API. Example script to parallelize the deletion of W&B runs:

import wandb
from concurrent.futures import ThreadPoolExecutor, as_completed


# Define a function to delete a single run
def delete_run(run):
    try:
        run.delete(delete_artifacts=True)
        return f"Run {run_id} deleted successfully."
    except Exception as e:
        return f"Error deleting run {run_id}: {e}"


# Initialize W&B API
api = wandb.Api()
runs = api.runs('entity_name/project_name', filters={"summary_metrics.total_model_wer": "infinity"})

# Set up the ThreadPoolExecutor to parallelize the deletion process
with ThreadPoolExecutor(max_workers=5) as executor:
    # Submit deletion tasks to the executor
    future_to_run = {executor.submit(delete_run, run): run for run in runs}

    # Process the results as they complete
    for future in as_completed(future_to_run):
        run_id = future_to_run[future]
        try:
            result = future.result()
        except Exception as exc:
            print(f"Run {run_id} generated an exception: {exc}")
        else:
            print(result)

Please let me know if the above script helps.