JinchuanTian commited on
Commit
559f0ce
·
verified ·
1 Parent(s): 821f04a

Publish completed release report, anonymous preparation checks, and tested recovery tools

Browse files
COMPLETED_PUBLIC_PREPARATION.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "repo": "espnet/Bagpiper_SFT_Data_ESPnet",
4
+ "revision": "4a258e780a1697be5b6476a14edd7c257d8df350",
5
+ "downloaded_helper": true,
6
+ "anonymous": true,
7
+ "completed_release_preparation": true
8
+ },
9
+ {
10
+ "repo": "espnet/Bagpiper_TTS_SFT_Data_ESPnet",
11
+ "revision": "821f04a8a4a6f4aaccc74ef7d7d39d54bc12d759",
12
+ "downloaded_helper": true,
13
+ "anonymous": true,
14
+ "completed_release_preparation": true
15
+ }
16
+ ]
CONVERSION.md CHANGED
@@ -26,3 +26,17 @@ Download preparation is portable and independent of that audit workspace. Run pr
26
  No audio resampling, PCM conversion or lossy recompression occurs. This format conversion does not change source dataset licenses, original source selection or paper-v1/v2 alignment.
27
 
28
  Use a separate `--work-root` for a new conversion and the same directory when resuming. The finalizer also accepts `--root` pointing to that work directory. The production general-SFT run started with six fixed source ranges per partition. After completing about half the conversion, unconverted work was split into smaller ranges while copying each parent stream's validated audio and ID state. STREAM_PLAN.json records the active ranges; STREAM_PLAN.before-rebalance.json and REBALANCE.json document the transition. Rebalancing was performed with production workers stopped, and every source shard belongs to exactly one active range. Independent ranges can repeat an audio file in multiple archives; extraction verifies and merges identical content. Per-archive unique_audio_added counts are stream-local and must not be summed as the final count of distinct audio files. Final validation separately computes global unique IDs/audio hashes. Incomplete trials are restricted to contiguous uploaded prefixes.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  No audio resampling, PCM conversion or lossy recompression occurs. This format conversion does not change source dataset licenses, original source selection or paper-v1/v2 alignment.
27
 
28
  Use a separate `--work-root` for a new conversion and the same directory when resuming. The finalizer also accepts `--root` pointing to that work directory. The production general-SFT run started with six fixed source ranges per partition. After completing about half the conversion, unconverted work was split into smaller ranges while copying each parent stream's validated audio and ID state. STREAM_PLAN.json records the active ranges; STREAM_PLAN.before-rebalance.json and REBALANCE.json document the transition. Rebalancing was performed with production workers stopped, and every source shard belongs to exactly one active range. Independent ranges can repeat an audio file in multiple archives; extraction verifies and merges identical content. Per-archive unique_audio_added counts are stream-local and must not be summed as the final count of distinct audio files. Final validation separately computes global unique IDs/audio hashes. Incomplete trials are restricted to contiguous uploaded prefixes.
29
+
30
+ ## Large-release Hub publication
31
+
32
+ The full general release exceeded the Hub's hourly repository-commit allowance with small archive batches. Continue converting/preuploading without repository commits, then run the batch publisher in another terminal:
33
+
34
+ ```bash
35
+ python convert_release.py --upload --dataset general --partition-parallel --lanes 6 --batch-shards 24 --download-workers 3 --defer-commit
36
+ HF_HUB_DISABLE_XET=1 python commit_staged_release.py --dataset general --batch-shards 256 --interval 60
37
+ python finalize_release.py --dataset general
38
+ ```
39
+
40
+ The staging command does not mark blobs as publicly uploaded and never deletes its archives. `preuploads.sqlite3` checkpoints storage preuploads. The batch publisher uses standard LFS existence checks for the already-preuploaded Xet blobs, commits up to 256 files plus aggregate status, verifies remote archive sizes and SHA256, and respects server rate limits. This avoids repeating expensive Xet chunk processing during the commit step. Both processes use the same work directory. Finalize only after both finish; finalization checks every source row and remote archive before declaring a complete release. Once the workers finish and every archive has been verified on the Hub, local pending archives can be removed.
41
+
42
+ Seven regression tests cover cross-shard deduplication, transactional rollback, parallel resume, parent audio references after rebalancing, commit/verification/status retries, and staging without premature uploaded flags. Public-download validation compares 5,932 rows and 12 decoded waveforms with pinned originals; these checks supplement the eight-partition sample validation and full inventory/hash reconciliation.
FINAL_REPORT.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "state": "complete",
3
+ "completed_at": "2026-10-01T01:31:49.992586+00:00",
4
+ "releases": [
5
+ {
6
+ "repository": "espnet/Bagpiper_SFT_Data_ESPnet",
7
+ "rows": 2667017,
8
+ "shards": 6804,
9
+ "archive_bytes": 719295381339,
10
+ "unique_audio_files": 1313767,
11
+ "unique_audio_scope": "partition_and_sha256",
12
+ "source_revision": "7dec4d68dc30e442368914619668fcd695a897f7",
13
+ "verified_archives_revision": "ddc7d626fecf295a0cc6c71d0515aa2e8bd2a0bf"
14
+ },
15
+ {
16
+ "repository": "espnet/Bagpiper_TTS_SFT_Data_ESPnet",
17
+ "rows": 738123,
18
+ "shards": 1151,
19
+ "archive_bytes": 252559973183,
20
+ "unique_audio_files": 734969,
21
+ "unique_audio_scope": "partition_and_sha256",
22
+ "source_revision": "f0eb112765d33f30ff6136a6fa5feaa84ca79880",
23
+ "verified_archives_revision": "589d441d96e842087a64e6f3a120e4bc78130e16"
24
+ }
25
+ ],
26
+ "validation": {
27
+ "source_and_remote_hashes": "all shards and archives verified",
28
+ "public_download_rows_compared": 5932,
29
+ "public_decoded_waveforms_compared": 12,
30
+ "all_partition_sample_rows_compared": 3814,
31
+ "all_partition_decoded_waveforms_compared": 24,
32
+ "converter_regression_tests_passed": 7,
33
+ "published_helpers_anonymously_downloaded_and_prepared": true,
34
+ "gpu_training_or_inference_validated": false
35
+ },
36
+ "preservation": {
37
+ "all_source_rows": true,
38
+ "original_audio_bytes": true,
39
+ "text_and_role_order": true,
40
+ "source_provenance": true,
41
+ "original_repositories_retained": true
42
+ },
43
+ "general_source_selection": "public recipe-v1; paper-v2 selection unchanged"
44
+ }
FINAL_REPORT.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Completed Bagpiper SFT format conversion
2
+
3
+ Both original SFT datasets are fully converted and publicly uploaded in portable lossless ESPnet dialogue format.
4
+
5
+ | Release | Preserved rows | Verified archives | Converted archive bytes |
6
+ | --- | ---: | ---: | ---: |
7
+ | [Bagpiper SFT](https://huggingface.co/datasets/espnet/Bagpiper_SFT_Data_ESPnet) | 2,667,017 | 6,804 | 719,295,381,339 |
8
+ | [Bagpiper-TTS SFT](https://huggingface.co/datasets/espnet/Bagpiper_TTS_SFT_Data_ESPnet) | 738,123 | 1,151 | 252,559,973,183 |
9
+
10
+ See FINAL_REPORT.json and each release's RELEASE_VALIDATION.json for precise statistics and pinned source revisions. Original encoded audio bytes, all rows, ordered text and roles, and provenance are preserved. Duplicate audio storage is removed within conversion streams; extraction verifies and merges identical files across streams. Original source repositories remain available. Their data cards now link directly to the converted training format.
11
+
12
+ The publicly downloaded preparation helper safely extracts audio, resolves local paths, checks global IDs and provenance linkage, and writes ESPnet all/train/valid manifests. The optional suggested validation split uses audio SHA256; all.json preserves the original complete pool. Source data terms and recipe-v1/paper-v2 selection are unchanged.
13
+
14
+ All source and remote archive hashes were reconciled. Actual ESPnet reading and exact original-versus-converted waveforms passed for the documented samples. Seven regression tests pass. No GPU training or inference was performed.
15
+
16
+ ESPnet recipe preparation documentation is ready as local commit 22666931398cecebf7c0646ca091b26fdacc559d and recipe-preparation.patch. GitHub publication was blocked by automatic approval review because the saved credential source was not specifically authorized; the permission question remains pending. This does not affect either completed Hugging Face release.
commit_staged_release.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Commit preuploaded bundles in large batches, respecting Hub rate limits."""
3
+ import argparse
4
+ from datetime import datetime, timezone
5
+ import json
6
+ from pathlib import Path
7
+ import sqlite3
8
+ import time
9
+
10
+ from huggingface_hub import CommitOperationAdd, HfApi, get_token
11
+ from huggingface_hub.errors import HfHubHTTPError
12
+ from huggingface_hub.utils import disable_progress_bars
13
+
14
+ from convert_release import RECIPES, status_document
15
+
16
+
17
+ def main():
18
+ disable_progress_bars()
19
+ parser = argparse.ArgumentParser(description=__doc__)
20
+ parser.add_argument("--dataset", choices=list(RECIPES), required=True)
21
+ parser.add_argument(
22
+ "--root", type=Path, default=Path("/root/bagpiper-sft-conversion/releases")
23
+ )
24
+ parser.add_argument("--batch-shards", type=int, default=256)
25
+ parser.add_argument("--interval", type=int, default=60)
26
+ args = parser.parse_args()
27
+ recipe = RECIPES[args.dataset]
28
+ root = args.root / args.dataset
29
+ manifest = json.loads((root / "SOURCE_MANIFEST.json").read_text())
30
+ inventory = manifest["shards"]
31
+ api = HfApi(token=get_token())
32
+ connection = sqlite3.connect(root / "conversion.sqlite3", timeout=120)
33
+ # Recover archives that were committed before a transient verification or
34
+ # STATUS error. Local files remain while conversion/preuploads are active.
35
+ remote = {
36
+ f.path: f
37
+ for f in api.list_repo_tree(
38
+ recipe["target"], repo_type="dataset", recursive=True
39
+ )
40
+ if hasattr(f, "size") and f.path.endswith(".tar.zst")
41
+ }
42
+ recovered = 0
43
+ for path, raw in connection.execute(
44
+ "SELECT path,record FROM shards WHERE uploaded=0"
45
+ ).fetchall():
46
+ record = json.loads(raw)
47
+ file = remote.get(record["archive_path"])
48
+ if file is not None:
49
+ assert (
50
+ file.size == record["archive_bytes"]
51
+ and file.lfs.sha256 == record["archive_sha256"]
52
+ )
53
+ connection.execute("UPDATE shards SET uploaded=1 WHERE path=?", (path,))
54
+ recovered += 1
55
+ connection.commit()
56
+ print(
57
+ json.dumps(dict(event="recovered_remote_commits", shards=recovered)), flush=True
58
+ )
59
+ retry_at = 0
60
+ while True:
61
+ uploaded = [
62
+ json.loads(r)
63
+ for r, in connection.execute(
64
+ "SELECT record FROM shards WHERE uploaded=1 ORDER BY path"
65
+ )
66
+ ]
67
+ if len(uploaded) == len(inventory):
68
+ print(
69
+ json.dumps(
70
+ dict(
71
+ event="all_archives_committed_verified",
72
+ shards=len(uploaded),
73
+ rows=sum(r["rows"] for r in uploaded),
74
+ )
75
+ ),
76
+ flush=True,
77
+ )
78
+ return
79
+ pending = [
80
+ json.loads(r)
81
+ for r, in connection.execute(
82
+ "SELECT record FROM shards WHERE uploaded=0 ORDER BY path"
83
+ )
84
+ ]
85
+ staged_path = root / "preuploads.sqlite3"
86
+ if not staged_path.exists():
87
+ time.sleep(20)
88
+ continue
89
+ staged = sqlite3.connect(staged_path, timeout=120)
90
+ staged_rows = {
91
+ p: (sha, size)
92
+ for p, sha, size in staged.execute("SELECT path,sha,size FROM blobs")
93
+ }
94
+ staged.close()
95
+ ready = [
96
+ r
97
+ for r in pending
98
+ if staged_rows.get(r["archive_path"])
99
+ == (r["archive_sha256"], r["archive_bytes"])
100
+ ][: args.batch_shards]
101
+ if not ready or time.time() < retry_at:
102
+ time.sleep(20)
103
+ continue
104
+ status = status_document(
105
+ recipe, manifest["revision"], inventory, uploaded + ready, "converting"
106
+ )
107
+ operations = [
108
+ CommitOperationAdd(
109
+ path_in_repo=r["archive_path"], path_or_fileobj=root / r["archive_path"]
110
+ )
111
+ for r in ready
112
+ ]
113
+ operations.append(
114
+ CommitOperationAdd(
115
+ path_in_repo="STATUS.json",
116
+ path_or_fileobj=(json.dumps(status, indent=2) + "\n").encode(),
117
+ )
118
+ )
119
+ try:
120
+ commit = api.create_commit(
121
+ recipe["target"],
122
+ repo_type="dataset",
123
+ operations=operations,
124
+ commit_message=f"Publish {len(ready)} verified preuploaded bundles ({len(uploaded)+len(ready)}/{len(inventory)})",
125
+ num_threads=4,
126
+ )
127
+ except HfHubHTTPError as error:
128
+ response = error.response
129
+ if response is None or response.status_code != 429:
130
+ raise
131
+ # Never hammer a limited commit endpoint. Use a server-provided
132
+ # retry delay when available, otherwise retry only after a minute.
133
+ delay = max(60, float(response.headers.get("Retry-After", 60)))
134
+ retry_at = time.time() + delay
135
+ print(
136
+ json.dumps(
137
+ dict(
138
+ event="commit_rate_limited",
139
+ retry_at=datetime.fromtimestamp(
140
+ retry_at, timezone.utc
141
+ ).isoformat(),
142
+ )
143
+ ),
144
+ flush=True,
145
+ )
146
+ continue
147
+ files = {
148
+ f.path: f
149
+ for f in api.get_paths_info(
150
+ recipe["target"],
151
+ [r["archive_path"] for r in ready],
152
+ repo_type="dataset",
153
+ revision=commit.oid,
154
+ )
155
+ }
156
+ for r in ready:
157
+ f = files[r["archive_path"]]
158
+ assert f.size == r["archive_bytes"] and f.lfs.sha256 == r["archive_sha256"]
159
+ connection.execute(
160
+ "UPDATE shards SET uploaded=1 WHERE path=?", (r["source_path"],)
161
+ )
162
+ connection.commit()
163
+ (root / "STATUS.json").write_text(json.dumps(status, indent=2) + "\n")
164
+ print(
165
+ json.dumps(
166
+ dict(
167
+ event="batch_committed_verified",
168
+ shards=len(ready),
169
+ total=len(uploaded) + len(ready),
170
+ revision=commit.oid,
171
+ )
172
+ ),
173
+ flush=True,
174
+ )
175
+ retry_at = time.time() + args.interval
176
+
177
+
178
+ if __name__ == "__main__":
179
+ main()
convert_release.py CHANGED
@@ -380,6 +380,39 @@ ESPnet recipes: [Bagpiper](https://github.com/jctian98/espnet/tree/bagpiper-e2e-
380
 
381
  def upload_batch(api, recipe, revision, inventory, records, previous):
382
  root = Path(recipe["root"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  commit_revision = None
384
  for attempt in range(8):
385
  try:
@@ -617,15 +650,21 @@ def convert_partition(
617
  pending,
618
  [],
619
  )
620
- for r in pending:
621
- state.execute(
622
- "UPDATE shards SET uploaded=1 WHERE path=?", (r["source_path"],)
623
- )
624
- state.commit()
 
 
625
  print(
626
  json.dumps(
627
  dict(
628
- event="uploaded",
 
 
 
 
629
  partition=partition,
630
  batch=len(pending),
631
  commit=commit,
@@ -633,8 +672,9 @@ def convert_partition(
633
  ),
634
  flush=True,
635
  )
636
- for r in pending:
637
- (root / r["archive_path"]).unlink(missing_ok=True)
 
638
  pending = []
639
  aggregate.close()
640
  state.close()
@@ -694,6 +734,20 @@ def run_partition_parallel(recipe, revision, inventory, workers, batch_shards, l
694
  flush=True,
695
  )
696
  connection = sqlite3.connect(root / "conversion.sqlite3")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  records = [
698
  json.loads(r[0])
699
  for r in connection.execute(
@@ -741,10 +795,16 @@ def main():
741
  parser.add_argument("--download-workers", type=int, default=4)
742
  parser.add_argument("--partition-parallel", action="store_true")
743
  parser.add_argument("--lanes", type=int, default=1)
 
 
 
 
 
744
  args = parser.parse_args()
745
  api = HfApi(token=get_token())
746
  for name in args.dataset or ["tts", "general"]:
747
  recipe = dict(RECIPES[name])
 
748
  revision, inventory = read_inventory(recipe["snapshot"])
749
  if args.local_samples:
750
  candidates = {
@@ -782,7 +842,7 @@ def main():
782
  pinned.write_text(json.dumps(document, indent=2) + "\n")
783
  (root / "README.md").write_text(readme(recipe, revision))
784
  scripts = Path(__file__).resolve().parent
785
- if args.upload:
786
  api.create_repo(
787
  recipe["target"], repo_type="dataset", private=False, exist_ok=True
788
  )
@@ -836,6 +896,10 @@ def main():
836
  args.lanes,
837
  )
838
  continue
 
 
 
 
839
  known = {
840
  r[0]: bool(r[1])
841
  for r in connection.execute("SELECT path,uploaded FROM shards")
 
380
 
381
  def upload_batch(api, recipe, revision, inventory, records, previous):
382
  root = Path(recipe["root"])
383
+ if recipe.get("defer_commit"):
384
+ staged = sqlite3.connect(root / "preuploads.sqlite3", timeout=120)
385
+ staged.execute(
386
+ "CREATE TABLE IF NOT EXISTS blobs (path TEXT PRIMARY KEY,sha TEXT,size INTEGER)"
387
+ )
388
+ known = {
389
+ p: (h, n) for p, h, n in staged.execute("SELECT path,sha,size FROM blobs")
390
+ }
391
+ additions = [
392
+ CommitOperationAdd(
393
+ path_in_repo=r["archive_path"], path_or_fileobj=root / r["archive_path"]
394
+ )
395
+ for r in records
396
+ if known.get(r["archive_path"]) != (r["archive_sha256"], r["archive_bytes"])
397
+ ]
398
+ if additions:
399
+ with UPLOAD_SLOTS:
400
+ api.preupload_lfs_files(
401
+ recipe["target"],
402
+ additions=additions,
403
+ repo_type="dataset",
404
+ num_threads=4,
405
+ )
406
+ staged.executemany(
407
+ "INSERT OR REPLACE INTO blobs VALUES (?,?,?)",
408
+ [
409
+ (r["archive_path"], r["archive_sha256"], r["archive_bytes"])
410
+ for r in records
411
+ ],
412
+ )
413
+ staged.commit()
414
+ staged.close()
415
+ return "preuploaded-awaiting-batched-commit"
416
  commit_revision = None
417
  for attempt in range(8):
418
  try:
 
650
  pending,
651
  [],
652
  )
653
+ if not recipe.get("defer_commit"):
654
+ for r in pending:
655
+ state.execute(
656
+ "UPDATE shards SET uploaded=1 WHERE path=?",
657
+ (r["source_path"],),
658
+ )
659
+ state.commit()
660
  print(
661
  json.dumps(
662
  dict(
663
+ event=(
664
+ "preuploaded"
665
+ if recipe.get("defer_commit")
666
+ else "uploaded"
667
+ ),
668
  partition=partition,
669
  batch=len(pending),
670
  commit=commit,
 
672
  ),
673
  flush=True,
674
  )
675
+ if not recipe.get("defer_commit"):
676
+ for r in pending:
677
+ (root / r["archive_path"]).unlink(missing_ok=True)
678
  pending = []
679
  aggregate.close()
680
  state.close()
 
734
  flush=True,
735
  )
736
  connection = sqlite3.connect(root / "conversion.sqlite3")
737
+ if recipe.get("defer_commit"):
738
+ count, rows = connection.execute(
739
+ "SELECT count(*),sum(json_extract(record,'$.rows')) FROM shards"
740
+ ).fetchone()
741
+ connection.close()
742
+ if count != len(inventory) or rows != sum(r["rows"] for r in inventory):
743
+ raise ValueError("Final staged conversion count mismatch")
744
+ print(
745
+ json.dumps(
746
+ dict(event="staged_conversion_finished", rows=rows, shards=count)
747
+ ),
748
+ flush=True,
749
+ )
750
+ return
751
  records = [
752
  json.loads(r[0])
753
  for r in connection.execute(
 
795
  parser.add_argument("--download-workers", type=int, default=4)
796
  parser.add_argument("--partition-parallel", action="store_true")
797
  parser.add_argument("--lanes", type=int, default=1)
798
+ parser.add_argument(
799
+ "--defer-commit",
800
+ action="store_true",
801
+ help="Convert/preupload only; keep archives for later batched commits",
802
+ )
803
  args = parser.parse_args()
804
  api = HfApi(token=get_token())
805
  for name in args.dataset or ["tts", "general"]:
806
  recipe = dict(RECIPES[name])
807
+ recipe["defer_commit"] = args.defer_commit
808
  revision, inventory = read_inventory(recipe["snapshot"])
809
  if args.local_samples:
810
  candidates = {
 
842
  pinned.write_text(json.dumps(document, indent=2) + "\n")
843
  (root / "README.md").write_text(readme(recipe, revision))
844
  scripts = Path(__file__).resolve().parent
845
+ if args.upload and not args.defer_commit:
846
  api.create_repo(
847
  recipe["target"], repo_type="dataset", private=False, exist_ok=True
848
  )
 
896
  args.lanes,
897
  )
898
  continue
899
+ if args.defer_commit:
900
+ raise ValueError(
901
+ "--defer-commit requires production --upload --partition-parallel"
902
+ )
903
  known = {
904
  r[0]: bool(r[1])
905
  for r in connection.execute("SELECT path,uploaded FROM shards")
finalize_release.py CHANGED
@@ -158,6 +158,13 @@ def main():
158
  status["validation"] = "RELEASE_VALIDATION.json"
159
  (root / "STATUS.json").write_text(json.dumps(status, indent=2) + "\n")
160
  card = readme(recipe, pinned["revision"])
 
 
 
 
 
 
 
161
  card = card.replace(
162
  "**Check `STATUS.json`: the release is usable in full only when `state` is `complete`.** An explicit prefix trial is possible while conversion is in progress.",
163
  f"**Complete:** all {unique_ids:,} source rows and {len(bundles):,} shards are converted and uploaded. "
@@ -197,6 +204,11 @@ def main():
197
  path_or_fileobj=root / "STREAM_PLAN.json",
198
  )
199
  )
 
 
 
 
 
200
  scripts = Path(__file__).resolve().parent
201
  for name in [
202
  "prepare_espnet.py",
@@ -207,6 +219,10 @@ def main():
207
  "test_converter.py",
208
  "validate_public_release.py",
209
  "PUBLIC_DOWNLOAD_VALIDATION.json",
 
 
 
 
210
  ]:
211
  operations.append(
212
  CommitOperationAdd(path_in_repo=name, path_or_fileobj=scripts / name)
 
158
  status["validation"] = "RELEASE_VALIDATION.json"
159
  (root / "STATUS.json").write_text(json.dumps(status, indent=2) + "\n")
160
  card = readme(recipe, pinned["revision"])
161
+ if args.dataset == "general":
162
+ card = card.replace(
163
+ "\nEach `.tar.zst`",
164
+ "\n**Source selection:** this preserves the public recipe-v1 pool (including "
165
+ "1,193,006 understanding rows). It does not reconstruct the paper-v2 filtered selection.\n\nEach `.tar.zst`",
166
+ 1,
167
+ )
168
  card = card.replace(
169
  "**Check `STATUS.json`: the release is usable in full only when `state` is `complete`.** An explicit prefix trial is possible while conversion is in progress.",
170
  f"**Complete:** all {unique_ids:,} source rows and {len(bundles):,} shards are converted and uploaded. "
 
204
  path_or_fileobj=root / "STREAM_PLAN.json",
205
  )
206
  )
207
+ for name in ["STREAM_PLAN.before-rebalance.json", "REBALANCE.json"]:
208
+ if (root / name).exists():
209
+ operations.append(
210
+ CommitOperationAdd(path_in_repo=name, path_or_fileobj=root / name)
211
+ )
212
  scripts = Path(__file__).resolve().parent
213
  for name in [
214
  "prepare_espnet.py",
 
219
  "test_converter.py",
220
  "validate_public_release.py",
221
  "PUBLIC_DOWNLOAD_VALIDATION.json",
222
+ "rebalance_streams.py",
223
+ "link_source_release.py",
224
+ "commit_staged_release.py",
225
+ "recipe-preparation.patch",
226
  ]:
227
  operations.append(
228
  CommitOperationAdd(path_in_repo=name, path_or_fileobj=scripts / name)
test_converter.py CHANGED
@@ -238,6 +238,7 @@ def test_upload_retry_does_not_reuse_committed_operations(
238
  source, inventory, tmp_path, state, "repo", "revision"
239
  )
240
  state.close()
 
241
  monkeypatch.setattr(converter.time, "sleep", lambda _: None)
242
 
243
  class Api:
@@ -291,3 +292,44 @@ def test_upload_retry_does_not_reuse_committed_operations(
291
  state = sqlite3.connect(tmp_path / "conversion.sqlite3")
292
  assert state.execute("SELECT uploaded FROM shards").fetchone()[0] == 1
293
  state.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  source, inventory, tmp_path, state, "repo", "revision"
239
  )
240
  state.close()
241
+
242
  monkeypatch.setattr(converter.time, "sleep", lambda _: None)
243
 
244
  class Api:
 
292
  state = sqlite3.connect(tmp_path / "conversion.sqlite3")
293
  assert state.execute("SELECT uploaded FROM shards").fetchone()[0] == 1
294
  state.close()
295
+
296
+
297
+ def test_staged_conversion_keeps_archives_uncommitted(tmp_path, monkeypatch):
298
+ source = tmp_path / "source"
299
+ root = tmp_path / "release"
300
+ root.mkdir()
301
+ inventory = [
302
+ make_source(source, "generation", i, [f"row:{i}"])[1] for i in range(2)
303
+ ]
304
+ converter.open_database(root / "conversion.sqlite3").close()
305
+ monkeypatch.setattr(
306
+ converter,
307
+ "download_shard",
308
+ lambda repo, revision, item, root, local_source: (source / item["path"], False),
309
+ )
310
+ uploaded = []
311
+
312
+ class Api:
313
+ def preupload_lfs_files(self, *args, additions, **kwargs):
314
+ uploaded.extend(op.path_in_repo for op in additions)
315
+
316
+ monkeypatch.setattr(converter, "HfApi", lambda **kwargs: Api())
317
+ recipe = dict(
318
+ root=str(root),
319
+ source="source",
320
+ target="target",
321
+ snapshot="sft_data",
322
+ defer_commit=True,
323
+ )
324
+ converter.convert_partition(recipe, "revision", inventory, "generation", 2, 2)
325
+ state = sqlite3.connect(root / "conversion.sqlite3")
326
+ records = [
327
+ json.loads(r)
328
+ for r, in state.execute("SELECT record FROM shards WHERE uploaded=0")
329
+ ]
330
+ assert len(records) == 2 and len(uploaded) == 2
331
+ assert all((root / r["archive_path"]).exists() for r in records)
332
+ staged = sqlite3.connect(root / "preuploads.sqlite3")
333
+ assert staged.execute("SELECT count(*) FROM blobs").fetchone()[0] == 2
334
+ converter.convert_partition(recipe, "revision", inventory, "generation", 2, 2)
335
+ assert len(uploaded) == 2