Skip to content

Instantly share code, notes, and snippets.

@skyprince999
Created November 9, 2021 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyprince999/621e9ba1bc9e7c665a5cc7f58442d7b3 to your computer and use it in GitHub Desktop.
Save skyprince999/621e9ba1bc9e7c665a5cc7f58442d7b3 to your computer and use it in GitHub Desktop.
Snippet to delete artifacts from Wandb
########################################################################################
# Loops through artifact files on Wandb server and deletes files with a given extension
########################################################################################
import wandb
from tqdm.notebook import tqdm
api = wandb.Api()
import os
# Used to increase the Wandb HTTP timeout. Apparently this should help
# But in my case I didn;t see any improvement
os.environ['WANDB_HTTP_TIMEOUT'] = "80"
'''
#Incase you are on colab
%env WANDB_HTTP_TIMEOUT = 80
'''
os.getenv('WANDB_HTTP_TIMEOUT')
from tqdm.notebook import tqdm
projects = api.projects("yourprojectname")
for project in projects:
project_name = project.path[0]
run_name = project_name + "/"+project.path[1]
print(run_name)
runs = api.runs(run_name)
for run in tqdm(runs):
extension = ".png"
files = run.files()
for file in files:
if file.name.endswith(extension):
file.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment