chunklet.common.batch_runner
Functions:
-
run_in_batch–Processes a batch of items in parallel using multiprocessing.
run_in_batch
run_in_batch(
func: Callable,
iterable_of_args: Iterable,
iterable_name: str,
n_jobs: int | None = None,
show_progress: bool = True,
on_errors: Literal["raise", "skip", "break"] = "raise",
separator: Any = None,
verbose: bool = True,
) -> Generator[Any, None, None]
Processes a batch of items in parallel using multiprocessing. Splits the iterable into chunks and executes the function on each.
Parameters:
-
(funcCallable) –The function to call for each argument.
-
(iterable_of_argsIterable) –An iterable of inputs to process.
-
(iterable_namestr) –Name of the iterable. needed for logging and exception message.
-
(n_jobsint | None, default:None) –Number of parallel workers to use. If None, uses all available CPUs. Must be >= 1 if specified.
-
(show_progressbool, default:True) –Whether to display a progress bar.
-
(on_errorsLiteral['raise', 'skip', 'break'], default:'raise') –How to handle errors during processing. Defaults to "raise".
-
(separatorAny, default:None) –A value to be yielded after the chunks of each text are processed. Note: None cannot be used as a separator.
-
(verbosebool, default:True) –Whether to enable verbose logging.
Yields:
-
Any(Any) –A
Boxobject containing the chunk content and metadata, or any separator object.