lplalbert opened a new pull request, #424:
URL: https://github.com/apache/hugegraph-ai/pull/424
## Problem
Two divergent parallel-embedding implementations for the same job:
- `utils/embedding_utils.get_embeddings_parallel` — batch 500, **no**
concurrency bound, despite its docstring promising "a semaphore to limit
maximum concurrency"
- `BuildSemanticIndex._get_embeddings_parallel` — batch 1000,
`Semaphore(10)`, sync method via `run_in_executor`
`build_gremlin_example_index.py` carried a FIXME for this split ("we need
keep the logic same with build_semantic_index.py"). The unbounded helper is a
hazard on large inputs: 100k chunks -> 200 batch requests all in flight at once.
## What this changes
One bounded implementation (`get_embeddings_parallel`) shared by all three
index builds:
- the helper now acquires a `Semaphore(10)` per batch (the bound
`BuildSemanticIndex` already used), honoring the docstring contract that
already existed
- `BuildSemanticIndex` delegates to the helper; its private copy is removed
and the FIXME is retired
- order preservation is unchanged (`asyncio.gather`)
### Behavior deltas (for review)
- Semantic vid index batches 500 instead of 1000 — progress-bar granularity
only; embedding models batch internally (32/10 texts per API call)
- Semantic vid index calls `async_get_texts_embeddings` instead of
executor-wrapped sync `get_texts_embeddings` — Ollama/OpenAI construct sync and
async clients from the same config, and both method pairs have identical
batching/ordering semantics
- Gremlin-example and vector-index builds (already on the helper) gain the
concurrency bound
## Validation (executed locally)
- `SKIP_EXTERNAL_SERVICES=true uv run pytest hugegraph-llm/src/tests` ->
**1290 passed, 12 skipped, 2 failed** — the two `test_external_config.py`
failures (`test_saved_complete_connection_survives_deployment_upgrade`,
`test_single_file_mount_fallback_and_existing_mode`) also fail on clean
`origin/main` (verified via stash), pre-existing and unrelated
- Red-green: new `test_bounds_concurrent_batches` fails before the fix (30
batches in flight vs bound 10) and passes after; the updated semantic-index
tests fail against the old private implementation (4 failed) and pass after
- `uv run --extra dev ruff format --check` + `ruff check` clean on changed
files
- `uv run --extra dev ty check` on changed files reports the same 4
pre-existing diagnostics as `origin/main` (none introduced)
- Pre-existing, out of scope:
`test_build_vector_index.py`/test_gremlin_example_index_query.py emit a
"coroutine never awaited" RuntimeWarning (their patched async helper returns a
coroutine the also-mocked `asyncio.run` discards) — reproduced on clean
`origin/main`
Refs #107
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]