elastic / elastic/elastic-evals-sdk-python
[kbn-evals] Code quality and dead-code cleanup
- Lingua principale
- Python
- Stelle
- 2
- Fork
- 0
- Merge medio
- 1g 13h
- PR unite (30g)
- 18
Descrizione
### Summary
Structural cleanups with no behaviour change.
1. URL constants and internal header builders are exported from the public API but shouldn't be. `SimpleEvaluator` and `KibanaScoresClient` are used externally but missing from `__all__`. (`__init__.py`, `api/__init__.py`)
2. Seven ES-export logging helpers in `utils/logging.py` have zero call sites in the codebase. Remove them.
3. `KibanaDatasetsClient`, `KibanaScoresClient`, and `KibanaEvaluatorsClient` each have an identical `__init__` (`kibana_url`, `api_key`, `timeout`). Extract a shared base or dataclass.
4. The connector-ID validation block is copy-pasted in `correctness/evaluator.py` and `groundedness/evaluator.py`. Extract a shared helper.
5. `runner/cli/commands/run.py` repeats env-var name strings that are already literals in `config.py`. Define them as constants in `config.py` and import them. The `_apply_overrides()` function is a slower `env.update(overrides)`. Remove it.
6. Dead `EvaluationResult.reasoning` and `.details` fields (never set or read).
7. `SimpleEvaluator` uses `@dataclass` but its `__init__` is overridden immediately, leaving an unintended `__repr__` and `__eq__`. Replace with a plain class.
8. Five always-populated fields on `EvaluationRun` are typed `Optional` for no reason. Make them required.
9. `log_evaluation_start` logs the same info that the following per-evaluator lines already cover. Remove it.
10. No tests for `runner/suites.py`, `cli/commands/run.py`, or `evaluators/criteria/*`. No `conftest.py`. `_RecordingAsyncClient` is copy-pasted into four separate test files. Move the best version to a shared fixture.
### Done when
- [ ] All items above are addressed in one PR
- [ ] No behaviour change
- [ ] Existing tests pass
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia mappando i file e gli entry point elencati: __init__.py, api/__init__.py, utils/logging.py, correctness/evaluator.py, groundedness/evaluator.py, config.py, runner/cli/commands/run.py e i moduli evaluator, suite e test. Prima di apportare modifiche, fai un inventario dei siti di chiamata, dei costruttori e degli helper duplicati, dei campi inutilizzati e delle quattro copie di _RecordingAsyncClient. Il lavoro è completato quando tutti i dieci elementi di pulizia sono stati affrontati in un unico PR, senza modifiche al comportamento e con i test esistenti superati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- testing-qa, tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100