auxiliarag commited on
Commit
a450c7f
·
verified ·
1 Parent(s): 98fac1e

Fix multi-config loading with uniform JSONL files

Browse files

Add a deterministic tidy metric_rows JSONL mirror and point both Hugging Face configs to JSONL files. The approved benchmark values, nested evaluations, CSV download, CC BY 4.0 license, disclosure, and campaign backlink are unchanged. Adds regression coverage for config-format compatibility and exact CSV/JSONL equivalence.

Makefile CHANGED
@@ -35,7 +35,8 @@ validate:
35
  fi
36
 
37
  hashes:
38
- @sha256sum $(EVALS) $(DATA)/benchmarks.csv $(DATA)/benchmarks.jsonl $(DATA)/summary.json README.md LICENSE
 
39
 
40
  help:
41
  @sed -n '1,13p' Makefile
 
35
  fi
36
 
37
  hashes:
38
+ @sha256sum $(EVALS) $(DATA)/metric_rows.jsonl $(DATA)/benchmarks.csv \
39
+ $(DATA)/benchmarks.jsonl $(DATA)/summary.json README.md LICENSE
40
 
41
  help:
42
  @sed -n '1,13p' Makefile
README.md CHANGED
@@ -19,7 +19,7 @@ configs:
19
  - config_name: metric_rows
20
  data_files:
21
  - split: train
22
- path: data/benchmarks.csv
23
  - config_name: evaluations
24
  data_files:
25
  - split: train
@@ -52,19 +52,38 @@ unchanged — three scorecards in this snapshot sit below 2.0 out of 10, and two
52
 
53
  ## Dataset structure
54
 
55
- Two views of the same 67 scorecards. Nothing is aggregated or re-scored between them.
 
56
 
57
- | Config | File | Rows | Grain |
58
  | --- | --- | --- | --- |
59
- | `metric_rows` | `data/benchmarks.csv` | 297 | one row per provider × capability × metric (tidy/long) |
60
  | `evaluations` | `data/benchmarks.jsonl` | 67 | one record per provider × capability, metrics nested |
61
 
62
- `data/summary.json` carries the computed snapshot facts (counts, date range, source
63
- hash, per-capability inventories). Every figure in it is derived by the generator.
 
 
64
 
65
- ### `data/benchmarks.csv` — tidy metric rows
66
 
67
- | Column | Type | Description |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  | --- | --- | --- |
69
  | `evaluation_id` | string | `{provider_id}:{capability_id}`, unique per scorecard |
70
  | `provider_id` | string | Provider slug as published by the source |
@@ -90,9 +109,43 @@ hash, per-capability inventories). Every figure in it is derived by the generato
90
  | `source_url` | url | `https://nativeport.ai/evals.json` |
91
  | `snapshot_sha256` | string | SHA-256 of the exact source snapshot these rows came from |
92
 
93
- Provenance columns repeat on every row so that a filtered slice stays interpretable
 
 
 
 
 
 
94
  and verifiable on its own.
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  ### `data/benchmarks.jsonl` — one record per evaluation
97
 
98
  ```json
@@ -196,13 +249,21 @@ rows = load_dataset("nativeport/web-access-api-benchmarks", "metric_rows", split
196
  evals = load_dataset("nativeport/web-access-api-benchmarks", "evaluations", split="train")
197
  ```
198
 
 
 
 
199
  Cheapest search provider that clears a recall floor — the typical routing question,
200
  answered from the tidy view with pandas:
201
 
202
  ```python
203
  import pandas as pd
204
 
205
- df = pd.read_csv("hf://datasets/nativeport/web-access-api-benchmarks/data/benchmarks.csv")
 
 
 
 
 
206
  search = df[df.capability_id == "search"]
207
 
208
  wide = search.pivot_table(
@@ -298,8 +359,10 @@ bytes produce byte-identical outputs. No wall-clock timestamp is written anywher
298
  a rebuild can be diffed directly against the published files. Numeric values are
299
  carried across as exact source tokens — the generator verifies that each emitted
300
  number serialises character-for-character back to the token it read, and aborts rather
301
- than emit a rounded stand-in. `data/summary.json` records the SHA-256 of both data
302
- files.
 
 
303
 
304
  Fields present in the source but **excluded by design**: gateway routing and
305
  authentication strings, list prices, latency prose, marketing summaries,
@@ -342,6 +405,11 @@ measurements and the provenance needed to interpret them are published here.
342
  numbers are not silently rewritten in place.
343
  - Schema changes that are not backward compatible will be described in the commit that
344
  makes them and reflected in the tables above.
 
 
 
 
 
345
  - No update cadence is promised here. `measured_date` and `run_id` are on every row
346
  precisely so a consumer can decide for itself whether the snapshot is still fresh
347
  enough to act on.
 
19
  - config_name: metric_rows
20
  data_files:
21
  - split: train
22
+ path: data/metric_rows.jsonl
23
  - config_name: evaluations
24
  data_files:
25
  - split: train
 
52
 
53
  ## Dataset structure
54
 
55
+ Two configs, two views of the same 67 scorecards. Nothing is aggregated or re-scored
56
+ between them.
57
 
58
+ | Config | File | Records | Grain |
59
  | --- | --- | --- | --- |
60
+ | `metric_rows` | `data/metric_rows.jsonl` | 297 | one record per provider × capability × metric (tidy/long) |
61
  | `evaluations` | `data/benchmarks.jsonl` | 67 | one record per provider × capability, metrics nested |
62
 
63
+ Both configs are JSONL deliberately. The Hub resolves a single packaged loader for the
64
+ whole repository from the declared config data files and then applies it to every
65
+ config, so a repository that mixes formats across its configs ends up parsing one of
66
+ them with the other's reader.
67
 
68
+ Two more files ship alongside them and back no config:
69
 
70
+ | File | Rows | What it is |
71
+ | --- | --- | --- |
72
+ | `data/benchmarks.csv` | 297 | the tidy view as CSV — same rows, same field order, same values as `data/metric_rows.jsonl` |
73
+ | `data/summary.json` | — | computed snapshot facts: counts, date range, source hash, per-capability and per-metric inventories, artifact digests |
74
+
75
+ `data/benchmarks.csv` is a download rather than a config. `load_dataset` never reads it,
76
+ but `pd.read_csv("hf://datasets/nativeport/web-access-api-benchmarks/data/benchmarks.csv")`,
77
+ `huggingface_hub.hf_hub_download` and a plain browser download all do. Both tidy files
78
+ are written in one pass from one row builder, so they cannot drift; the test suite
79
+ compares them field by field across all 297 rows, including the exact text of every
80
+ number. Every figure in `data/summary.json` is derived by the generator, never typed.
81
+
82
+ ### `data/metric_rows.jsonl` and `data/benchmarks.csv` — tidy metric rows
83
+
84
+ Both carry these 23 fields, in this order:
85
+
86
+ | Field | Type | Description |
87
  | --- | --- | --- |
88
  | `evaluation_id` | string | `{provider_id}:{capability_id}`, unique per scorecard |
89
  | `provider_id` | string | Provider slug as published by the source |
 
109
  | `source_url` | url | `https://nativeport.ai/evals.json` |
110
  | `snapshot_sha256` | string | SHA-256 of the exact source snapshot these rows came from |
111
 
112
+ In `data/metric_rows.jsonl` the types above are the JSON types: `metric_raw` and
113
+ `composite_score` are JSON numbers, `metric_index` / `rank` / `rank_of` /
114
+ `composite_scale_max` are integers, and `is_capability_top` is a boolean. CSV has no
115
+ types, so `data/benchmarks.csv` carries the same values as text — numbers written as
116
+ the exact source token, booleans as `true` / `false`.
117
+
118
+ Provenance fields repeat on every row so that a filtered slice stays interpretable
119
  and verifiable on its own.
120
 
121
+ ```json
122
+ {
123
+ "evaluation_id": "serper:serp",
124
+ "provider_id": "serper",
125
+ "provider_name": "Serper",
126
+ "provider_group": "Search",
127
+ "provider_category": "Google SERP scrape",
128
+ "capability_id": "serp",
129
+ "capability_label": "SERP verticals",
130
+ "metric_key": "latency_p50_ms",
131
+ "metric_label": "Latency p50",
132
+ "metric_raw": 886.0,
133
+ "metric_display": "886 ms",
134
+ "metric_index": 1,
135
+ "composite_score": 9.13,
136
+ "composite_scale_max": 10,
137
+ "rank": 1,
138
+ "rank_of": 4,
139
+ "is_capability_top": true,
140
+ "measured_date": "2026-08-05",
141
+ "note": "Lowest cost and latency; Google only.",
142
+ "provider_page_url": "https://nativeport.ai/providers/serper/",
143
+ "run_id": "2026-08-05",
144
+ "source_url": "https://nativeport.ai/evals.json",
145
+ "snapshot_sha256": "f46bf416803d5adf696c66ac14a6cbf06f4dfa39727cca164e8f3872abd6ed9b"
146
+ }
147
+ ```
148
+
149
  ### `data/benchmarks.jsonl` — one record per evaluation
150
 
151
  ```json
 
249
  evals = load_dataset("nativeport/web-access-api-benchmarks", "evaluations", split="train")
250
  ```
251
 
252
+ Both configs load as JSON Lines. `rows` has the 23 flat fields listed above, `evals` the
253
+ nested `metrics` list.
254
+
255
  Cheapest search provider that clears a recall floor — the typical routing question,
256
  answered from the tidy view with pandas:
257
 
258
  ```python
259
  import pandas as pd
260
 
261
+ df = pd.read_json(
262
+ "hf://datasets/nativeport/web-access-api-benchmarks/data/metric_rows.jsonl", lines=True
263
+ )
264
+ # The CSV mirror gives the same frame, for tools that prefer a spreadsheet:
265
+ # df = pd.read_csv("hf://datasets/nativeport/web-access-api-benchmarks/data/benchmarks.csv")
266
+
267
  search = df[df.capability_id == "search"]
268
 
269
  wide = search.pivot_table(
 
359
  a rebuild can be diffed directly against the published files. Numeric values are
360
  carried across as exact source tokens — the generator verifies that each emitted
361
  number serialises character-for-character back to the token it read, and aborts rather
362
+ than emit a rounded stand-in. That same serialiser writes the CSV cell and the JSON
363
+ number, which is why the two tidy files agree token for token. `data/summary.json`
364
+ records the SHA-256 of all three data files, together with the config-to-file mapping
365
+ the front matter declares.
366
 
367
  Fields present in the source but **excluded by design**: gateway routing and
368
  authentication strings, list prices, latency prose, marketing summaries,
 
405
  numbers are not silently rewritten in place.
406
  - Schema changes that are not backward compatible will be described in the commit that
407
  makes them and reflected in the tables above.
408
+ - File layout, for anyone who loaded an earlier revision: the `metric_rows` config is
409
+ backed by `data/metric_rows.jsonl`. It previously pointed at `data/benchmarks.csv`,
410
+ which left the two configs in different formats and made the Hub read one of them
411
+ with the wrong parser. No row, field or measured value changed — only the file the
412
+ config resolves to — and `data/benchmarks.csv` still ships, unchanged, as a download.
413
  - No update cadence is promised here. `measured_date` and `run_id` are on every row
414
  precisely so a consumer can decide for itself whether the snapshot is still fresh
415
  enough to act on.
data/metric_rows.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/summary.json CHANGED
@@ -876,7 +876,49 @@
876
  ]
877
  }
878
  ],
 
 
 
 
 
 
 
 
 
 
879
  "outputs": {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  "benchmarks.csv": {
881
  "kind": "csv",
882
  "data_rows": 297,
@@ -906,6 +948,7 @@
906
  "source_url",
907
  "snapshot_sha256"
908
  ],
 
909
  "bytes": 101064,
910
  "sha256": "6153966709823465ffa1c369b4e48170d793bbece92a25938dd63fec9bd5ceb9"
911
  },
 
876
  ]
877
  }
878
  ],
879
+ "hub_config_data_files": {
880
+ "metric_rows": "data/metric_rows.jsonl",
881
+ "evaluations": "data/benchmarks.jsonl"
882
+ },
883
+ "hub_config_data_file_format": [
884
+ "jsonl"
885
+ ],
886
+ "downloadable_only_artifacts": [
887
+ "data/benchmarks.csv"
888
+ ],
889
  "outputs": {
890
+ "metric_rows.jsonl": {
891
+ "kind": "jsonl",
892
+ "records": 297,
893
+ "fields": 23,
894
+ "field_names": [
895
+ "evaluation_id",
896
+ "provider_id",
897
+ "provider_name",
898
+ "provider_group",
899
+ "provider_category",
900
+ "capability_id",
901
+ "capability_label",
902
+ "metric_key",
903
+ "metric_label",
904
+ "metric_raw",
905
+ "metric_display",
906
+ "metric_index",
907
+ "composite_score",
908
+ "composite_scale_max",
909
+ "rank",
910
+ "rank_of",
911
+ "is_capability_top",
912
+ "measured_date",
913
+ "note",
914
+ "provider_page_url",
915
+ "run_id",
916
+ "source_url",
917
+ "snapshot_sha256"
918
+ ],
919
+ "bytes": 228423,
920
+ "sha256": "0f9f2a8c395997579fce91123e9c0996a7d164c91a581acbef5bc956739aacda"
921
+ },
922
  "benchmarks.csv": {
923
  "kind": "csv",
924
  "data_rows": 297,
 
948
  "source_url",
949
  "snapshot_sha256"
950
  ],
951
+ "mirrors": "metric_rows.jsonl",
952
  "bytes": 101064,
953
  "sha256": "6153966709823465ffa1c369b4e48170d793bbece92a25938dd63fec9bd5ceb9"
954
  },
scripts/build_dataset.py CHANGED
@@ -1,12 +1,22 @@
1
  #!/usr/bin/env python3
2
  """Deterministic generator for the NativePort Web-Access API Benchmarks dataset.
3
 
4
- Reads a NativePort ``evals.json`` snapshot and writes three artifacts:
5
 
6
- data/benchmarks.csv tidy/long form, one row per provider x capability x metric
7
- data/benchmarks.jsonl one record per provider x capability evaluation
 
8
  data/summary.json computed snapshot facts (every count is derived, never typed)
9
 
 
 
 
 
 
 
 
 
 
10
  Design rules
11
  ------------
12
  * Standard library only.
@@ -48,7 +58,29 @@ LEADERBOARDS_URL = "https://nativeport.ai/leaderboards/"
48
  # has to assume the scale.
49
  COMPOSITE_SCALE_MAX = 10
50
 
51
- CSV_COLUMNS = [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  "evaluation_id",
53
  "provider_id",
54
  "provider_name",
@@ -309,41 +341,91 @@ def extract_evaluations(document, snapshot_sha256):
309
  # writers
310
  # --------------------------------------------------------------------------- #
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  def write_csv(evaluations, path):
313
  rows = 0
314
  with path.open("w", encoding="utf-8", newline="") as handle:
315
  writer = csv.writer(handle, lineterminator="\n", quoting=csv.QUOTE_MINIMAL)
316
- writer.writerow(CSV_COLUMNS)
317
- for evaluation in evaluations:
318
- for metric in evaluation["metrics"]:
319
- writer.writerow(
320
- [
321
- evaluation["evaluation_id"],
322
- evaluation["provider_id"],
323
- evaluation["provider_name"],
324
- evaluation["provider_group"],
325
- evaluation["provider_category"],
326
- evaluation["capability_id"],
327
- evaluation["capability_label"],
328
- metric["metric_key"],
329
- metric["metric_label"],
330
- metric["raw_text"],
331
- metric["display_value"],
332
- metric["metric_index"],
333
- evaluation["composite_text"],
334
- evaluation["composite_scale_max"],
335
- evaluation["rank_text"],
336
- evaluation["rank_of_text"],
337
- "true" if evaluation["is_capability_top"] else "false",
338
- evaluation["measured_date"],
339
- evaluation["note"],
340
- evaluation["provider_page_url"],
341
- evaluation["run_id"],
342
- evaluation["source_url"],
343
- evaluation["snapshot_sha256"],
344
- ]
345
- )
346
- rows += 1
347
  return rows
348
 
349
 
@@ -396,8 +478,14 @@ def sha256_of(path):
396
  return hashlib.sha256(path.read_bytes()).hexdigest()
397
 
398
 
399
- def build_summary(evaluations, meta, csv_path, jsonl_path, csv_rows, jsonl_records, source_bytes):
400
- """Every figure here is computed from the extracted rows."""
 
 
 
 
 
 
401
  provider_ids = sorted({e["provider_id"] for e in evaluations})
402
  capability_ids = sorted({e["capability_id"] for e in evaluations})
403
  measured_dates = sorted({e["measured_date"] for e in evaluations})
@@ -505,12 +593,26 @@ def build_summary(evaluations, meta, csv_path, jsonl_path, csv_rows, jsonl_recor
505
  "capabilities": capabilities,
506
  "providers": providers,
507
  "metric_keys": metric_keys,
 
 
 
 
 
508
  "outputs": {
 
 
 
 
 
 
 
 
509
  csv_path.name: {
510
  "kind": "csv",
511
  "data_rows": csv_rows,
512
- "columns": len(CSV_COLUMNS),
513
- "column_names": list(CSV_COLUMNS),
 
514
  "bytes": csv_path.stat().st_size,
515
  "sha256": sha256_of(csv_path),
516
  },
@@ -543,14 +645,27 @@ def build(input_path, output_dir):
543
  evaluations, meta = extract_evaluations(document, snapshot_sha256)
544
  require(evaluations, "no evaluations found in the snapshot")
545
 
546
- csv_path = output_dir / "benchmarks.csv"
547
- jsonl_path = output_dir / "benchmarks.jsonl"
548
- summary_path = output_dir / "summary.json"
 
549
 
 
550
  csv_rows = write_csv(evaluations, csv_path)
551
  jsonl_records = write_jsonl(evaluations, jsonl_path)
 
 
 
 
552
  summary = build_summary(
553
- evaluations, meta, csv_path, jsonl_path, csv_rows, jsonl_records, source_bytes
 
 
 
 
 
 
 
554
  )
555
  write_summary(summary, summary_path)
556
  return summary
@@ -572,7 +687,10 @@ def main(argv=None):
572
  parser.add_argument(
573
  "--output-dir",
574
  default=str(default_output_dir()),
575
- help="Directory to write benchmarks.csv, benchmarks.jsonl and summary.json into.",
 
 
 
576
  )
577
  args = parser.parse_args(argv)
578
 
@@ -598,7 +716,9 @@ def main(argv=None):
598
  entry = outputs[name]
599
  size = entry.get("data_rows", entry.get("records"))
600
  print(f"wrote {name} ({size} rows, {entry['bytes']} bytes) {entry['sha256']}")
601
- print("wrote summary.json")
 
 
602
  return 0
603
 
604
 
 
1
  #!/usr/bin/env python3
2
  """Deterministic generator for the NativePort Web-Access API Benchmarks dataset.
3
 
4
+ Reads a NativePort ``evals.json`` snapshot and writes four artifacts:
5
 
6
+ data/metric_rows.jsonl tidy/long form, one record per provider x capability x metric
7
+ data/benchmarks.csv the same tidy rows as CSV, value for value identical
8
+ data/benchmarks.jsonl one record per provider x capability evaluation, metrics nested
9
  data/summary.json computed snapshot facts (every count is derived, never typed)
10
 
11
+ Both Hugging Face configs declared in README.md front matter are backed by JSONL
12
+ (``metric_rows`` -> data/metric_rows.jsonl, ``evaluations`` -> data/benchmarks.jsonl).
13
+ The Hub resolves a single packaged builder for a whole repository from the declared
14
+ config data files and applies it to every config, so a repository that mixes CSV and
15
+ JSONL across configs has the wrong parser applied to one of them.
16
+ ``data/benchmarks.csv`` therefore stays a plain downloadable artifact and backs no
17
+ config. The tidy CSV and the tidy JSONL are emitted from one row builder, so the two
18
+ cannot drift.
19
+
20
  Design rules
21
  ------------
22
  * Standard library only.
 
58
  # has to assume the scale.
59
  COMPOSITE_SCALE_MAX = 10
60
 
61
+ # Output file names. The tidy view is published twice from one row builder: as JSONL,
62
+ # which backs the `metric_rows` config, and as CSV, which is a downloadable artifact
63
+ # only. See HUB_CONFIG_DATA_FILES below for why the config cannot point at the CSV.
64
+ METRIC_ROWS_JSONL_NAME = "metric_rows.jsonl"
65
+ CSV_NAME = "benchmarks.csv"
66
+ EVALUATIONS_JSONL_NAME = "benchmarks.jsonl"
67
+ SUMMARY_NAME = "summary.json"
68
+
69
+ # The Hugging Face configs declared in README.md front matter, and the file backing
70
+ # each one. Both must be JSONL. The Hub resolves one packaged builder for the entire
71
+ # repository from the declared config data files and applies it to every config; mixing
72
+ # formats therefore parses one config with the other's reader. `data/benchmarks.csv` is
73
+ # deliberately absent from this mapping: it ships as a documented download, not as
74
+ # config data.
75
+ HUB_CONFIG_DATA_FILES = {
76
+ "metric_rows": f"data/{METRIC_ROWS_JSONL_NAME}",
77
+ "evaluations": f"data/{EVALUATIONS_JSONL_NAME}",
78
+ }
79
+ DOWNLOADABLE_ONLY_ARTIFACTS = [f"data/{CSV_NAME}"]
80
+
81
+ # Field order of the tidy view. The CSV header and the keys of every record in
82
+ # data/metric_rows.jsonl are this list, in this order.
83
+ TIDY_FIELDS = [
84
  "evaluation_id",
85
  "provider_id",
86
  "provider_name",
 
341
  # writers
342
  # --------------------------------------------------------------------------- #
343
 
344
+ def tidy_record(evaluation, metric):
345
+ """One tidy metric row, typed, with keys in ``TIDY_FIELDS`` order.
346
+
347
+ This is the single definition of the tidy view. ``write_metric_rows_jsonl`` writes
348
+ these values as JSON; ``write_csv`` writes the same values rendered as text by
349
+ ``csv_cell``. Neither view can gain, lose or reorder a field without the other.
350
+ """
351
+ record = {
352
+ "evaluation_id": evaluation["evaluation_id"],
353
+ "provider_id": evaluation["provider_id"],
354
+ "provider_name": evaluation["provider_name"],
355
+ "provider_group": evaluation["provider_group"],
356
+ "provider_category": evaluation["provider_category"],
357
+ "capability_id": evaluation["capability_id"],
358
+ "capability_label": evaluation["capability_label"],
359
+ "metric_key": metric["metric_key"],
360
+ "metric_label": metric["metric_label"],
361
+ "metric_raw": metric["raw_value"],
362
+ "metric_display": metric["display_value"],
363
+ "metric_index": metric["metric_index"],
364
+ "composite_score": evaluation["composite_score"],
365
+ "composite_scale_max": evaluation["composite_scale_max"],
366
+ "rank": evaluation["rank"],
367
+ "rank_of": evaluation["rank_of"],
368
+ "is_capability_top": evaluation["is_capability_top"],
369
+ "measured_date": evaluation["measured_date"],
370
+ "note": evaluation["note"],
371
+ "provider_page_url": evaluation["provider_page_url"],
372
+ "run_id": evaluation["run_id"],
373
+ "source_url": evaluation["source_url"],
374
+ "snapshot_sha256": evaluation["snapshot_sha256"],
375
+ }
376
+ require(
377
+ list(record) == TIDY_FIELDS,
378
+ "tidy record fields drifted from TIDY_FIELDS: "
379
+ f"{[f for f in record if f not in TIDY_FIELDS]} / "
380
+ f"{[f for f in TIDY_FIELDS if f not in record]}",
381
+ )
382
+ return record
383
+
384
+
385
+ def tidy_records(evaluations):
386
+ for evaluation in evaluations:
387
+ for metric in evaluation["metrics"]:
388
+ yield tidy_record(evaluation, metric)
389
+
390
+
391
+ def csv_cell(value):
392
+ """Render one tidy value as CSV text.
393
+
394
+ Numbers go through ``json_number_text``, the same serialiser the JSONL writer uses,
395
+ so a measurement reads identically in both files. ``exact_number`` has already
396
+ proved that this text is the source token character for character.
397
+ """
398
+ if isinstance(value, bool):
399
+ return "true" if value else "false"
400
+ if isinstance(value, (int, float)):
401
+ return json_number_text(value)
402
+ return value
403
+
404
+
405
  def write_csv(evaluations, path):
406
  rows = 0
407
  with path.open("w", encoding="utf-8", newline="") as handle:
408
  writer = csv.writer(handle, lineterminator="\n", quoting=csv.QUOTE_MINIMAL)
409
+ writer.writerow(TIDY_FIELDS)
410
+ for record in tidy_records(evaluations):
411
+ writer.writerow([csv_cell(value) for value in record.values()])
412
+ rows += 1
413
+ return rows
414
+
415
+
416
+ def write_metric_rows_jsonl(evaluations, path):
417
+ """The tidy view as JSONL, one record per metric row.
418
+
419
+ This is what the ``metric_rows`` Hugging Face config loads. It carries the same
420
+ fields as the CSV in the same order, with numbers as JSON numbers and
421
+ ``is_capability_top`` as a JSON boolean.
422
+ """
423
+ rows = 0
424
+ with path.open("w", encoding="utf-8", newline="") as handle:
425
+ for record in tidy_records(evaluations):
426
+ handle.write(json.dumps(record, ensure_ascii=False))
427
+ handle.write("\n")
428
+ rows += 1
 
 
 
 
 
 
 
 
 
 
 
429
  return rows
430
 
431
 
 
478
  return hashlib.sha256(path.read_bytes()).hexdigest()
479
 
480
 
481
+ def build_summary(evaluations, meta, artifacts, source_bytes):
482
+ """Every figure here is computed from the extracted rows.
483
+
484
+ ``artifacts`` maps each written data file to (path, record count).
485
+ """
486
+ (metric_rows_path, metric_rows) = artifacts["metric_rows_jsonl"]
487
+ (csv_path, csv_rows) = artifacts["csv"]
488
+ (jsonl_path, jsonl_records) = artifacts["evaluations_jsonl"]
489
  provider_ids = sorted({e["provider_id"] for e in evaluations})
490
  capability_ids = sorted({e["capability_id"] for e in evaluations})
491
  measured_dates = sorted({e["measured_date"] for e in evaluations})
 
593
  "capabilities": capabilities,
594
  "providers": providers,
595
  "metric_keys": metric_keys,
596
+ "hub_config_data_files": dict(HUB_CONFIG_DATA_FILES),
597
+ "hub_config_data_file_format": sorted(
598
+ {Path(relative).suffix.lstrip(".") for relative in HUB_CONFIG_DATA_FILES.values()}
599
+ ),
600
+ "downloadable_only_artifacts": list(DOWNLOADABLE_ONLY_ARTIFACTS),
601
  "outputs": {
602
+ metric_rows_path.name: {
603
+ "kind": "jsonl",
604
+ "records": metric_rows,
605
+ "fields": len(TIDY_FIELDS),
606
+ "field_names": list(TIDY_FIELDS),
607
+ "bytes": metric_rows_path.stat().st_size,
608
+ "sha256": sha256_of(metric_rows_path),
609
+ },
610
  csv_path.name: {
611
  "kind": "csv",
612
  "data_rows": csv_rows,
613
+ "columns": len(TIDY_FIELDS),
614
+ "column_names": list(TIDY_FIELDS),
615
+ "mirrors": metric_rows_path.name,
616
  "bytes": csv_path.stat().st_size,
617
  "sha256": sha256_of(csv_path),
618
  },
 
645
  evaluations, meta = extract_evaluations(document, snapshot_sha256)
646
  require(evaluations, "no evaluations found in the snapshot")
647
 
648
+ metric_rows_path = output_dir / METRIC_ROWS_JSONL_NAME
649
+ csv_path = output_dir / CSV_NAME
650
+ jsonl_path = output_dir / EVALUATIONS_JSONL_NAME
651
+ summary_path = output_dir / SUMMARY_NAME
652
 
653
+ metric_rows = write_metric_rows_jsonl(evaluations, metric_rows_path)
654
  csv_rows = write_csv(evaluations, csv_path)
655
  jsonl_records = write_jsonl(evaluations, jsonl_path)
656
+ require(
657
+ metric_rows == csv_rows,
658
+ f"tidy views disagree: {metric_rows} JSONL records vs {csv_rows} CSV rows",
659
+ )
660
  summary = build_summary(
661
+ evaluations,
662
+ meta,
663
+ {
664
+ "metric_rows_jsonl": (metric_rows_path, metric_rows),
665
+ "csv": (csv_path, csv_rows),
666
+ "evaluations_jsonl": (jsonl_path, jsonl_records),
667
+ },
668
+ source_bytes,
669
  )
670
  write_summary(summary, summary_path)
671
  return summary
 
687
  parser.add_argument(
688
  "--output-dir",
689
  default=str(default_output_dir()),
690
+ help=(
691
+ f"Directory to write {METRIC_ROWS_JSONL_NAME}, {CSV_NAME}, "
692
+ f"{EVALUATIONS_JSONL_NAME} and {SUMMARY_NAME} into."
693
+ ),
694
  )
695
  args = parser.parse_args(argv)
696
 
 
716
  entry = outputs[name]
717
  size = entry.get("data_rows", entry.get("records"))
718
  print(f"wrote {name} ({size} rows, {entry['bytes']} bytes) {entry['sha256']}")
719
+ print(f"wrote {SUMMARY_NAME}")
720
+ for config_name in sorted(summary["hub_config_data_files"]):
721
+ print(f"hub config {config_name} -> {summary['hub_config_data_files'][config_name]}")
722
  return 0
723
 
724
 
tests/test_dataset.py CHANGED
@@ -27,8 +27,20 @@ from pathlib import Path
27
  ROOT = Path(__file__).resolve().parent.parent
28
  DATA = ROOT / "data"
29
  CSV_PATH = DATA / "benchmarks.csv"
 
30
  JSONL_PATH = DATA / "benchmarks.jsonl"
31
  SUMMARY_PATH = DATA / "summary.json"
 
 
 
 
 
 
 
 
 
 
 
32
  README_PATH = ROOT / "README.md"
33
  LICENSE_PATH = ROOT / "LICENSE"
34
  MAKEFILE_PATH = ROOT / "Makefile"
@@ -63,6 +75,7 @@ CC_BY_4_0_NORMALISED_SHA256 = (
63
  PUBLIC_UPLOAD_SET = (
64
  "README.md",
65
  "LICENSE",
 
66
  "data/benchmarks.csv",
67
  "data/benchmarks.jsonl",
68
  "data/summary.json",
@@ -103,6 +116,20 @@ def read_jsonl_records():
103
  return [json.loads(line) for line in handle]
104
 
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  def read_summary():
107
  return json.loads(SUMMARY_PATH.read_text(encoding="utf-8"))
108
 
@@ -230,7 +257,7 @@ class GeneratorDeterminismTest(unittest.TestCase):
230
  digests.append(
231
  tuple(
232
  sha256_of(out / name)
233
- for name in ("benchmarks.csv", "benchmarks.jsonl", "summary.json")
234
  )
235
  )
236
  self.assertEqual(digests[0], digests[1])
@@ -281,7 +308,7 @@ class GeneratorDeterminismTest(unittest.TestCase):
281
  with tempfile.TemporaryDirectory() as workspace:
282
  out = Path(workspace) / "out"
283
  build_dataset.build(SOURCE_PATH, out)
284
- for name in ("benchmarks.csv", "benchmarks.jsonl", "summary.json"):
285
  self.assertEqual(
286
  sha256_of(out / name),
287
  sha256_of(DATA / name),
@@ -365,10 +392,11 @@ class SchemaAndCountConsistencyTest(unittest.TestCase):
365
  def test_csv_header_matches_the_generator_contract(self):
366
  with CSV_PATH.open(encoding="utf-8", newline="") as handle:
367
  header = next(csv.reader(handle))
368
- self.assertEqual(header, build_dataset.CSV_COLUMNS)
369
 
370
  def test_row_counts_agree_across_artifacts(self):
371
  self.assertEqual(len(self.rows), self.summary["metric_row_count"])
 
372
  self.assertEqual(len(self.records), self.summary["evaluation_count"])
373
  self.assertEqual(
374
  sum(len(record["metrics"]) for record in self.records),
@@ -446,8 +474,9 @@ class SchemaAndCountConsistencyTest(unittest.TestCase):
446
  )
447
 
448
  def test_excluded_commercial_fields_did_not_leak(self):
449
- blob = CSV_PATH.read_text(encoding="utf-8") + JSONL_PATH.read_text(encoding="utf-8")
450
- blob += SUMMARY_PATH.read_text(encoding="utf-8")
 
451
  for field in (
452
  "pricing_entry",
453
  "choose_if",
@@ -461,6 +490,192 @@ class SchemaAndCountConsistencyTest(unittest.TestCase):
461
  self.assertNotIn(field, blob, f"{field} leaked into the published data")
462
 
463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  class RankingIntegrityTest(unittest.TestCase):
465
  def setUp(self):
466
  self.records = read_jsonl_records()
@@ -519,12 +734,9 @@ class UrlPolicyTest(unittest.TestCase):
519
  URL_FIELDS = ("provider_page_url", "source_url")
520
 
521
  def test_data_urls_are_https(self):
522
- for row in read_csv_rows():
523
  for field in self.URL_FIELDS:
524
  self.assertTrue(row[field].startswith("https://"), f"{field}={row[field]}")
525
- for record in read_jsonl_records():
526
- for field in self.URL_FIELDS:
527
- self.assertTrue(record[field].startswith("https://"), f"{field}={record[field]}")
528
 
529
  def test_summary_urls_are_https(self):
530
  summary = read_summary()
@@ -548,8 +760,8 @@ class UrlPolicyTest(unittest.TestCase):
548
  self.assertEqual(offenders, [])
549
 
550
  def test_data_files_carry_no_campaign_tagged_urls(self):
551
- for path in (CSV_PATH, JSONL_PATH, SUMMARY_PATH):
552
- self.assertNotIn("utm_", path.read_text(encoding="utf-8"), path.name)
553
 
554
 
555
  class ReadmeCardTest(unittest.TestCase):
@@ -879,6 +1091,11 @@ class PublicUploadSetTest(unittest.TestCase):
879
  )
880
  self.assertIn("LICENSE", makefile, "make hashes must cover LICENSE")
881
 
 
 
 
 
 
882
 
883
  class NoSecretsOrStandInsTest(unittest.TestCase):
884
  """Patterns are written self-avoidingly so this file can be scanned by its own rules."""
@@ -922,7 +1139,9 @@ class NoSecretsOrStandInsTest(unittest.TestCase):
922
  self.assertEqual(hits, [])
923
 
924
  def test_no_environment_or_key_material_is_referenced_in_the_data(self):
925
- blob = CSV_PATH.read_text(encoding="utf-8") + JSONL_PATH.read_text(encoding="utf-8")
 
 
926
  for needle in ("Bearer", "api.nativeport.ai", "accounts.nativeport.ai", "panel."):
927
  self.assertNotIn(needle, blob, needle)
928
 
 
27
  ROOT = Path(__file__).resolve().parent.parent
28
  DATA = ROOT / "data"
29
  CSV_PATH = DATA / "benchmarks.csv"
30
+ METRIC_ROWS_PATH = DATA / "metric_rows.jsonl"
31
  JSONL_PATH = DATA / "benchmarks.jsonl"
32
  SUMMARY_PATH = DATA / "summary.json"
33
+
34
+ DATA_FILE_NAMES = ("metric_rows.jsonl", "benchmarks.csv", "benchmarks.jsonl", "summary.json")
35
+
36
+ # The Hugging Face configs declared in the card's front matter and the file backing
37
+ # each. Both must be JSONL: the Hub resolves one packaged loader for the whole
38
+ # repository from the declared config data files and applies it to every config, so
39
+ # mixing formats parses one config with the other's reader. The CSV backs no config.
40
+ HUB_CONFIG_DATA_FILES = {
41
+ "metric_rows": "data/metric_rows.jsonl",
42
+ "evaluations": "data/benchmarks.jsonl",
43
+ }
44
  README_PATH = ROOT / "README.md"
45
  LICENSE_PATH = ROOT / "LICENSE"
46
  MAKEFILE_PATH = ROOT / "Makefile"
 
75
  PUBLIC_UPLOAD_SET = (
76
  "README.md",
77
  "LICENSE",
78
+ "data/metric_rows.jsonl",
79
  "data/benchmarks.csv",
80
  "data/benchmarks.jsonl",
81
  "data/summary.json",
 
116
  return [json.loads(line) for line in handle]
117
 
118
 
119
+ def read_metric_row_records():
120
+ with METRIC_ROWS_PATH.open(encoding="utf-8") as handle:
121
+ return [json.loads(line) for line in handle]
122
+
123
+
124
+ def csv_text_of(value):
125
+ """The CSV rendering of one typed tidy value, per the generator's contract."""
126
+ if isinstance(value, bool):
127
+ return "true" if value else "false"
128
+ if isinstance(value, (int, float)):
129
+ return json.dumps(value)
130
+ return value
131
+
132
+
133
  def read_summary():
134
  return json.loads(SUMMARY_PATH.read_text(encoding="utf-8"))
135
 
 
257
  digests.append(
258
  tuple(
259
  sha256_of(out / name)
260
+ for name in DATA_FILE_NAMES
261
  )
262
  )
263
  self.assertEqual(digests[0], digests[1])
 
308
  with tempfile.TemporaryDirectory() as workspace:
309
  out = Path(workspace) / "out"
310
  build_dataset.build(SOURCE_PATH, out)
311
+ for name in DATA_FILE_NAMES:
312
  self.assertEqual(
313
  sha256_of(out / name),
314
  sha256_of(DATA / name),
 
392
  def test_csv_header_matches_the_generator_contract(self):
393
  with CSV_PATH.open(encoding="utf-8", newline="") as handle:
394
  header = next(csv.reader(handle))
395
+ self.assertEqual(header, build_dataset.TIDY_FIELDS)
396
 
397
  def test_row_counts_agree_across_artifacts(self):
398
  self.assertEqual(len(self.rows), self.summary["metric_row_count"])
399
+ self.assertEqual(len(read_metric_row_records()), self.summary["metric_row_count"])
400
  self.assertEqual(len(self.records), self.summary["evaluation_count"])
401
  self.assertEqual(
402
  sum(len(record["metrics"]) for record in self.records),
 
474
  )
475
 
476
  def test_excluded_commercial_fields_did_not_leak(self):
477
+ blob = "".join(
478
+ (DATA / name).read_text(encoding="utf-8") for name in DATA_FILE_NAMES
479
+ )
480
  for field in (
481
  "pricing_entry",
482
  "choose_if",
 
490
  self.assertNotIn(field, blob, f"{field} leaked into the published data")
491
 
492
 
493
+ class HubConfigFormatTest(unittest.TestCase):
494
+ """Both declared configs must be backed by the same data format.
495
+
496
+ The Hub resolves one packaged loader for the whole repository from the declared
497
+ config data files and applies it to every config. A repository that mixes CSV and
498
+ JSONL across configs therefore has one config parsed by the other's reader:
499
+ `load_dataset(..., "evaluations")` failed on the published revision, and the
500
+ datasets-server first-rows call for it failed with it. These tests pin the fix.
501
+ """
502
+
503
+ def setUp(self):
504
+ self.front = README_PATH.read_text(encoding="utf-8")
505
+ self.front = self.front[4 : self.front.find("\n---\n", 4)]
506
+
507
+ def declared_configs(self):
508
+ """(config_name, path) pairs read from the front matter, in declared order."""
509
+ pairs, config_name = [], None
510
+ for line in self.front.splitlines():
511
+ stripped = line.strip()
512
+ if stripped.startswith("- config_name:"):
513
+ config_name = stripped.split(":", 1)[1].strip()
514
+ elif stripped.startswith("path:"):
515
+ pairs.append((config_name, stripped.split(":", 1)[1].strip()))
516
+ return pairs
517
+
518
+ def test_front_matter_declares_the_expected_config_to_file_mapping(self):
519
+ self.assertEqual(dict(self.declared_configs()), HUB_CONFIG_DATA_FILES)
520
+ self.assertEqual(self.declared_configs(), list(HUB_CONFIG_DATA_FILES.items()))
521
+
522
+ def test_generator_and_card_agree_on_the_config_mapping(self):
523
+ self.assertEqual(build_dataset.HUB_CONFIG_DATA_FILES, HUB_CONFIG_DATA_FILES)
524
+ self.assertEqual(read_summary()["hub_config_data_files"], HUB_CONFIG_DATA_FILES)
525
+
526
+ def test_every_config_data_file_is_jsonl(self):
527
+ """The regression itself: one format across all declared configs."""
528
+ suffixes = {Path(path).suffix for _, path in self.declared_configs()}
529
+ self.assertEqual(suffixes, {".jsonl"}, f"configs mix formats: {suffixes}")
530
+ for _, relative in self.declared_configs():
531
+ self.assertTrue((ROOT / relative).is_file(), relative)
532
+
533
+ def test_no_config_points_at_the_csv(self):
534
+ for _, relative in self.declared_configs():
535
+ self.assertNotEqual(relative, "data/benchmarks.csv")
536
+ self.assertEqual(
537
+ read_summary()["downloadable_only_artifacts"], ["data/benchmarks.csv"]
538
+ )
539
+
540
+ def test_every_config_data_file_parses_as_json_lines(self):
541
+ """Not just the extension: every line of every config file is one JSON object."""
542
+ for config_name, relative in self.declared_configs():
543
+ path = ROOT / relative
544
+ with path.open(encoding="utf-8") as handle:
545
+ lines = handle.read().splitlines()
546
+ self.assertTrue(lines, relative)
547
+ for number, line in enumerate(lines, start=1):
548
+ try:
549
+ record = json.loads(line)
550
+ except json.JSONDecodeError as exc:
551
+ self.fail(f"{config_name} ({relative}) line {number}: {exc}")
552
+ self.assertIsInstance(record, dict, f"{relative} line {number}")
553
+
554
+ def test_config_records_are_uniform_in_fields_and_types(self):
555
+ """One type per field across every record.
556
+
557
+ The loader infers one Arrow column type per field from the records it reads. A
558
+ field that is an integer on one line and a float or a string on another is the
559
+ other common way a config loads locally but fails the viewer's first-rows call.
560
+ """
561
+ for config_name, relative in self.declared_configs():
562
+ lines = (ROOT / relative).read_text(encoding="utf-8").splitlines()
563
+ records = [json.loads(line) for line in lines]
564
+ types = {}
565
+ for index, record in enumerate(records):
566
+ self.assertEqual(
567
+ list(record),
568
+ list(records[0]),
569
+ f"{config_name} record {index}: field set or order differs",
570
+ )
571
+ for field, value in record.items():
572
+ types.setdefault(field, set()).add(type(value).__name__)
573
+ mixed = {field: sorted(seen) for field, seen in types.items() if len(seen) > 1}
574
+ self.assertEqual(mixed, {}, f"{config_name}: fields change type between records")
575
+
576
+ def test_csv_is_still_published_as_a_downloadable_artifact(self):
577
+ self.assertTrue(CSV_PATH.is_file())
578
+ self.assertIn("benchmarks.csv", read_summary()["outputs"])
579
+ self.assertIn("data/benchmarks.csv", PUBLIC_UPLOAD_SET)
580
+ readme = " ".join(README_PATH.read_text(encoding="utf-8").split())
581
+ self.assertIn("`data/benchmarks.csv` is a download rather than a config", readme)
582
+ self.assertIn("| `data/benchmarks.csv` | 297 |", readme)
583
+
584
+
585
+ class TidyMirrorEquivalenceTest(unittest.TestCase):
586
+ """data/benchmarks.csv and data/metric_rows.jsonl are the same tidy rows.
587
+
588
+ The CSV is the approved artifact; the JSONL is what the `metric_rows` config loads.
589
+ They are written from one row builder, and these tests hold them to that: same
590
+ fields in the same order, same count, same order of rows, and every value equal —
591
+ numbers compared as text, so a rounded or reformatted measurement fails here.
592
+ """
593
+
594
+ def setUp(self):
595
+ self.rows = read_csv_rows()
596
+ self.records = read_metric_row_records()
597
+
598
+ def test_both_tidy_views_carry_the_same_row_count(self):
599
+ summary = read_summary()
600
+ self.assertEqual(len(self.rows), summary["metric_row_count"])
601
+ self.assertEqual(len(self.records), summary["metric_row_count"])
602
+ self.assertEqual(len(self.rows), len(self.records))
603
+
604
+ def test_field_names_and_order_are_identical(self):
605
+ with CSV_PATH.open(encoding="utf-8", newline="") as handle:
606
+ header = next(csv.reader(handle))
607
+ self.assertEqual(header, build_dataset.TIDY_FIELDS)
608
+ for index, record in enumerate(self.records):
609
+ self.assertEqual(list(record), build_dataset.TIDY_FIELDS, f"record {index}")
610
+
611
+ def test_rows_are_semantically_identical_in_the_same_order(self):
612
+ for index, (row, record) in enumerate(zip(self.rows, self.records)):
613
+ self.assertEqual(
614
+ (record["evaluation_id"], record["metric_key"]),
615
+ (row["evaluation_id"], row["metric_key"]),
616
+ f"row {index}: the two tidy views are ordered differently",
617
+ )
618
+ for field in build_dataset.TIDY_FIELDS:
619
+ self.assertEqual(
620
+ csv_text_of(record[field]),
621
+ row[field],
622
+ f"row {index} field {field}",
623
+ )
624
+
625
+ def test_numbers_are_preserved_exactly_not_reformatted(self):
626
+ """Every numeric field is a JSON number whose text is the CSV token verbatim."""
627
+ numeric = ("metric_raw", "composite_score", "metric_index", "rank", "rank_of",
628
+ "composite_scale_max")
629
+ compared = 0
630
+ for row, record in zip(self.rows, self.records):
631
+ for field in numeric:
632
+ value = record[field]
633
+ self.assertIsInstance(value, (int, float), field)
634
+ self.assertNotIsInstance(value, bool, field)
635
+ self.assertEqual(json.dumps(value), row[field], f"{field} in {row['evaluation_id']}")
636
+ compared += 1
637
+ self.assertIsInstance(record["is_capability_top"], bool)
638
+ self.assertEqual(csv_text_of(record["is_capability_top"]), row["is_capability_top"])
639
+ self.assertEqual(compared, len(self.rows) * len(numeric))
640
+
641
+ def test_tidy_jsonl_agrees_with_the_nested_evaluations(self):
642
+ """The third view must carry the same measurements as the other two."""
643
+ nested = {
644
+ record["evaluation_id"]: {m["metric_key"]: m for m in record["metrics"]}
645
+ for record in read_jsonl_records()
646
+ }
647
+ seen = set()
648
+ for record in self.records:
649
+ metric = nested[record["evaluation_id"]][record["metric_key"]]
650
+ self.assertEqual(json.dumps(record["metric_raw"]), json.dumps(metric["raw_value"]))
651
+ self.assertEqual(record["metric_display"], metric["display_value"])
652
+ self.assertEqual(record["metric_label"], metric["metric_label"])
653
+ self.assertEqual(record["metric_index"], metric["metric_index"])
654
+ seen.add((record["evaluation_id"], record["metric_key"]))
655
+ self.assertEqual(len(seen), len(self.records))
656
+ self.assertEqual(
657
+ len(seen), sum(len(metrics) for metrics in nested.values())
658
+ )
659
+
660
+ def test_generator_emits_both_tidy_views_from_one_builder(self):
661
+ """A fixture build: change nothing, and the two files still agree row for row."""
662
+ with tempfile.TemporaryDirectory() as workspace:
663
+ out = Path(workspace) / "out"
664
+ build_dataset.build(write_fixture(workspace), out)
665
+ with (out / "benchmarks.csv").open(encoding="utf-8", newline="") as handle:
666
+ rows = list(csv.DictReader(handle))
667
+ records = [
668
+ json.loads(line)
669
+ for line in (out / "metric_rows.jsonl").read_text(encoding="utf-8").splitlines()
670
+ ]
671
+ self.assertEqual(len(rows), len(records))
672
+ self.assertEqual(len(rows), 10) # 3 + 4 + 3 metrics in the fixture
673
+ for row, record in zip(rows, records):
674
+ self.assertEqual(list(record), build_dataset.TIDY_FIELDS)
675
+ for field in build_dataset.TIDY_FIELDS:
676
+ self.assertEqual(csv_text_of(record[field]), row[field], field)
677
+
678
+
679
  class RankingIntegrityTest(unittest.TestCase):
680
  def setUp(self):
681
  self.records = read_jsonl_records()
 
734
  URL_FIELDS = ("provider_page_url", "source_url")
735
 
736
  def test_data_urls_are_https(self):
737
+ for row in read_csv_rows() + read_metric_row_records() + read_jsonl_records():
738
  for field in self.URL_FIELDS:
739
  self.assertTrue(row[field].startswith("https://"), f"{field}={row[field]}")
 
 
 
740
 
741
  def test_summary_urls_are_https(self):
742
  summary = read_summary()
 
760
  self.assertEqual(offenders, [])
761
 
762
  def test_data_files_carry_no_campaign_tagged_urls(self):
763
+ for name in DATA_FILE_NAMES:
764
+ self.assertNotIn("utm_", (DATA / name).read_text(encoding="utf-8"), name)
765
 
766
 
767
  class ReadmeCardTest(unittest.TestCase):
 
1091
  )
1092
  self.assertIn("LICENSE", makefile, "make hashes must cover LICENSE")
1093
 
1094
+ def test_make_hashes_covers_every_data_file(self):
1095
+ makefile = MAKEFILE_PATH.read_text(encoding="utf-8")
1096
+ for name in DATA_FILE_NAMES:
1097
+ self.assertIn(name, makefile, f"make hashes must cover {name}")
1098
+
1099
 
1100
  class NoSecretsOrStandInsTest(unittest.TestCase):
1101
  """Patterns are written self-avoidingly so this file can be scanned by its own rules."""
 
1139
  self.assertEqual(hits, [])
1140
 
1141
  def test_no_environment_or_key_material_is_referenced_in_the_data(self):
1142
+ blob = "".join(
1143
+ (DATA / name).read_text(encoding="utf-8") for name in DATA_FILE_NAMES
1144
+ )
1145
  for needle in ("Bearer", "api.nativeport.ai", "accounts.nativeport.ai", "panel."):
1146
  self.assertNotIn(needle, blob, needle)
1147