promptflow.batch module#
- class promptflow.batch.BatchEngine(flow_file: Union[Path, Callable], working_dir: Optional[Path] = None, *, connections: Optional[dict] = None, storage: Optional[AbstractRunStorage] = None, batch_timeout_sec: Optional[int] = None, line_timeout_sec: Optional[int] = None, worker_count: Optional[int] = None, init_kwargs: Optional[Dict[str, Any]] = None, **kwargs)#
Bases:
object
This class is used to execute flows in batch mode
- cancel()#
Cancel the batch run
- classmethod register_executor(language: str, executor_proxy_cls: Type[AbstractExecutorProxy])#
Register a executor proxy class for a specific program language.
this function is left to keep the compatibility with the old version promptflow-runtime; it will redirect the registration to the ExecutorProxyFactory.
- run(input_dirs: Dict[str, str], inputs_mapping: Dict[str, str], output_dir: Path, run_id: Optional[str] = None, max_lines_count: Optional[int] = None, raise_on_line_failure: Optional[bool] = False, resume_from_run_storage: Optional[AbstractBatchRunStorage] = None, resume_from_run_output_dir: Optional[Path] = None, executor_proxy: Optional[AbstractExecutorProxy] = None) BatchResult #
Run flow in batch mode
- Parameters:
input_dirs (Dict[str, str]) – The directories path of input files
inputs_mapping (Dict[str, str]) – The mapping of input names to their corresponding values.
output_dir (The directory path of output files) – output dir
run_id (Optional[str]) – The run id of this run
max_lines_count (Optional[int]) – The max count of inputs. If it is None, all inputs will be used.
raise_on_line_failure (Optional[bool]) – Whether to raise exception when a line fails.
resume_from_run_storage (Optional[AbstractRunStorage]) – The run storage to load flow run and node run from the original run. The resume behavior is to reuse succeeded line result of the original run and run/rerun the remaining/failed lines.
resume_from_run_output_dir (Optional[Path]) – The output dir of the original run.
- Returns:
The result of this batch run
- Return type:
- class promptflow.batch.BatchResult(status: Status, total_lines: int, completed_lines: int, failed_lines: int, node_status: Mapping[str, int], start_time: datetime, end_time: datetime, metrics: Mapping[str, str], system_metrics: SystemMetrics, error_summary: ErrorSummary)#
Bases:
object
The result of a batch run.
- completed_lines: int#
- classmethod create(start_time: datetime, end_time: datetime, line_results: List[LineResult], aggr_result: AggregationResult, status: Status = Status.Completed, exception: Optional[Exception] = None) BatchResult #
- end_time: datetime#
- error_summary: ErrorSummary#
- failed_lines: int#
- metrics: Mapping[str, str]#
- node_status: Mapping[str, int]#
- start_time: datetime#
- system_metrics: SystemMetrics#
- total_lines: int#