I accidentally logged way too much to wandb and would like to delete some artifacts. I've tried the following script, but I get an error 400 whenever I run it:
import wandb
wandb.login(key=KEY)
api = wandb.Api(overrides={"project": PROJECT, "entity": ENTITY})
for run in api.runs():
files = sorted([f for f in run.logged_artifacts()], key=lambda f: f.updated_at)
print("Total files:", len(files))
print("Last file:", files[-1].name)
print("Last file date:", files[-1].updated_at)
for f in files[:-1]:
if ".tar" in f.name:
# also tried just f.delete()
a = api.artifact(f"{PROJECT}/{f.name}")
print("Deleting {}".format(f.name))
a.delete()
All I get is requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.wandb.ai/graphql
I work at Weights & Biases, I checked internally and it might be related to the artifacts having aliases, you might just need to try:
a.delete(delete_aliases=True)