Back to the room

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

Code Observatory / function

run

codeintel.jobs.run

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 (5)
SymbolFileResolved by
CodeIndexerindexer.pythrough an import
classify_errorjobs.pysame file
heartbeatjobs.pysame file
retry_delay_secondsjobs.pysame file
utcnowjobs.pysame file
Inside (1)
SymbolFileResolved by
jobsjobs.pysame file
codeintel.jobs.runbackend/app/codeintel/jobs.py, lines 252–302Open source
def run(db: Session, job: IngestionJob, ref: RepoRef, embedder: Embedder | None, *,        max_file_bytes: int, max_files: int, clone_timeout: int, clone_token: str | None) -> IngestionJob:    """Execute a claimed job to a terminal (or re-queued) state. Never raises."""    job_id = job.id    def beat() -> None:        try:            heartbeat(db, job_id)        except Exception:  # heartbeats are best-effort            db.rollback()    indexer = CodeIndexer(        db, embedder,        max_file_bytes=max_file_bytes, max_files=max_files,        clone_timeout=clone_timeout, clone_token=clone_token, heartbeat=beat,    )    try:        stats = indexer.index(ref, job.branch_key or None, force=job.force)    except Exception as exc:        db.rollback()        kind, retryable = classify_error(exc)        job = db.get(IngestionJob, job_id)        job.error_kind = kind        job.error = f"{type(exc).__name__}: {exc}"[:2000]        if retryable and job.attempts < job.max_attempts:            job.status = "queued"            job.available_at = utcnow() + timedelta(seconds=retry_delay_seconds(job.attempts))            logger.warning("Ingestion job %s failed (%s), will retry: %s", job_id, kind, exc)        else:            job.status = "failed"            job.finished_at = utcnow()            logger.error("Ingestion job %s failed permanently (%s): %s", job_id, kind, exc,                         exc_info=kind == "internal_error")        db.commit()        return job    job = db.get(IngestionJob, job_id)    repo = db.execute(select(Repository).where(Repository.url == ref.canonical_url)).scalar_one()    job.repository_id = repo.id    job.status = "succeeded"    job.commit_sha = stats.commit_sha    job.stats = stats.as_dict()    job.finished_at = utcnow()    job.error = None    job.error_kind = None    db.commit()    logger.info(        "Ingestion job %s succeeded: %s @ %s (%s, %d files indexed, %d chunks)",        job_id, ref.canonical_url, stats.commit_sha[:12], stats.outcome, stats.files_indexed, stats.chunks_total,    )    return job

What the index recorded

Signature
def run(db: Session, job: IngestionJob, ref: RepoRef, embedder: Embedder | None, *, max_file_bytes: int, max_files: int, clone_timeout: int, clone_token: str | None) -> IngestionJob:
File
backend/app/codeintel/jobs.py
Lines
252–302
Parser
python-ast
Git blob
54c9a5d84ee5feda5176c3e05d0aa9a7d46f6016
Call sites
19 named, 9 resolved, 10 left unlinked
Outside this subset
4 more edges reach code outside the graph shown here

Read it on GitHub at this commit