Commit 6dc4535
Resolve issue #23: expose benchmark_codes and standardize task identity
Closes #23. The FormulaCode website's `npm run sync` script needs benchmark
source code, a queryable task identifier, the level-aggregation statistic,
and (optionally) `benchmark_type` exposed by `api.formulacode.org`. This
change lands all four, and along the way collapses the two competing
`task_id` string formats (`owner__repo-N` in publish, `owner_repo_N` in
harbor_adapter) into a single integer alias of `issue_number`, with
`(owner, repo, issue_number)` as the canonical row identity everywhere.
New Supabase tables / columns
- `benchmark_codes(owner, repo, benchmark_without_params, source, ...)` —
public-read; populated by stage 9.
- `candidate_containers.task_id` — generated column = issue_number.
- `benchmark_information.benchmark_type` — generated column derived from
the ASV `time_*`/`timeraw_*`/`mem_*`/`peakmem_*`/`track_*` convention.
New pipeline stage 9 `scrape_benchmark_source`
- Reuses `prepare_repo_checkout` / AST traversal under each repo's
`benchmark_dir` (resolved from `asv.conf.json` when present) to extract
per-function source + co-located `setup` / `setup_cache`.
- Idempotent upsert keyed on (owner, repo, benchmark_without_params).
- Tunables: `DATASMITH_BENCH_SCRAPE_MAX_FILE_BYTES`,
`DATASMITH_BENCH_SCRAPE_DIRS`.
task_id collapse
- `FormulaCodeRecord.task_id` is now `int` = `issue_number` across
`github.models`, `publish.records`, `publish.huggingface`, and
`harbor_adapter.{records,adapter,utils,template/*}`.
- Harbor templates pass `OWNER`/`REPO`/`ISSUE_NUMBER` to `upload.py` /
`parser.py`; storage layout moves from `snapshots/{task_id}/...` to
`snapshots/{owner}/{repo}/{issue_number}/...`; Supabase queries on the
`tasks` table switch to a composite filter.
- Harbor task directory layout uses a derived `task_dir_name`
(`owner__repo__issue_number`) so Harbor's flat-dataset discovery and
trial-name patching keep working.
Companion scripts (apply once against Harbor's Supabase, not datasmith's)
- `scripts/harbor_tasks_migration.sql` — backfill `owner/repo/issue_number`
from legacy task_id strings, swap the PK to the triple, retain
`task_id` as a deprecated mirror.
- `scripts/migrate_snapshot_keys.py` — rename existing
`snapshots/{old_task_id}/oracle.tar.gz` objects under the new prefix.
Defaults to `--dry-run`; pass `--apply` to commit.
Docs
- CLAUDE.md gains the new table, stage 9, tunables, and a "Level
aggregation" subsection documenting the geomean rollup
(`harbor_adapter/template/parser.py:158-204`) — the answer the issue
explicitly asks for.
Verification
- `make check` clean (ruff + mypy + deptry).
- `pytest tests/scrape tests/publish tests/github` — 108 passing,
including a new AST-extraction test against an inline ASV fixture.
- Migrations 00016/00017/00019/00020 applied locally; schema introspection
confirms generated columns produce expected values (35,152
benchmark_information rows resolved to `time`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 89efaad commit 6dc4535
32 files changed
Lines changed: 1314 additions & 82 deletions
File tree
- scripts
- src/datasmith
- github
- harbor_adapter
- template
- publish
- runners
- scrape
- update
- supabase/migrations
- tests
- github
- publish
- scrape
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | | - | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| |||
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
173 | 192 | | |
174 | 193 | | |
175 | 194 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
0 commit comments