Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / method

_finalize

codeintel.retrieval.Retriever._finalize

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (1)
SymbolFileResolved by
path_roleretrieval.pysame file
Called by (1)
SymbolFileResolved by
searchretrieval.pysame file
Inside (1)
SymbolFileResolved by
Retrieverretrieval.pysame file
codeintel.retrieval.Retriever._finalizebackend/app/codeintel/retrieval.py, lines 511–531Open source
    def _finalize(self, hits: dict[str, Hit], k: int, wanted: set[str] = frozenset()) -> list[Hit]:        if not hits:            return []        # Down-rank tests, docs and examples (they repeat the words of the        # code they exercise or describe and crowd out implementations);        # applied after fusion so they still surface when they are the only        # match, and not at all for roles the query asks for.        paths = dict(            self.db.execute(                select(DocumentChunk.id, DocumentChunk.chunk_metadata["path"].as_string()).where(                    DocumentChunk.id.in_([uuid.UUID(c) for c in hits])                )            ).all()        )        for cid, h in hits.items():            role = path_role(paths.get(uuid.UUID(cid)) or "")            if role != "source" and role not in wanted:                h.score *= NOISE_PATH_FACTOR                h.evidence.boosts.append(f"{role}_path_penalty")        ranked = sorted(hits.values(), key=lambda h: (-h.score, h.chunk_id))        return ranked[:k]

What the index recorded

Signature
def _finalize(self, hits: dict[str, Hit], k: int, wanted: set[str]) -> list[Hit]:
File
backend/app/codeintel/retrieval.py
Lines
511–531
Parser
python-ast
Git blob
884729a39ae0b3d340ad83f75946677dcddf3791
Call sites
14 named, 3 resolved, 11 left unlinked
Outside this subset
2 more edges reach code outside the graph shown here

Read it on GitHub at this commit