Permanently delete Artifact Versions

Hi,

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)
artifact.delete()

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).

image

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

Hi @andreapesare,

Following up on the recent issue you were facing with incorrect Artifact versions being fetched by our API after an artifact is deleted. Our eng team has released a fix for this with our latest client release, 0.13.5. Please let us know if there is anything else we could do for you.

Hi @mohammadbakir,

I updated my wandb version to 0.13.5 but unfortunately this doesn’t seem to fix the issue.
For instance, in W&B UI I have the following artifact versions (i.e. I deleted v13)
image
but when I run

artifact_versions = api.artifact_versions(name='generator', type_name='model')
for v in artifact_versions:
    print(v.name)

the output is the following, meaning that the version v13 is still counted as available.
image

Hi,

Just encountered a similar issue to the one you describe in your answer. I deleted all the artifact versions through the API but an empty artifact “group” remains. How do I delete it using the API?
image

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.