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/lib/instruments/types.py | osprey_worker/src/osprey/worker/lib/instruments/types.py | from __future__ import annotations
from typing import Any, TypeVar, Union
from typing_extensions import Protocol, TypeAlias
T = TypeVar('T')
# Comparison protocols
class SupportsDunderLT(Protocol):
def __lt__(self, __other: Any) -> bool: ...
class SupportsDunderGT(Protocol):
def __gt__(self, __other: A... | 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/tests/test_metrics.py | osprey_worker/src/osprey/worker/lib/instruments/tests/test_metrics.py | from typing import Dict, List, Union
import pytest
from osprey.worker.lib.instruments import metrics
from pytest_mock import MockFixture
@pytest.mark.parametrize(
'tags',
(
pytest.param(['test_tag_1:test_value_1', 'test_tag_2:test_value_2'], id='list'),
pytest.param({'test_tag_1': 'test_value... | 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/tests/test_concurrency.py | osprey_worker/src/osprey/worker/lib/instruments/tests/test_concurrency.py | # Patch so we can test concurrency
import gevent
import gevent.monkey
gevent.monkey.patch_all()
from unittest.mock import call # noqa: E402
import pytest # noqa: E402
from osprey.worker.lib.instruments import concurrency, metrics # noqa: E402
@pytest.fixture(scope='function', autouse=True)
def datadog(mocker):
... | 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/utils/bigtable.py | osprey_worker/src/osprey/worker/lib/utils/bigtable.py | import os
import grpc
from google.cloud.bigtable import Client
BIGTABLE_EMULATOR_HOST = 'BIGTABLE_EMULATOR_HOST'
def fix_bigtable_client_if_using_emulator(client: Client) -> None:
"""
We call this if the bigtable client is being used in integration tests with a bigtable emulator.
The emulator channel 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/utils/ip_address.py | osprey_worker/src/osprey/worker/lib/utils/ip_address.py | import socket
IPV4 = socket.AF_INET
IPV6 = socket.AF_INET6
def is_v4(ip_address):
"""
Helper function to determine if an address is IPv4.
:param str ip_address: IP Address to check
:return: True if the IP Address is a valid IPv4 address, False otherwise
:rtype: bool
"""
try:
sock... | 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/utils/generic_events.py | osprey_worker/src/osprey/worker/lib/utils/generic_events.py | import json
from typing import Any, Dict, Optional
from google.cloud import pubsub_v1
DEFAULT_PUBLISHER_CLIENT = pubsub_v1.PublisherClient()
def publish_generic_event(
event: Dict[str, Any],
env: str,
topic: str = 'projects/osprey-data-{}/topics/generic-events',
client: Optional[pubsub_v1.PublisherC... | 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/utils/trace.py | osprey_worker/src/osprey/worker/lib/utils/trace.py | import gc
from dataclasses import dataclass, field
from time import time
from typing import Dict, List, Optional, Sequence
from osprey.worker.lib.instruments import metrics
from typing_extensions import Literal
PhaseType = Literal['start', 'stop']
InfoType = Dict[str, int]
# these names reflect those collected by dd... | 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/utils/grpc.py | osprey_worker/src/osprey/worker/lib/utils/grpc.py | from typing import Optional, Set
import grpc
from osprey.worker.lib.pigeon.client import RetryPolicy
DEFAULT_RETRYABLE_GRPC_STATUSES: Set[grpc.StatusCode] = {
grpc.StatusCode.UNAVAILABLE,
grpc.StatusCode.INTERNAL,
grpc.StatusCode.UNKNOWN,
grpc.StatusCode.DEADLINE_EXCEEDED, # timeout
}
DATA_SERVICES_... | 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/utils/request_utils.py | osprey_worker/src/osprey/worker/lib/utils/request_utils.py | from __future__ import annotations
import logging
import random
import time
from typing import Callable, Optional, Tuple, Type
import requests
from requests.exceptions import ConnectionError, ReadTimeout
DEFAULT_NUM_RETRIES = 5
logger = logging.getLogger(__name__)
class SessionWithRetries:
def __init__(
... | 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/utils/input_stream_ready_signaler.py | osprey_worker/src/osprey/worker/lib/utils/input_stream_ready_signaler.py | import random
import gevent
class InputStreamReadySignaler:
def __init__(self) -> None:
self._event = gevent.event.Event()
self._event.set()
def should_pause_input_stream(self) -> bool:
return not self._event.is_set()
def wait_until_resume(self) -> None:
self._event.wait... | 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/utils/grpc_client_pool.py | osprey_worker/src/osprey/worker/lib/utils/grpc_client_pool.py | import itertools
from typing import Callable, Generic, TypeVar
T = TypeVar('T')
class GrpcClientPool(Generic[T]):
"""
A basic gRPC client pool.
The pool is filled by `func` during construction.
"""
def __init__(self, size: int, func: Callable[[int], T]) -> None:
# In HTTP/2, streams are... | 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/utils/sentry.py | osprey_worker/src/osprey/worker/lib/utils/sentry.py | import sentry_sdk
from ..singletons import CONFIG
def init_sentry_from_config() -> None:
config = CONFIG.instance()
sentry_dsn = config.get_str('SENTRY_RULES_SINK_DSN', '')
if sentry_dsn:
sentry_sdk.init(sentry_dsn)
return
| 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/utils/click_utils.py | osprey_worker/src/osprey/worker/lib/utils/click_utils.py | from enum import Enum
from typing import Dict, Generic, Optional, Type, TypeVar, Union
import click
from click import Context, Parameter
T = TypeVar('T', bound=Enum)
class EnumChoice(click.Choice, Generic[T]):
"""For use with `@click.option(...)` in order to support for choosing a single value of an `Enum`.
... | 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/utils/flask_utils.py | osprey_worker/src/osprey/worker/lib/utils/flask_utils.py | import dataclasses
from typing import TYPE_CHECKING, Any, Callable, Mapping, Optional, cast
import simplejson
from flask import Flask
from pydantic import BaseModel
if TYPE_CHECKING:
from _typeshed import DataclassInstance
class OspreyFlask(Flask):
def make_response(self, rv: Any) -> Any:
"""
... | 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/utils/flask_signing.py | osprey_worker/src/osprey/worker/lib/utils/flask_signing.py | import base64
import binascii
import functools
import hashlib
import json
from typing import Any, Callable, Dict, List, Optional, TypeVar, Union
from urllib.parse import urlparse
from Crypto.Hash import SHA256
from Crypto.PublicKey import ECC
from Crypto.Signature import DSS
from flask import abort, request
from six.m... | 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/utils/__init__.py | osprey_worker/src/osprey/worker/lib/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/lib/utils/dates.py | osprey_worker/src/osprey/worker/lib/utils/dates.py | import time
from datetime import datetime
from typing import Union
import pytz
from dateutil import parser
from pytz import UTC
OSPREY_EPOCH = 1420070400000
UNIX_EPOCH = datetime(year=1970, month=1, day=1, tzinfo=UTC)
def parse_go_timestamp(go_timestamp: str) -> datetime:
"""Parse a json-formatted golang time.T... | 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/utils/json.py | osprey_worker/src/osprey/worker/lib/utils/json.py | import datetime
from collections.abc import Set
import pytz
try:
import simplejson as json
except ImportError:
import json # type: ignore # https://github.com/python/mypy/issues/1153
class CustomJSONEncoder(json.JSONEncoder):
def __init__(self, serializable_classes=(), serialize_patches=None, dictable_... | 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/utils/secret_manager.py | osprey_worker/src/osprey/worker/lib/utils/secret_manager.py | from google.cloud import secretmanager
def fetch_secret(project_id: str, name: str, version: str = 'latest') -> str:
gsm_client = secretmanager.SecretManagerServiceClient()
secret_reference = gsm_client.secret_version_path(project=project_id, secret=name, secret_version=version)
response = gsm_client.acce... | 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/profiling/pyroscope_reporter.py | osprey_worker/src/osprey/worker/lib/profiling/pyroscope_reporter.py | from __future__ import annotations
import atexit
import logging
import os
import socket
import time
import types
from collections import defaultdict
from dataclasses import dataclass
from typing import DefaultDict, Dict, Optional, Tuple, Union
import gevent
import greenlet
import requests
from typing_extensions impor... | 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/profiling/sampler.py | osprey_worker/src/osprey/worker/lib/profiling/sampler.py | from __future__ import annotations
import atexit
import logging
import signal
import types
from typing import Optional
from flask import request
from .feature import current_features
from .pyroscope_reporter import Reporter, StackTrace
sampler: Optional[Sampler] = None
logger = logging.getLogger(__name__)
class ... | 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/profiling/__init__.py | osprey_worker/src/osprey/worker/lib/profiling/__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/profiling/feature.py | osprey_worker/src/osprey/worker/lib/profiling/feature.py | from contextvars import ContextVar
from enum import StrEnum
from typing import List, Optional
class Feature(StrEnum):
pass
_features_var: ContextVar[Optional[List[Feature]]] = ContextVar('features', default=None)
def current_features() -> List[Feature]:
"""Return the current features"""
return _featur... | 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_logging/request_metadata.py | osprey_worker/src/osprey/worker/lib/osprey_logging/request_metadata.py | from typing import Any, Optional
from flask import has_request_context, request
from osprey.worker.lib.osprey_logging.util import METADATA_FINALIZER_KEY, METADATA_KEY, USER_ID_KEY
def set_user_id(user_id):
if not has_request_context():
return
request.environ[USER_ID_KEY] = str(user_id)
def set_use... | 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_logging/util.py | osprey_worker/src/osprey/worker/lib/osprey_logging/util.py | import os
import time
METADATA_KEY = 'METADATA'
USER_ID_KEY = 'USER'
METADATA_FINALIZER_KEY = 'METADATA_FINALIZERS'
# NOTE: this function sits here because its imported by gunicorn on initialization
# before we've had gevent monkey patch things, so it must sit in a module that
# does not import anything that can 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/osprey_logging/__init__.py | osprey_worker/src/osprey/worker/lib/osprey_logging/__init__.py | import datetime
import importlib.resources
import inspect
import logging
import logging.config
import os
import sys
import types
from logging.handlers import SysLogHandler
from typing import Dict, List, Optional, Tuple, Union, cast
import pythonjsonlogger.jsonlogger
import pytz
import yaml
from flask import g as flask... | 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_logging/tests/test_log_formatter.py | osprey_worker/src/osprey/worker/lib/osprey_logging/tests/test_log_formatter.py | import logging
import pytest
from flask import Flask
from flask import g as flask_global
from osprey.worker.lib.osprey_logging import (
DATADOG_ROUTE_METADATA_ATTR,
DATADOG_ROUTE_NAME_TAG,
DATADOG_ROUTE_OWNER_TAG,
JsonLogFormatter,
PrettyLogFormatter,
)
@pytest.fixture()
def app():
app = Flas... | 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_logging/tests/test_request_metadata.py | osprey_worker/src/osprey/worker/lib/osprey_logging/tests/test_request_metadata.py | import json
import pytest
from flask import Flask, has_request_context, request
from osprey.worker.lib.osprey_logging import request_metadata
from osprey.worker.lib.osprey_logging.util import METADATA_KEY, USER_ID_KEY, get_metadata
class DummyUser:
def __init__(self, user_id):
self.id = user_id
@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/osprey_logging/tests/__init__.py | osprey_worker/src/osprey/worker/lib/osprey_logging/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/ddtrace_utils/constants.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/constants.py | from enum import Enum
class BaggagePrefix(Enum):
LOCAL = 'local.'
PEER = 'peer.'
ROOT = 'root.'
def prepend(self, key):
return f'{self.value}{key}'
class SpanAttributes:
METHOD = 'method'
OPERATION = 'operation'
RESOURCE = 'resource'
SERVICE = 'service'
URL = 'url'
A... | 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/ddtrace_utils/__init__.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/__init__.py | import functools
import sys
from typing import Any, Callable, Dict, Optional, TypeVar, Union
import ddtrace
from ddtrace.span import Span
from flask import Flask
from osprey.worker.lib.ddtrace_utils.instrumentation.flask.middleware import TraceMiddleware
from osprey.worker.lib.ddtrace_utils.internal.baggage import Bag... | 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/ddtrace_utils/internal/__init__.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/internal/__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/ddtrace_utils/internal/globals.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/internal/globals.py | from ..propagation.baggage import HTTPBaggagePropagator
from .baggage import BaggageManager
baggage_manager = BaggageManager()
baggage_propagator = HTTPBaggagePropagator()
| 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/ddtrace_utils/internal/baggage.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/internal/baggage.py | from typing import Dict, List, Optional, Union
from ddtrace.filters import TraceFilter
from ddtrace.span import Span
from ..constants import BaggagePrefix
Baggage = Dict[str, str]
DEFAULT_BAGGAGE_PREFIX = 'baggage.'
class BaggageManager:
"""
The BaggageManager provides support for managing tracing "baggag... | 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/ddtrace_utils/instrumentation/__init__.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/instrumentation/__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/ddtrace_utils/instrumentation/flask/middleware.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/instrumentation/flask/middleware.py | # Copied from https://github.com/DataDog/dd-trace-py/blob/v0.39.0/ddtrace/contrib/flask/middleware.py
# In order to fix status_code bug
import re
import sys
from typing import Any, Callable, Dict, List, Optional, Union
import flask.templating
from ddtrace import Span, Tracer
from ddtrace.constants import ERROR_MSG, ER... | 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/ddtrace_utils/instrumentation/flask/__init__.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/instrumentation/flask/__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/ddtrace_utils/propagation/__init__.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/propagation/__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/ddtrace_utils/propagation/baggage.py | osprey_worker/src/osprey/worker/lib/ddtrace_utils/propagation/baggage.py | from re import compile, split, sub
from typing import Dict, List
from urllib.parse import quote_plus, unquote_plus
from osprey.worker.lib.ddtrace_utils.constants import BaggagePrefix
from osprey.worker.lib.ddtrace_utils.internal.baggage import Baggage
DEFAULT_BAGGAGE_HEADER = 'baggage'
_LOCAL_PREFIX_PATTERN = compil... | 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/testing/util.py | osprey_worker/src/osprey/worker/lib/testing/util.py | from time import time
from gevent import sleep
def wait_for_condition(condition, max_wait=2):
start_time = time()
while not condition():
if time() - start_time > max_wait:
raise Exception('Timed out after %ss.' % max_wait)
sleep(0.001)
| 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/testing/__init__.py | osprey_worker/src/osprey/worker/lib/testing/__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/data_exporters/constants.py | osprey_worker/src/osprey/worker/lib/data_exporters/constants.py | DATA_EVENT = 'event' # required value for data ingestion
EXPERIMENT_METADATA_UPDATE_EVENT = 'osprey_experiment_metadata_update' # table name of event being sent to data
| 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/data_exporters/models.py | osprey_worker/src/osprey/worker/lib/data_exporters/models.py | from typing import List
from osprey.worker.lib.data_exporters.constants import DATA_EVENT, EXPERIMENT_METADATA_UPDATE_EVENT
from pydantic import BaseModel
class ospreyExperimentMetadataUpdate(BaseModel):
name: str = DATA_EVENT
event_type: str = EXPERIMENT_METADATA_UPDATE_EVENT
experiment: str
buckets... | 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/data_exporters/__init__.py | osprey_worker/src/osprey/worker/lib/data_exporters/__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/data_exporters/validation_result_exporter.py | osprey_worker/src/osprey/worker/lib/data_exporters/validation_result_exporter.py | import abc
from osprey.engine.ast_validator.validation_context import ValidatedSources
from osprey.engine.ast_validator.validators.validate_experiments import (
ValidateExperiments,
)
from osprey.worker.lib.data_exporters.models import ospreyExperimentMetadataUpdate
from osprey.worker.lib.publisher import BasePubl... | 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/data_exporters/test/test_validation_result_exporter.py | osprey_worker/src/osprey/worker/lib/data_exporters/test/test_validation_result_exporter.py | import json
from typing import Any, Dict, List
from unittest.mock import MagicMock
import pytest
from osprey.engine.ast.sources import Sources
from osprey.engine.ast_validator.validation_context import ValidatedSources
from osprey.engine.ast_validator.validators.validate_experiments import (
ExperimentValidationRe... | 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/data_exporters/test/conftest.py | osprey_worker/src/osprey/worker/lib/data_exporters/test/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/data_exporters/test/__init__.py | osprey_worker/src/osprey/worker/lib/data_exporters/test/__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/pigeon/client.py | osprey_worker/src/osprey/worker/lib/pigeon/client.py | import copy
import itertools
import weakref
from collections import defaultdict
from collections.abc import Mapping
from dataclasses import dataclass
from functools import partial
from time import time_ns
from typing import Any, Callable, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar, Union, cast
import grp... | 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/pigeon/exceptions.py | osprey_worker/src/osprey/worker/lib/pigeon/exceptions.py | from typing import Optional, cast
import grpc
class PigeonException(Exception):
pass
class InvalidRoutingValueException(PigeonException):
def __init__(self, field: str, value):
self.field = field
self.value = value
def __str__(self):
return f'Field {self.field} is empty. value=... | 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/pigeon/__init__.py | osprey_worker/src/osprey/worker/lib/pigeon/__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/pigeon/skip_rate_limit.py | osprey_worker/src/osprey/worker/lib/pigeon/skip_rate_limit.py | from typing import TypeVar
from gevent.local import local
# Type variables for argument and return types
R = TypeVar('R')
class SkipRateLimitContext(local): # type: ignore[misc]
skip = False
skip_rate_limit_context = SkipRateLimitContext()
| 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/pigeon/tests/test_retry.py | osprey_worker/src/osprey/worker/lib/pigeon/tests/test_retry.py | from concurrent import futures
import grpc
import pytest
from osprey.rpc.pigeon.tests.v1.tests_pb2 import ScalarRoutingValueRequest, ScalarRoutingValueResponse
from osprey.rpc.pigeon.tests.v1.tests_pb2_grpc import (
TestServiceServicer,
TestServiceStub,
add_TestServiceServicer_to_server,
)
from osprey.work... | 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/pigeon/tests/test_client.py | osprey_worker/src/osprey/worker/lib/pigeon/tests/test_client.py | from osprey.rpc.pigeon.tests.v1 import tests_pb2
from osprey.worker.lib.pigeon.client import _make_message
REQUEST_FIELD = 'routing_values'
def test_make_message_list():
message_template = tests_pb2.ListRoutingValueRequest()
routing_values = [43, 56, 10, 54]
routing_values_chunk = routing_values[0:2]
... | 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/pigeon/tests/test_integration.py | osprey_worker/src/osprey/worker/lib/pigeon/tests/test_integration.py | from concurrent import futures
import grpc
import pytest
from osprey.rpc.pigeon.tests.v1.tests_pb2 import (
Foo,
ListRoutingValueRequest,
ListRoutingValueResponse,
MapMessageRoutingValueRequest,
MapMessageRoutingValueResponse,
MapRoutingValueRequest,
MapRoutingValueResponse,
ScalarRouti... | 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/pigeon/interceptors/metadata.py | osprey_worker/src/osprey/worker/lib/pigeon/interceptors/metadata.py | import collections
from typing import Dict, Text
import grpc
class MetadataInterceptor(
grpc.UnaryUnaryClientInterceptor, # type: ignore[misc]
grpc.UnaryStreamClientInterceptor, # type: ignore[misc]
grpc.StreamUnaryClientInterceptor, # type: ignore[misc]
grpc.StreamStreamClientInterceptor, # type... | 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/pigeon/interceptors/baggage.py | osprey_worker/src/osprey/worker/lib/pigeon/interceptors/baggage.py | import collections
from typing import Dict, Optional
import grpc
from osprey.worker.lib.ddtrace_utils import (
baggage_propagator,
current_span,
get_baggage,
)
BAGGAGE_HEADER = 'baggage'
class BaggageInterceptor(
grpc.UnaryUnaryClientInterceptor, # type: ignore[misc]
grpc.UnaryStreamClientInter... | 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/config/callbacks.py | osprey_worker/src/osprey/worker/lib/config/callbacks.py | from typing import TYPE_CHECKING
from osprey.worker.lib.instruments import metrics
from osprey.worker.lib.utils.trace import GCMetrics
if TYPE_CHECKING:
from osprey.worker.lib.config import Config
def tracing_callback(config: 'Config') -> None:
"""
Enable metrics collection if the `TRACING_COLLECT_METRI... | 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/config/__init__.py | osprey_worker/src/osprey/worker/lib/config/__init__.py | import json
import os
from typing import Any, Callable, Dict, List, Optional, Tuple
from osprey.worker.lib.config.callbacks import tracing_callback
ConfigT = Dict[str, Any]
ConfigurationCallback = Callable[['Config'], None]
DEFAULT_CONFIGURATION_CALLBACKS: Tuple[ConfigurationCallback] = (tracing_callback,)
class ... | 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_shared/labels.py | osprey_worker/src/osprey/worker/lib/osprey_shared/labels.py | import copy
from collections import UserDict
from dataclasses import dataclass, field, replace
from datetime import datetime, timedelta, timezone
from enum import Enum, IntEnum
from typing import Any, Dict, Self
from osprey.worker.lib.osprey_shared.logging import get_logger
from osprey.worker.lib.utils.request_utils 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/lib/osprey_shared/abilities.py | osprey_worker/src/osprey/worker/lib/osprey_shared/abilities.py | from dataclasses import dataclass, field
from typing import Any, List, Mapping, Optional, Sequence, Set
from urllib.parse import urlencode
import requests
from osprey.engine.language_types.entities import EntityT
from osprey.worker.lib.utils.flask_signing import Signer
from pydantic.main import BaseModel
from requests... | 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_shared/logging.py | osprey_worker/src/osprey/worker/lib/osprey_shared/logging.py | import logging
from datetime import datetime, timedelta
from random import SystemRandom
from typing import Optional
class RollingCounter:
"""
A circular buffer that keeps track of a rolling sum of counts per defined interval.
The `buffer_capacity` defines the size of the buffer, and the `milliseconds_per... | 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_shared/__init__.py | osprey_worker/src/osprey/worker/lib/osprey_shared/__init__.py | import sys
assert sys.version_info >= (3, 6), 'This package only supports Python 3.6 or higher!'
| 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_shared/counters.py | osprey_worker/src/osprey/worker/lib/osprey_shared/counters.py | from datetime import timedelta
from enum import Enum
from typing import List
import requests
from osprey.worker.lib.utils.flask_signing import Signer
from pydantic.main import BaseModel
BULK_READ_COUNTER_TIMEOUT = 60
class CountService(str, Enum):
"""
Used to determine whether a request refers to a `unique`... | 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/etcd/dict.py | osprey_worker/src/osprey/worker/lib/etcd/dict.py | from __future__ import absolute_import
import json
from multiprocessing import RLock
from typing import Callable, Dict, List, Mapping, MutableMapping, Optional, TypeVar
import gevent
from osprey.worker.lib import etcd
# Apparently we can't easily add pip requirements for transitive dependencies of confy...
# Use the... | 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/etcd/tree.py | osprey_worker/src/osprey/worker/lib/etcd/tree.py | from __future__ import print_function
import os
from collections import defaultdict
from multiprocessing import RLock
from typing import Callable, Dict, List, Mapping, Optional
import gevent
from osprey.worker.lib import etcd
TWatcherCallback = Callable[[str, Optional[str]], None]
class ReadOnlyEtcdTree(Mapping[st... | 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/etcd/set.py | osprey_worker/src/osprey/worker/lib/etcd/set.py | from __future__ import absolute_import
import json
from typing import AbstractSet, Any, MutableSet
import gevent
from gevent.lock import RLock
from osprey.worker.lib import etcd
class ReadOnlyEtcdSet(AbstractSet[Any]):
def __init__(
self, etcd_key, etcd_client=None, lazy=True, item_encode_hook=None, ite... | 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/etcd/__main__.py | osprey_worker/src/osprey/worker/lib/etcd/__main__.py | from . import EtcdClient
if __name__ == '__main__':
EtcdClient().delete('/doctest', directory=True, recursive=True)
import doctest
doctest.testmod()
| 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/etcd/__init__.py | osprey_worker/src/osprey/worker/lib/etcd/__init__.py | from __future__ import absolute_import, print_function
import base64
import errno
import json
import logging
import os
import random
import socket
from email.message import Message
from typing import Any, Callable, Dict, List, Optional
import gevent
import six
import six.moves.http_client
import six.moves.urllib.erro... | 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/etcd/ring.py | osprey_worker/src/osprey/worker/lib/etcd/ring.py | from __future__ import absolute_import
import json
import logging
import random
from typing import Text, Union
import gevent
import six
from gevent.lock import RLock
from gevent.threadpool import ThreadPool
from hash_ring import HashRing, HashRingNode
from osprey.worker.lib import etcd
log = logging.getLogger(__name... | 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/etcd/locking.py | osprey_worker/src/osprey/worker/lib/etcd/locking.py | from __future__ import absolute_import
import os
import uuid
import gevent
from gevent.timeout import with_timeout
from osprey.worker.lib import etcd
LOCK_DIR_KEY = '/locks'
class DistributedLock(object):
"""
Distributed lock powered by Etcd.
"""
def __init__(self, key, ttl=5, etcd_client=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/etcd/watcher/_base.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/_base.py | class BaseWatcher(object):
"""The base watcher interface that all other watchers should implement."""
def begin_watching(self):
"""
Call this to begin watching a key. Returning the initial sync event. This is useful if you want to perform
the initial sync of the key with the data struct... | 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/etcd/watcher/_events.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/_events.py | class BaseEvent(object):
def __eq__(self, other):
return self.__class__ is other.__class__ and self.__dict__ == other.__dict__
def __ne__(self, other):
return not self == other
def __repr__(self):
return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % it for it in self.__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/lib/etcd/watcher/_mux.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/_mux.py | from ._events import FullSyncRecursive, IncrementalSyncDelete, IncrementalSyncUpsert
class PassthruMux(object):
def reset_with_initial_event(self, event):
pass
def dedupe_event(self, event):
yield event
class WatchMux(object):
"""Watch mux takes a stream of events and de-duplicates them... | 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/etcd/watcher/client_impl.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/client_impl.py | import logging
import time
from osprey.worker.lib.backoff import Backoff
from ._base import BaseWatcher
from ._events import FullSyncOne, FullSyncOneNoKey, FullSyncRecursive, IncrementalSyncDelete, IncrementalSyncUpsert
from ._mux import PassthruMux, RecursiveWatchMux, WatchMux
log = logging.getLogger('etcd.watcher'... | 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/etcd/watcher/__init__.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/__init__.py | from ._base import BaseWatcher # noqa F401
from ._events import ( # noqa F401
BaseEvent,
FullSyncOne,
FullSyncOneNoKey,
FullSyncRecursive,
IncrementalSyncDelete,
IncrementalSyncUpsert,
)
from .client_impl import EtcdWatcher # noqa F401
| 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/etcd/watcher/watcherd_impl.py | osprey_worker/src/osprey/worker/lib/etcd/watcher/watcherd_impl.py | import logging
import time
from osprey.rpc.etcd_watcherd.v1.etcd_watcherd_pb2 import WatchKeyRecursiveRequest, WatchKeyRequest
from osprey.worker.lib.backoff import Backoff
from osprey.worker.lib.ddtrace_utils import with_tracing_context
from ._base import BaseWatcher
from ._events import FullSyncOne, FullSyncOneNoKe... | 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/etcd/tests/test_dict.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_dict.py | from __future__ import absolute_import
import pytest
from osprey.worker.lib.etcd import ETCD_HISTORY_BUFFER_SIZE, RequestError, Timeout
from osprey.worker.lib.etcd.dict import EtcdDict, ReadOnlyEtcdDict
pytestmark = pytest.mark.timeout(2)
def test_dict_start(etcd_client, etcd_key, dict_key, dict_value, dictionary, ... | 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/etcd/tests/test_watcher.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_watcher.py | import pytest
from osprey.worker.lib import etcd
@pytest.mark.parametrize('has_initial_key', [True, False])
def test_watcher_non_recursive(etcd_client, etcd_key, has_initial_key):
watcher = etcd_client.get_watcher(etcd_key, recursive=False)
if has_initial_key:
etcd_client.set(etcd_key, 'genesis')
... | 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/etcd/tests/test_ring.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_ring.py | from __future__ import absolute_import
import json
from collections import Counter
import pytest
from osprey.worker.lib.etcd.ring import EtcdHashRing, EtcdHashRingMember, EtcdHashRingTopology
from six.moves import range
@pytest.fixture(scope='function')
def ring(etcd_client, etcd_key):
return EtcdHashRing(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/etcd/tests/test_tree.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_tree.py | import json
from osprey.worker.lib.etcd.tree import ReadOnlyEtcdTree as EtcdTree
def test_set(etcd_client, etcd_key, wait_for_condition):
"""Test that setting a sub path deeper in the tree works."""
etcd_tree = EtcdTree(etcd_key)
etcd_tree.watch()
wait_for_condition(lambda: etcd_tree.get('%s/a' % et... | 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/etcd/tests/conftest.py | osprey_worker/src/osprey/worker/lib/etcd/tests/conftest.py | # flake8: noqa E402
# ruff: noqa: E402
from gevent.monkey import patch_all
patch_all()
import json
import pytest
from osprey.worker.lib import etcd
from osprey.worker.lib.testing.util import wait_for_condition as wait_for_condition_impl
@pytest.fixture(scope='module')
def etcd_client():
return etcd.EtcdClient(... | 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/etcd/tests/test_set.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_set.py | import pytest
from osprey.worker.lib.etcd import ETCD_HISTORY_BUFFER_SIZE, RequestError, Timeout
from osprey.worker.lib.etcd.set import EtcdSet, ReadOnlyEtcdSet
def test_set_start(etcd_client, etcd_key, dict_value, serializer):
etcd_client.set(etcd_key, serializer.dumps([dict_value]))
etcd_set = ReadOnlyEtcd... | 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/etcd/tests/test_watcher_mux.py | osprey_worker/src/osprey/worker/lib/etcd/tests/test_watcher_mux.py | from osprey.worker.lib.etcd.watcher import (
FullSyncOne,
FullSyncOneNoKey,
FullSyncRecursive,
IncrementalSyncDelete,
IncrementalSyncUpsert,
)
from osprey.worker.lib.etcd.watcher._mux import RecursiveWatchMux, WatchMux
def run_events_thru_mux(events_and_expected_outputs, mux):
for i, (event, e... | 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/cli/sinks.py | osprey_worker/src/osprey/worker/cli/sinks.py | # mypy: ignore-errors
# ruff: noqa: E402, E501
from osprey.worker.lib.patcher import patch_all
# do not move this below other imports
patch_all(ddtrace_args={'cassandra': True, 'psycopg': True})
import signal
from uuid import uuid1
# this is required to avoid memory leaks with gRPC
from gevent import config as geve... | 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/cli/__init__.py | osprey_worker/src/osprey/worker/cli/__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/engine/conftest.py | osprey_worker/src/osprey/engine/conftest.py | import itertools
import json
import pathlib
import sys
from contextlib import contextmanager
from datetime import datetime
from textwrap import dedent
from typing import (
TYPE_CHECKING,
Any,
Callable,
ContextManager,
Dict,
Generator,
Iterator,
Optional,
Set,
Type,
TypeVar,
... | 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/engine/__init__.py | osprey_worker/src/osprey/engine/__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/engine/shared_constants.py | osprey_worker/src/osprey/engine/shared_constants.py | import typing
from enum import StrEnum
if typing.TYPE_CHECKING:
from osprey.engine.language_types.labels import LabelStatus
ENTITY_LABEL_MUTATION_DIMENSION_NAME = '__entity_label_mutations'
VERDICT_DIMENSION_NAME = '__verdicts'
def ENTITY_LABEL_MUTATION_DIMENSION_VALUE(entity_type: str, label_name: str, label_s... | 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/engine/utils/graph.py | osprey_worker/src/osprey/engine/utils/graph.py | from collections import defaultdict, deque
from typing import DefaultDict, Deque, Dict, Generic, Hashable, Iterator, List, Sequence, Set, TypeVar
T = TypeVar('T', bound=Hashable)
class Graph(Generic[T]):
def __init__(self) -> None:
self._graph: DefaultDict[T, Set[T]] = defaultdict(set)
def add_node(... | 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/engine/utils/osprey_unary_executor.py | osprey_worker/src/osprey/engine/utils/osprey_unary_executor.py | from typing import Mapping, Type, Union
from osprey.engine.ast.grammar import Number, UnaryOperation, UnaryOperator, USub
from osprey.engine.executor.node_executor.unary_operation_executor import _UNARY_OPERATORS
class OspreyUnaryExecutor:
"""There exists a need to execute certain Unary operations outside of the... | 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/engine/utils/imports.py | osprey_worker/src/osprey/engine/utils/imports.py | import importlib
import types
from pathlib import Path
def import_all_direct_children(module: types.ModuleType) -> None:
"""Dynamically import all child modules in a given package.
The name *must* be absolute and *must* be a package. This can be useful in cases where the act of importing
children can be ... | 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/engine/utils/__init__.py | osprey_worker/src/osprey/engine/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/engine/utils/types.py | osprey_worker/src/osprey/engine/utils/types.py | import dataclasses
import weakref
from functools import wraps
from typing import Callable, Dict, Optional, Sequence, Type, TypeVar
from typing_extensions import Protocol
TypeT = TypeVar('TypeT', bound=type)
def _weakref_inherited(cls: type) -> bool:
# Taken from:
# https://github.com/python-attrs/attrs/blob... | 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/engine/utils/periodic_execution_yielder.py | osprey_worker/src/osprey/engine/utils/periodic_execution_yielder.py | import threading
import time
from contextlib import contextmanager
from typing import Any, Iterator
class PeriodicExecutionYielder:
"""Periodically sleeps calling thread for `yield_time_sec` if it's been over `execution_time_sec` since last sleep.
Do not set `execution_time_sec` too low (< 0.001 s) to protec... | 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/engine/utils/get_closest_string_within_threshold.py | osprey_worker/src/osprey/engine/utils/get_closest_string_within_threshold.py | import functools
from typing import Iterable, Optional
import Levenshtein
def get_closest_string_within_threshold(
string: str, candidate_strings: Iterable[str], distance_threshold: int = 3
) -> Optional[str]:
"""Given a string, return the string that is the closest (in terms of case-insensitive levenshtein ... | 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/engine/utils/tests/test_osprey_unary_executor.py | osprey_worker/src/osprey/engine/utils/tests/test_osprey_unary_executor.py | from typing import Union
import pytest
from osprey.engine.ast.grammar import Boolean, Number, Span, UnaryOperation, USub
from osprey.engine.ast.sources import Sources
from osprey.engine.utils.osprey_unary_executor import OspreyUnaryExecutor
@pytest.fixture
def sources() -> Sources:
return Sources.from_dict({'mai... | 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/engine/utils/tests/test_graph.py | osprey_worker/src/osprey/engine/utils/tests/test_graph.py | import pytest
from osprey.engine.utils.graph import CyclicDependencyError, Graph
def test_graph_ops() -> None:
g: Graph[str] = Graph()
g.add_edge('a', 'b')
g.add_edge('b', 'c')
assert list(sorted(g.iter_nodes())) == ['a', 'b', 'c']
assert list(sorted(g.iter_edges('a'))) == ['b']
assert list(... | 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/engine/utils/tests/test_get_closest_string_within_threshold.py | osprey_worker/src/osprey/engine/utils/tests/test_get_closest_string_within_threshold.py | from typing import List, Optional
import pytest
from osprey.engine.utils.get_closest_string_within_threshold import get_closest_string_within_threshold
@pytest.mark.parametrize(
'string, candidates, expected',
[
# Prefer case insensitive match.
('USERNAME', ['UserName', 'USERNAMW'], 'UserName... | 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/engine/utils/tests/__init__.py | osprey_worker/src/osprey/engine/utils/tests/__init__.py | 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.