repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/test_users.py | osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/test_users.py | import json
from typing import Any, Type
from unittest.mock import patch
import pytest
from flask import Flask
from osprey.worker.ui_api.osprey.lib.abilities import (
Ability,
CanViewActionData,
CanViewLabels,
CanViewLabelsForEntity,
HashableEntityKey,
)
from osprey.worker.ui_api.osprey.lib.users i... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/test_abilities.py | osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/test_abilities.py | import copy
from typing import Any, Dict, Optional
from osprey.worker.ui_api.osprey.lib.abilities import (
CENSOR_TEXT,
Ability,
AbilityRegistry,
CanViewActionData,
CanViewFeatureData,
DataCensorAbility,
QueryFilterAbility,
)
from pydantic import BaseModel
class FakeRequest(BaseModel):
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/__init__.py | osprey_worker/src/osprey/worker/ui_api/osprey/lib/tests/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/input_stream_chooser.py | osprey_worker/src/osprey/worker/sinks/input_stream_chooser.py | import platform
import random
from datetime import datetime, timedelta
from google.cloud import pubsub_v1
from kafka.coordinator.assignors.roundrobin import RoundRobinPartitionAssignor
from osprey.engine.executor.execution_context import Action
from osprey.worker.adaptor.plugin_manager import bootstrap_input_stream
fr... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/conftest.py | osprey_worker/src/osprey/worker/sinks/conftest.py | # ruff: noqa: E402
from osprey.worker.lib.patcher import patch_all
patch_all(patch_gevent=False, patch_ddtrace=False) # please ensure this occurs before *any* other imports !
from osprey.worker.lib.tests import test_utils
postgres_database_config = test_utils.make_postgres_database_config_fixture()
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/__init__.py | osprey_worker/src/osprey/worker/sinks/__init__.py | from enum import StrEnum, auto
class InputStreamSource(StrEnum):
"""Where data for the input to the classification engine are sourced."""
PUBSUB = auto()
"""
Sources events from pubsub
"""
OSPREY_COORDINATOR = auto()
"""
Sources events from the osprey coordinator
"""
SYNTHET... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/osprey_coordinator_input_stream.py | osprey_worker/src/osprey/worker/sinks/sink/osprey_coordinator_input_stream.py | import json
import random
import time
from queue import SimpleQueue as Queue
from typing import Any, Dict, Iterator, Optional, Tuple
import grpc
import pytz
import sentry_sdk
from osprey.engine.executor.execution_context import Action as OspreyEngineAction
from osprey.engine.executor.execution_context import Execution... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/bulk_label_sink.py | osprey_worker/src/osprey/worker/sinks/sink/bulk_label_sink.py | import time
from datetime import datetime, timedelta
from typing import Any, Iterable, List, Optional, Set
import sentry_sdk
from osprey.engine.language_types.entities import EntityT
from osprey.engine.language_types.labels import LabelStatus
from osprey.worker.lib.bulk_label import TaskStatus
from osprey.worker.lib.d... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/input_stream.py | osprey_worker/src/osprey/worker/sinks/sink/input_stream.py | import abc
import inspect
import json
from collections import deque
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Generic, Iterator, List, Optional, Sequence, Type, TypeVar, Union, cast
import gevent
import msgpack
import sentry_sdk
from gevent.lock import RLock
from gevent.queue import Que... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/rules_sink.py | osprey_worker/src/osprey/worker/sinks/sink/rules_sink.py | import logging
import os
from dataclasses import dataclass
from random import randint
from typing import Optional
import gevent
import sentry_sdk
from ddtrace import tracer
from ddtrace.span import Span as TracerSpan
from osprey.engine.executor.execution_context import Action, ExecutionResult
from osprey.engine.execut... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/stored_execution_result_output_sink.py | osprey_worker/src/osprey/worker/sinks/sink/stored_execution_result_output_sink.py | from osprey.engine.executor.execution_context import ExecutionResult
from osprey.worker.lib.storage.stored_execution_result import bootstrap_execution_result_storage_service
from osprey.worker.sinks.sink.output_sink import BaseOutputSink
class StoredExecutionResultOutputSink(BaseOutputSink):
"""An output sink tha... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/kafka_output_sink.py | osprey_worker/src/osprey/worker/sinks/sink/kafka_output_sink.py | from typing import Any
import sentry_sdk
from kafka import KafkaProducer
from osprey.engine.executor.execution_context import ExecutionResult
from osprey.worker.lib.osprey_shared.logging import get_logger
from osprey.worker.sinks.sink.output_sink import BaseOutputSink
logger = get_logger()
class KafkaOutputSink(Bas... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/__init__.py | osprey_worker/src/osprey/worker/sinks/sink/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/output_sink.py | osprey_worker/src/osprey/worker/sinks/sink/output_sink.py | import abc
from collections import defaultdict
from datetime import datetime
from typing import Any, DefaultDict, Dict, Mapping, Optional, Sequence
import gevent
import sentry_sdk
from osprey.engine.executor.execution_context import (
ExecutionResult,
)
from osprey.engine.language_types.entities import EntityT
fro... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/base_sink.py | osprey_worker/src/osprey/worker/sinks/sink/base_sink.py | import abc
import logging
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Callable, Dict, List, Optional
import gevent
LOGGER = logging.getLogger(__name__)
class BaseSink(abc.ABC):
"""Represents an object that consumes objects from some sort of source."""
@abc.abstractmethod
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/tests/test_bulk_label_sink.py | osprey_worker/src/osprey/worker/sinks/sink/tests/test_bulk_label_sink.py | from dataclasses import dataclass
from datetime import datetime
from typing import Dict, List, Optional, Sequence
from unittest.mock import MagicMock, call
import pytest
from osprey.engine.ast.sources import Sources
from osprey.worker.adaptor.plugin_manager import bootstrap_ast_validators, bootstrap_udfs
from osprey.w... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/tests/conftest.py | osprey_worker/src/osprey/worker/sinks/sink/tests/conftest.py | from unittest.mock import MagicMock
import pytest
@pytest.fixture(scope='session')
def monkeypatch_session(request):
"""Experimental (https://github.com/pytest-dev/pytest/issues/363)."""
from _pytest.monkeypatch import MonkeyPatch
patch = MonkeyPatch()
yield patch
patch.undo()
@pytest.fixture(... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/tests/test_pubsub_input_stream.py | osprey_worker/src/osprey/worker/sinks/sink/tests/test_pubsub_input_stream.py | import json
from typing import cast
from unittest.mock import MagicMock, patch
import msgpack
import pytest
from _pytest.fixtures import FixtureRequest
from google.pubsub_v1 import PubsubMessage
from osprey.engine.executor.execution_context import Action
from osprey.worker.lib.encryption.envelope import Envelope
from ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/tests/__init__.py | osprey_worker/src/osprey/worker/sinks/sink/tests/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/tests/test_input_stream.py | osprey_worker/src/osprey/worker/sinks/sink/tests/test_input_stream.py | from typing import Iterator, List
import gevent
import gevent.event
from osprey.worker.sinks.sink.input_stream import BaseInputStream
def test_does_not_lock_non_generator_iterator() -> None:
waiting_events: List[gevent.event.Event] = []
class MyIterator(Iterator[int]):
def __init__(self) -> None:
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/constants.py | osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/constants.py | from enum import Enum
class OspreyAnalyticsEvents(str, Enum):
EXTRACTED_FEATURES = 'osprey_extracted_features'
ACTION_CLASSIFICATION = 'osprey_action_classification'
EXPERIMENT_EXPOSURE_EVENT = 'osprey_experiment_exposure_event'
LABEL_MUTATIONS = 'osprey_label_mutations'
BULK_LABEL_JOB = 'osprey_b... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/models.py | osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/models.py | from typing import List, Optional
from pydantic import BaseModel
from .constants import OspreyAnalyticsEvents
class OspreyBulkJobAnalyticsEvent(BaseModel):
name: str = 'event'
event_type: str = OspreyAnalyticsEvents.BULK_LABEL_JOB
task_id: str
total_entities_to_label: int
label_name: str
lab... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/helpers.py | osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/helpers.py | from typing import Any, Dict, Optional
from osprey.worker.sinks.sink.output_sink_utils.constants import EntityType
USER_ID_FEATURE_NAME = 'UserId' # assuming that if userid exists, it's in feature called 'UserId'
def get_user_id(entity_id: str, entity_type: str) -> Optional[int]:
return int(entity_id) if entit... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/__init__.py | osprey_worker/src/osprey/worker/sinks/sink/output_sink_utils/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/bulk_actions.py | osprey_worker/src/osprey/worker/sinks/utils/bulk_actions.py | from dataclasses import dataclass
from typing import List
from osprey.engine.executor.execution_context import Action
from osprey.engine.utils.types import add_slots
@add_slots
@dataclass
class BulkActions:
actions: List[Action]
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/envoy_status.py | osprey_worker/src/osprey/worker/sinks/utils/envoy_status.py | import socket
from gevent.server import StreamServer
def get_envoy_check_server(port: int) -> StreamServer:
"""
In order to have the Envoy sidecar not shut down too early, we start up a dummy TCP server whose only purpose is
to accept connections so that in the pre-stop hook we can loop using `nc -z` as ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/gevent.py | osprey_worker/src/osprey/worker/sinks/utils/gevent.py | from typing import Optional
from gevent import sleep
from gevent.lock import RLock
class FairRLock(RLock): # type: ignore
"""A RLock that is fair, and will allow lock acquisitions that were attempted first to be acquired,
which is distinct from the way that RLock works in gevent, which will allow the greenl... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/kafka.py | osprey_worker/src/osprey/worker/sinks/utils/kafka.py | from typing import Any
from kafka import KafkaConsumer
from .gevent import FairRLock
class PatchedKafkaConsumer(KafkaConsumer): # type: ignore
"""A KafkaConsnsumer that has had its lock patched to FairRLock, that prevents deadlocking."""
def __init__(self, *args: Any, **kwargs: Any) -> None:
super... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/__init__.py | osprey_worker/src/osprey/worker/sinks/utils/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/sinks/utils/acking_contexts.py | osprey_worker/src/osprey/worker/sinks/utils/acking_contexts.py | import abc
from datetime import datetime
from types import TracebackType
from typing import Dict, Generic, List, Optional, Type, TypeVar, Union
import gevent
from google.api_core.exceptions import DeadlineExceeded
from google.cloud.pubsub_v1 import SubscriberClient
from google.cloud.pubsub_v1.subscriber.message import... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/osprey_typing.py | osprey_worker/src/osprey/worker/lib/osprey_typing.py | from __future__ import annotations
from typing import AbstractSet, Any, Tuple, TypeVar, Union
from typing_extensions import Protocol, TypeAlias
T = TypeVar('T')
T_contra = TypeVar('T_contra', contravariant=True)
KT_co = TypeVar('KT_co', covariant=True)
VT_co = TypeVar('VT_co', covariant=True)
class SupportsItems(P... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/webhooks.py | osprey_worker/src/osprey/worker/lib/webhooks.py | from enum import Enum
from typing import Collection
class WebhookStatus(Enum):
QUEUED = 'QUEUED'
RUNNING = 'RUNNING'
COMPLETE = 'COMPLETE'
SKIPPED = 'SKIPPED'
FAILED = 'FAILED'
@staticmethod
def final_statuses() -> Collection['WebhookStatus']:
return {WebhookStatus.COMPLETE, Webho... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/publisher.py | osprey_worker/src/osprey/worker/lib/publisher.py | import abc
from typing import Dict, Optional, TypeVar
from google.cloud import pubsub_v1
from osprey.worker.lib.instruments import metrics
from osprey.worker.lib.pubsub.publisher_client import BatchPubsubPublisherClient
from pydantic import BaseModel
_PydanticModelT = TypeVar('_PydanticModelT', bound=BaseModel)
cla... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/patcher.py | osprey_worker/src/osprey/worker/lib/patcher.py | """Helper to apply necessary patches (gevent, grpc, ddtrace), safe to call multiple times.
This must be imported and called before any other imports in the project.
Example:
```python
from osprey.worker.lib.patcher import patch_all
patch_all()
...other imports...
```
"""
# Importing non-std modules here may break p... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_provider.py | osprey_worker/src/osprey/worker/lib/sources_provider.py | import abc
import logging
from typing import Callable, Dict, Optional
from osprey.engine.ast.sources import Sources
from osprey.worker.lib.etcd import EtcdClient
from osprey.worker.lib.etcd.dict import ReadOnlyEtcdDict
from osprey.worker.lib.utils.input_stream_ready_signaler import InputStreamReadySignaler
SourcesWat... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/singleton.py | osprey_worker/src/osprey/worker/lib/singleton.py | from contextlib import contextmanager
from typing import Callable, Generic, Iterator, Optional, TypeVar
T = TypeVar('T')
class Singleton(Generic[T]):
"""A generic singleton.
Example usage:
```
class Foo:
def bar(self):
return "hi"
foo_singleton = Singleton(Fo... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/cli.py | osprey_worker/src/osprey/worker/lib/cli.py | # mypy: ignore-errors
import sys
from pathlib import Path # noqa: E402
from osprey.engine.language_types.entities import EntityT
from osprey.worker.lib.osprey_shared.labels import EntityLabelMutation, LabelStatus
from osprey.worker.lib.patcher import patch_all
from osprey.worker.lib.singletons import LABELS_PROVIDER ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/action_proto_deserializer.py | osprey_worker/src/osprey/worker/lib/action_proto_deserializer.py | import abc
from dataclasses import dataclass
from typing import Any, Dict
@dataclass
class ActionProtoDeserializeResult:
data: Dict[str, Any]
action_id: int
action_name: str
class ActionProtoDeserializer(abc.ABC):
@abc.abstractmethod
def proto_bytes_to_dict(cls, data: bytes) -> ActionProtoDeseri... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/snowflake.py | osprey_worker/src/osprey/worker/lib/snowflake.py | import time
from datetime import UTC, datetime
import requests
from osprey.worker.lib.singletons import CONFIG
class Snowflake:
"""
A snowflake contains a 64-bit integer ID that contains timestamp information in the first 22 bits
"""
def __init__(self, id: int):
self.id = id
def to_int(... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/conftest.py | osprey_worker/src/osprey/worker/lib/conftest.py | # ruff: noqa: E402
from .patcher import patch_all # isort: skip
# please ensure this occurs before *any* other imports !
patch_all(patch_gevent=False, patch_ddtrace=False)
from osprey.engine import conftest as rules_conftest # noqa: E402
from .tests import test_utils # noqa: E402
postgres_database_config = test... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/osprey_engine.py | osprey_worker/src/osprey/worker/lib/osprey_engine.py | import logging
from dataclasses import dataclass
from pathlib import Path
from time import time
from typing import Callable, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar
import gevent
import gevent.pool
from ddtrace.span import Span as TracerSpan
from gevent.threadpool import ThreadPool
from osprey.engine.... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/__init__.py | osprey_worker/src/osprey/worker/lib/__init__.py | # DO NOT PUT ANYTHING IN THIS FILE
# patcher.py must run before any other imports
# TODO: we should probably get rid of patcher.py
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/bulk_label.py | osprey_worker/src/osprey/worker/lib/bulk_label.py | from enum import Enum
from typing import Collection
class TaskStatus(Enum):
QUEUED = 'QUEUED'
RUNNING_DEPRECATED = (
'RUNNING' # **DEPRECATED** - Please use COLLECTING / LABELLING to more clearly indicate the status!
)
COLLECTING = 'COLLECTING'
LABELLING = 'LABELLING'
COMPLETE = 'COMP... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/singletons.py | osprey_worker/src/osprey/worker/lib/singletons.py | from typing import TYPE_CHECKING
from osprey.engine.config.config_registry import ConfigRegistry
from osprey.engine.stdlib import get_config_registry
from osprey.worker.lib.config import Config
from osprey.worker.lib.singleton import Singleton
if TYPE_CHECKING:
from osprey.worker.lib.osprey_engine import OspreyEn... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_publisher.py | osprey_worker/src/osprey/worker/lib/sources_publisher.py | import abc
import logging
from datetime import datetime
from typing import Dict, Optional, Set
from google.cloud import bigquery
from osprey.engine.ast.grammar import Assign, Call
from osprey.engine.ast.sources import Sources
from osprey.engine.ast_validator import validate_sources
from osprey.engine.ast_validator.val... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/publisher_client.py | osprey_worker/src/osprey/worker/lib/pubsub/publisher_client.py | import abc
from concurrent import futures
from threading import Lock
from typing import Set, Union
from google.cloud import pubsub_v1
from osprey.worker.lib.instruments import metrics
class BasePubsubPublisherClient(abc.ABC):
def __init__(self):
pass
@abc.abstractmethod
def publish(self, topic: ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/__init__.py | osprey_worker/src/osprey/worker/lib/pubsub/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/tasks/__init__.py | osprey_worker/src/osprey/worker/lib/pubsub/tasks/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/tasks/types.py | osprey_worker/src/osprey/worker/lib/pubsub/tasks/types.py | from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import NotRequired, TypedDict
class PubSubTaskMessageData(TypedDict):
task_name: str
old_task_name: NotRequired[Optional[str]]
task_args: Union[List, Tuple] # type: ignore[type-arg]
task_kwargs: Dict[str, Any]
# Th... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/tests/test_publisher_client.py | osprey_worker/src/osprey/worker/lib/pubsub/tests/test_publisher_client.py | # import time
# from concurrent import futures
# from unittest.mock import MagicMock
import pytest
from google.cloud import pubsub_v1
from osprey.worker.lib.pubsub.publisher_client import BatchPubsubPublisherClient
@pytest.fixture(scope='function')
def batch_pubsub_publisher() -> BatchPubsubPublisherClient:
batc... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/pubsub/tests/conftest.py | osprey_worker/src/osprey/worker/lib/pubsub/tests/conftest.py | from unittest.mock import MagicMock
import pytest
@pytest.fixture(scope='session')
def monkeypatch_session(request):
"""Experimental (https://github.com/pytest-dev/pytest/issues/363)."""
from _pytest.monkeypatch import MonkeyPatch
patch = MonkeyPatch()
yield patch
patch.undo()
@pytest.fixture(... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/directory.py | osprey_worker/src/osprey/worker/lib/discovery/directory.py | from __future__ import annotations
import os
from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterable, List, Optional, Tuple, Union
from osprey.worker.lib.discovery.service import Service
from osprey.worker.lib.discovery.service_watcher import ServiceWatcher
from osprey.worker.lib.etcd import EtcdClient
from o... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/service.py | osprey_worker/src/osprey/worker/lib/discovery/service.py | from __future__ import annotations
from typing import Any, Dict, Optional, Tuple
import simplejson as json
class Service:
def __init__(
self,
name: str,
port: int,
address: str = 'localhost',
metadata: Optional[Dict[str, Any]] = None,
ports: Optional[Dict[str, int... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/exceptions.py | osprey_worker/src/osprey/worker/lib/discovery/exceptions.py | class ServiceException(Exception):
"""Base call for all discovery exceptions."""
class ServiceUnavailable(ServiceException):
"""Raised when there are no instances availiable for service."""
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/service_watcher.py | osprey_worker/src/osprey/worker/lib/discovery/service_watcher.py | from __future__ import annotations
import collections
import logging
import weakref
from random import choice, randint, uniform
from time import time
from typing import TYPE_CHECKING, Callable, Deque, Dict, List, Optional, Union
import gevent
import six
from gevent.lock import RLock
from osprey.worker.lib import etcd... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/__init__.py | osprey_worker/src/osprey/worker/lib/discovery/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/tests/test_service_watcher.py | osprey_worker/src/osprey/worker/lib/discovery/tests/test_service_watcher.py | import pytest
from osprey.worker.lib import etcd
from osprey.worker.lib.discovery.directory import Directory
from osprey.worker.lib.discovery.exceptions import ServiceUnavailable
from osprey.worker.lib.discovery.service import Service
from osprey.worker.lib.etcd.ring import EtcdHashRing, EtcdHashRingMember
from pytest ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/tests/test_service.py | osprey_worker/src/osprey/worker/lib/discovery/tests/test_service.py | from __future__ import annotations
import pytest
from osprey.worker.lib.discovery.service import Service
@pytest.fixture
def basic_service():
return Service('name', 1234, 'localhost', None, None, '127.0.0.2')
@pytest.fixture
def noip_service():
return Service('name', 1234, 'localhost', None, None, None)
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/discovery/tests/test_discovery.py | osprey_worker/src/osprey/worker/lib/discovery/tests/test_discovery.py | from gevent import monkey
monkey.patch_all(aggressive=True) # noqa: E402
import gevent # noqa: E402
import pytest # noqa: E402
from osprey.worker.lib import etcd # noqa: E402
from osprey.worker.lib.discovery.directory import Directory # noqa: E402
from osprey.worker.lib.discovery.exceptions import ServiceUnavail... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/bigtable.py | osprey_worker/src/osprey/worker/lib/storage/bigtable.py | # import logging
# import os
#
# import pytest
import logging
from abc import ABC, abstractmethod
from typing import Dict
from google.cloud.bigtable import Client
from google.cloud.bigtable.instance import Instance
from google.cloud.bigtable.table import Table
from osprey.worker.lib.config import Config
from osprey.wo... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/labels.py | osprey_worker/src/osprey/worker/lib/storage/labels.py | import copy
from abc import ABC, abstractmethod
from collections import defaultdict
from contextlib import contextmanager
from datetime import timedelta
from typing import Any, Generator, Optional, Sequence
from osprey.engine.executor.external_service_utils import ExternalService
from osprey.engine.language_types.enti... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/bigquery.py | osprey_worker/src/osprey/worker/lib/storage/bigquery.py | import time
from typing import Any, Dict, List, Optional, Sequence, Union
from uuid import uuid4
from google.cloud import bigquery
from google.cloud.bigquery.client import Client
from google.cloud.bigquery.job import QueryJob, QueryJobConfig, QueryPriority
from google.cloud.bigquery.table import RowIterator
from ospre... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/bulk_label_task.py | osprey_worker/src/osprey/worker/lib/storage/bulk_label_task.py | from __future__ import absolute_import
import logging
import time
from datetime import datetime
from random import random
from typing import Any, Dict, Iterator, List, Optional
from osprey.worker.lib.osprey_shared.labels import LabelStatus
from osprey.worker.lib.storage.types import Enum
from sqlalchemy import BigInt... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/bulk_action_task.py | osprey_worker/src/osprey/worker/lib/storage/bulk_action_task.py | from __future__ import absolute_import
import logging
from datetime import datetime, timezone
from enum import StrEnum
from typing import Any, Dict, List, Optional
from sqlalchemy import ARRAY, BigInteger, Column, DateTime, Enum, Integer, Text
from .postgres import Model, scoped_session
logger = logging.getLogger(_... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/postgres.py | osprey_worker/src/osprey/worker/lib/storage/postgres.py | import psycogreen.gevent
import sqlalchemy
psycogreen.gevent.patch_psycopg() # noqa: E402
from contextlib import contextmanager # noqa: E402
from typing import TYPE_CHECKING, Dict, Iterator, Optional # noqa: E402
from flask import Flask, has_request_context # noqa: E402
from osprey.worker.lib.config import Confi... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/stored_execution_result.py | osprey_worker/src/osprey/worker/lib/storage/stored_execution_result.py | from __future__ import annotations
import gzip
import json
from abc import ABC, abstractmethod
from datetime import datetime
from io import BytesIO
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence
import gevent
import google.cloud.storage as storage
import pytz
from google.api_core import retry
f... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/__init__.py | osprey_worker/src/osprey/worker/lib/storage/__init__.py | # Import all models to ensure they're registered with SQLAlchemy
# This is required for metadata.create_all() to create all tables
from .bulk_action_task import BulkActionJob, BulkActionTask # noqa: F401
from .bulk_label_task import BulkLabelTask # noqa: F401
from .queries import Query, SavedQuery # noqa: F401
from ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/queries.py | osprey_worker/src/osprey/worker/lib/storage/queries.py | import enum
from typing import Any, Dict, List, Optional
from osprey.worker.lib.snowflake import Snowflake, generate_snowflake
from sqlalchemy import ARRAY, BigInteger, Column, Text, select
from sqlalchemy.orm import relationship, selectinload
from sqlalchemy.schema import ForeignKey
from sqlalchemy_utils import DateT... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/types.py | osprey_worker/src/osprey/worker/lib/storage/types.py | from typing import TYPE_CHECKING, Type, TypeVar
# Workaround taken from https://github.com/dropbox/sqlalchemy-stubs/issues/114
if TYPE_CHECKING:
from sqlalchemy.sql.type_api import TypeEngine
_T = TypeVar('_T')
class Enum(TypeEngine[_T]):
def __init__(self, enum: Type[_T], name: str = ..., create... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/local_label_provider.py | osprey_worker/src/osprey/worker/lib/storage/local_label_provider.py | from typing import Any, Dict, List, Sequence
from osprey.engine.language_types.entities import EntityT
from osprey.worker.lib.osprey_shared.labels import EntityLabelMutation, EntityLabelMutationsResult, EntityLabels
from osprey.worker.lib.storage.labels import LabelsProvider
from result import Result
class LocalLabe... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/bulk_action_files.py | osprey_worker/src/osprey/worker/lib/storage/bulk_action_files.py | import csv
import os
import tempfile
from itertools import islice
from typing import Any, Dict, Generator, Optional, Protocol
from google.cloud import storage
from osprey.worker.lib.singletons import CONFIG
from werkzeug.datastructures import FileStorage
BULK_ACTION_BUCKET_NAME_ENV_KEY = 'OSPREY_BULK_ACTION_FILE_UPLO... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/temporary_ability_token.py | osprey_worker/src/osprey/worker/lib/storage/temporary_ability_token.py | import base64
import json
import os
from datetime import datetime, timedelta
from enum import Enum
from typing import Any, List, Optional
import pytz
from osprey.worker.ui_api.osprey.lib.abilities import Ability
from sqlalchemy import BigInteger, Column, DateTime, Text
from sqlalchemy.dialects.postgresql import JSONB
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/access_audit_log.py | osprey_worker/src/osprey/worker/lib/storage/access_audit_log.py | import dataclasses
from typing import Optional
from osprey.engine.utils.types import add_slots
@add_slots
# Can unfreeze if we ever need to modify instances of this.
@dataclasses.dataclass(frozen=True)
class AccessAuditLog:
"""
Stores the access log in scylladb.
"""
id: int # snowflake
requeste... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/tests/test_bulk_label_task.py | osprey_worker/src/osprey/worker/lib/storage/tests/test_bulk_label_task.py | from __future__ import absolute_import
from datetime import datetime, timedelta
from typing import Iterator
import pytest
from osprey.worker.lib.bulk_label import TaskStatus
from osprey.worker.lib.osprey_shared.labels import LabelStatus
from osprey.worker.lib.storage.bulk_label_task import BASE_DELAY_SECONDS, BulkLab... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/tests/test_labels.py | osprey_worker/src/osprey/worker/lib/storage/tests/test_labels.py | from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from osprey.engine.language_types.entities import EntityT
from osprey.worker.lib.osprey_shared.labels import (
EntityLabelMutation,
EntityLabels,
LabelReason,
LabelReasons,
LabelState,
LabelStatus,
Mutat... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/tests/test_bulk_action_task.py | osprey_worker/src/osprey/worker/lib/storage/tests/test_bulk_action_task.py | from typing import Iterator
from unittest.mock import patch
import pytest
from osprey.worker.lib.snowflake import generate_snowflake
from osprey.worker.lib.storage.bulk_action_task import (
BulkActionJob,
BulkActionJobStatus,
BulkActionTask,
BulkActionTaskStatus,
)
from osprey.worker.lib.storage.postgr... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/tests/test_queries.py | osprey_worker/src/osprey/worker/lib/storage/tests/test_queries.py | from __future__ import absolute_import
from random import choice
from typing import Iterator, Optional
import pytest
from faker import Faker
from intervals.interval import DateTimeInterval
from osprey.worker.lib.snowflake import Snowflake
from osprey.worker.lib.storage.postgres import scoped_session
from osprey.worke... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/storage/tests/__init__.py | osprey_worker/src/osprey/worker/lib/storage/tests/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/acls/acls.py | osprey_worker/src/osprey/worker/lib/acls/acls.py | import json
import logging
from pathlib import Path
from typing import Any, Dict, List
from osprey.worker.ui_api.osprey.lib.abilities import Ability
from pydantic import BaseModel
logger = logging.getLogger(__name__)
DIR = Path(__file__).parent
ACL_DEFINITIONS_DIR = DIR / 'definitions'
ACL_ABILITY_GROUPS_DIR = DIR /... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/acls/__init__.py | osprey_worker/src/osprey/worker/lib/acls/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/encryption/exception.py | osprey_worker/src/osprey/worker/lib/encryption/exception.py | class EncryptionEnvelopeNotSetUpException(Exception):
"""Exception indicating that encryption envelope client is not set up."""
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/encryption/envelope.py | osprey_worker/src/osprey/worker/lib/encryption/envelope.py | import logging
from base64 import b64decode, b64encode
from typing import Optional, Union
import tink
from osprey.worker.lib.encryption.base import EncryptionBase
from osprey.worker.lib.encryption.exception import EncryptionEnvelopeNotSetUpException
from tink import JsonKeysetReader, aead, cleartext_keyset_handle
from... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/encryption/__init__.py | osprey_worker/src/osprey/worker/lib/encryption/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/encryption/base.py | osprey_worker/src/osprey/worker/lib/encryption/base.py | import logging
from dataclasses import dataclass
from typing import Optional
import tink
from tink import aead
from tink.integration import gcpkms
@dataclass
class EncryptionBase:
kek_uri: Optional[str] = None
gcp_credential_path: str = ''
is_setup: bool = False
def __post_init__(self):
try:... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/encryption/tests/test_envelope.py | osprey_worker/src/osprey/worker/lib/encryption/tests/test_envelope.py | import pytest
from osprey.worker.lib.encryption.envelope import Envelope
from osprey.worker.lib.encryption.exception import EncryptionEnvelopeNotSetUpException
"""
Run this test after creating the test GCP resources required and only run this test locally.
The gcp_credential will use the default service account if emp... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/backoff/backoff_handlers.py | osprey_worker/src/osprey/worker/lib/backoff/backoff_handlers.py | from __future__ import absolute_import
import time
from osprey.worker.lib.backoff import Backoff
class ExpiringBackoffHandler(object):
"""
Simplifies working with a Backoff if you want to have attempt count
and time limit restrictions applied.
"""
def __init__(self, backoff=None, max_attempts=1... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/backoff/__init__.py | osprey_worker/src/osprey/worker/lib/backoff/__init__.py | from __future__ import absolute_import
import random
from typing import Optional
class Backoff(object):
"""
A class that manages an exponential backoff.
"""
def __init__(self, min_delay: float = 0.5, max_delay: Optional[float] = None, jitter: bool = True):
self._min = min_delay
if ma... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/__init__.py | osprey_worker/src/osprey/worker/lib/sources_config/__init__.py | from typing import Callable, Type
from osprey.engine.config.config_registry import ConfigRegistry
from osprey.engine.config.config_subkey_handler import ModelT
from osprey.engine.utils.imports import import_all_direct_children
from osprey.worker.lib.singletons import CONFIG_REGISTRY
def register_config_subkey(subkey... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/ui_config.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/ui_config.py | from typing import Dict, List
from osprey.worker.lib.sources_config import register_config_subkey
from pydantic import BaseModel
class FeatureSummaryConfig(BaseModel):
actions: List[str] = []
features: List[str] = []
@register_config_subkey('ui_config')
class UIConfig(BaseModel):
class Config:
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/example_config.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/example_config.py | from osprey.worker.lib.sources_config import register_config_subkey
from pydantic import BaseModel
@register_config_subkey('example')
class ExampleConfig(BaseModel):
some_str: str = 'abc'
some_int: int = 3
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/acl_config.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/acl_config.py | from __future__ import annotations
import json
from typing import Any, Iterable, List, Mapping
from osprey.worker.lib.acls.acls import ACL, DEV_ACL_ASSIGNMENTS_FILE
from osprey.worker.lib.instruments import metrics
from osprey.worker.lib.singletons import CONFIG
from osprey.worker.lib.sources_config import register_c... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/authorized_keys.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/authorized_keys.py | from osprey.worker.lib.sources_config import register_config_subkey
from pydantic import BaseModel, Extra
@register_config_subkey('authorized_keys')
class AuthorizedKeys(BaseModel):
"""Dummy class to allow the top-level 'authorized_keys' config"""
class Config:
extra = Extra.ignore
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/action_config.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/action_config.py | from typing import Any, Dict, Optional
from osprey.worker.lib.sources_config import register_config_subkey
from pydantic import BaseModel, Field, root_validator
class ActionConfig(BaseModel):
sample_rate: int = Field(ge=0, le=100, default=100)
@register_config_subkey('actions')
class ActionConfigs(BaseModel):
... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/sources_config/subkeys/__init__.py | osprey_worker/src/osprey/worker/lib/sources_config/subkeys/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/tests/test_logging.py | osprey_worker/src/osprey/worker/lib/tests/test_logging.py | from time import sleep
from osprey.worker.lib.osprey_shared.logging import DynamicLogSampler, RollingCounter
def test_rolling_counter_clears():
"""
A rolling counter should clear after the buffer_capacity * milliseconds_per_index has passed (⸝⸝⸝╸w╺⸝⸝⸝)
"""
counter = RollingCounter(buffer_capacity=3, ... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/tests/test_utils.py | osprey_worker/src/osprey/worker/lib/tests/test_utils.py | import os
import textwrap
from typing import TYPE_CHECKING, Callable, Iterator
import pytest
from flask import Flask
from osprey.engine.ast.sources import Sources
from osprey.worker.lib.osprey_engine import bootstrap_engine
from osprey.worker.lib.singletons import CONFIG, ENGINE
from osprey.worker.lib.sources_provider... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/tests/test_current_osprey_rules.py | osprey_worker/src/osprey/worker/lib/tests/test_current_osprey_rules.py | def test_latest_osprey_rules_are_valid() -> None:
assert True
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/tests/__init__.py | osprey_worker/src/osprey/worker/lib/tests/__init__.py | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false | |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/instruments/__test__.py | osprey_worker/src/osprey/worker/lib/instruments/__test__.py | import os
import pytest
pytest.main(['-x', os.path.dirname(__file__)])
| python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
roostorg/osprey | https://github.com/roostorg/osprey/blob/5c1f999c156b420043be7efdd472c8e31096bfb5/osprey_worker/src/osprey/worker/lib/instruments/__init__.py | osprey_worker/src/osprey/worker/lib/instruments/__init__.py | from __future__ import absolute_import, annotations, print_function
import contextlib
import os
import re
from types import TracebackType
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Pattern, Sequence, Type, Union
from datadog.dogstatsd.base import DogStatsd
UNDERSCORE_REPLACEMENT_CHARACTERS: Pattern... | python | Apache-2.0 | 5c1f999c156b420043be7efdd472c8e31096bfb5 | 2026-01-05T07:11:51.519046Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.