Improve batch processing API
This commit is contained in:
parent
1d30fd730a
commit
00714bef4e
4 changed files with 104 additions and 94 deletions
|
|
@ -12,6 +12,19 @@ def test_process_batch() -> None:
|
|||
assert [v.output for v in f.process_batch([3, 9, 34])] == [5, 11, 36]
|
||||
|
||||
|
||||
def test_process_batch_unpacked() -> None:
|
||||
@GreatAI.create
|
||||
def f(a: int, b: str) -> str:
|
||||
return b * a
|
||||
|
||||
assert [
|
||||
v.output
|
||||
for v in f.process_batch(
|
||||
[(2, "aa"), (1, "fa"), (3, "b")], unpack_arguments=True
|
||||
)
|
||||
] == ["aaaa", "fa", "bbb"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_batch_async() -> None:
|
||||
@GreatAI.create
|
||||
|
|
@ -20,3 +33,17 @@ async def test_process_batch_async() -> None:
|
|||
return x + 2
|
||||
|
||||
assert [v.output for v in f.process_batch([3, 9, 34])] == [5, 11, 36]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_batch_async_unpacked() -> None:
|
||||
@GreatAI.create
|
||||
async def f(a: int, b: str) -> str:
|
||||
return b * a
|
||||
|
||||
assert [
|
||||
v.output
|
||||
for v in f.process_batch(
|
||||
[(2, "aa"), (1, "fa"), (3, "b")], unpack_arguments=True
|
||||
)
|
||||
] == ["aaaa", "fa", "bbb"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue