Datasets:
Document Stack v3.1 selection; verified shard upload in progress
Browse files- reproduction/extract_stack_v3_subset.py +26 -25
- selection_config.json +1 -1
reproduction/extract_stack_v3_subset.py
CHANGED
|
@@ -331,6 +331,8 @@ def main():
|
|
| 331 |
parser.add_argument('--pilot-indices', type=int, nargs='*')
|
| 332 |
parser.add_argument('--self-test', action='store_true')
|
| 333 |
args = parser.parse_args()
|
|
|
|
|
|
|
| 334 |
pa.set_cpu_count(1); pa.set_io_thread_count(1)
|
| 335 |
if args.self_test:
|
| 336 |
self_test(); return
|
|
@@ -353,36 +355,35 @@ def main():
|
|
| 353 |
process = {'status': 'running', 'host': socket.gethostname(), 'pid': os.getpid(), 'pgid': os.getpgrp(),
|
| 354 |
'start_ticks': Path('/proc/self/stat').read_text().split()[21], 'started_utc': now(),
|
| 355 |
'command': sys.argv, 'interpreter': sys.executable, 'workers': args.workers,
|
| 356 |
-
'memory_gib_per_worker': args.memory_gib_per_worker, '
|
|
|
|
| 357 |
'plan_sha256': digest(args.plan), 'code_sha256': {n: digest(Path(__file__).parent / n) for n in
|
| 358 |
('extract_stack_v3_subset.py', 'analyze_stack_v3_recipes.py', 'estimate_stack_v3_lengths.py')}}
|
| 359 |
save(out / 'extraction_process.json', process)
|
| 360 |
results = {}
|
| 361 |
try:
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
save(out / 'extraction_progress.json', progress)
|
| 385 |
-
print(json.dumps(progress), flush=True)
|
| 386 |
ordered = [results[i] for i in range(len(groups))]
|
| 387 |
sources = [s for r in ordered for s in r['sources']]
|
| 388 |
assert [s['index'] for s in sources] == list(range(len(items)))
|
|
|
|
| 331 |
parser.add_argument('--pilot-indices', type=int, nargs='*')
|
| 332 |
parser.add_argument('--self-test', action='store_true')
|
| 333 |
args = parser.parse_args()
|
| 334 |
+
if args.workers < 1:
|
| 335 |
+
parser.error('--workers must be positive')
|
| 336 |
pa.set_cpu_count(1); pa.set_io_thread_count(1)
|
| 337 |
if args.self_test:
|
| 338 |
self_test(); return
|
|
|
|
| 355 |
process = {'status': 'running', 'host': socket.gethostname(), 'pid': os.getpid(), 'pgid': os.getpgrp(),
|
| 356 |
'start_ticks': Path('/proc/self/stat').read_text().split()[21], 'started_utc': now(),
|
| 357 |
'command': sys.argv, 'interpreter': sys.executable, 'workers': args.workers,
|
| 358 |
+
'memory_gib_per_worker': args.memory_gib_per_worker, 'worker_lifecycle': 'fresh pool after each bounded wave',
|
| 359 |
+
'source_manifest_sha256': digest(out / 'source_manifest.json'),
|
| 360 |
'plan_sha256': digest(args.plan), 'code_sha256': {n: digest(Path(__file__).parent / n) for n in
|
| 361 |
('extract_stack_v3_subset.py', 'analyze_stack_v3_recipes.py', 'estimate_stack_v3_lengths.py')}}
|
| 362 |
save(out / 'extraction_process.json', process)
|
| 363 |
results = {}
|
| 364 |
try:
|
| 365 |
+
# Recycle the worker pool after each bounded wave. Arrow can retain
|
| 366 |
+
# virtual arenas across tasks even when resident memory has been freed;
|
| 367 |
+
# fresh pools keep that reservation within the per-worker address cap.
|
| 368 |
+
# Python 3.10's ProcessPoolExecutor lacks max_tasks_per_child.
|
| 369 |
+
for start_id in range(0, len(groups), args.workers):
|
| 370 |
+
with ProcessPoolExecutor(max_workers=args.workers, mp_context=mp.get_context('spawn'),
|
| 371 |
+
initializer=initialize, initargs=(str(args.plan), args.memory_gib_per_worker)) as pool:
|
| 372 |
+
pending = {pool.submit(process_partition, i, groups[i], str(Path(config['dataset_dir']) / 'data'), len(groups)): i
|
| 373 |
+
for i in range(start_id, min(start_id + args.workers, len(groups)))}
|
| 374 |
+
while pending:
|
| 375 |
+
done, _ = wait(pending, timeout=15, return_when=FIRST_COMPLETED)
|
| 376 |
+
for future in done:
|
| 377 |
+
i = pending.pop(future)
|
| 378 |
+
results[i] = future.result()
|
| 379 |
+
progress = {'status': 'running', 'updated_utc': now(), 'partitions_done': len(results),
|
| 380 |
+
'partitions_total': len(groups), 'active_partitions': list(pending.values()),
|
| 381 |
+
'source_shards_done': sum(len(r['source_indices']) for r in results.values()),
|
| 382 |
+
'rows': sum(r['rows'] for r in results.values()),
|
| 383 |
+
'estimated_tokens': sum(r['estimated_tokens'] for r in results.values()),
|
| 384 |
+
'output_bytes': sum(r['output_bytes'] for r in results.values()), 'elapsed_seconds': time.monotonic() - started}
|
| 385 |
+
save(out / 'extraction_progress.json', progress)
|
| 386 |
+
print(json.dumps(progress), flush=True)
|
|
|
|
|
|
|
| 387 |
ordered = [results[i] for i in range(len(groups))]
|
| 388 |
sources = [s for r in ordered for s in r['sources']]
|
| 389 |
assert [s['index'] for s in sources] == list(range(len(items)))
|
selection_config.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
"code_sha256": {
|
| 7 |
"analyze_stack_v3_recipes.py": "70b03a8fdcb46e4acc794647aae5be618a5cb239cef20be15569b40f14bf9757",
|
| 8 |
"estimate_stack_v3_lengths.py": "381dcecda13c2e74665cc762b4c00671e046b0c2659fc94916918290cc18e8f3",
|
| 9 |
-
"extract_stack_v3_subset.py": "
|
| 10 |
"linguist-LICENSE": "7717070c5a8c85440ff2312930bb30dd19002ab5bc235c9800042767f6f5242f",
|
| 11 |
"linguist-languages.yml": "0c82627ad17a5901c36453aa068330f062668e156bbffc181c1d89ecb1e1e761",
|
| 12 |
"reproduce_stack_v3_subset.py": "e9d7b2b97add83dd59ddc2b98a80a4b0c3c279efcc5be95429c2869fb270d2af",
|
|
|
|
| 6 |
"code_sha256": {
|
| 7 |
"analyze_stack_v3_recipes.py": "70b03a8fdcb46e4acc794647aae5be618a5cb239cef20be15569b40f14bf9757",
|
| 8 |
"estimate_stack_v3_lengths.py": "381dcecda13c2e74665cc762b4c00671e046b0c2659fc94916918290cc18e8f3",
|
| 9 |
+
"extract_stack_v3_subset.py": "6eb3af7c4e3051643ab059104e5c0cd7aa2a4a904dec26d09887f488a577ee9d",
|
| 10 |
"linguist-LICENSE": "7717070c5a8c85440ff2312930bb30dd19002ab5bc235c9800042767f6f5242f",
|
| 11 |
"linguist-languages.yml": "0c82627ad17a5901c36453aa068330f062668e156bbffc181c1d89ecb1e1e761",
|
| 12 |
"reproduce_stack_v3_subset.py": "e9d7b2b97add83dd59ddc2b98a80a4b0c3c279efcc5be95429c2869fb270d2af",
|