Files
karaoke-gen/docs/PYPI-STORAGE-PRUNE.md
T
Andrew Beveridge ☄️andClaude Opus 4.8 37b9e6088b ci(pypi): recurring storage-cap prune reminder (fix failing PyPI publish) (#960)
## Problem

The `Deploy - Publish to PyPI` step on `main` has been failing:

```
HTTP Error 400: Project size too large. Limit for project 'karaoke-gen'
total size is 10 GB.
```

This is a recurrence of the known 10 GB PyPI project cap. The project is
at
**10.71 GB / 479 releases**; each release is a ~62 MiB universal wheel
(bundled
33-locale frontend) auto-published on every merge (~3 GB/month), so it
refills
the cap every few months. **Only the public `pip install` publish step
fails** —
Cloud Run and the GCE encoding worker (pulls the wheel from GCS) are
unaffected.

The prior fix (v0.187.5) was wheel-only publishing + a one-time manual
deletion,
which only bought ~2 months. This makes the cleanup **recurring and
durable**.

## Why not just automate deletion in CI?

PyPI has **no deletion API** (upload tokens / Trusted Publishing are
upload-only,
and 2FA is mandatory). Deletion is only possible from a logged-in
browser
session, which can't be safely/durably stored in CI. So we automate the
*decision + reminder* and keep the *deletion* a ~1-minute human step.

## What this adds

- **`scripts/prune_pypi_releases.py`** (stdlib-only) — reads the public
JSON API
and computes a retention plan: **keep last 60 days + newest release per
older
calendar month + latest overall**. Renders a table / JSON / Markdown
report and
a **paste-into-browser-console** deletion snippet. Never deletes
anything
  itself. Today's plan: keep 82, delete 397, **10.71 GB → 4.17 GB**.
- **`.github/workflows/pypi-prune-reminder.yml`** — monthly cron (+
manual
dispatch) that runs the planner and, once the project crosses a 7 GB
watermark,
opens/updates a single tracking issue with the plan + snippet. No
secrets.
- **`docs/PYPI-STORAGE-PRUNE.md`** runbook + a `TROUBLESHOOTING.md`
entry.
- **`tests/unit/test_prune_pypi_releases.py`** — 13 tests covering the
policy
(recency window, per-month keeper, latest-overall, same-day timestamp
ranking,
  empty/undated releases, sizes, rendering).

## Testing

- `pytest tests/unit/test_prune_pypi_releases.py` → 13 passed.
- Ran the planner against live PyPI data; generated JS validated with
`node --check`.
- `black` clean; workflow YAML validated; `should_nag` gate verified.

## Notes

- **No version bump** — tooling/CI/docs only, nothing in the wheel
changes.
Merging therefore **skips** the publish step (tag `v0.209.1` already
exists),
so this PR does not itself add another fat wheel while we're over the
cap.
- **To unblock publishing now:** after merge, run the prune (locally via
the
script or trigger the workflow with `workflow_dispatch`), paste the
snippet on
the logged-in PyPI releases page, then re-run the publish. The monthly
cron
  keeps it under the cap going forward.
- Related: filed
[pypi/support#12050](https://github.com/pypi/support/issues/12050)
requesting a 50 GB limit as a one-off buffer; the recurring prune is the
  durable fix.

@coderabbitai ignore

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-29 21:46:10 -04:00

89 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PyPI storage-cap prune runbook
## The problem
PyPI caps **total project size at 10 GB**. `karaoke-gen` publishes a universal
`py3-none-any` wheel on every merge to `main` (auto-versioned in CI). Since the
i18n initiative the wheel bundles a Next.js static export pre-rendered into 33
locales (the CLI local lyrics-review UI serves it at runtime), so each release is
**~62 MiB**. At ~50 releases/month that's **~3 GB/month**, so the project refills
the cap every few months and the publish step fails:
```
HTTP Error 400: Project size too large. Limit for project 'karaoke-gen'
total size is 10 GB.
```
Only the public `pip install` publish step fails — the Cloud Run backend and the
GCE encoding worker (which pulls the wheel from **GCS**, not PyPI) are unaffected.
## Why we can't just automate deletion
PyPI has **no deletion API**. Upload tokens and Trusted Publishing are
upload-only, and PyPI mandates 2FA, so deletion is only possible from a
logged-in browser session — which can't be safely or durably stored in CI. So we
automate the *decision and the reminder*, and keep the *deletion* a ~1-minute
human step.
## Retention policy
Keep every release from the **last 60 days**, plus the **newest release of each
older calendar month**, plus the **latest release overall**. Delete the rest.
Run recurringly, this holds steady-state around 6–7 GB — permanently under the
cap. Deletion is irreversible and a deleted version/filename can never be
re-uploaded; that's acceptable here (nothing builds from source; PyPI is only the
public `pip install` channel, whose users want recent versions).
## How it runs
- **`.github/workflows/pypi-prune-reminder.yml`** — monthly cron (1st, 09:00
UTC) + manual `workflow_dispatch`. Computes the plan and, when there's anything
to prune, opens or updates a single tracking issue titled
**"🧹 PyPI storage prune due: karaoke-gen"** with the plan + a paste-in
deletion snippet. No secrets.
- **`scripts/prune_pypi_releases.py`** — the planner. Reads the public JSON API,
applies the policy, and renders a table / JSON / Markdown / browser-console JS.
It never deletes anything itself.
## How to prune (≈1 minute)
1. Open the tracking issue (or run the script locally, below) to get the snippet.
2. Go to **<https://pypi.org/manage/project/karaoke-gen/releases/>** and log in.
3. Open browser devtools → **Console**.
4. Paste the snippet and press Enter. It reads the page's CSRF token and POSTs a
whole-version delete for each planned version, ~0.5s apart, logging progress.
5. Reload to confirm. If a publish was blocked, re-run it: push an empty commit /
re-run the failed CI `Deploy - Publish to PyPI` job, or `poetry publish`
locally.
> The aggregate `pypi.org/pypi/karaoke-gen/json` is Fastly-cached and lags a few
> minutes after deletes — trust the logged-in manage page for live state.
## Running the planner locally
```bash
# Dry-run table (what would be deleted, and the resulting size)
python scripts/prune_pypi_releases.py
# Just the paste-in deletion snippet
python scripts/prune_pypi_releases.py --format console-js
# Machine-readable / the Markdown the workflow posts
python scripts/prune_pypi_releases.py --format json
python scripts/prune_pypi_releases.py --format markdown
# Tune the window (default 60 days) or target another project
python scripts/prune_pypi_releases.py --keep-days 90 --project karaoke-gen
```
Stdlib only — no dependencies to install.
## Related
- One-off escape hatch: request a PyPI storage-limit increase via the
`limit-request-project` template on
[`pypi/support`](https://github.com/pypi/support) (we filed
[pypi/support#12050](https://github.com/pypi/support/issues/12050) for 50 GB).
A larger cap just buys time; the recurring prune is the durable fix.
- History of the first time this bit us: `docs/LESSONS-LEARNED.md`.