Compare commits
No commits in common. "2403a20ed04b1816205c3ca470b49dba2339abe8" and "8faee98ec644af3b66b31514b3584f5372fc0f85" have entirely different histories.
2403a20ed0
...
8faee98ec6
4 changed files with 22 additions and 26 deletions
|
|
@ -47,10 +47,10 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
# pyproject declares >= 3.7, but uv's standalone CPython and the current
|
# pyproject declares >= 3.7, but uv's standalone CPython and the current
|
||||||
# dependency floors (scikit-learn/numpy now require >= 3.9) no longer
|
# dependency floors (scikit-learn/numpy now require >= 3.9) no longer
|
||||||
# build on the older interpreters, so we test the current supported set.
|
# build on 3.7/3.8. Re-add those rows if the constraints are relaxed.
|
||||||
# The windows leg of the old GitHub matrix is dropped: this Forgejo
|
# The windows leg of the old GitHub matrix is dropped: this Forgejo
|
||||||
# instance only has a Linux `docker` runner.
|
# instance only has a Linux `docker` runner.
|
||||||
python-version: ['3.10', '3.11', '3.12', '3.13']
|
python-version: ['3.9', '3.10']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
|
|
@ -230,17 +230,17 @@ class GreatAI(Generic[T, V]):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# inner/inner_async return the class' T (bound to Trace | Awaitable[Trace]);
|
|
||||||
# in this method T resolves to Trace[V], but that is not provable to mypy, so
|
|
||||||
# cast to the concrete shape parallel_map expects.
|
|
||||||
map_function = cast(
|
|
||||||
Callable[[Any], Union[Trace[V], Awaitable[Trace[V]]]],
|
|
||||||
inner_async if get_function_metadata_store(self).is_asynchronous else inner,
|
|
||||||
)
|
|
||||||
|
|
||||||
return list(
|
return list(
|
||||||
tqdm(
|
tqdm(
|
||||||
parallel_map(map_function, batch, concurrency=concurrency),
|
parallel_map(
|
||||||
|
(
|
||||||
|
inner_async
|
||||||
|
if get_function_metadata_store(self).is_asynchronous
|
||||||
|
else inner
|
||||||
|
),
|
||||||
|
batch,
|
||||||
|
concurrency=concurrency,
|
||||||
|
),
|
||||||
total=len(batch),
|
total=len(batch),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
24
tests/external/test_internals.py
vendored
24
tests/external/test_internals.py
vendored
|
|
@ -242,7 +242,7 @@ async def test_wait_closed():
|
||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
)
|
)
|
||||||
assert ret == []
|
assert ret == []
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
with mock.patch("great_ai.external.async_lru._close_waited") as mocked:
|
with mock.patch("great_ai.external.async_lru._close_waited") as mocked:
|
||||||
|
|
@ -251,7 +251,7 @@ async def test_wait_closed():
|
||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
)
|
)
|
||||||
assert ret == []
|
assert ret == []
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
asyncio.set_event_loop(None)
|
asyncio.set_event_loop(None)
|
||||||
|
|
||||||
fut = loop.create_future()
|
fut = loop.create_future()
|
||||||
|
|
@ -263,7 +263,7 @@ async def test_wait_closed():
|
||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
)
|
)
|
||||||
assert ret == [None]
|
assert ret == [None]
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
exc = ZeroDivisionError()
|
exc = ZeroDivisionError()
|
||||||
fut = loop.create_future()
|
fut = loop.create_future()
|
||||||
|
|
@ -275,7 +275,7 @@ async def test_wait_closed():
|
||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
)
|
)
|
||||||
assert ret == [exc]
|
assert ret == [exc]
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
fut = loop.create_future()
|
fut = loop.create_future()
|
||||||
fut.set_exception(ZeroDivisionError)
|
fut.set_exception(ZeroDivisionError)
|
||||||
|
|
@ -286,21 +286,17 @@ async def test_wait_closed():
|
||||||
wrapped,
|
wrapped,
|
||||||
return_exceptions=False,
|
return_exceptions=False,
|
||||||
)
|
)
|
||||||
# the awaited result raised before _wait_closed could flush its done
|
assert mocked.called_once()
|
||||||
# callback, so yield once to let the scheduled _close_waited run
|
|
||||||
await asyncio.sleep(0)
|
|
||||||
mocked.assert_called_once()
|
|
||||||
|
|
||||||
|
|
||||||
def test_close_waited():
|
def test_close_waited():
|
||||||
wrapped = Wrapped()
|
wrapped = Wrapped()
|
||||||
# _close_waited calls wrapped.cache_clear(); mock that directly (patching the
|
wrapped.cache_clear = partial(_cache_clear, wrapped)
|
||||||
# module-level _cache_clear would not affect the already-bound partial).
|
|
||||||
wrapped.cache_clear = mock.Mock()
|
|
||||||
|
|
||||||
|
with mock.patch("great_ai.external.async_lru._cache_clear") as mocked:
|
||||||
_close_waited(wrapped, None)
|
_close_waited(wrapped, None)
|
||||||
|
|
||||||
wrapped.cache_clear.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
|
|
||||||
def test_cache_info():
|
def test_cache_info():
|
||||||
|
|
@ -347,7 +343,7 @@ def test_cache_hit():
|
||||||
with mock.patch("great_ai.external.async_lru.__cache_touch") as mocked:
|
with mock.patch("great_ai.external.async_lru.__cache_touch") as mocked:
|
||||||
_cache_hit(wrapped, 1)
|
_cache_hit(wrapped, 1)
|
||||||
|
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
assert wrapped.hits == 2
|
assert wrapped.hits == 2
|
||||||
|
|
||||||
|
|
@ -365,7 +361,7 @@ def test_cache_miss():
|
||||||
with mock.patch("great_ai.external.async_lru.__cache_touch") as mocked:
|
with mock.patch("great_ai.external.async_lru.__cache_touch") as mocked:
|
||||||
_cache_miss(wrapped, 1)
|
_cache_miss(wrapped, 1)
|
||||||
|
|
||||||
mocked.assert_called_once()
|
assert mocked.called_once()
|
||||||
|
|
||||||
assert wrapped.misses == 2
|
assert wrapped.misses == 2
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue