lekdan commited on
Commit
ff6af6e
·
verified ·
1 Parent(s): 570e28e

Document stateless popular sweep behavior

Browse files
crates/osu_fetcher/README.md CHANGED
@@ -73,7 +73,7 @@ editing the file.
73
 
74
  | Command | What it does |
75
  |---|---|
76
- | `enumerate` | Paginates `/api/v2/beatmapsets/search?m={mode}&s={status}&sort=updated_desc` for each requested status, upserts every beatmapset into `sets`. Cursor checkpoints saved per-status after each successful page → can resume mid-run. **Incremental by default**: each run saves a `last_updated` high-water mark and the next run stops paginating once it crosses that mark; pass `--full-rescan` to re-walk everything. For popular maps, use `--statuses any --sort favourites-desc --min-favourites 100 --min-playcount 1000 --stateless`; that walks the favourite-sorted prefix, filters low-play rows, and stops below the favourite threshold. |
77
  | `discover` | Walks mirror search/list surfaces for ranked/approved/loved/qualified candidates and promotes sets to `wanted` when at least `--min-quorum` independent mirrors agree. Use after `enumerate` to catch cached sets not surfaced by official API search. |
78
  | `scan` | Walks `--archives-dir`, parses `<set_id>.osz` filenames, marks each as `success` in the state DB. Optional `--verify` opens each archive and walks its zip entries; corrupt files stay pending. |
79
  | `download` | Runs a bounded greedy worker pool. Each idle worker claims the next `pending wanted` row in `set_id` order and cycles mirrors per-set. See **Failure modes** below for the resilience guarantees. |
 
73
 
74
  | Command | What it does |
75
  |---|---|
76
+ | `enumerate` | Paginates `/api/v2/beatmapsets/search?m={mode}&s={status}&sort=updated_desc` for each requested status, upserts every beatmapset into `sets`. Cursor checkpoints saved per-status after each successful page → can resume mid-run. **Incremental by default**: each run saves a `last_updated` high-water mark and the next run stops paginating once it crosses that mark; pass `--full-rescan` to re-walk everything. For popular maps, use `--statuses any --sort favourites-desc --min-favourites 100 --min-playcount 1000 --stateless`; that walks the favourite-sorted prefix, filters low-play rows, persists matching set IDs as normal wanted rows, and stops below the favourite threshold. Because it is stateless, repeating it re-queries the popular prefix but does not re-download already-successful rows. |
77
  | `discover` | Walks mirror search/list surfaces for ranked/approved/loved/qualified candidates and promotes sets to `wanted` when at least `--min-quorum` independent mirrors agree. Use after `enumerate` to catch cached sets not surfaced by official API search. |
78
  | `scan` | Walks `--archives-dir`, parses `<set_id>.osz` filenames, marks each as `success` in the state DB. Optional `--verify` opens each archive and walks its zip entries; corrupt files stay pending. |
79
  | `download` | Runs a bounded greedy worker pool. Each idle worker claims the next `pending wanted` row in `set_id` order and cycles mirrors per-set. See **Failure modes** below for the resilience guarantees. |
docs/PIPELINE_RUNBOOK.md CHANGED
@@ -117,8 +117,20 @@ sorts by `favourites_desc` and stops when the page stream falls below
117
  `POPULAR_MIN_FAVOURITES`, while also filtering out rows below
118
  `POPULAR_MIN_PLAYCOUNT`. This is intentionally more expensive than the normal
119
  updated-desc enumerate, but it walks only the popular prefix rather than the
120
- whole search catalog. Set `POPULAR=0` to disable it for a quick maintenance
121
- run.
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  ## Metadata Compaction
124
 
@@ -268,6 +280,10 @@ drains. That second pass is skipped when `DOWNLOAD_LIMIT` is set so smoke-test
268
  limits remain meaningful. Rows that all mirrors reported absent are left alone
269
  unless you set `RETRY_MISSING=1`.
270
 
 
 
 
 
271
  If ingest is interrupted, rerun the same script with a fresh `BATCH_ID`.
272
  Committed archives are skipped by SHA-256. An incomplete chunk has no
273
  `archive_revisions` commit marker and is retried.
 
117
  `POPULAR_MIN_FAVOURITES`, while also filtering out rows below
118
  `POPULAR_MIN_PLAYCOUNT`. This is intentionally more expensive than the normal
119
  updated-desc enumerate, but it walks only the popular prefix rather than the
120
+ whole search catalog.
121
+
122
+ The popular sweep persists its results as normal wanted rows in the fetcher
123
+ state DB, so already-acquired popular sets are not downloaded again. The sweep
124
+ itself is still stateless: it does not store a popular-sweep cursor, high-water
125
+ mark, or "completed recently" checkpoint. Each normal update reruns the
126
+ favourite-sorted API walk and idempotently upserts rows it has already seen.
127
+
128
+ Set `POPULAR=0` for retry-only or quick maintenance runs, especially when the
129
+ goal is just to retry failed downloads already present in `state/fetcher`.
130
+
131
+ ```bash
132
+ POPULAR=0 DOWNLOAD_CONCURRENCY=4 bash scripts/update_maps_v1.sh
133
+ ```
134
 
135
  ## Metadata Compaction
136
 
 
280
  limits remain meaningful. Rows that all mirrors reported absent are left alone
281
  unless you set `RETRY_MISSING=1`.
282
 
283
+ For a failed-download retry run where you do not want to re-walk the popular
284
+ favourites prefix, set `POPULAR=0`. Existing wanted rows and failed rows remain
285
+ in the hydrated fetcher state DB.
286
+
287
  If ingest is interrupted, rerun the same script with a fresh `BATCH_ID`.
288
  Committed archives are skipped by SHA-256. An incomplete chunk has no
289
  `archive_revisions` commit marker and is retried.
docs/osu_fetcher_guide.md CHANGED
@@ -25,10 +25,22 @@ The script:
25
 
26
  - hydrates compact `data/`, `schemas/`, and fetcher state from the bucket;
27
  - seeds existing compact beatmapset IDs as already acquired;
28
- - runs osu! API enumeration and a small ranked-front scan;
 
29
  - downloads only pending new or changed sets to `incoming_osz/`;
30
  - ingests the archives, compacts metadata by default, and publishes the update.
31
 
 
 
 
 
 
 
 
 
 
 
 
32
  Archive publication uses `hf buckets sync archives ... --ignore-existing
33
  --no-delete`. The archive prefix is content-addressed and append-only, so a
34
  cancelled upload can be resumed by rerunning the wrapper with `HYDRATE=0` when
 
25
 
26
  - hydrates compact `data/`, `schemas/`, and fetcher state from the bucket;
27
  - seeds existing compact beatmapset IDs as already acquired;
28
+ - runs osu! API enumeration, a small ranked-front scan, and the popular
29
+ favourites sweep unless `POPULAR=0`;
30
  - downloads only pending new or changed sets to `incoming_osz/`;
31
  - ingests the archives, compacts metadata by default, and publishes the update.
32
 
33
+ The popular sweep stores matching set IDs as normal wanted rows in
34
+ `.fetcher/state.db`, but the sweep is stateless. It does not store a cursor or
35
+ "already completed" marker, because favourite/play counts can change without a
36
+ beatmapset `last_updated` change. Normal updates rerun the favourite-sorted
37
+ prefix and upsert already-known rows idempotently. For retry-only runs, skip
38
+ that API walk:
39
+
40
+ ```bash
41
+ POPULAR=0 DOWNLOAD_CONCURRENCY=4 bash scripts/update_maps_v1.sh
42
+ ```
43
+
44
  Archive publication uses `hf buckets sync archives ... --ignore-existing
45
  --no-delete`. The archive prefix is content-addressed and append-only, so a
46
  cancelled upload can be resumed by rerunning the wrapper with `HYDRATE=0` when