Back to the room

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

Code Observatory / method

neighbors

codeintel.retrieval.Retriever.neighbors

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

Inside (1)
SymbolFileResolved by
Retrieverretrieval.pysame file
codeintel.retrieval.Retriever.neighborsbackend/app/codeintel/retrieval.py, lines 567–590Open source
    def neighbors(self, chunk_ids: Iterable[str], limit: int = 10) -> list[tuple[str, str, str]]:        """``(seed_id, neighbor_id, relation)`` for one hop around ``chunk_ids``."""        ids = [uuid.UUID(c) for c in chunk_ids]        if not ids:            return []        rows = self.db.execute(            select(CodeEdge.source_chunk_id, CodeEdge.target_chunk_id, CodeEdge.edge_type)            .where(                and_(                    CodeEdge.edge_type != "contains",                    or_(CodeEdge.source_chunk_id.in_(ids), CodeEdge.target_chunk_id.in_(ids)),                )            )            .limit(limit * 4)        ).all()        seeds = {str(i) for i in ids}        out = []        for s, t, etype in rows:            s, t = str(s), str(t)            if s in seeds and t not in seeds:                out.append((s, t, etype))            elif t in seeds and s not in seeds:                out.append((t, s, {"calls": "called_by", "imports": "imported_by"}.get(etype, etype)))        return out[:limit]

What the index recorded

Signature
def neighbors(self, chunk_ids: Iterable[str], limit: int) -> list[tuple[str, str, str]]:
File
backend/app/codeintel/retrieval.py
Lines
567–590
Parser
python-ast
Git blob
884729a39ae0b3d340ad83f75946677dcddf3791
Call sites
12 named, 2 resolved, 10 left unlinked
Outside this subset
2 more edges reach code outside the graph shown here

Read it on GitHub at this commit