Skip to content

Repo checker: trim PyPI's project JSON to the fields the driver reads before it goes into Pyodide #206

Closed

Description

@patrickballard

The checker fetches PyPI's JSON in the browser and passes it to the Python driver as one string. A project's full JSON is big: https://pypi.org/pypi/numpy/json is 3.8 MB today, and most of it is fields nothing reads (description, downloads, md5_digest, comment_text, every digest of every file of every release).

Two paths carry whole documents:

  • check() in site/check/worker.mjs: for a requirements file or pyproject.toml, up to 300 lookups (MAX_LOOKUPS). A range or bare name fetches the project JSON. All of them are kept in fetched and sent with JSON.stringify(fetched).
  • fixes(): the releases map of up to 80 gap packages (MAX_FIX_LOOKUPS), kept in the releases Map for the life of the worker and sent with JSON.stringify(have).

Each document exists three times at the peak: the parsed JS object, the JSON string, and the Python object in Pyodide's heap. A requirements.txt with 40 unpinned scientific packages is hundreds of megabytes. On a phone the tab reloads, and the visitor sees the page start over with no error.

Where

  • site/check/worker.mjs: check() and fixes().
  • site/check/driver.py: _fill_lookups() (what a lookup's JSON is read for) and fixes() (what releases is read for), and behind them wheelgap's pypi._fill_json_data() and suggest.suggest().

What to do

  • Add trimProject(doc) and trimReleases(releases) to site/check/check-logic.mjs (pure functions, so they're testable in Node). Keep only what the driver and wheelgap read. Find the list by reading the pinned wheelgap's code, not by guessing; at the time of writing it's roughly: info.requires_python, info.yanked, info.project_urls, info.home_page, info.version; for each file in urls and in each releases[version] list: filename, packagetype, requires_python, yanked, upload_time_iso_8601. Say in the PR where each kept field is read.
  • Call them right after r.json() in both paths, so the big object is garbage before the next request finishes.
  • The answer must not change. tests/test_check_parity.py already compares the page with the CLI; add a case that runs the driver on a trimmed and an untrimmed copy of a recorded project JSON and gets the same result.
  • Later: fetch https://pypi.org/simple/<name>/ as JSON (PEP 691) for ranges, which is much smaller than the project JSON.

Done when:

  • tests/site/check-logic.test.mjs covers both functions: fields kept, fields dropped, a document that isn't the expected shape (returned in a form the driver still reports as "not PyPI's JSON", never as "no files").
  • tests/test_check_driver.py shows check() and fixes() give equal results for trimmed and untrimmed input, for a pin, a range and a bare name.
  • In the PR: the size of the string passed to driver.check() before and after for a requirements.txt with numpy, scipy, pandas and matplotlib unpinned, and a note of the browser's memory for the tab if you can measure it.

Activity

  1. added
    enhancement
    help wanted
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions