Skip to content

Commit bac40ac

Browse files
committed
Update package version and include minor bug fixes for batch queries
1 parent ee1df68 commit bac40ac

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
GITHUB_TOKEN: ${{ github.token }}
9191
run: >-
9292
gh release create
93-
'v0.2.1'
93+
'v0.2.2'
9494
--repo '${{ github.repository }}'
9595
--notes ""
9696
@@ -102,5 +102,5 @@ jobs:
102102
# sigstore-produced signatures and certificates.
103103
run: >-
104104
gh release upload
105-
'v0.2.1' dist/**
105+
'v0.2.2' dist/**
106106
--repo '${{ github.repository }}'

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ cython_debug/
167167
# Case Studies
168168
case_studies/
169169

170-
# Testing files
171-
test.py
170+
# Local testing files
171+
local
172172

173173
# Lint cache
174-
.ruff_cache
174+
.ruff_cache

aifn/client.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -730,29 +730,25 @@ def batch_query(
730730
List[NamedTuple]
731731
A list of NamedTuples, each containing the output and metadata of the response.
732732
"""
733-
try:
734-
# Check if an event loop is already running
735-
loop = asyncio.get_running_loop()
736-
if loop.is_running():
737-
nest_asyncio.apply()
738-
task = loop.create_task(
739-
self._batch_query(
740-
fn_name=fn_name,
741-
version=version,
742-
batch_inputs=batch_inputs,
743-
return_reasoning=return_reasoning,
744-
strict=strict,
745-
)
733+
734+
async def run_batch():
735+
return await self._batch_query(
736+
fn_name=fn_name, version=version, batch_inputs=batch_inputs, return_reasoning=return_reasoning, strict=strict
746737
)
747-
return loop.run_until_complete(task)
738+
739+
# Create a new event loop if one doesn't exist
740+
try:
741+
loop = asyncio.get_event_loop()
748742
except RuntimeError:
749-
# If no event loop is running, use asyncio.run
750-
return asyncio.run(
751-
self._batch_query(
752-
fn_name=fn_name,
753-
version=version,
754-
batch_inputs=batch_inputs,
755-
return_reasoning=return_reasoning,
756-
strict=strict,
757-
)
758-
)
743+
loop = asyncio.new_event_loop()
744+
asyncio.set_event_loop(loop)
745+
746+
# Apply nest_asyncio if the loop is already running
747+
if loop.is_running():
748+
nest_asyncio.apply()
749+
750+
try:
751+
return loop.run_until_complete(run_batch())
752+
finally:
753+
# Don't close the loop, just let it be cleaned up naturally
754+
pass

aifn/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.1" # DO NOT EDIT (this is the package version)
1+
__version__ = "0.2.2" # DO NOT EDIT (this is the package version)
22
MAX_TEXT_LENGTH = 1e6 # 1 million characters
33
MAX_IMAGE_UPLOADS = 10 # 10 images
44
MAX_IMAGE_SIZE_MB = 10 # 10 MB

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
]
1111
description = "Documentation for `aifn`, a client facing API for interacting with the WecoAI's AI functions."
1212
readme = "README.md"
13-
version = "0.2.1"
13+
version = "0.2.2"
1414
license = {text = "MIT"}
1515
requires-python = ">=3.8"
1616
dependencies = ["requests", "asyncio", "nest_asyncio", "httpx[http2]", "pillow"]

0 commit comments

Comments
 (0)