promptflow.batch 模块#
- 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)#
基础类:
object
此类用于以批处理模式执行流程
- cancel()#
取消批量运行
- classmethod register_executor(language: str, executor_proxy_cls: Type[AbstractExecutorProxy])#
为特定编程语言注册一个执行器代理类。
此函数保留是为了与旧版本的promptflow-runtime保持兼容;它将把注册重定向到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 #
以批处理模式运行流程
- Parameters:
input_dirs (Dict[str, str]) – 输入文件的目录路径
inputs_mapping (Dict[str, str]) – 输入名称与其对应值的映射。
output_dir (输出文件的目录路径) – 输出目录
run_id (可选[str]) – 此运行的运行ID
max_lines_count (可选[int]) – 输入的最大行数。如果为None,将使用所有输入。
raise_on_line_failure (可选[bool]) – 当一行失败时是否引发异常。
resume_from_run_storage (可选[AbstractRunStorage]) – 用于从原始运行中加载流程运行和节点运行的运行存储。恢复行为是重用原始运行中成功的行结果,并运行/重新运行剩余/失败的行。
resume_from_run_output_dir (可选[路径]) – 原始运行的输出目录。
- Returns:
这批运行的结果
- Return type:
- class promptflow.batch.BatchResult(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)#
基础类:
object
批量运行的结果。
- completed_lines: int#
- classmethod create(start_time: datetime, end_time: datetime, line_results: List[LineResult], aggr_result: AggregationResult, 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#