fix: remove test import (#1017)

Convention in the tests is to just import the libraries as production
code would. This is fragile, and could possibly be used to inject
malicious code in the CI environment.
This commit is contained in:
cybermaggedon 2026-07-03 13:44:09 +01:00 committed by GitHub
parent f04ae5331d
commit c05296376e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,30 +1,8 @@
import importlib.util
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[3]
RERANK_PATH = (
REPO_ROOT
/ "trustgraph-flow"
/ "trustgraph"
/ "retrieval"
/ "document_rag"
/ "rerank.py"
from trustgraph.retrieval.document_rag.rerank import (
RerankCandidate, normalize_candidate_scores, mmr_select,
_pair_diversity_penalty
)
spec = importlib.util.spec_from_file_location(
"document_rag_diversity_rerank",
RERANK_PATH,
)
rerank = importlib.util.module_from_spec(spec)
spec.loader.exec_module(rerank)
RerankCandidate = rerank.RerankCandidate
normalize_candidate_scores = rerank.normalize_candidate_scores
mmr_select = rerank.mmr_select
_pair_diversity_penalty = rerank._pair_diversity_penalty
def candidate(index, chunk_id, text, score):
return RerankCandidate(
index=index,