elastic / elastic/elastic-evals-sdk-python
[kbn-evals] HTTP efficiency: connection pooling and score batching
- 主要言語
- Python
- スター
- 2
- フォーク
- 0
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 18
説明
### Summary
Every request to Kibana opens a new `httpx.AsyncClient`, makes one call, and closes it. For N examples x R repetitions, every score ingest is a separate TCP connection to the same host. The scores API supports batching but each evaluator result is sent alone.
The [httpx async docs](https://www.python-httpx.org/async/#opening-and-closing-clients) say: "do not instantiate multiple client instances inside a hot loop."
### Problem
- `datasets_client.py:61-62`, `scores_client.py:39`, `evaluators_client.py:83-88`, `inference/client.py:179-180` all use `async with httpx.AsyncClient(...) as client:` per request
- Score ingest sends one `POST` per evaluator result; the scores API accepts a list of scores per request
### Fix
- Create one `httpx.AsyncClient` per API client class in `__init__`, close it in `aclose()`
- `ElasticEvalsClient` manages the lifecycle via `async with` or a `finally` block
- Batch score ingest calls per example rather than per evaluator result
### Done when
- [ ] Each API client holds one `httpx.AsyncClient` for the lifetime of a run
- [ ] `ElasticEvalsClient` supports `async with client:` or `await client.aclose()`
- [ ] Score ingest sends one request per example instead of one per evaluator result
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
datasets_client.py、scores_client.py、evaluators_client.py、inference/client.pyを読み、リクエストごとのAsyncClientのライフサイクルを比較してから、ElasticEvalsClientの所有関係を追跡します。クライアントが1回の実行につき1つのHTTPクライアントを再利用し、非同期クリーンアップをサポートし、例ごとに1つのスコア取り込みリクエストを送信することを確認して、完了した作業を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, networking, performance
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100