Skip to main content
Schedule when artifacts are deleted from W&B with a W&B Artifact time-to-live (TTL) policy. When you delete an artifact, W&B marks that artifact as a soft-delete. In other words, the artifact is marked for deletion but files are not immediately deleted from storage. For more information on how W&B deletes artifacts, see the Delete artifacts page. Watch a Managing data retention with Artifacts TTL video tutorial to learn how to manage data retention with Artifacts TTL in the W&B App.
W&B deactivates the option to set a TTL policy for artifacts linked to the Registry. This helps ensure that linked artifacts don’t accidentally expire when used in production workflows.
  • Only team admins can view a team’s settings and access team-level TTL settings such as (1) permitting who can set or edit a TTL policy or (2) setting a team default TTL.
  • If you don’t see the option to set or edit a TTL policy in an artifact’s details in the W&B App UI, or if setting a TTL programmatically doesn’t change an artifact’s TTL property, your team admin hasn’t given you permissions to do so.

Autogenerated artifacts

Only user-generated artifacts can use TTL policies. W&B-generated artifacts can’t have TTL policies set for them. The following artifact types indicate an autogenerated artifact:
  • run_table
  • code
  • job
  • Any artifact type starting with wandb-*
You can check an artifact’s type on the W&B platform or programmatically:
Replace the bracketed placeholders with your own values.

Define who can edit and set TTL policies

Define who can set and edit TTL policies within a team. Grant TTL permissions only to team admins, or grant both team admins and team members TTL permissions.
Only team admins can define who can set or edit a TTL policy.
  1. Navigate to your team’s profile page.
  2. Select the Settings tab.
  3. Navigate to the Artifacts time-to-live (TTL) section.
  4. From the TTL permissions dropdown, select who can set and edit TTL policies.
  5. Click Review and save settings.
  6. Confirm the changes and select Save settings.
Setting TTL permissions

Create a TTL policy

Set a TTL policy for an artifact either when you create the artifact or retroactively after you create the artifact. For all the following code snippets, replace the bracketed placeholders with your own values to use the code snippet.

Set a TTL policy when you create an artifact

Use the W&B Python SDK to define a TTL policy when you create an artifact. You typically define TTL policies in days.
Defining a TTL policy when you create an artifact is similar to how you normally create an artifact, except that you pass in a time delta to the artifact’s ttl attribute.
The steps are as follows:
  1. Create an artifact.
  2. Add content to the artifact such as files, a directory, or a reference.
  3. Define a TTL time limit with the datetime.timedelta data type that is part of Python’s standard library.
  4. Log the artifact.
The following code snippet demonstrates how to create an artifact and set a TTL policy.
The preceding code snippet sets the TTL policy for the artifact to 30 days. In other words, W&B deletes the artifact after 30 days.

Set or edit a TTL policy after you create an artifact

Use the W&B App UI or the W&B Python SDK to define a TTL policy for an artifact that already exists.
When you modify an artifact’s TTL, W&B still calculates the expiration time using the artifact’s createdAt timestamp.
  1. Fetch your artifact.
  2. Pass in a time delta to the artifact’s ttl attribute.
  3. Update the artifact with the save method.
The following code snippet shows how to set a TTL policy for an artifact:
The preceding code example sets the TTL policy to two years.

Set default TTL policies for a team

Only team admins can set a default TTL policy for a team.
Set a default TTL policy for your team. Default TTL policies apply to all existing and future artifacts based on their respective creation dates. Artifacts with existing version-level TTL policies are not affected by the team’s default TTL.
  1. Navigate to your team’s profile page.
  2. Select the Settings tab.
  3. Navigate to the Artifacts time-to-live (TTL) section.
  4. Click the Set team’s default TTL policy.
  5. Within the Duration field, set the TTL policy in units of days.
  6. Click Review and save settings.
  7. Confirm the changes and then select Save settings.
Setting default TTL policy

Set a TTL policy outside of a run

Use the public API to retrieve an artifact without fetching a run, and set the TTL policy. You typically define TTL policies in days. The following code sample shows how to fetch an artifact using the public API and set the TTL policy.

Deactivate a TTL policy

Use the W&B Python SDK or W&B App UI to deactivate a TTL policy for a specific artifact version.
  1. Fetch your artifact.
  2. Set the artifact’s ttl attribute to None.
  3. Update the artifact with the save method.
The following code snippet shows how to deactivate a TTL policy for an artifact:

View TTL policies

View TTL policies for artifacts with the Python SDK or with the W&B App UI.
Use a print statement to view an artifact’s TTL policy. The following example shows how to retrieve an artifact and view its TTL policy: