Spaces:
Sleeping

PERDYPTO commited on
Commit
b71dec9
·
verified ·
1 Parent(s): 804bc4d

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +0 -83
pipeline.py CHANGED
@@ -185,17 +185,6 @@ DATASETS = [
185
  "repo_fields": [],
186
  "path_fields": [],
187
  "license_fields": [],
188
- },
189
- {
190
- "name": "mbpp",
191
- "dataset": "google-research-datasets/mbpp",
192
- "config": None,
193
- "split": "train",
194
- "kind": "generic",
195
- "text_fields": ["code", "text"],
196
- "repo_fields": [],
197
- "path_fields": [],
198
- "license_fields": [],
199
  }
200
  ]
201
 
@@ -344,25 +333,12 @@ def worker_process_task(task: Dict[str, Any]) -> Dict[str, Any]:
344
  all_fields.update(ds_info.get("repo_fields", []))
345
  all_fields.update(ds_info.get("path_fields", []))
346
  all_fields.update(ds_info.get("license_fields", []))
347
- # Some datasets have nested fields; we'll just load all and then access safely.
348
- # But to avoid casting errors, we can load without specifying columns.
349
- # The error was due to a struct field that couldn't cast to null.
350
- # We'll load all columns and then ignore extra ones during processing.
351
- # To be safe, we use `columns` to select only the ones we know, but if the
352
- # dataset schema has other fields that cause errors, we might still fail.
353
- # Alternative: use `features` to explicitly define schema. We'll skip columns
354
- # parameter and handle missing fields gracefully.
355
- # Actually, the error was for a field that was a struct and the schema expected null.
356
- # That likely came from a field not in our list. So we will load only the columns
357
- # we need. But we must ensure that the dataset supports column selection.
358
- # We'll attempt to load with `select_columns` after loading.
359
 
360
  # Build load_kwargs
361
  load_kwargs = {
362
  "path": ds_info["dataset"],
363
  "split": ds_info["split"],
364
  "streaming": True,
365
- "trust_remote_code": True,
366
  }
367
  if ds_info.get("config"):
368
  load_kwargs["name"] = ds_info["config"]
@@ -508,65 +484,6 @@ def run_pipeline():
508
  verified_dir.mkdir(parents=True, exist_ok=True)
509
  rejected_dir.mkdir(parents=True, exist_ok=True)
510
 
511
- # For each dataset, we need to partition the data.
512
- # We'll use the underlying shards count if available, but we don't know it.
513
- # We'll just create a single task that processes the whole dataset.
514
- # However, for large datasets, we want to parallelize.
515
- # We'll split by record count: we'll create tasks of size ~50,000 records.
516
- # But we need to know the total length, which we don't have in streaming.
517
- # Alternative: we can split by number of shards (if dataset has shards).
518
- # We'll use the `num_shards` if we can get it, else we'll use a single task.
519
- # For simplicity, we'll use a single task per dataset, but we can split if we know.
520
- # The user had many shards, so we can split by shard index if we know the shard count.
521
- # We'll implement a simple split: use 2 tasks per dataset by default.
522
- # But we want to avoid overloading memory, so we'll limit records per worker.
523
- # We'll set a max_records_per_task = 100_000.
524
- # We'll create tasks accordingly by iterating the dataset once to count? That's inefficient.
525
- # Instead, we'll let each task process a chunk of records by using the `take` or `skip`? Not straightforward.
526
- # In streaming, we can use `ds.shard`? But we don't know total.
527
- # We'll use `ds.iter` and break after max_records.
528
- # However, we need to resume from previous checkpoint? Not needed if we start fresh.
529
- # We'll just create tasks that process a fixed number of records, but we need to know where to start.
530
- # We'll create tasks with start and end offsets, but we need to skip records.
531
- # We can use `itertools.islice` to skip records, but that's slow.
532
-
533
- # Given the complexity, we'll revert to a simpler approach: one task per dataset.
534
- # With MAX_WORKERS=4, we can process multiple datasets concurrently.
535
- # But we want to process datasets in parallel? The user may want to process multiple datasets at once.
536
- # We'll create a task for each dataset and submit them all to the executor.
537
- # However, some datasets are huge (like starcoderdata), we might want to split.
538
- # For now, we'll use one task per dataset to keep it simple.
539
-
540
- # But we need to handle the case where a dataset is too large and may cause memory issues.
541
- # We'll set a per-worker record limit, but we don't know total.
542
-
543
- # Given the user's request for master-worker, we'll process each dataset as a task.
544
- # But we can also split starcoderdata into multiple tasks by using shard indices if available.
545
- # We'll detect if the dataset supports sharding via `num_shards`. Not always available.
546
-
547
- # We'll implement a fallback: if the dataset is known to be large (like starcoderdata),
548
- # we can split it into 2 tasks by using the `split` parameter with a slice? Not possible.
549
- # We'll use a hack: we'll create tasks that process a range of records by using `take` and `skip`
550
- # on the iterable. But that requires knowing total count or doing multiple passes.
551
-
552
- # Considering the errors, we'll just process each dataset in a single task for now.
553
- # We'll rely on the worker to iterate all rows and return results.
554
- # To avoid memory blow, we'll limit the number of records returned by the worker
555
- # by setting a cap. But we can't easily cap without knowing total.
556
-
557
- # We'll implement a streaming worker that yields results in batches to master.
558
- # But that requires inter-process communication with a queue.
559
-
560
- # Given time, we'll simplify: each worker processes the whole dataset and returns
561
- # the lists. For starcoderdata (450k records), that might be okay (450k * ~1KB = 450MB).
562
- # Might be high but possible. We'll trust the memory.
563
-
564
- # We'll submit tasks for all datasets and let the executor handle them.
565
- # However, we need to aggregate dedup across all datasets, so master must process
566
- # results as they come, and update global sets.
567
-
568
- # We'll create tasks for each dataset.
569
- # We'll also include dataset info.
570
  tasks = []
571
  for ds_info in DATASETS:
572
  # We can optionally split into multiple tasks by shard ranges if we know shard count.
 
185
  "repo_fields": [],
186
  "path_fields": [],
187
  "license_fields": [],
 
 
 
 
 
 
 
 
 
 
 
188
  }
189
  ]
190
 
 
333
  all_fields.update(ds_info.get("repo_fields", []))
334
  all_fields.update(ds_info.get("path_fields", []))
335
  all_fields.update(ds_info.get("license_fields", []))
 
 
 
 
 
 
 
 
 
 
 
 
336
 
337
  # Build load_kwargs
338
  load_kwargs = {
339
  "path": ds_info["dataset"],
340
  "split": ds_info["split"],
341
  "streaming": True,
 
342
  }
343
  if ds_info.get("config"):
344
  load_kwargs["name"] = ds_info["config"]
 
484
  verified_dir.mkdir(parents=True, exist_ok=True)
485
  rejected_dir.mkdir(parents=True, exist_ok=True)
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  tasks = []
488
  for ds_info in DATASETS:
489
  # We can optionally split into multiple tasks by shard ranges if we know shard count.