repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
onyx | backend/onyx/file_processing/extract_file_text.py | .py | import csv
import gc
import io
import json
import os
import re
import tempfile
import zipfile
from collections.abc import Callable, Iterator, Sequence
from email.parser import Parser as EmailParser
from io import BytesIO
from pathlib import Path
from typing import IO, TYPE_CHECKING, Any, NamedTuple, Optional, cast
from... | 1,045 | 37,096 |
onyx | backend/onyx/file_processing/enums.py | .py | from enum import Enum
class HtmlBasedConnectorTransformLinksStrategy(str, Enum):
# remove links entirely
STRIP = "strip"
# turn HTML links into markdown links
MARKDOWN = "markdown"
| 9 | 199 |
onyx | backend/onyx/file_processing/html_utils.py | .py | import re
from copy import copy
from dataclasses import dataclass
from io import BytesIO
from typing import IO
import bs4
from onyx.configs.app_configs import (
HTML_BASED_CONNECTOR_TRANSFORM_LINKS_STRATEGY,
PARSE_WITH_TRAFILATURA,
WEB_CONNECTOR_IGNORED_CLASSES,
WEB_CONNECTOR_IGNORED_ELEMENTS,
)
from ... | 232 | 7,938 |
onyx | backend/onyx/file_processing/file_types.py | .py | PRESENTATION_MIME_TYPE = (
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
)
SPREADSHEET_MIME_TYPE = (
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)
# Macro-enabled Excel workbooks (.xlsm) — parseable by openpyxl just like xlsx.
# Stored lowercase; chat MIME ... | 101 | 2,592 |
onyx | backend/onyx/file_processing/unstructured.py | .py | from typing import IO, TYPE_CHECKING, Any, cast
from onyx.configs.constants import KV_UNSTRUCTURED_API_KEY
from onyx.key_value_store.factory import get_kv_store
from onyx.key_value_store.interface import KvKeyNotFoundError
from onyx.utils.logger import setup_logger
if TYPE_CHECKING:
from unstructured_client.model... | 72 | 2,207 |
onyx | backend/onyx/file_processing/password_validation.py | .py | from collections.abc import Callable, Generator
from contextlib import contextmanager
from typing import IO, Any
from onyx.file_processing.extract_file_text import get_file_ext
from onyx.utils.logger import setup_logger
logger = setup_logger()
PASSWORD_PROTECTED_FILES = [
".pdf",
".docx",
".pptx",
".... | 98 | 2,530 |
onyx | backend/onyx/file_processing/image_utils.py | .py | from collections.abc import Callable
from io import BytesIO
from typing import Tuple
from onyx.configs.constants import FileOrigin
from onyx.connectors.models import ImageSection, TabularSection, TextSection
from onyx.file_processing.file_types import OnyxMimeTypes
from onyx.file_store.file_store import get_default_fi... | 99 | 3,233 |
onyx | backend/onyx/httpx/httpx_pool.py | .py | import threading
from typing import Any
import httpx
def make_default_kwargs() -> dict[str, Any]:
return {
"http2": True,
"limits": httpx.Limits(),
}
class HttpxPool:
"""Class to manage a global httpx Client instance"""
_clients: dict[str, httpx.Client] = {}
_lock: threading.Lo... | 61 | 1,739 |
onyx | backend/onyx/tracing/incognito.py | .py | from onyx.db.enums import IncognitoRecordMode
from shared_configs.contextvars import get_current_incognito_record_mode
def suppresses_external_traces() -> bool:
"""External tracing processors must check this at trace start and drop the
whole trace, spans included, when True."""
mode = IncognitoRecordMode.... | 10 | 439 |
onyx | backend/onyx/tracing/llm_utils.py | .py | from __future__ import annotations
from collections.abc import Iterator, Mapping, Sequence
from contextlib import contextmanager
from typing import Any, cast
from onyx.llm.interfaces import LLM
from onyx.llm.model_response import ModelResponse
from onyx.llm.models import ToolCall
from onyx.tracing.flows import LLMFlo... | 215 | 7,807 |
onyx | backend/onyx/tracing/setup.py | .py | """Registers the DynamicTracingProcessor, which resolves the live (DB-or-env)
provider config at runtime so config changes apply without a restart."""
from onyx.configs.app_configs import USER_USAGE_TRACKING_ENABLED
from onyx.tracing.dynamic_processor import DynamicTracingProcessor
from onyx.tracing.framework import a... | 82 | 2,961 |
onyx | backend/onyx/tracing/provider_config.py | .py | """Resolve the effective tracing-provider config: a DB row (if present) wins per
provider, else env-var fallback. Env-only under MULTI_TENANT (UI config is
unsupported on cloud)."""
from __future__ import annotations
from dataclasses import dataclass
from onyx.configs.app_configs import (
BRAINTRUST_API_KEY,
... | 145 | 4,573 |
onyx | backend/onyx/tracing/flows.py | .py | """Registry of flow tags applied to LLM-related generation spans.
Each value identifies the *operation* a span represents — e.g.
``contextual_rag_chunk_context`` or ``image_generation``. The provider, model,
and deployment are captured separately on the span's ``model_config``, so the
flow tag should describe **what t... | 75 | 2,687 |
onyx | backend/onyx/tracing/langfuse_tracing_processor.py | .py | """Langfuse tracing processor using the native Langfuse SDK."""
from __future__ import annotations
import logging
import threading
from datetime import datetime
from typing import Any, Optional, Union
from langfuse import Langfuse
from langfuse._client.span import LangfuseObservationWrapper
from onyx.tracing.flows ... | 442 | 18,053 |
onyx | backend/onyx/tracing/masking.py | .py | """Shared data masking utilities for tracing processors."""
import os
import re
from typing import Any
# Set loosely because some tool call results may be very long.
# Ideally we don't pass those to the LLM but it's fine if we want to trace them in full.
MASKING_LENGTH = int(os.environ.get("TRACING_MASKING_LENGTH", "... | 72 | 2,640 |
onyx | backend/onyx/tracing/dynamic_processor.py | .py | """Tracing processor that reflects the live (DB-or-env) provider config.
Registered once at startup; resolves the effective config on a short TTL and
rebuilds the Braintrust/Langfuse delegates when it changes, so connect/disconnect
applies without a restart. The delegate set is pinned per-trace so a config change
neve... | 212 | 8,069 |
onyx | backend/onyx/tracing/validation.py | .py | """Best-effort credential validation for tracing providers (used by /test).
Validation hits each provider's REST API directly with the supplied credentials
rather than the provider SDKs. The SDK entry points (e.g. ``braintrust.login``)
mutate process-global state, so calling them here would let a test key clobber the
... | 79 | 2,813 |
onyx | backend/onyx/tracing/braintrust_tracing_processor.py | .py | import datetime
from typing import Any, Dict, Optional
import braintrust
from braintrust import NOOP_SPAN
from onyx.llm.cost import compute_cost_cents
from onyx.tracing.flows import IMAGE_FLOWS
from onyx.tracing.incognito import suppresses_external_traces
from .framework.processor_interface import TracingProcessor
f... | 312 | 11,842 |
onyx | backend/onyx/tracing/processors/user_usage_processor.py | .py | """Universal per-user usage recorder — buffers priced generation spans and
drains them to the per-user usage rollup off the LLM hot path."""
from __future__ import annotations
import queue
import threading
from collections import defaultdict
from dataclasses import dataclass, replace
from datetime import datetime, ti... | 308 | 11,560 |
onyx | backend/onyx/tracing/framework/provider.py | .py | from __future__ import annotations
import threading
import uuid
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import Any
from onyx.utils.logger import setup_logger
from .processor_interface import TracingProcessor
from .scope import Scope
from .spans import NoOpSpan, Span, S... | 317 | 10,324 |
onyx | backend/onyx/tracing/framework/span_data.py | .py | import abc
from collections.abc import Mapping, Sequence
from typing import Any
class SpanData(abc.ABC):
"""
Represents span data in the trace.
"""
@abc.abstractmethod
def export(self) -> dict[str, Any]:
"""Export the span data as a dictionary."""
@property
@abc.abstractmethod
... | 152 | 4,125 |
onyx | backend/onyx/tracing/framework/scope.py | .py | import contextvars
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from .spans import Span
from .traces import Trace
_current_span: contextvars.ContextVar["Span[Any] | None"] = contextvars.ContextVar(
"current_span", default=None
)
_current_trace: contextvars.ContextVar["Trace | None"] = contextv... | 49 | 1,280 |
onyx | backend/onyx/tracing/framework/processor_interface.py | .py | import abc
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from .spans import Span
from .traces import Trace
class TracingProcessor(abc.ABC):
"""Interface for processing and monitoring traces and spans in the OpenAI Agents system.
This abstract class defines the interface that all tracing pr... | 136 | 4,294 |
onyx | backend/onyx/tracing/framework/setup.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .provider import TraceProvider
GLOBAL_TRACE_PROVIDER: TraceProvider | None = None
def set_trace_provider(provider: TraceProvider) -> None:
"""Set the global trace provider used by tracing utilities."""
global GLO... | 22 | 612 |
onyx | backend/onyx/tracing/framework/util.py | .py | import uuid
from datetime import datetime, timezone
def time_iso() -> str:
"""Return the current time in ISO 8601 format."""
return datetime.now(timezone.utc).isoformat()
def gen_trace_id() -> str:
"""Generate a new trace ID."""
return f"trace_{uuid.uuid4().hex}"
def gen_span_id() -> str:
"""G... | 18 | 389 |
onyx | backend/onyx/tracing/framework/__init__.py | .py | from .processor_interface import TracingProcessor
from .provider import DefaultTraceProvider
from .setup import get_trace_provider, set_trace_provider
def add_trace_processor(span_processor: TracingProcessor) -> None:
"""
Adds a new trace processor. This processor will receive all traces/spans.
"""
ge... | 21 | 647 |
onyx | backend/onyx/tracing/framework/create.py | .py | from __future__ import annotations
from collections.abc import Iterator, Mapping, Sequence
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from pydantic import BaseModel, Field
from onyx.utils.logger import setup_logger
from shared_configs.contextvars import get_current_tenant_id
from .s... | 239 | 9,045 |
onyx | backend/onyx/tracing/framework/spans.py | .py | from __future__ import annotations
import abc
import contextvars
from types import TracebackType
from typing import Any, Generic, TypeVar
from typing_extensions import TypedDict
from . import util
from .processor_interface import TracingProcessor
from .scope import Scope
from .span_data import SpanData
TSpanData = ... | 355 | 9,455 |
onyx | backend/onyx/tracing/framework/traces.py | .py | from __future__ import annotations
import abc
import contextvars
from types import TracebackType
from typing import TYPE_CHECKING, Any
from . import util
from .scope import Scope
if TYPE_CHECKING:
from .processor_interface import TracingProcessor
class Trace(abc.ABC):
"""A complete end-to-end workflow cont... | 286 | 8,040 |
onyx | backend/onyx/tracing/framework/_error_tracing.py | .py | from typing import Any
from onyx.utils.logger import setup_logger
from .create import get_current_span
from .spans import Span, SpanError
logger = setup_logger(__name__)
def attach_error_to_span(span: Span[Any], error: SpanError) -> None:
span.set_error(error)
def attach_error_to_current_span(error: SpanErro... | 21 | 487 |
onyx | backend/onyx/background/periodic_poller.py | .py | """Periodic poller for NO_VECTOR_DB deployments.
Replaces Celery Beat and background workers with a lightweight daemon thread
that runs from the API server process. Two responsibilities:
1. Recovery polling (every 30 s): re-processes user files stuck in
PROCESSING / DELETING / needs_sync states via the drain loop... | 336 | 10,743 |
onyx | backend/onyx/background/error_logging.py | .py | from sqlalchemy.exc import IntegrityError
from onyx.db.background_error import create_background_error
from onyx.db.engine.sql_engine import get_session_with_current_tenant
def emit_background_error(
message: str,
cc_pair_id: int | None = None,
) -> None:
"""Currently just saves a row in the background_e... | 38 | 1,286 |
onyx | backend/onyx/background/task_utils.py | .py | """Background task utilities.
Contains query-history report helpers (used by all deployment modes), the
shared enqueue path for user file deletes, and in-process background task
execution helpers for NO_VECTOR_DB mode:
- Atomic claim-and-mark helpers that prevent duplicate processing
- Drain loops that process all pe... | 281 | 9,714 |
onyx | backend/onyx/background/indexing/dask_utils.py | .py | import asyncio
import psutil
from dask.distributed import WorkerPlugin
from distributed import Worker
from onyx.utils.logger import setup_logger
logger = setup_logger()
class ResourceLogger(WorkerPlugin):
def __init__(self, log_interval: int = 60 * 5):
self.log_interval = log_interval
def setup(se... | 37 | 1,267 |
onyx | backend/onyx/background/indexing/models.py | .py | from datetime import datetime
from pydantic import BaseModel
from onyx.db.models import IndexAttemptError
class IndexAttemptErrorPydantic(BaseModel):
id: int
connector_credential_pair_id: int
document_id: str | None
document_link: str | None
entity_id: str | None
failed_time_range_start: d... | 44 | 1,248 |
onyx | backend/onyx/background/indexing/job_client.py | .py | """Custom client that works similarly to Dask, but simpler and more lightweight.
Dask jobs behaved very strangely - they would die all the time, retries would
not follow the expected behavior, etc.
NOTE: cannot use Celery directly due to
https://github.com/celery/celery/issues/7007#issuecomment-1740139367"""
import m... | 256 | 8,399 |
onyx | backend/onyx/background/indexing/run_docfetching.py | .py | import sys
import time
import traceback
from collections.abc import Generator, Iterable
from datetime import datetime, timedelta, timezone
from typing import TypeVar
import sentry_sdk
from celery import Celery
from sqlalchemy.orm import Session
from onyx.access.access import source_should_fetch_permissions_during_ind... | 1,085 | 43,857 |
onyx | backend/onyx/background/indexing/checkpointing_utils.py | .py | from datetime import datetime, timedelta
from io import BytesIO
from sqlalchemy import and_
from sqlalchemy.orm import Session
from onyx.configs.constants import NUM_DAYS_TO_KEEP_CHECKPOINTS, FileOrigin
from onyx.connectors.interfaces import BaseConnector, CheckpointedConnector
from onyx.connectors.models import Conn... | 217 | 8,154 |
onyx | backend/onyx/background/indexing/index_attempt_utils.py | .py | from datetime import timedelta
from sqlalchemy import func
from sqlalchemy.orm import Session
from onyx.configs.constants import NUM_DAYS_TO_KEEP_INDEX_ATTEMPTS
from onyx.db.engine.time_utils import get_db_current_time
from onyx.db.models import IndexAttempt, IndexAttemptError
# Always retain at least this many atte... | 71 | 2,508 |
onyx | backend/onyx/background/indexing/memory_tracer.py | .py | import tracemalloc
from onyx.utils.logger import setup_logger
logger = setup_logger()
DANSWER_TRACEMALLOC_FRAMES = 10
class MemoryTracer:
def __init__(self, interval: int = 0, num_print_entries: int = 5):
self.interval = interval
self.num_print_entries = num_print_entries
self.snapshot_... | 91 | 3,172 |
onyx | backend/onyx/background/indexing/run_targeted_reindex.py | .py | """Per-cc-pair fetch + index for the targeted-reindex flow.
The targeted-reindex celery task delegates the actual connector
invocation + pipeline plumbing to this module so the task body stays
focused on lifecycle and resolution-tracking. One call to
`process_targets_for_cc_pair` covers a single cc_pair: it instantiat... | 371 | 14,138 |
onyx | backend/onyx/background/celery/celery_k8s_probe.py | .py | # script to use as a kubernetes readiness / liveness probe
import argparse
import sys
import time
from pathlib import Path
def main_readiness(filename: str) -> int:
"""Checks if the file exists."""
path = Path(filename)
if not path.is_file():
return 1
return 0
def main_liveness(filename: s... | 56 | 1,353 |
onyx | backend/onyx/background/celery/celery_redis.py | .py | # These are helper objects for tracking the keys we need to write in redis
import json
import threading
from typing import Any, cast
from celery import Celery
from redis import Redis
from onyx.background.celery.configs.base import CELERY_SEPARATOR
from onyx.configs.app_configs import REDIS_HEALTH_CHECK_INTERVAL
from ... | 243 | 8,593 |
onyx | backend/onyx/background/celery/memory_monitoring.py | .py | # backend/onyx/background/celery/memory_monitoring.py
import logging
import os
import threading
import tracemalloc
from logging.handlers import RotatingFileHandler
import psutil
from onyx.configs.app_configs import (
INDEXING_WORKER_MEMORY_LIMIT_MB,
INDEXING_WORKER_TRACEMALLOC,
)
from onyx.utils.logger import... | 163 | 5,411 |
onyx | backend/onyx/background/celery/celery_utils.py | .py | import time
from collections.abc import Generator, Iterator, Sequence
from datetime import datetime, timezone
from pathlib import Path
from typing import Any, TypeVar, cast
import httpx
from pydantic import BaseModel
from onyx.configs.app_configs import (
MAX_PRUNING_DOCUMENT_RETRIEVAL_PER_MINUTE,
VESPA_REQUE... | 318 | 11,835 |
onyx | backend/onyx/background/celery/apps/docprocessing.py | .py | from typing import Any, cast
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import (
celeryd_init,
worker_init,
worker_process_init,
worker_ready,
worker_shutdown,
)
import onyx.background.celery.apps.app_base as app_base
from onyx.background.cel... | 172 | 5,874 |
onyx | backend/onyx/background/celery/apps/docfetching.py | .py | from typing import Any, cast
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import (
celeryd_init,
worker_init,
worker_ready,
worker_shutdown,
worker_shutting_down,
)
import onyx.background.celery.apps.app_base as app_base
from onyx.background.ce... | 162 | 5,219 |
onyx | backend/onyx/background/celery/apps/monitoring.py | .py | import multiprocessing
from typing import Any
from celery import Celery, Task, signals
from celery.signals import celeryd_init, worker_init, worker_ready, worker_shutdown
import onyx.background.celery.apps.app_base as app_base
from onyx.configs.constants import POSTGRES_CELERY_WORKER_MONITORING_APP_NAME
from onyx.db.... | 153 | 4,871 |
onyx | backend/onyx/background/celery/apps/user_file_processing.py | .py | from typing import Any, cast
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import (
celeryd_init,
worker_init,
worker_process_init,
worker_ready,
worker_shutdown,
)
import onyx.background.celery.apps.app_base as app_base
from onyx.configs.consta... | 116 | 3,502 |
onyx | backend/onyx/background/celery/apps/scheduled_tasks.py | .py | from typing import Any, cast
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import celeryd_init, worker_init, worker_ready, worker_shutdown
import onyx.background.celery.apps.app_base as app_base
from onyx.configs.constants import POSTGRES_CELERY_WORKER_SCHEDULED_TA... | 137 | 4,458 |
onyx | backend/onyx/background/celery/apps/app_base.py | .py | import logging
import multiprocessing
import os
import sys
import time
from typing import Any, cast
from celery import (
Task,
bootsteps,
)
from celery.app import trace
from celery.exceptions import WorkerShutdown
from celery.signals import before_task_publish, task_postrun, task_prerun
from celery.states impo... | 755 | 27,085 |
onyx | backend/onyx/background/celery/apps/client.py | .py | from celery import Celery
import onyx.background.celery.apps.app_base as app_base
celery_app = Celery(__name__)
celery_app.config_from_object("onyx.background.celery.configs.client")
celery_app.Task = app_base.TenantAwareTask # ty: ignore[invalid-assignment]
| 8 | 262 |
onyx | backend/onyx/background/celery/apps/primary.py | .py | import logging
import os
from typing import Any, cast
from celery import (
Celery,
Task,
bootsteps,
signals,
)
from celery.apps.worker import Worker
from celery.exceptions import WorkerShutdown
from celery.result import AsyncResult
from celery.signals import celeryd_init, worker_init, worker_ready, wor... | 364 | 13,948 |
onyx | backend/onyx/background/celery/apps/task_formatters.py | .py | import logging
from celery import current_task
from onyx.utils.logger import ColoredFormatter, PlainFormatter, get_json_formatter
class CeleryTaskJsonFormatter(logging.Formatter):
"""JSON formatter for celery tasks. Emits ``task_id``/``task_name`` as
structured fields instead of prefixing the message string... | 41 | 1,416 |
onyx | backend/onyx/background/celery/apps/heavy.py | .py | from typing import Any, cast
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import celeryd_init, worker_init, worker_ready, worker_shutdown
import onyx.background.celery.apps.app_base as app_base
from onyx.configs.constants import POSTGRES_CELERY_WORKER_HEAVY_APP_NA... | 136 | 4,315 |
onyx | backend/onyx/background/celery/apps/beat.py | .py | from collections.abc import ItemsView
from datetime import timedelta
from typing import Any
from celery import Celery, signals
from celery.beat import PersistentScheduler
from celery.signals import beat_init
from celery.utils.log import get_task_logger
import onyx.background.celery.apps.app_base as app_base
from onyx... | 277 | 10,026 |
onyx | backend/onyx/background/celery/apps/light.py | .py | from typing import Any
from celery import Celery, Task, signals
from celery.apps.worker import Worker
from celery.signals import celeryd_init, worker_init, worker_ready, worker_shutdown
import onyx.background.celery.apps.app_base as app_base
from onyx.background.celery.celery_utils import httpx_init_vespa_pool
from o... | 167 | 5,329 |
onyx | backend/onyx/background/celery/tasks/beat_schedule.py | .py | import copy
from datetime import timedelta
from typing import Any
from celery.schedules import crontab
from onyx.configs.app_configs import (
AUTO_LLM_CONFIG_URL,
AUTO_LLM_UPDATE_INTERVAL_SECONDS,
DISABLE_OPENSEARCH_MIGRATION_TASK,
DISABLE_VECTOR_DB,
ENABLE_OPENSEARCH_INDEXING_FOR_ONYX,
ENTERP... | 501 | 18,469 |
onyx | backend/onyx/background/celery/tasks/models.py | .py | from enum import Enum
from pydantic import BaseModel
class DocProcessingContext(BaseModel):
tenant_id: str
cc_pair_id: int
search_settings_id: int
index_attempt_id: int
class IndexingWatchdogTerminalStatus(str, Enum):
"""The different statuses the watchdog can finish with.
TODO: create bro... | 125 | 5,147 |
onyx | backend/onyx/background/celery/tasks/hierarchyfetching/tasks.py | .py | """Celery tasks for hierarchy fetching.
This module provides tasks for fetching hierarchy node information from connectors.
Hierarchy nodes represent structural elements like folders, spaces, and pages that
can be used to filter search results.
The hierarchy fetching pipeline runs once per day per connector and fetch... | 421 | 13,847 |
onyx | backend/onyx/background/celery/tasks/user_file_processing/tasks.py | .py | import datetime
import time
from uuid import UUID
import sqlalchemy as sa
from celery import Celery, Task, shared_task
from redis.lock import Lock as RedisLock
from sqlalchemy import select
from onyx.access.access import build_access_for_user_files
from onyx.access.models import DocumentAccess
from onyx.background.ce... | 1,249 | 49,867 |
onyx | backend/onyx/background/celery/tasks/shared/RetryDocumentIndex.py | .py | import httpx
from tenacity import (
retry,
retry_if_exception_type,
stop_after_delay,
wait_random_exponential,
)
from onyx.document_index.interfaces_new import DocumentIndex, MetadataUpdateRequest
class RetryDocumentIndex:
"""A wrapper class to help with specific retries against Vespa involving
... | 49 | 1,395 |
onyx | backend/onyx/background/celery/tasks/shared/tasks.py | .py | import time
from datetime import datetime
from enum import Enum
from http import HTTPStatus
import httpx
from celery import Task, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from sqlalchemy.orm import Session
from tenacity import RetryError
from onyx.access.access import get_access_for_document
fr... | 370 | 16,170 |
onyx | backend/onyx/background/celery/tasks/monitoring/tasks.py | .py | import json
import time
from datetime import timedelta
from itertools import islice
from typing import Any, Literal, cast
import psutil
from celery import Task, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from pydantic import BaseModel
from redis import Redis
from redis.lock import Lock as RedisLoc... | 1,199 | 45,074 |
onyx | backend/onyx/background/celery/tasks/opensearch_migration/transformer.py | .py | import traceback
from datetime import datetime, timezone
from typing import Any
from onyx.configs.constants import PUBLIC_DOC_PAT
from onyx.document_index.interfaces_new import TenantState
from onyx.document_index.opensearch.schema import DocumentChunk
from onyx.document_index.vespa_constants import (
ACCESS_CONTR... | 349 | 13,294 |
onyx | backend/onyx/background/celery/tasks/opensearch_migration/constants.py | .py | # Tasks are expected to cease execution and do cleanup after the soft time
# limit. In principle they are also forceably terminated after the hard time
# limit, in practice this does not happen since we use threadpools for Celery
# task execution, and we simple hope that the total task time plus cleanup does
# not exce... | 57 | 2,974 |
onyx | backend/onyx/background/celery/tasks/opensearch_migration/tasks.py | .py | """Celery tasks for migrating documents from Vespa to OpenSearch."""
import time
import traceback
from celery import Task, shared_task
from redis.lock import Lock as RedisLock
from onyx.background.celery.apps.app_base import task_logger
from onyx.background.celery.tasks.opensearch_migration.constants import (
FI... | 335 | 15,434 |
onyx | backend/onyx/background/celery/tasks/connector_deletion/tasks.py | .py | import traceback
from datetime import datetime, timezone
from typing import Any, cast
from celery import Celery, Task, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from pydantic import ValidationError
from redis import Redis
from redis.lock import Lock as RedisLock
from sqlalchemy.orm import Session... | 779 | 30,870 |
onyx | backend/onyx/background/celery/tasks/vespa/document_sync.py | .py | import time
from typing import cast
from uuid import uuid4
from celery import Celery
from redis.lock import Lock as RedisLock
from sqlalchemy.orm import Session
from onyx.configs.app_configs import DB_YIELD_PER_DEFAULT
from onyx.configs.constants import (
CELERY_DOCUMENT_SYNC_TASK_EXPIRES,
CELERY_VESPA_SYNC_B... | 217 | 7,246 |
onyx | backend/onyx/background/celery/tasks/vespa/tasks.py | .py | import time
from collections.abc import Callable
from datetime import datetime
from http import HTTPStatus
from typing import Any, cast
import httpx
from celery import Celery, Task, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from redis.lock import Lock as RedisLock
from sqlalchemy.orm import Sessi... | 641 | 24,323 |
onyx | backend/onyx/background/celery/tasks/docprocessing/utils.py | .py | import time
from datetime import datetime, timezone
from redis.exceptions import LockError
from redis.lock import Lock as RedisLock
from sqlalchemy.orm import Session
from onyx.configs.app_configs import DISABLE_INDEX_UPDATE_ON_SWAP
from onyx.configs.constants import CELERY_GENERIC_BEAT_LOCK_TIMEOUT, DocumentSource
f... | 310 | 12,212 |
onyx | backend/onyx/background/celery/tasks/docprocessing/heartbeat.py | .py | import contextvars
import threading
from sqlalchemy import update
from onyx.configs.constants import INDEXING_WORKER_HEARTBEAT_INTERVAL
from onyx.db.engine.sql_engine import get_session_with_current_tenant
from onyx.db.models import IndexAttempt
from onyx.utils.logger import setup_logger
logger = setup_logger()
de... | 45 | 1,663 |
onyx | backend/onyx/background/celery/tasks/docprocessing/targeted_reindex_task.py | .py | """Celery task for executing a targeted reindex.
This task wires the job-and-target rows persisted by the API to the
synthetic IndexAttempt(s) that drive per-cc-pair execution. Lifecycle
+ counter aggregation + resolution-tracking gating live here; per-cc-pair
connector invocation + indexing pipeline plumbing live in
... | 213 | 8,817 |
onyx | backend/onyx/background/celery/tasks/docprocessing/batch_counters.py | .py | """Batch counter signal handlers for docprocessing tasks.
Maintains two per-attempt Redis counters (id = IndexAttempt.id):
docprocessing_pending_{id} - batches dispatched but not yet picked up
docprocessing_in_flight_{id} - batches picked up but not yet completed
These counters let the monitor distinguish worke... | 101 | 3,434 |
onyx | backend/onyx/background/celery/tasks/docprocessing/tasks.py | .py | import gc
import os
import time
import traceback
from collections import defaultdict
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import Any
from celery import Celery, Task, current_app, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from pydantic im... | 2,047 | 81,174 |
onyx | backend/onyx/background/celery/tasks/llm_model_update/tasks.py | .py | from celery import Task, shared_task
from onyx.background.celery.apps.app_base import task_logger
from onyx.configs.app_configs import AUTO_LLM_CONFIG_URL
from onyx.configs.constants import OnyxCeleryTask
from onyx.db.engine.sql_engine import get_session_with_current_tenant
from onyx.llm.well_known_providers.auto_upda... | 49 | 1,511 |
onyx | backend/onyx/background/celery/tasks/port/tasks.py | .py | """Reindexing port machinery: the producer task plus the beat scheduler.
`run_port_attempt` (producer) drains one PortAttempt, copying a cc_pair's
documents PRESENT -> FUTURE (re-embedded under the new model) and committing a
per-batch cursor so a crash or stall resumes rather than restarts.
`check_for_port` (beat sc... | 870 | 35,504 |
onyx | backend/onyx/background/celery/tasks/pruning/tasks.py | .py | import time
from datetime import datetime, timedelta, timezone
from typing import Any, cast
from uuid import uuid4
from celery import Celery, Task, shared_task
from celery.exceptions import SoftTimeLimitExceeded
from pydantic import ValidationError
from redis import Redis
from redis.lock import Lock as RedisLock
from ... | 1,043 | 38,432 |
onyx | backend/onyx/background/celery/tasks/docfetching/task_creation_utils.py | .py | from uuid import uuid4
from celery import Celery
from redis.lock import Lock as RedisLock
from sqlalchemy.orm import Session
from onyx.background.celery.apps.app_base import task_logger
from onyx.configs.constants import (
DANSWER_REDIS_FUNCTION_LOCK_PREFIX,
OnyxCeleryPriority,
OnyxCeleryQueues,
OnyxC... | 126 | 4,151 |
onyx | backend/onyx/background/celery/tasks/docfetching/worker_shutdown.py | .py | """Process-global flag that the docfetching worker is shutting down.
The ``worker_shutting_down`` handler sets it on SIGTERM. The indexing watchdog
polls it and interrupts its in-flight attempt for a fast checkpoint resume instead
of the heartbeat timeout. Both run in the same process (handler on the main thread,
watc... | 20 | 622 |
onyx | backend/onyx/background/celery/tasks/docfetching/tasks.py | .py | import multiprocessing
import os
import time
import traceback
from time import sleep
import psutil
from celery import Celery, Task, shared_task
from onyx.background.celery.apps.app_base import task_logger
from onyx.background.celery.memory_monitoring import (
emit_process_memory,
start_memory_observer,
st... | 839 | 33,926 |
onyx | backend/onyx/background/celery/tasks/evals/tasks.py | .py | from datetime import datetime, timezone
from typing import Any
from celery import Task, shared_task
from onyx.configs.app_configs import (
BRAINTRUST_API_KEY,
JOB_TIMEOUT,
SCHEDULED_EVAL_DATASET_NAMES,
SCHEDULED_EVAL_PERMISSIONS_EMAIL,
SCHEDULED_EVAL_PROJECT,
)
from onyx.configs.constants import O... | 153 | 4,878 |
onyx | backend/onyx/background/celery/tasks/scheduled_tasks/tasks.py | .py | """Celery tasks for Craft Scheduled Tasks.
Three @shared_task wrappers, split across two queues:
- ``dispatch_due_scheduled_tasks`` (primary queue, per tenant, every
30 s): claims due rows via ``FOR UPDATE SKIP LOCKED``, advances
``next_run_at``, writes either a QUEUED run row (and enqueues the
executor onto ``... | 298 | 11,624 |
onyx | backend/onyx/background/celery/configs/docprocessing.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_DOCPROCESSING_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker... | 33 | 1,511 |
onyx | backend/onyx/background/celery/configs/docfetching.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_DOCFETCHING_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_t... | 26 | 1,161 |
onyx | backend/onyx/background/celery/configs/monitoring.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_MONITORING_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_tr... | 26 | 1,162 |
onyx | backend/onyx/background/celery/configs/user_file_processing.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_USER_FILE_PROCESSING_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit... | 26 | 1,188 |
onyx | backend/onyx/background/celery/configs/scheduled_tasks.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_SCHEDULED_TASKS_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
brok... | 28 | 1,361 |
onyx | backend/onyx/background/celery/configs/client.py | .py | import onyx.background.celery.configs.base as shared_config
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_transport_options = shared_config.broker_transport_options
broker_use_ssl = ... | 20 | 936 |
onyx | backend/onyx/background/celery/configs/primary.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_PRIMARY_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_trans... | 25 | 1,118 |
onyx | backend/onyx/background/celery/configs/heavy.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import CELERY_WORKER_HEAVY_CONCURRENCY
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_transpo... | 25 | 1,114 |
onyx | backend/onyx/background/celery/configs/beat.py | .py | # docs: https://docs.celeryq.dev/en/stable/userguide/configuration.html
import onyx.background.celery.configs.base as shared_config
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_limit = shared_config.broker_pool_limit
broker_tran... | 18 | 901 |
onyx | backend/onyx/background/celery/configs/base.py | .py | # docs: https://docs.celeryq.dev/en/stable/userguide/configuration.html
import urllib.parse
from onyx.configs.app_configs import (
CELERY_BROKER_POOL_LIMIT,
CELERY_RESULT_EXPIRES,
REDIS_DB_NUMBER_CELERY,
REDIS_DB_NUMBER_CELERY_RESULT_BACKEND,
REDIS_HEALTH_CHECK_INTERVAL,
REDIS_HOST,
REDIS_P... | 187 | 7,303 |
onyx | backend/onyx/background/celery/configs/light.py | .py | import onyx.background.celery.configs.base as shared_config
from onyx.configs.app_configs import (
CELERY_WORKER_LIGHT_CONCURRENCY,
CELERY_WORKER_LIGHT_PREFETCH_MULTIPLIER,
)
broker_url = shared_config.broker_url
broker_connection_retry_on_startup = shared_config.broker_connection_retry_on_startup
broker_pool_... | 28 | 1,206 |
onyx | backend/onyx/background/celery/versioned_apps/docprocessing.py | .py | """Factory stub for running celery worker / celery beat."""
from celery import Celery
from onyx.utils.variable_functionality import (
fetch_versioned_implementation,
set_is_ee_based_on_env_variable,
)
set_is_ee_based_on_env_variable()
app: Celery = fetch_versioned_implementation(
"onyx.background.celery.... | 15 | 361 |
onyx | backend/onyx/background/celery/versioned_apps/docfetching.py | .py | """Factory stub for running celery worker / celery beat."""
from celery import Celery
from onyx.utils.variable_functionality import (
fetch_versioned_implementation,
set_is_ee_based_on_env_variable,
)
set_is_ee_based_on_env_variable()
app: Celery = fetch_versioned_implementation(
"onyx.background.celery.... | 15 | 359 |
onyx | backend/onyx/background/celery/versioned_apps/monitoring.py | .py | """Factory stub for running celery worker / celery beat."""
from celery import Celery
from onyx.utils.variable_functionality import (
fetch_versioned_implementation,
set_is_ee_based_on_env_variable,
)
set_is_ee_based_on_env_variable()
app: Celery = fetch_versioned_implementation(
"onyx.background.celery.... | 15 | 358 |
onyx | backend/onyx/background/celery/versioned_apps/user_file_processing.py | .py | """Factory stub for running the user file processing Celery worker."""
from celery import Celery
from onyx.utils.variable_functionality import (
fetch_versioned_implementation,
set_is_ee_based_on_env_variable,
)
set_is_ee_based_on_env_variable()
app: Celery = fetch_versioned_implementation(
"onyx.backgro... | 15 | 379 |
onyx | backend/onyx/background/celery/versioned_apps/scheduled_tasks.py | .py | """Factory stub for running the Craft scheduled-tasks Celery worker."""
from celery import Celery
from onyx.utils.variable_functionality import (
fetch_versioned_implementation,
set_is_ee_based_on_env_variable,
)
set_is_ee_based_on_env_variable()
app: Celery = fetch_versioned_implementation(
"onyx.backgr... | 15 | 375 |
onyx | backend/onyx/background/celery/versioned_apps/client.py | .py | """Factory stub for running celery worker / celery beat.
This code is different from the primary/beat stubs because there is no EE version to
fetch. Port over the code in those files if we add an EE version of this worker.
This is an app stub purely for sending tasks as a client.
"""
from celery import Celery
from o... | 22 | 557 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.