8000 #557: Crawler version spread for staff, and versioned crawler releases by blueheron786 · Pull Request #558 · mwmbl/mwmbl · GitHub
[go: up one dir, main page]

Skip to content

#557: Crawler version spread for staff, and versioned crawler releases - #558

Merged
daoudclarke merged 2 commits into
mwmbl:mainfrom
blueheron786:crawler_update
Oct 28, 2026
Merged

daoudclarke merged 2 commits into
mwmbl:mainfrom
blueheron786:crawler_update

Conversation

@blueheron786
@blueheron786 blueheron786 commented Oct 27, 2026 •
Copy link
Copy Markdown
Collaborator

Part of #557.

Front-end: mwmbl/front-end#99

What

  • Records, per day and per crawler version, how many crawlers submitted results and how many results they sent.
  • Serves the last seven days to staff at GET /api/v1/platform/crawler-versions (403 for anyone who isn't staff).
  • Moves CRAWLER_VERSION into mwmbl/crawler/version.py, which imports nothing.
  • Adds crawler-release.yml: pushing a crawler-vX.Y.Z tag publishes mwmbl/crawler:X.Y.Z, :X.Y and :stable, and refuses a tag that doesn't match CRAWLER_VERSION. :latest still follows main.

Why

The epic asks for "what spread of versions users are actually crawling" before any crawler is told to update. A crawler is counted as a user plus a device name, not an API key: one key can serve several crawlers and one user can hold several keys. Counts live in Redis with the same 30 day expiry as the other daily stats, so there is no migration.

How it was verified

  • make check passes. ty reports 8 more warnings than before, all of the kinds the repo already has (Django and redis stubs, ninja_jwt token types).
  • Full suite: 1618 passed, 10 skipped.
  • New tests in test/test_crawler_versions.py cover the counting, the per-user device identity, version ordering, the 7-day window, truncation, expiry, the real /results endpoint, dry runs not being counted, and the staff gate on the new endpoint.
  • Checked by hand against a local back-end and the front-end PR above, signed in through the real login form.

Screenshot

The page in the front-end PR, fed by this endpoint, with sample data:

Crawler versions page

After merging

Nothing is tagged yet. To publish the first release: git tag crawler-v0.2.0 && git push upstream crawler-v0.2.0. Docker Hub secrets are needed, and the release workflow has not been run.

Record, per day and per crawler version, how many crawlers submitted and how many
results they sent, and serve the last seven days to staff at
GET /api/v1/platform/crawler-versions. A crawler is a user and a device name, not an
API key, since one key can serve several crawlers and one user can hold several keys.

Move CRAWLER_VERSION into mwmbl/crawler/version.py, which imports nothing, and add a
workflow that publishes mwmbl/crawler:X.Y.Z, :X.Y and :stable for a crawler-vX.Y.Z tag,
refusing a tag that does not match it.
Review fixes:
- A client-supplied version containing a digit int() rejects (e.g. "1.²") made the
  staff endpoint raise a 500 for as long as the counters lived. Only X.Y.Z versions of
  ASCII digits are now given their own row; anything else is counted as "unknown", which
  also stops a client minting a row and Redis keys per request.
- Cut the device name to MAX_ERROR_TAG_LENGTH before it goes in the Redis set.
- Read the per-version crawler counts in one pipelined round trip.
- Only publish a crawler-vX.Y.Z tag whose commit is on main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@daoudclarke
Copy link
Copy Markdown
Contributor

This is looking good. Can you clarify the deploy/release procedure?

@blueheron786
Copy link
Copy Markdown
Collaborator Author

As usual, this (back-end) before the front end. If you push a tag in the format of vX.Y.Z, it'll trigger the build and push that tagged commit of the crawler to Dockerhub.

@daoudclarke
daoudclarke merged commit e429009 into mwmbl:main Oct 28, 2026
4 checks passed
@blueheron786
blueheron786 deleted the crawler_update branch October 28, 2026 15:06
daoudclarke pushed a commit that referenced this pull request Oct 31, 2026
Part of #557. The version-spread dashboard (#558) and tagged crawler
releases are merged, so the server can now tell old crawlers to upgrade:
POST /api/v1/crawler/results returns 426 Upgrade Required when the
submitted crawler_version is below the new MIN_CRAWLER_VERSION setting
(default 0.0.0, which accepts every crawler, including ones too old to
report a version). The crawler waits out an hour on a 426 instead of
crash-looping, giving an external updater time to replace the process.

CRAWLER_VERSION is raised to 1.0.2 because this changes what the
crawler runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@blueheron786
blueheron786 restored the crawler_update branch November 1, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0