Something went wrong. Try again.
Command line interface for accessing the Open Web Index shards and slices.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273"""Batch Commands - Typer CLI for batch job operations.
Commands:- run: Execute batch jobs from YAML task files"""from typing import Optionalfrom pathlib import Pathimport typer
from ._common.context import CLIContext
# Create sub-app for batch commandsapp = typer.Typer( name="batch", help="Batch job operations", no_args_is_help=True,)
@app.command("run")def batch_run( ctx: typer.Context, specifier: str = typer.Argument(..., help="Dataset specifier"), taskfile: str = typer.Argument(..., help="Path to YAML task file"), workers: int = typer.Option(1, "--workers", "-w", help="Number of parallel workers"), keep_going: bool = typer.Option(False, "--keep-going", "-k", help="Continue on errors"), resume: bool = typer.Option(False, "--resume", help="Resume from previous execution"), job_name: Optional[str] = typer.Option(None, "--job", "-j", help="Job name for progress tracking"), reset_progress: bool = typer.Option(False, "--reset", help="Reset progress and start fresh"), dry_run: bool = typer.Option(False, "--dry-run", "-n", help="Show what would be done"),): """ Execute batch jobs from YAML task files. Runs tasks defined in a YAML file against datasets matching the specifier. Supports parallel execution, resumable progress, and error handling. Examples: owi batch run main:latest tasks.yaml --workers 4 owi batch run lrz:* process.yaml --resume --keep-going """ cli_ctx: CLIContext = ctx.obj # Validate taskfile exists taskfile_path = Path(taskfile) if not taskfile_path.exists(): cli_ctx.console.print(f"[red]Error: Task file not found: {taskfile}[/red]") raise typer.Exit(code=1) # Delegate to legacy BatchCommands from owilix.compat.batch import BatchCommands batch_cmd = BatchCommands(cli_ctx.owi, console=cli_ctx.console) result = batch_cmd.run( specifier=specifier, taskfile=str(taskfile_path), workers=workers, keep_going=keep_going, resume=resume, job_name=job_name, reset_progress=reset_progress, dry_run=dry_run, ) if result and not result.success: cli_ctx.console.print(f"[red]Batch job failed: {result.msg}[/red]") raise typer.Exit(code=1) if result and result.success: cli_ctx.console.print(f"[green]✓ Batch job completed successfully[/green]")