Back to the room

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

Code Observatory / class

CodeIndexer

codeintel.indexer.CodeIndexer

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

Called by (1)
SymbolFileResolved by
runjobs.pythrough an import
Contains (13)
SymbolFileResolved by
__init__indexer.pysame file
_build_rowsindexer.pysame file
_count_chunksindexer.pysame file
_count_linesindexer.pysame file
_delete_resourcesindexer.pysame file
_embedindexer.pysame file
_index_batchindexer.pysame file
_rebuild_graphindexer.pysame file
_repoint_unchangedindexer.pysame file
_skip_reasonindexer.pysame file
_syncindexer.pysame file
get_or_create_repositoryindexer.pysame file
indexindexer.pysame file
Inside (1)
SymbolFileResolved by
indexerindexer.pysame file
codeintel.indexer.CodeIndexerbackend/app/codeintel/indexer.py, lines 141–200Open source
class CodeIndexer:    def __init__(        self,        session: Session,        embedder: Embedder | None,        *,        max_file_bytes: int = 1_000_000,        max_files: int = 20_000,        clone_timeout: int = 600,        clone_token: str | None = None,        heartbeat: Callable[[], None] | None = None,    ) -> None:        self.db = session        self.embedder = embedder        self.max_file_bytes = max_file_bytes        self.max_files = max_files        self.clone_timeout = clone_timeout        self.clone_token = clone_token        self.heartbeat = heartbeat or (lambda: None)    # ── public ─────────────────────────────────────────────────────────    def get_or_create_repository(self, ref: RepoRef, branch: str | None) -> Repository:        repo = self.db.execute(            select(Repository).where(Repository.url == ref.canonical_url)        ).scalar_one_or_none()        if repo is None:            repo = Repository(                url=ref.canonical_url,                name=ref.name,                repo_metadata={},                source_type=ref.source_type,                branch=branch,                local_path=ref.local_path,                index_status="never_indexed",            )            self.db.add(repo)            self.db.flush()        else:            repo.branch = branch            if ref.local_path:                repo.local_path = ref.local_path        return repo    def index(self, ref: RepoRef, branch: str | None = None, *, force: bool = False) -> IndexStats:        stats = IndexStats(repository=ref.canonical_url)        stats.embedding_model = self.embedder.model_id if self.embedder else None        t0 = time.monotonic()        repo = self.get_or_create_repository(ref, branch)        repo_id = repo.id        previous_commit = repo.last_commit_sha        previous_model = (repo.stats or {}).get("embedding_model")        repo.index_status = "indexing"        self.db.commit()        try:            t = time.monotonic()            checkout = open_checkout(ref, branch=branch, token=self.clone_token, timeout=self.clone_timeout)            stats.timings_s["checkout"] += time.monotonic() - t

Shows the first 60 of 423 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
class CodeIndexer:
File
backend/app/codeintel/indexer.py
Lines
141–563
Parser
python-ast
Git blob
e8fdfa7b5545e821f7649d68cfadd2aae85b89d0
Outside this subset
16 more edges reach code outside the graph shown here

Read it on GitHub at this commit