elastic / elastic/elastic-evals-sdk-python

[kbn-evals] HTTP efficiency: connection pooling and score batching

Offen
#39 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
kbn-evals Team:nightshift-context-and-research
Vorherrschende Sprache
Python
Sterne
2
Forks
0
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
18

Beschreibung

### 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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Lies datasets_client.py, scores_client.py, evaluators_client.py und inference/client.py, um ihre AsyncClient-Lebenszyklen pro Anfrage zu vergleichen, und verfolge anschließend die Eigentümerschaft von ElasticEvalsClient. Überprüfe die abgeschlossene Arbeit, indem du kontrollierst, dass Clients einen HTTP-Client pro Lauf wiederverwenden, asynchrones Aufräumen unterstützen und eine Score-Ingest-Anfrage pro Beispiel senden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, networking, performance
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.