lplalbert commented on code in PR #424:
URL: https://github.com/apache/hugegraph-ai/pull/424#discussion_r4581502989
##########
hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py:
##########
@@ -68,7 +48,7 @@ def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
if added_vids:
vids_to_process = self._extract_names(added_vids) if all_pk_flag
else added_vids
- added_embeddings =
asyncio.run(self._get_embeddings_parallel(vids_to_process))
+ added_embeddings =
asyncio.run(get_embeddings_parallel(self.embedding, vids_to_process))
Review Comment:
Root cause: the shared fetch ran every batch through
`embedding.async_get_texts_embeddings`, so the instance-owned async client (and
its pooled keep-alive connections) outlived the per-update loop that
`asyncio.run` creates and closes. The same failure applied to all three
consumers of the helper (`BuildSemanticIndex`, `BuildGremlinExampleIndex`,
`BuildVectorIndex`).
Structural fix (0722aac): retained the synchronous executor path. Each batch
now runs `get_texts_embeddings` on the loop's executor — the route
`BuildSemanticIndex` used before this PR. The synchronous clients hold no
loop-bound state, so client and loop lifetimes no longer need to match across
updates. Order, batching (500) and the in-flight bound (10) are unchanged; the
async fetch methods stay on the embedding API for direct use.
Validation:
- `test_two_updates_on_one_instance_keep_indexing`: two nonempty updates on
one `BuildSemanticIndex` instance through the real helper. Red before 0722aac
with `RuntimeError: Event loop is closed` on the second update; both updates
now index their new vertices. The embedding fake reproduces the reported
lifecycle (one pooled connection bound to the loop that first used it) — it
models the transport binding, not a live HTTP keep-alive exchange, so it does
not establish real-client behavior.
- `test_fetch_avoids_loop_bound_async_clients` pins the fetch to the sync
client.
- Full suite: 1292 passed, 12 skipped, 2 failed — the same two pre-existing
`test_external_config.py` Windows mode-bit failures as on main. `ruff
format`/`check` clean on touched files; `ty check hugegraph_llm` 265
diagnostics before and after (zero new).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]