Permanently delete Artifact Versions


I am trying to delete Artifact Versions using the API, for instance with something like this:

api = wandb.Api(overrides={"entity": entity, "project": project})
artifact = api.artifact(name, type)

The artifact is indeed deleted from the web UI, but then when I call api.artifact_versions(type, name) it is still present in the iterator.

So, in order to get the list of all available artifacts, what I’m currently doing is call the api.artifact_versions() method and then check if a specific version really exists by usiing api.artifact inside a try/except clause (if the artifact was deleted, it will raise a wandb.CommError exception), but of course this solution is more expensive.

My question is: is there a way to permanently delete artifact versions so that they are not shown in api.artifact_versions() anymore? This would also help keep the version number from growing too high

Hi @andreapesare, at this time although you can delete an artifact and all its sub versions via the API, an empty artifact remains in the project. The engineering team is considering automatically deleting this as well once a user has deleted all content within an artifact. After deleting all versions of the artifact, the empty artifact will be automatically deleted from the project.

Hi @mohammadbakir , thanks for your answer.
I am referring to a different (though probably linked) problem. I don’t want to delete an empty artifact, but some artifact versions.

Let me clarify it with an example:

In my example project on W&B I have a SimpleNet artifact collection of type model with versions ['v2', 'v3', 'v4', 'v5'] (see image below).


Let’s assume that when I run
api.artifact_versions(name='SimpleNet', type='model')
I receive a list of ArtifactVersion, corresponding to the versions ['v2', 'v3', 'v4', 'v5'].
Now I would like to delete some useless version, e.g. ‘v2’. I can do it either from the web UI or from the API itself.

Then, if I ran again the command
api.artifact_versions(name='SimpleNet', type='model'),
I would expect the output to be a list with versions ['v3', 'v4', 'v5'], but instead I get still ['v2', 'v3', 'v4', 'v5']. However, when I try to access the ArtifactVersion v2, I get a wandb.CommError exception since that version has been deleted. It’s like the W&B server keeps a “phantom” view of all deleted artifact versions.
My question is: is it possible to permanently delete them? Thanks for any help

Hi @andreapesare , thank-you for the clarification. We tested this on our end and confirmed it’s a bug. We are working on a fix, once implemented, I will provide you an update.

1 Like