Created
November 9, 2021 08:06
-
-
Save skyprince999/621e9ba1bc9e7c665a5cc7f58442d7b3 to your computer and use it in GitHub Desktop.
Snippet to delete artifacts from Wandb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################################## | |
# 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