# Permanently delete Artifact Versions

**URL:** <https://community.wandb.ai/t/permanently-delete-artifact-versions/3065>\
**Category:** W&B Help\
**Tags:** artifacts\
**Created:** [September 5, 2022, 8:28am UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065 "2022-09-05T08:28:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreapesare](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@andreapesare](https://community.wandb.ai/u/andreapesare)\
**Post date:** [September 5, 2022, 8:28am UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/1 "2022-09-05T08:28:26Z")

</div>

Hi,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![mohammadbakir](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mohammadbakir](https://community.wandb.ai/u/mohammadbakir)\
**Post date:** [September 7, 2022, 11:31pm UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/2 "2022-09-07T23:31:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreapesare](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@andreapesare](https://community.wandb.ai/u/andreapesare)\
**Post date:** [September 9, 2022, 10:38am UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/3 "2022-09-09T10:38:14Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/e133e393d5ad8572ba0f957a2c5bbb4cb960498d.png)

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

---

<div class="post-metadata">

**Author:** ![mohammadbakir](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mohammadbakir](https://community.wandb.ai/u/mohammadbakir)\
**Post date:** [September 14, 2022, 10:52pm UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/4 "2022-09-14T22:52:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mohammadbakir](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mohammadbakir](https://community.wandb.ai/u/mohammadbakir)\
**Post date:** [November 4, 2022, 6:09pm UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/5 "2022-11-04T18:09:17Z")

</div>

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](https://github.com/wandb/wandb/pull/4221) for this with our latest client release, [0.13.5](https://github.com/wandb/wandb/releases/tag/v0.13.5). Please let us know if there is anything else we could do for you.

---

<div class="post-metadata">

**Author:** ![andreapesare](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@andreapesare](https://community.wandb.ai/u/andreapesare)\
**Post date:** [November 7, 2022, 12:31pm UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/6 "2022-11-07T12:31:30Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/2/22d6117910e77523b0ca06d79bedea04eebd0ca5.png)  
but when I run

```auto
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](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/4/4555ed0487f1d0807fc749d15dea749f39f9229b.png)

---

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [December 8, 2022, 11:09am UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/7 "2022-12-08T11:09:41Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/4/4f6ba41d9190a802c83af016905ccbe9feb84539.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [February 6, 2023, 11:10am UTC](https://community.wandb.ai/t/permanently-delete-artifact-versions/3065/8 "2023-02-06T11:10:10Z")

</div>

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