Delete augment_dataset.py
Browse files- augment_dataset.py +0 -481
augment_dataset.py
DELETED
|
@@ -1,481 +0,0 @@
|
|
| 1 |
-
# /// script
|
| 2 |
-
# requires-python = ">=3.12"
|
| 3 |
-
# dependencies = [
|
| 4 |
-
# "datasets",
|
| 5 |
-
# "huggingface-hub",
|
| 6 |
-
# "rich",
|
| 7 |
-
# "typer",
|
| 8 |
-
# ]
|
| 9 |
-
# ///
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
|
| 12 |
-
import yaml
|
| 13 |
-
from huggingface_hub import InferenceClient
|
| 14 |
-
from datasets import Dataset, load_dataset
|
| 15 |
-
from collections import defaultdict, deque
|
| 16 |
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 17 |
-
import time
|
| 18 |
-
import requests
|
| 19 |
-
import traceback
|
| 20 |
-
from rich.console import Console
|
| 21 |
-
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TaskProgressColumn
|
| 22 |
-
from rich.panel import Panel
|
| 23 |
-
from rich import print as rprint
|
| 24 |
-
import multiprocessing
|
| 25 |
-
import random
|
| 26 |
-
|
| 27 |
-
import typer
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
class Pipeline:
|
| 31 |
-
"""A parallel pipeline for generating dataset rows using language models."""
|
| 32 |
-
|
| 33 |
-
def __init__(
|
| 34 |
-
self,
|
| 35 |
-
*,
|
| 36 |
-
repo_id: str,
|
| 37 |
-
subset: str | None = None,
|
| 38 |
-
split: str = "train",
|
| 39 |
-
config: str | None = None,
|
| 40 |
-
num_rows: int | None = None,
|
| 41 |
-
bill_to: str | None = None,
|
| 42 |
-
max_workers: int | None = None,
|
| 43 |
-
debug: bool = False,
|
| 44 |
-
request_delay: float = 0
|
| 45 |
-
) -> None:
|
| 46 |
-
"""
|
| 47 |
-
Initialize the pipeline.
|
| 48 |
-
|
| 49 |
-
Args:
|
| 50 |
-
config: Path or URL to YAML configuration file
|
| 51 |
-
num_rows: Number of rows to generate (if None with source_dataset, uses entire dataset)
|
| 52 |
-
max_workers: Maximum number of concurrent workers (defaults to CPU count - 1)
|
| 53 |
-
debug: Enable debug logging (default: False)
|
| 54 |
-
request_delay: Delay in seconds between API requests (default: 0)
|
| 55 |
-
|
| 56 |
-
Raises:
|
| 57 |
-
ValueError: If no root nodes are found in the dependency graph
|
| 58 |
-
"""
|
| 59 |
-
self.debug = debug
|
| 60 |
-
self.console = Console()
|
| 61 |
-
self.request_delay = request_delay
|
| 62 |
-
self.bill_to = bill_to
|
| 63 |
-
|
| 64 |
-
with self.console.status("[bold green]Loading configuration..."):
|
| 65 |
-
self.config = self._load_config(config)
|
| 66 |
-
|
| 67 |
-
# Handle source dataset if specified
|
| 68 |
-
self.source_dataset = self._load_source_dataset(repo_id=repo_id, subset=subset, split=split)
|
| 69 |
-
self.source_columns = set()
|
| 70 |
-
|
| 71 |
-
# Get columns from source dataset
|
| 72 |
-
available_columns = set(self.source_dataset.features.keys())
|
| 73 |
-
self.source_columns = available_columns
|
| 74 |
-
|
| 75 |
-
self.num_rows = num_rows
|
| 76 |
-
# If num_rows is None, get the dataset size
|
| 77 |
-
if self.num_rows is None:
|
| 78 |
-
self.num_rows = self._get_dataset_size(repo_id, split, subset)
|
| 79 |
-
|
| 80 |
-
# Validate no overlap between source and generated columns
|
| 81 |
-
generated_columns = set(self.config.get('columns', {}).keys())
|
| 82 |
-
if overlap := (self.source_columns & generated_columns):
|
| 83 |
-
raise ValueError(f"Columns defined in both source dataset and generation config: {overlap}")
|
| 84 |
-
|
| 85 |
-
self.results: list[dict] = []
|
| 86 |
-
self.max_workers = max_workers or max(1, multiprocessing.cpu_count() - 1)
|
| 87 |
-
|
| 88 |
-
# Build dependency graph
|
| 89 |
-
self._build_dependency_graph()
|
| 90 |
-
self._display_configuration_summary()
|
| 91 |
-
|
| 92 |
-
def _get_dataset_size(self, repo_id: str, split: str, subset: str | None = None) -> int | None:
|
| 93 |
-
# Load dataset info (not the actual dataset)
|
| 94 |
-
from datasets import load_dataset_builder
|
| 95 |
-
|
| 96 |
-
builder = load_dataset_builder(repo_id, subset)
|
| 97 |
-
info = builder.info
|
| 98 |
-
|
| 99 |
-
# Get the number of examples in the specified split
|
| 100 |
-
if hasattr(info, 'splits') and split in info.splits:
|
| 101 |
-
return info.splits[split].num_examples
|
| 102 |
-
else:
|
| 103 |
-
# Fallback if split info is not available
|
| 104 |
-
self.console.print("[yellow]Warning: Could not determine dataset size. Using streaming mode.")
|
| 105 |
-
return None
|
| 106 |
-
|
| 107 |
-
@staticmethod
|
| 108 |
-
def _load_config(yml_source: str) -> dict:
|
| 109 |
-
"""Load and parse YAML configuration from file or URL."""
|
| 110 |
-
if yml_source.startswith(('http://', 'https://')):
|
| 111 |
-
response = requests.get(yml_source)
|
| 112 |
-
response.raise_for_status()
|
| 113 |
-
return yaml.safe_load(response.text)
|
| 114 |
-
|
| 115 |
-
with open(yml_source) as f:
|
| 116 |
-
return yaml.safe_load(f)
|
| 117 |
-
|
| 118 |
-
def _build_dependency_graph(self) -> None:
|
| 119 |
-
"""Build directed dependency graph from configuration."""
|
| 120 |
-
self.graph = defaultdict(list)
|
| 121 |
-
self.reverse_graph = defaultdict(list)
|
| 122 |
-
all_nodes = set()
|
| 123 |
-
dependent_nodes = set()
|
| 124 |
-
|
| 125 |
-
# Add source columns as potential dependencies
|
| 126 |
-
all_nodes.update(self.source_columns)
|
| 127 |
-
|
| 128 |
-
for col, config in self.config.get('columns', {}).items():
|
| 129 |
-
all_nodes.add(col)
|
| 130 |
-
if deps := config.get('columnsReferences'):
|
| 131 |
-
# Validate dependencies exist in either source or generated columns
|
| 132 |
-
invalid_deps = set(deps) - (self.source_columns | set(self.config['columns'].keys()))
|
| 133 |
-
if invalid_deps:
|
| 134 |
-
raise ValueError(f"Invalid dependencies for {col}: {invalid_deps}")
|
| 135 |
-
|
| 136 |
-
for dep in deps:
|
| 137 |
-
self.graph[dep].append(col)
|
| 138 |
-
self.reverse_graph[col].append(dep)
|
| 139 |
-
# Only mark as dependent if it depends on non-source columns
|
| 140 |
-
if dep not in self.source_columns:
|
| 141 |
-
dependent_nodes.add(col)
|
| 142 |
-
|
| 143 |
-
# A node is a root if it:
|
| 144 |
-
# 1. Is not a source column AND
|
| 145 |
-
# 2. Either has no dependencies OR only depends on source columns
|
| 146 |
-
self.root_nodes = [
|
| 147 |
-
node for node in self.config.get('columns', {}).keys()
|
| 148 |
-
if node not in dependent_nodes
|
| 149 |
-
]
|
| 150 |
-
|
| 151 |
-
if not self.root_nodes and self.config.get('columns'):
|
| 152 |
-
raise ValueError("No root nodes found! Circular dependencies may exist.")
|
| 153 |
-
|
| 154 |
-
def get_client_for_node(self, node, bill_to: str | None = None) -> InferenceClient:
|
| 155 |
-
config = self.config['columns'][node]
|
| 156 |
-
|
| 157 |
-
return InferenceClient(
|
| 158 |
-
provider=config['modelProvider'],
|
| 159 |
-
bill_to=bill_to,
|
| 160 |
-
)
|
| 161 |
-
|
| 162 |
-
def _debug_log(self, message: str) -> None:
|
| 163 |
-
"""Print debug message if debug mode is enabled."""
|
| 164 |
-
if self.debug:
|
| 165 |
-
rprint(message)
|
| 166 |
-
|
| 167 |
-
def process_node(self, node: str, row: dict, bill_to: str | None = None) -> tuple[str, str]:
|
| 168 |
-
"""Process a single node in the pipeline."""
|
| 169 |
-
try:
|
| 170 |
-
if node in self.source_columns:
|
| 171 |
-
return node, row[node]
|
| 172 |
-
|
| 173 |
-
self._debug_log(f"[cyan]Processing node {node} with row data: {row}")
|
| 174 |
-
|
| 175 |
-
config = self.config['columns'][node]
|
| 176 |
-
prompt = self._prepare_prompt(config['prompt'], row)
|
| 177 |
-
|
| 178 |
-
self._debug_log(f"[cyan]Getting client for {node}...")
|
| 179 |
-
client = self.get_client_for_node(node, bill_to=bill_to)
|
| 180 |
-
|
| 181 |
-
self._debug_log(f"[cyan]Generating completion for {node} with prompt: {prompt}")
|
| 182 |
-
result = self._generate_completion(client, config['modelName'], prompt)
|
| 183 |
-
|
| 184 |
-
if not result or result.isspace():
|
| 185 |
-
raise ValueError(f"Empty or whitespace-only response from model")
|
| 186 |
-
|
| 187 |
-
self._debug_log(f"[green]Completed {node} with result: {result[:100]}...")
|
| 188 |
-
return node, result
|
| 189 |
-
|
| 190 |
-
except Exception as e:
|
| 191 |
-
self._log_error(node, e)
|
| 192 |
-
raise
|
| 193 |
-
|
| 194 |
-
def _prepare_prompt(self, prompt: str, row: dict) -> str:
|
| 195 |
-
"""Prepare prompt template by filling in values from row."""
|
| 196 |
-
for key, value in row.items():
|
| 197 |
-
placeholder = f"{{{{{key}}}}}"
|
| 198 |
-
if placeholder in prompt:
|
| 199 |
-
self._debug_log(f"[cyan]Replacing {placeholder} with: {value}")
|
| 200 |
-
prompt = prompt.replace(placeholder, str(value))
|
| 201 |
-
|
| 202 |
-
self._debug_log(f"[yellow]Final prompt:\n{prompt}")
|
| 203 |
-
return prompt
|
| 204 |
-
|
| 205 |
-
def _generate_completion(self, client: InferenceClient, model: str, prompt: str) -> str:
|
| 206 |
-
"""Generate completion using the specified model."""
|
| 207 |
-
messages = [{"role": "user", "content": prompt}]
|
| 208 |
-
|
| 209 |
-
# Implement retry with exponential backoff for rate limiting
|
| 210 |
-
max_retries = 5
|
| 211 |
-
retry_count = 0
|
| 212 |
-
base_delay = self.request_delay or 1.0 # Use request_delay if set, otherwise default to 1 second
|
| 213 |
-
|
| 214 |
-
while retry_count < max_retries:
|
| 215 |
-
try:
|
| 216 |
-
# Add delay if specified to avoid rate limiting
|
| 217 |
-
if retry_count > 0 or self.request_delay > 0:
|
| 218 |
-
# Calculate exponential backoff with jitter
|
| 219 |
-
if retry_count > 0:
|
| 220 |
-
delay = base_delay * (2 ** retry_count) + random.uniform(0, 1)
|
| 221 |
-
self._debug_log(
|
| 222 |
-
f"[yellow]Rate limit hit. Retrying in {delay:.2f} seconds (attempt {retry_count + 1}/{max_retries})")
|
| 223 |
-
else:
|
| 224 |
-
delay = base_delay
|
| 225 |
-
time.sleep(delay)
|
| 226 |
-
|
| 227 |
-
completion = client.chat.completions.create(
|
| 228 |
-
model=model,
|
| 229 |
-
messages=messages,
|
| 230 |
-
)
|
| 231 |
-
return completion.choices[0].message.content
|
| 232 |
-
|
| 233 |
-
except Exception as e:
|
| 234 |
-
# Check if it's a rate limit error
|
| 235 |
-
if "429" in str(e) or "rate_limit" in str(e).lower():
|
| 236 |
-
retry_count += 1
|
| 237 |
-
if retry_count >= max_retries:
|
| 238 |
-
self._debug_log(f"[red]Max retries reached for rate limit. Giving up.")
|
| 239 |
-
raise
|
| 240 |
-
else:
|
| 241 |
-
# Not a rate limit error, re-raise
|
| 242 |
-
raise
|
| 243 |
-
|
| 244 |
-
# Should not reach here, but just in case
|
| 245 |
-
raise Exception("Failed to generate completion after maximum retries")
|
| 246 |
-
|
| 247 |
-
def generate_row(self, progress, task_nodes, row_num, row_data=None):
|
| 248 |
-
"""Process a single node in the pipeline."""
|
| 249 |
-
try:
|
| 250 |
-
row = {}
|
| 251 |
-
if row_data:
|
| 252 |
-
row.update(row_data)
|
| 253 |
-
progress.update(task_nodes, description=f"[cyan]Row {row_num}: Loaded source data")
|
| 254 |
-
|
| 255 |
-
queue = deque(self.root_nodes)
|
| 256 |
-
in_progress = set()
|
| 257 |
-
processed_nodes = set()
|
| 258 |
-
|
| 259 |
-
with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
|
| 260 |
-
while queue or in_progress:
|
| 261 |
-
ready_nodes = [
|
| 262 |
-
node for node in queue
|
| 263 |
-
if node not in processed_nodes
|
| 264 |
-
and node not in in_progress
|
| 265 |
-
and all(dep in row for dep in self.reverse_graph[node])
|
| 266 |
-
]
|
| 267 |
-
|
| 268 |
-
for node in ready_nodes:
|
| 269 |
-
queue.remove(node)
|
| 270 |
-
progress.update(task_nodes, description=f"[cyan]Row {row_num}: Processing {node}")
|
| 271 |
-
|
| 272 |
-
futures = {
|
| 273 |
-
executor.submit(self.process_node, node, row, self.bill_to): node
|
| 274 |
-
for node in ready_nodes
|
| 275 |
-
}
|
| 276 |
-
in_progress.update(futures.values())
|
| 277 |
-
|
| 278 |
-
for future in as_completed(futures):
|
| 279 |
-
node = futures[future]
|
| 280 |
-
try:
|
| 281 |
-
node, result = future.result()
|
| 282 |
-
row[node] = result
|
| 283 |
-
in_progress.remove(node)
|
| 284 |
-
processed_nodes.add(node)
|
| 285 |
-
progress.advance(task_nodes)
|
| 286 |
-
|
| 287 |
-
for dependent in self.graph[node]:
|
| 288 |
-
if (dependent not in processed_nodes and
|
| 289 |
-
dependent not in queue and
|
| 290 |
-
dependent not in in_progress):
|
| 291 |
-
queue.append(dependent)
|
| 292 |
-
except Exception as e:
|
| 293 |
-
in_progress.remove(node)
|
| 294 |
-
processed_nodes.add(node)
|
| 295 |
-
progress.update(task_nodes, description=f"[red]Row {row_num}: Failed {node}")
|
| 296 |
-
raise
|
| 297 |
-
|
| 298 |
-
return row
|
| 299 |
-
except Exception as e:
|
| 300 |
-
self._debug_log(f"\n[red]Error processing row {row_num}: {str(e)}")
|
| 301 |
-
raise
|
| 302 |
-
|
| 303 |
-
def run(self):
|
| 304 |
-
start_time = time.time()
|
| 305 |
-
with Progress(
|
| 306 |
-
SpinnerColumn(),
|
| 307 |
-
TextColumn("[progress.description]{task.description}"),
|
| 308 |
-
BarColumn(complete_style="green", finished_style="green"),
|
| 309 |
-
TaskProgressColumn(),
|
| 310 |
-
console=self.console,
|
| 311 |
-
expand=True
|
| 312 |
-
) as progress:
|
| 313 |
-
task_rows = progress.add_task("[bold cyan]Generating dataset rows", total=self.num_rows)
|
| 314 |
-
task_nodes = progress.add_task("[cyan]Processing nodes (per row)", total=len(self.config['columns']))
|
| 315 |
-
|
| 316 |
-
with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
|
| 317 |
-
|
| 318 |
-
# If num_rows is None, use the entire dataset
|
| 319 |
-
if self.num_rows is None:
|
| 320 |
-
dataset_iter = enumerate(self.source_dataset)
|
| 321 |
-
# Update progress bar with unknown total
|
| 322 |
-
progress.update(task_rows, total=None)
|
| 323 |
-
else:
|
| 324 |
-
dataset_iter = enumerate(self.source_dataset.take(self.num_rows))
|
| 325 |
-
|
| 326 |
-
futures = {
|
| 327 |
-
executor.submit(
|
| 328 |
-
self.generate_row,
|
| 329 |
-
progress,
|
| 330 |
-
task_nodes,
|
| 331 |
-
i + 1,
|
| 332 |
-
dict(source_row) # Convert to dict if streaming
|
| 333 |
-
): i
|
| 334 |
-
for i, source_row in dataset_iter
|
| 335 |
-
}
|
| 336 |
-
|
| 337 |
-
for future in as_completed(futures):
|
| 338 |
-
i = futures[future]
|
| 339 |
-
row_num = i + 1
|
| 340 |
-
try:
|
| 341 |
-
row = future.result()
|
| 342 |
-
self.results.append(row)
|
| 343 |
-
progress.advance(task_rows)
|
| 344 |
-
progress.update(task_rows,
|
| 345 |
-
description=f"[bold green]✓ Completed {len(self.results)}/{self.num_rows} rows")
|
| 346 |
-
progress.reset(task_nodes) # Reset node progress for next row
|
| 347 |
-
except Exception as e:
|
| 348 |
-
progress.update(task_rows, description=f"[bold red]✗ Row {row_num} failed")
|
| 349 |
-
rprint(f"\n[red]Error in row {row_num}: {str(e)}")
|
| 350 |
-
continue
|
| 351 |
-
|
| 352 |
-
total_time = time.time() - start_time
|
| 353 |
-
minutes = int(total_time // 60)
|
| 354 |
-
seconds = int(total_time % 60)
|
| 355 |
-
|
| 356 |
-
if len(self.results) == self.num_rows:
|
| 357 |
-
rprint(Panel(
|
| 358 |
-
f"[bold green]✓[/] Successfully generated all {self.num_rows} rows!\nTotal time: {minutes}m {seconds}s"))
|
| 359 |
-
else:
|
| 360 |
-
rprint(Panel(
|
| 361 |
-
f"[bold yellow]![/] Completed with {len(self.results)}/{self.num_rows} rows generated\nTotal time: {minutes}m {seconds}s"))
|
| 362 |
-
|
| 363 |
-
# Create Hugging Face dataset with both source and generated columns
|
| 364 |
-
dataset_dict = {}
|
| 365 |
-
|
| 366 |
-
# Add source columns first
|
| 367 |
-
for col in self.source_columns:
|
| 368 |
-
dataset_dict[col] = [row.get(col) for row in self.results]
|
| 369 |
-
|
| 370 |
-
# Add generated columns
|
| 371 |
-
for col in self.config['columns']:
|
| 372 |
-
dataset_dict[col] = [row.get(col) for row in self.results]
|
| 373 |
-
|
| 374 |
-
dataset = Dataset.from_dict(dataset_dict)
|
| 375 |
-
return dataset
|
| 376 |
-
|
| 377 |
-
@staticmethod
|
| 378 |
-
def _log_error(node: str, e: Exception) -> None:
|
| 379 |
-
print(f"\n❌ Error in node {node}:")
|
| 380 |
-
print(f"Error type: {type(e).__name__}")
|
| 381 |
-
print(f"Error message: {str(e)}")
|
| 382 |
-
print(f"Full traceback:")
|
| 383 |
-
traceback.print_exc()
|
| 384 |
-
|
| 385 |
-
@staticmethod
|
| 386 |
-
def _load_source_dataset(
|
| 387 |
-
repo_id: str,
|
| 388 |
-
subset: str | None = None,
|
| 389 |
-
split: str = "train"
|
| 390 |
-
) -> Dataset:
|
| 391 |
-
|
| 392 |
-
"""Load the source dataset from Hugging Face Hub."""
|
| 393 |
-
|
| 394 |
-
return load_dataset(
|
| 395 |
-
repo_id,
|
| 396 |
-
subset,
|
| 397 |
-
split=split,
|
| 398 |
-
streaming=True
|
| 399 |
-
)
|
| 400 |
-
|
| 401 |
-
def _display_configuration_summary(self) -> None:
|
| 402 |
-
summary = [
|
| 403 |
-
f"[bold green]Pipeline Configuration Summary[/]",
|
| 404 |
-
f"• Source columns: [cyan]{len(self.source_columns)}[/]",
|
| 405 |
-
f"• Generated columns: [cyan]{len(self.config.get('columns', {}))}[/]",
|
| 406 |
-
f"• Worker threads: [cyan]{self.max_workers}[/]",
|
| 407 |
-
f"• Rows to generate: [cyan]{self.num_rows}[/]",
|
| 408 |
-
]
|
| 409 |
-
|
| 410 |
-
if self.source_columns:
|
| 411 |
-
summary.append("\n[bold blue]Source Dataset:[/]")
|
| 412 |
-
for col in sorted(self.source_columns):
|
| 413 |
-
summary.append(f"• [cyan]{col}[/]")
|
| 414 |
-
|
| 415 |
-
if self.config.get('columns'):
|
| 416 |
-
summary.append("\n[bold blue]Models and Providers:[/]")
|
| 417 |
-
# Add model and provider information for each generated node
|
| 418 |
-
for node, config in self.config['columns'].items():
|
| 419 |
-
model_name = config['modelName']
|
| 420 |
-
provider = config['modelProvider']
|
| 421 |
-
summary.append(f"• [cyan]{node}[/]: {model_name} ({provider})")
|
| 422 |
-
|
| 423 |
-
summary.append("\n[bold blue]Node Dependencies:[/]")
|
| 424 |
-
# Add dependency information for each node
|
| 425 |
-
for node in self.config['columns']:
|
| 426 |
-
deps = self.reverse_graph[node]
|
| 427 |
-
if deps:
|
| 428 |
-
summary.append(f"• [cyan]{node}[/] ← {', '.join(deps)}")
|
| 429 |
-
else:
|
| 430 |
-
summary.append(f"• [cyan]{node}[/] (root node)")
|
| 431 |
-
|
| 432 |
-
rprint(Panel("\n".join(summary)))
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
def main(
|
| 436 |
-
*,
|
| 437 |
-
repo_id: str,
|
| 438 |
-
split: str = "train",
|
| 439 |
-
config: str = './config.yml',
|
| 440 |
-
destination: str,
|
| 441 |
-
destination_split: str = "train",
|
| 442 |
-
create_pr: bool = False,
|
| 443 |
-
num_rows: int | None = None,
|
| 444 |
-
bill_to: str | None = None,
|
| 445 |
-
max_workers: int | None = None,
|
| 446 |
-
debug: bool = False,
|
| 447 |
-
):
|
| 448 |
-
"""
|
| 449 |
-
Main entry point for the dataset augmentation pipeline.
|
| 450 |
-
|
| 451 |
-
Args:
|
| 452 |
-
repo_id: The dataset repository ID to augment (e.g., "fka/awesome-chatgpt-prompts").
|
| 453 |
-
split: Dataset split to use (default: "train").
|
| 454 |
-
config: Path to the YAML configuration file for the pipeline.
|
| 455 |
-
destination: Destination repository ID for the augmented dataset.
|
| 456 |
-
destination_split: Split name for the destination dataset (default: "train").
|
| 457 |
-
create_pr: Whether to create a pull request for the destination dataset (default: False).
|
| 458 |
-
bill_to: Billing account for the inference client (if applicable).
|
| 459 |
-
num_rows: Number of rows to use (if None, uses entire dataset).
|
| 460 |
-
max_workers: Maximum number of concurrent workers (defaults to CPU count - 1).
|
| 461 |
-
debug: Enable debug logging (default: False).
|
| 462 |
-
"""
|
| 463 |
-
|
| 464 |
-
pipeline = Pipeline(
|
| 465 |
-
repo_id=repo_id,
|
| 466 |
-
subset=None,
|
| 467 |
-
split=split,
|
| 468 |
-
config=config,
|
| 469 |
-
num_rows=num_rows,
|
| 470 |
-
bill_to=bill_to,
|
| 471 |
-
request_delay=0.5,
|
| 472 |
-
max_workers=max_workers,
|
| 473 |
-
debug=debug,
|
| 474 |
-
)
|
| 475 |
-
|
| 476 |
-
augmented_dataset = pipeline.run()
|
| 477 |
-
augmented_dataset.push_to_hub(destination, split=destination_split, create_pr=create_pr)
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
if __name__ == "__main__":
|
| 481 |
-
typer.run(main)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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