# Artifacts version

**URL:** <https://community.wandb.ai/t/artifacts-version/4379>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [May 11, 2023, 2:29pm UTC](https://community.wandb.ai/t/artifacts-version/4379 "2023-05-11T14:29:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![parisi](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@parisi](https://community.wandb.ai/u/parisi)\
**Post date:** [May 11, 2023, 2:29pm UTC](https://community.wandb.ai/t/artifacts-version/4379/1 "2023-05-11T14:29:48Z")

</div>

Is there a way to either 1) set a max to the number of versions an artifact can have (if more are uploaded then oldest get deleted), or 2) keep only the latest version?

---

<div class="post-metadata">

**Author:** ![raphael-sanandres](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@raphael-sanandres](https://community.wandb.ai/u/raphael-sanandres)\
**Post date:** [May 11, 2023, 11:15pm UTC](https://community.wandb.ai/t/artifacts-version/4379/2 "2023-05-11T23:15:19Z")

</div>

Hello @parisi !

You can do this by deleting all artifacts that do not have the alias `latest` (which is outlined [here](https://docs.wandb.ai/guides/artifacts/delete-artifacts#delete-all-versions-of-an-artifact-that-do-not-have-an-alias) in our docs. You could write a script to assign tags to the last newest 5 artifacts by obtaining the versions of all artifacts and deleting anything that is not the five newest versions. However, deleting all artifacts but the `latest` will be easier.

Warning: I would recommend waiting to delete artifacts once that have already been uploaded to `wandb`. If you delete an artifact that is still in the middle of uploading, it may cause issues. For example, if you make deleting all but the latest artifact as part of your code, it may break the process since some artifacts will be delete before they are uploaded. Therefore, it would be safe to include a buffer i.e. delete all but the last 5 artifacts.

---

<div class="post-metadata">

**Author:** ![parisi](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@parisi](https://community.wandb.ai/u/parisi)\
**Post date:** [May 12, 2023, 6:10pm UTC](https://community.wandb.ai/t/artifacts-version/4379/3 "2023-05-12T18:10:39Z")

</div>

Thanks!

It would be nice to have a command to define a policy that takes care of that. Like `wand.config_artifacts` where you define how many versions of each artifact (or what artifact, passing its name) you want to keep.

---

<div class="post-metadata">

**Author:** ![raphael-sanandres](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@raphael-sanandres](https://community.wandb.ai/u/raphael-sanandres)\
**Post date:** [May 17, 2023, 6:10pm UTC](https://community.wandb.ai/t/artifacts-version/4379/4 "2023-05-17T18:10:27Z")

</div>

That is a fair recommendation and I can pass this to our SDK team via a feature request. The team is scoping on what methods to implement for artifact deletion so this will be helpful. Thanks!

---

<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:** [July 16, 2023, 6:10pm UTC](https://community.wandb.ai/t/artifacts-version/4379/5 "2023-07-16T18:10:35Z")

</div>

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