Compare commits

...

4 Commits

Author SHA1 Message Date
Bagatur
107bdd975e fmt 2024-01-23 19:51:57 -08:00
Bagatur
0ffeecf218 Merge branch 'master' into bagatur/batch_overload_typing 2024-01-23 19:51:22 -08:00
Bagatur
edb1173d32 fmt 2024-01-15 14:22:00 -08:00
Bagatur
d3555806d7 rfc: correct batch typing 2024-01-15 14:20:29 -08:00

View File

@@ -533,6 +533,28 @@ class Runnable(Generic[Input, Output], ABC):
with get_executor_for_config(configs[0]) as executor:
return cast(List[Output], list(executor.map(invoke, inputs, configs)))
@overload
async def abatch(
self,
inputs: List[Input],
config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None,
*,
return_exceptions: Literal[False] = False,
**kwargs: Optional[Any],
) -> List[Output]:
...
@overload
async def abatch(
self,
inputs: List[Input],
config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None,
*,
return_exceptions: Literal[True],
**kwargs: Optional[Any],
) -> List[Union[Output, BaseException]]:
...
async def abatch(
self,
inputs: List[Input],
@@ -540,7 +562,7 @@ class Runnable(Generic[Input, Output], ABC):
*,
return_exceptions: bool = False,
**kwargs: Optional[Any],
) -> List[Output]:
) -> List[Union[Output, BaseException]]:
"""Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.