Skip to content
Notifications
Clear all

Guide: Reducing W&B storage costs by pruning old run files automatically.

2 Posts
2 Users
0 Reactions
2 Views
(@ci_cd_enthusiast)
Estimable Member
Joined: 5 months ago
Posts: 117
Topic starter   [#13355]

Hey everyone! 👋 I've been noticing our team's W&B storage costs creeping up as our experiment volume increases. While the run history is invaluable, we don't always need to keep every single artifact file from old runs forever.

I've built a simple automated pipeline to prune old run files (like model checkpoints, large logs, or heavy media) while keeping the run metadata and summaries. This keeps the dashboard useful for comparison but trims the storage bulk.

Here's a GitHub Actions workflow that runs monthly, targeting runs older than 90 days. It uses the W&B CLI to delete files *within* runs, preserving the run itself.

```yaml
name: Prune Old W&B Run Files
on:
schedule:
- cron: '0 0 1 * *' # First day of the month
workflow_dispatch: # Allow manual trigger

jobs:
prune:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure W&B CLI
run: |
pip install wandb
wandb login --anonymously

- name: Fetch and prune old runs
env:
WANDB_ENTITY: your-entity
WANDB_PROJECT: your-project
RETENTION_DAYS: 90
run: |
# Get runs older than RETENTION_DAYS
RUNS=$(wandb artifact ls "$WANDB_ENTITY/$WANDB_PROJECT" --type run --before $(date -d "$RETENTION_DAYS days ago" +%Y-%m-%d) --format json | jq -r '.[].name')

for RUN in $RUNS; do
echo "Pruning files for: $RUN"
# This removes files but leaves the run metadata intact
wandb artifact delete "$RUN" --only-artifact-files --yes
done
```

Key points:
* It uses `--only-artifact-files` to keep the run record alive in the UI.
* Adjust `RETENTION_DAYS` and the cron schedule to fit your needs.
* You can filter by tags (e.g., `prod-model`) if you only want to target specific runs.
* Always test on a copy of a project first! 🚨

This has cut our storage growth by about 70% without losing our experiment tracking. How are others managing W&B storage? Any alternative scripts or tools you're using?

-pipelinepilot


Pipeline Pilot


   
Quote
(@cloud_cost_hawk_2)
Reputable Member
Joined: 3 months ago
Posts: 129
 

Love the idea, but that --anonymously flag is going to haunt you. The CLI needs a real API key to delete files, even from public projects. You'll hit a wall there.

Also, be careful with the 90-day blanket rule. You might nuke the checkpoint file for a run that's still actively cited in papers or used for model comparisons. I'd add a tag filter step first, maybe tag runs earmarked for archival as "prune_ok" before they hit the age threshold.

One more thing - have you estimated the actual storage cost delta this will yield? I've seen teams spend hours on cleanup scripts only to save $12 a month, while ignoring the 17 TB of orphaned S3 buckets next door. Not saying that's you, but always do the math first.



   
ReplyQuote