text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""Tests for the spurious-cancellation helper."""
from __future__ import annotations
import asyncio
import pytest
from bleak_esphome._cancellation import is_spurious_cancellation
@pytest.mark.asyncio
async def test_returns_true_when_not_externally_cancelled() -> None:
"""Inside a normal task with no pending c... | Bluetooth-Devices/bleak-esphome | tests/test_cancellation.py | .py | 7bdc0b6df0d453b5 | 8 | 9 |
"""Tests for the top-level ``bleak_esphome`` package surface."""
from __future__ import annotations
import bleak_esphome
from bleak_esphome import (
APIConnectionManager,
ESPHomeDeviceConfig,
ESPHomeStartAborted,
connect_scanner,
)
from bleak_esphome.connect import connect_scanner as _connect_scanner_... | Bluetooth-Devices/bleak-esphome | tests/test_init.py | .py | b425b94a0ec78e1e | 8 | 9 |
from collections import defaultdict
from dateutil import parser as dateparser
# Helper function to validate ISO datetime format
def validate_iso_datetime(param_name, value):
if value:
try:
return dateparser.isoparse(value)
except ValueError:
raise ValueError(f"Invalid {par... | wmo-raf/adl | adl/src/adl/api/utils.py | .py | 55df13f3d5839088 | 7.62 | 16 |
from celery_singleton.backends import RedisBackend
from django_redis import get_redis_connection
class RedisBackendForSingleton(RedisBackend):
def __init__(self, *args, **kwargs):
"""
Use the existing redis connection instead of creating a new one.
"""
self.redis = get_red... | wmo-raf/adl | adl/src/adl/celery_singleton_backend.py | .py | 881f9dcc16a4cd54 | 7.12 | 16 |
"""
Django settings for adl project.
Generated by 'django-admin startproject' using Django 5.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import importlib... | wmo-raf/adl | adl/src/adl/config/settings/base.py | .py | 85e34c2980e0a668 | 7.62 | 16 |
"""
Layer-2 broker and queue observations for the ingestion diagnostic.
All broker interaction for "is a worker consuming the ingestion queue, and is
work backing up?" lives behind :func:`get_ingestion_queue_health` — callers
and tests substitute that one name instead of patching kombu and the Celery
control API. The ... | wmo-raf/adl | adl/src/adl/core/broker.py | .py | 1a90105085e361ab | 7.62 | 16 |
"""
The one bounded broker connection every in-process broker call goes through.
Celery's defaults are built for workers, not for request threads. Left alone
they hang the caller (measured in issue #151, re-confirmed in #166):
- The app's **default connection** retries on failure —
``broker_connection_timeout=4`` a... | wmo-raf/adl | adl/src/adl/core/broker_connection.py | .py | c5bad88b33bab7dc | 7.62 | 16 |
"""
Write-time failure classification.
When an ingestion or dispatch run fails, core stamps the activity log with
*what kind* of failure it was — a category from a closed vocabulary, the
diagnostic layer it implicates (4 = network path, 5 = source), and the
fully-qualified exception class. This is the trusted tier of ... | wmo-raf/adl | adl/src/adl/core/classification.py | .py | 7a3f4a180298a512 | 7.62 | 16 |
"""
Core-side containment for :meth:`DispatchChannel.test_connection`.
``test_connection()`` is documented on the base class as returning a dict and
never raising, but every implementation past ``Wis2BoxUpload`` lives in an
independently-versioned plugin repo that upgrades on its own schedule. The
contract had already... | wmo-raf/adl | adl/src/adl/core/dispatch_checks.py | .py | 85dde3d87e7feb81 | 7.62 | 16 |
import csv
import logging
import time
from datetime import timedelta
from io import StringIO, BytesIO
from django.utils import timezone as dj_timezone
from minio import Minio
from minio.error import S3Error
from urllib3 import PoolManager
from adl.core.utils import get_object_or_none
logger = logging.getLogger(__nam... | wmo-raf/adl | adl/src/adl/core/dispatchers/wis2box.py | .py | aa1e3ecc65f393f5 | 7.62 | 16 |
class InstanceTypeAlreadyRegistered(Exception):
"""
Raised when the instance model instance is already registered in the registry.
"""
class InstanceTypeDoesNotExist(Exception):
"""
Raised when a requested instance model instance isn't registered in the registry.
"""
def __init__(self, ty... | wmo-raf/adl | adl/src/adl/core/exceptions.py | .py | dcabeca01b3bf86f | 7.12 | 16 |
import logging
from datetime import datetime
from typing import Optional
from django_eventstream import send_event
from .redaction import redact_secrets
logger = logging.getLogger(__name__)
class TaskLogger:
"""
Unified logger that sends to both standard logging and SSE via django-eventstream
"""
... | wmo-raf/adl | adl/src/adl/core/logging.py | .py | 279673ddba562099 | 7.62 | 16 |
from dataclasses import dataclass
from typing import Optional
@dataclass
class LLMConfigError(Exception):
"""Raised when the request configuration is invalid or incompatible."""
message: str = "Invalid LLM request configuration."
detail: Optional[str] = None
def __post_init__(self):
full_mess... | Inozem/llm_api_adapter | src/llm_api_adapter/errors/config_errors.py | .py | de338b4dc9af1860 | 7.6 | 15 |
from dataclasses import dataclass
from typing import Optional
@dataclass
class LLMAPIError(Exception):
"""Base class for API-related errors."""
message: str = "An API error occurred."
detail: Optional[str] = None
def __post_init__(self):
full_message = self.message
if self.detail:
... | Inozem/llm_api_adapter | src/llm_api_adapter/errors/llm_api_error.py | .py | 075528704268021e | 7.6 | 15 |
"""Organization-scoped schemas for registry-backed request rule metadata.
The registry JSON selects only known handler IDs and validated data. It never
imports code, evaluates expressions, or carries arbitrary callback payloads.
"""
from __future__ import annotations
import copy
from dataclasses import dataclass
imp... | Inozem/llm_api_adapter | src/llm_api_adapter/llm_registry/request_rules.py | .py | a3387fec2f2c2701 | 7.6 | 15 |
"""Asynchronous HTTPX client for the Anthropic Messages API."""
from __future__ import annotations
from dataclasses import dataclass
from typing import AsyncIterator
from ..async_streaming import async_request, async_stream_request
from ..streaming import SSEEvent
from .sync_client import ClaudeSyncClient
@datacla... | Inozem/llm_api_adapter | src/llm_api_adapter/llms/anthropic/async_client.py | .py | 7d2d1160cc9dfe8f | 7.6 | 15 |
"""Shared asynchronous HTTPX transport for provider clients.
This module deliberately knows only about JSON POST requests and Server-Sent
Events framing. Provider clients remain responsible for interpreting decoded
payloads and mapping provider-specific error bodies.
"""
from __future__ import annotations
import log... | Inozem/llm_api_adapter | src/llm_api_adapter/llms/async_streaming.py | .py | f7b05a6003cddbed | 7.6 | 15 |
"""Asynchronous HTTPX client for the Google Generative Language API."""
from __future__ import annotations
from dataclasses import dataclass
from typing import AsyncIterator
from ..async_streaming import async_request, async_stream_request
from ..streaming import SSEEvent
from .sync_client import GeminiSyncClient
... | Inozem/llm_api_adapter | src/llm_api_adapter/llms/google/async_client.py | .py | 742074c3b59c5a4c | 7.6 | 15 |
"""Shared registry lookups for provider-client request payloads."""
from __future__ import annotations
from typing import Any, Mapping, Optional
from ..llm_registry.llm_registry import LLM_REGISTRY, ModelSpec, resolve_model_spec
from ..llm_registry.request_rules import (
AppliedRequestRule,
RequestRules,
... | Inozem/llm_api_adapter | src/llm_api_adapter/llms/request_rules.py | .py | d32c10922bc7f56d | 7.6 | 15 |
"""Shared synchronous SSE transport for provider streaming clients.
This module deliberately knows only about the Server-Sent Events transport.
Provider clients remain responsible for interpreting the decoded payloads.
"""
from __future__ import annotations
import time
from typing import Any, Callable, Iterator, Lis... | Inozem/llm_api_adapter | src/llm_api_adapter/llms/streaming.py | .py | a79b88696be3ad87 | 7.6 | 15 |
#! /usr/bin/env python3
"""pyaki CLI tool to process AKI stages from time series data."""
from pathlib import Path
import pandas as pd
import typer
from pyaki.kdigo import Analyser
from pyaki.utils import Dataset, DatasetType
def main(
path: str,
urineoutput_file: str = "urineoutput.csv",
creatinine_fi... | aidh-ms/pyAKI | pyaki/bin/process_aki_stages.py | .py | d76fc5af6d818ae0 | 7.52 | 10 |
"""
This module contains the analysis class for processing AKI stages from time series data.
"""
import logging
from typing import Optional
import pandas as pd
from pyaki.preprocessors import (
CreatininePreProcessor,
DemographicsPreProcessor,
Preprocessor,
RRTPreProcessor,
TimeIndexCreator,
... | aidh-ms/pyAKI | pyaki/kdigo.py | .py | 6e50327bd373e42b | 7.52 | 10 |
"""
This module contains the utility functions and classes used in the pyaki package.
"""
import logging
from enum import StrEnum, auto
from functools import wraps
from typing import Any, Callable, NamedTuple, cast
import numpy as np
import pandas as pd
logger = logging.getLogger(__name__)
class DatasetType(StrEnu... | aidh-ms/pyAKI | pyaki/utils.py | .py | 300f5a070689da6e | 7.52 | 10 |
"""Command-line entry point.
python -m scripts.validate # everything
python -m scripts.validate --only announcements
python -m scripts.validate --changed-only changed.txt --format github
Exit codes:
0 clean (warnings and notices do not fail)
1 at least one error
2 the val... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/__main__.py | .py | 591129190c5aa7b7 | 7.52 | 10 |
"""Locating the files a schema applies to.
Two subtleties worth stating, because getting either wrong makes the whole
framework misleading:
1. Build output must never be scanned. `_site/`, `_freeze/` and `.quarto/`
contain copies of real content; findings there are noise and, worse, would
report paths that do n... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/discovery.py | .py | 7397daefef6048b0 | 7.52 | 10 |
"""Parser for Pandoc fenced divs (`::: name` ... `:::`).
Several contribution types are structural rather than field-based: a tool
entry is a `::: software-card` whose first child must be an `### ` heading
(the CSS attaches the gear glyph and the underline to `.software-card h3`,
so a card using `##` or `####` renders... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/divs.py | .py | 9cefe6a217fb3e3e | 7.52 | 10 |
"""The unit of validator output.
Every check produces `Finding` objects. Nothing prints directly: renderers in
`report.py` decide how a finding appears (console, GitHub annotation, JSON).
"""
from __future__ import annotations
import enum
from dataclasses import dataclass
class Severity(enum.IntEnum):
"""Order... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/finding.py | .py | 1fba0478fb51de0c | 7.52 | 10 |
"""A linter for GROMACS topology (.itp) files carrying Martini parameters.
Scope, stated plainly because it matters for how results are read: this
validates **syntax, internal consistency, and force-field compatibility**. It
does not and cannot validate whether a parameter set reproduces experiment.
Scientific validat... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/itp.py | .py | 06f47618b59e19e0 | 7.52 | 10 |
"""Link extraction and resolution.
The failure this defends against is the quiet one: a renamed or deleted file
leaves a link pointing nowhere, Quarto renders it without complaint, and the
navigation is broken until a reader happens to click it.
"""
from __future__ import annotations
import re
from dataclasses impor... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/links.py | .py | 0ee87beca4c1c3a3 | 7.52 | 10 |
"""Parsing of Quarto `.qmd` source files.
This module exists because the obvious approach is wrong. The announcements
metadata generator used to do::
parts = content.split('---', 2)
which finds *any* ``---`` anywhere in the file. A post whose body contains a
horizontal rule, an em-dash run, or a YAML block in a ... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/qmd.py | .py | ff14df92b43ffa44 | 7.52 | 10 |
"""Rendering of findings.
Three output modes:
* ``console`` -- for local `make validate`
* ``github`` -- workflow commands that GitHub renders inline on the PR diff
* ``json`` -- machine-readable, used by the scheduled link-health job
Plus a markdown job summary, which is what makes CI read like a curation
re... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/core/report.py | .py | b0abf1712478cdb2 | 7.52 | 10 |
"""Registry of relational rules.
The declarative schemas handle everything expressible as "this field must look
like that". Rules registered here handle checks that must look outside a
single field: at the file's directory, at its siblings, at another file's
contents, or at a downstream consumer's parser.
A schema na... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/rules/__init__.py | .py | 65a9b486b5cacaf6 | 7.52 | 10 |
"""Relational rules for announcement posts.
The rules here defend the two consumers that a field-level schema cannot
reach: the S3-triggered email Lambda, and the homepage feed.
"""
from __future__ import annotations
import re
from datetime import date, datetime, timedelta
from ..core.finding import Finding, error,... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/rules/announcements.py | .py | 73edb0e44f61361a | 7.52 | 10 |
"""Relational rules for publication entries."""
from __future__ import annotations
import re
import unicodedata
from collections import defaultdict
from pathlib import Path
from ..core.finding import Finding, Severity, error, warning
from ..core.qmd import QmdDoc
from . import rule
# Characters that look like ASCII... | Martini-Force-Field-Initiative/Martini-Force-Field-Initiative.github.io | scripts/validate/rules/publications.py | .py | b53e7378c88156e2 | 7.52 | 10 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from cagecleaner.utils import generate_cblaster_session
import argparse
import sys
import logging
from pathlib import Path
from cblaster.classes import Session
LOG = logging.getLogger(__name__)
logging.basicConfig(
level = logging.ERROR,
format = "[%(asctime)s... | LucoDevro/CAGEcleaner | cagecleaner/generate_session.py | .py | c860c53cdebf0236 | 7.56 | 12 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from cagecleaner.run import Run
from cagecleaner.utils import run_command
import logging
LOG = logging.getLogger(__name__)
class GenomeRun(Run):
"""
Abstract intermediary class grouping the methods shared by every run involving whole-genome dereplication.
... | LucoDevro/CAGEcleaner | cagecleaner/genome_run.py | .py | 60bc4d71021b083d | 7.56 | 12 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from cagecleaner.run import Run
from cagecleaner.file_utils import is_fasta, is_genbank, remove_suffixes, convert_genbanks_to_fastas
import logging
import os
import shutil
from abc import abstractmethod
from cblaster.extract_clusters import get_sorted_cluster_hierarchies... | LucoDevro/CAGEcleaner | cagecleaner/local_run.py | .py | f8c4c5caa791a42b | 7.56 | 12 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from cagecleaner.run import Run
from cagecleaner.utils import run_command
import logging
from pathlib import Path
LOG = logging.getLogger(__name__)
class RegionRun(Run):
"""
Abstract intermediary class grouping the methods shared by every run involving region... | LucoDevro/CAGEcleaner | cagecleaner/region_run.py | .py | bc182e4ab573e2b5 | 7.56 | 12 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from cagecleaner.run import Run
import logging
from abc import abstractmethod
LOG = logging.getLogger(__name__)
class RemoteRun(Run):
"""
Abstract intermediary class grouping the methods shared by every run involving remote sequence files.
Inherits f... | LucoDevro/CAGEcleaner | cagecleaner/remote_run.py | .py | 213174550cfb4aa8 | 7.56 | 12 |
import ipaddress
import logging
from functools import cache
from pytest_testconfig import py_config
LOGGER = logging.getLogger(__name__)
@cache
def supported_cluster_ip_versions() -> set[int]:
"""Return the set of IP versions (4, 6) supported by the cluster."""
return {version for version, enabled in ((4, i... | RedHatQE/openshift-virtualization-tests | libs/net/cluster.py | .py | 5012fd48410ed8b7 | 7.65 | 19 |
import ipaddress
import random
from functools import cache
from ipaddress import IPv4Interface, IPv6Interface
from typing import Final
from libs.net.cluster import ipv4_supported_cluster, ipv6_supported_cluster, supported_cluster_ip_versions
_MAX_NUM_OF_RANDOM_OCTETS_PER_SESSION: Final[int] = 16
_MAX_NUM_OF_RANDOM_HE... | RedHatQE/openshift-virtualization-tests | libs/net/ip.py | .py | c4d4320485b10e71 | 7.65 | 19 |
from __future__ import annotations
import json
from dataclasses import asdict, dataclass, field
from enum import Enum
from typing import Any, Final
from kubernetes.dynamic import DynamicClient
from ocp_resources.resource import NamespacedResource
_DEFAULT_CNI_VERSION: Final[str] = "0.3.1"
@dataclass
class Ipam:
... | RedHatQE/openshift-virtualization-tests | libs/net/netattachdef.py | .py | 9a65ead0a5822925 | 7.65 | 19 |
from __future__ import annotations
import ipaddress
from collections.abc import Callable
from copy import deepcopy
from typing import TYPE_CHECKING, Any, Final
from kubernetes.dynamic.client import ResourceField
from ocp_resources.utils.resource_constants import ResourceConstants
from ocp_resources.virtual_machine im... | RedHatQE/openshift-virtualization-tests | libs/net/vmspec.py | .py | f0cd1fdbbc9ef5ba | 7.15 | 19 |
import logging
from kubernetes.client import ApiException
from libs.net.vmspec import wait_for_ifaces_status
from libs.vm.vm import BaseVirtualMachine
LOGGER = logging.getLogger(__name__)
def run_vm(
vm: BaseVirtualMachine,
ip_addresses_by_spec_net_name: dict[str, list[str]],
) -> BaseVirtualMachine:
"... | RedHatQE/openshift-virtualization-tests | libs/vm/oper.py | .py | 566b9e885f345199 | 7.65 | 19 |
#!/usr/bin/env python3
"""Retry CodeRabbit reviews that hit rate limits.
Scans open, non-draft, non-WIP, non-stale, non-conflicting PRs (updated in the
last 2 days) for CodeRabbit rate-limit comments and re-triggers review once the
wait period has elapsed.
Intended to be invoked from GitHub Actions with env vars::
... | RedHatQE/openshift-virtualization-tests | scripts/coderabbit_retry/coderabbit_retry.py | .py | d5132e51ced2bdb7 | 7.65 | 19 |
from __future__ import annotations
from datetime import datetime
from unittest.mock import MagicMock
def make_completed_process(returncode: int = 0, stdout: str = "", stderr: str = "") -> MagicMock:
"""Create a mock subprocess CompletedProcess.
Args:
returncode: Process exit code.
stdout: St... | RedHatQE/openshift-virtualization-tests | scripts/coderabbit_retry/tests/utils.py | .py | 1cad5bb789e15e0b | 8.15 | 19 |
# Co-authored-by: Claude <noreply@anthropic.com>
"""Auto-fill ReportPortal launch attributes from a connected cluster.
Queries the OpenShift cluster for architecture, versions, storage class,
and cluster identity.
"""
from __future__ import annotations
import logging
from dataclasses import dataclass
from typing imp... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_manual_reporter/cluster_info.py | .py | 9163b625950c498f | 7.65 | 19 |
# Co-authored-by: Claude <noreply@anthropic.com>
"""Collector for STD placeholder tests with full context.
Extends std_placeholder_stats test discovery to extract docstrings,
markers, fixtures, and Polarion IDs for each placeholder test.
"""
from __future__ import annotations
import ast
import logging
import re
from... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_manual_reporter/collector.py | .py | 0fae2a3ca26a2ebc | 7.65 | 19 |
"""Conftest for rp_manual_reporter tests."""
import os
from collections.abc import Generator
import pytest
from scripts.reportportal.tests_common import ORIGINAL_ARCH
@pytest.fixture(autouse=True, scope="session")
def _mock_cluster_architecture() -> Generator[None]:
"""Restore original architecture env var aft... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_manual_reporter/tests/conftest.py | .py | 18f39df414e95f97 | 7.15 | 19 |
# Co-authored-by: Claude <noreply@anthropic.com>
"""Tests for scripts.reportportal.rp_manual_reporter.collector module.
RFE: https://github.com/RedHatQE/openshift-virtualization-tests/pull/5207
"""
from __future__ import annotations
import ast
import textwrap
from pathlib import Path
from unittest.mock import patch
... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_manual_reporter/tests/test_collector.py | .py | 496fb2148b24660f | 8.15 | 19 |
# Co-authored-by: Claude <noreply@anthropic.com>
"""Test utilities for rp_manual_reporter collector tests."""
from __future__ import annotations
from dataclasses import dataclass, field
from scripts.reportportal.rp_manual_reporter.collector import PlaceholderTestDetail
from scripts.reportportal.rp_utils.naming impor... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_manual_reporter/tests/utils.py | .py | 552aa283df385086 | 8.15 | 19 |
# Co-authored-by: Claude <noreply@anthropic.com>
"""ReportPortal API client for CNV test coverage tools.
Provides authenticated access to the ReportPortal REST API with
automatic pagination support. Used by both the Manual Test Reporter
and the CI Coverage Gate tools.
"""
from __future__ import annotations
import lo... | RedHatQE/openshift-virtualization-tests | scripts/reportportal/rp_utils/rp_client.py | .py | f49423e3a3011fd8 | 7.65 | 19 |
"""
Tests for unisi/autotest.py: check_block/check_module (screen-structure
validation), Recorder (records a live session to a JSON fixture),
test() (replays a JSON fixture against a real user), run_tests()
(orchestrates both, plus custom @test functions), and the toolbar-button
handlers that drive Recorder from a UI c... | unisi-tech/unisi | tests/autotest/test_autotest.py | .py | 580055a47500537f | 7.1 | 15 |
"""
Shared pytest fixtures for the server.py / utils.py / common.py unit tests.
These three modules are the framework's own foundation -- common.py has the
handler-composition/message primitives everything else is built from,
utils.py owns process bootstrap (config loading, Screen.defaults, logging)
plus a handful of ... | unisi-tech/unisi | tests/core/conftest.py | .py | 1370c3071636150f | 8.1 | 15 |
"""
Tests for common.py: the framework's pure-ish primitives -- flatten,
compose_handlers, ArgObject/ReceivedMessage, Message/TypeMessage and its
Warning/Error/Info/Answer shortcuts, delete_unit, set_defaults,
context_object, and a handful of small helpers.
Almost none of this needs a fixtures_app: these are either pl... | unisi-tech/unisi | tests/core/test_common.py | .py | b0d194cd7a43887c | 7.1 | 15 |
"""
Tests for server.py: generate_random_string, context_user/context_screen,
message_logger, make_user, handle(), post_handler, static_serve,
websocket_handler, ensure_directory_exists, ensure_unisi_typings, and
start()'s route/composition wiring.
server.py is architecturally an aiohttp app, not a library of pure
fun... | unisi-tech/unisi | tests/core/test_server.py | .py | 9fc6e2ad8aeff123 | 7.1 | 15 |
"""
Tests for utils.py: path/url helpers (filename2url, url2filepath,
url2filename, upload_path, cache_url), the layout-tree walkers
(iter_layout_units, fill_parents), py_files, Screen.defaults, and the
module-import-time config bootstrap block at the top of the file.
Most of this is plain functions reading either the... | unisi-tech/unisi | tests/core/test_utils.py | .py | 82068adeb7c20f0e | 8.1 | 15 |
"""
Shared pytest fixtures for the db.py / dbunits.py unit tests.
Unlike tests/users/ and tests/persist_voice_reloder/ (which need a real
fixtures_app on disk because User is architecturally tied to screen
loading), db.py's Database/Dbtable and dbunits.py's Dblist are pure
data-layer classes with no dependency on the ... | unisi-tech/unisi | tests/db_units/conftest.py | .py | b31692a29a624cda | 8.1 | 15 |
"""
Shared pytest fixtures for the modules.py (ModulesMixin) unit tests.
Same real-User, real-fixture-app philosophy as tests/users/conftest.py and
tests/persist_voice_reloder/conftest.py -- see either for the full
rationale. This directory covers ModulesMixin's own concerns specifically:
the screen registry (build/lo... | unisi-tech/unisi | tests/modules/conftest.py | .py | 32f6d31080e5a3a5 | 8.1 | 15 |
"""
Shared pytest fixtures for the multimon.py unit tests.
multimon.py is architecturally distinct from the "pure logic" modules
covered under tests/units/ (units.py/tables.py/graphs.py/containers.py):
it's a multiprocessing-based IPC/monitoring subsystem with real module-
level side effects gated by config.froze_time... | unisi-tech/unisi | tests/multimon/conftest.py | .py | e6558327ce0aecbe | 8.1 | 15 |
"""This module handles environment variables"""
import os
def get_config():
"""get env and return config with all env vals required"""
eic_host_url = get_os_env_string("EIC_HOST_URL", "")
ca_cert_file_name = get_os_env_string("CA_CERT_FILE_NAME", "")
ca_cert_file_path = get_os_env_string("CA_CERT_FIL... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/config.py | .py | 045ee2e1396f2093 | 7.6 | 15 |
"""
This module performs client credentials grant authentication
by sending HTTP requests with TLS and with required environment
variables.
"""
import os
from urllib.parse import urljoin
import json
import time
import requests
from config import get_config
class LoginError(Exception):
"""Raised when EIC login f... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/login.py | .py | c50919cb3bd4109d | 7.6 | 15 |
#!/usr/bin/env python3
"""
Flask Application for Hello World Service
This Python script defines a Flask application that implements a simple "Hello World" service
along with a health check and metrics endpoints.
"""
import time
from flask import abort
from flask import Flask
from login import login
from config import ... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/main.py | .py | 29e60393f133824f | 7.6 | 15 |
"""This module handles mTLS logging"""
import json
import os
import logging
import sys
from enum import IntEnum
from datetime import datetime, timezone
import requests
from config import get_config, get_os_env_string
class Severity(IntEnum):
"""We use this to map the logging library severity to the mTLS logging""... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/mtls_logging.py | .py | b77c7590e872f069 | 7.6 | 15 |
"""Configure a Flask fixture based off the Application defined in main.py"""
import os
from urllib.parse import urljoin
import pytest
import requests_mock
from prometheus_client import REGISTRY as GLOBAL_METRICS_REGISTRY
from main import Application
from config import get_config
def pytest_generate_tests():
popul... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/tests/conftest.py | .py | 8556000e96970ea1 | 8.1 | 15 |
"""Tests which ensure the application handles Authentication & Authorisation properly"""
from urllib.parse import urljoin
import time
from login import login, LoginError
import pytest
def test_login_receives_token_x509(mock_login_api, config):
# pylint: disable=unused-argument
"""Check if we receive a token""... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/tests/test_login.py | .py | 5f4632bd102333cf | 8.1 | 15 |
"""Tests which cover the routes of the application"""
from config import get_metrics_namespace
def test_get_root_returns_bad_response(client):
"""
GET to "/"
400 Bad Request
"""
response = client.get("/sample-app/python/")
assert response.status_code == 400
def test_get_hello_returns_hello_w... | ericsson-iap/python-sample-app | eric-oss-hello-world-python-app/tests/test_main.py | .py | f2d5b425215b4857 | 7.1 | 15 |
"""Nuke helpers: open EXR Converter with a Read path + session OCIO.
Install
-------
Copy this file (and ``menu.py``) onto ``NUKE_PATH`` or into ``~/.nuke``, then
restart Nuke. See ``docs/nuke.md``.
Environment
-----------
``EXR_CONVERTER``
Path to the ``exr_converter`` binary, or to ``python`` if launching from ... | derek-rein/exr-converter | integrations/nuke/exr_converter_nuke.py | .py | d7b39180fdcf32a6 | 7.6 | 15 |
#!/usr/bin/env python3
"""Build the optional oxideav-prores PyO3 extension (``exr_prores``).
Requires a Rust toolchain (rustc/cargo) and maturin. The extension links
pure-Rust oxideav-prores and ships as a normal Python module so Nuitka
can include it without a subprocess sidecar.
Usage:
python3 scripts/build_oxide... | derek-rein/exr-converter | scripts/build_oxideav_prores.py | .py | 32d1240d9df58c6b | 7.6 | 15 |
#!/usr/bin/env python3
"""Build the optional R3D SDK C ABI bridge shared library.
Requires a local copy of the official RED R3D SDK (headers + static lib +
Redistributable dynamic libraries). The SDK is proprietary — do not commit it.
Usage:
R3D_SDK_ROOT=/path/to/R3DSDKv9_2_1 python3 scripts/build_r3d_bridge.py
#... | derek-rein/exr-converter | scripts/build_r3d_bridge.py | .py | 1aef538698e6dcf3 | 7.6 | 15 |
#!/usr/bin/env python3
"""Ensure the runtime OpenColorIO library is 2.5+ (matches the bundled config).
``oiio-python`` sometimes rewires ``PyOpenColorIO`` to its vendored OpenColorIO
**2.4**. This script reinstalls ``opencolorio`` so PyOpenColorIO is 2.5+ again.
**Windows:** reinstalling opencolorio overwrites oiio's... | derek-rein/exr-converter | scripts/ensure_ocio.py | .py | d43f6c4db0e17d8a | 7.6 | 15 |
#!/usr/bin/env python3
"""Extract a versioned section from CHANGELOG.md."""
from __future__ import annotations
import sys
from pathlib import Path
def extract_section(changelog: Path, version: str) -> str:
"""Return the ``## [version]`` section body (through next ``## [`` or EOF)."""
text = changelog.read_t... | derek-rein/exr-converter | scripts/extract_changelog_section.py | .py | a39478c4c0821c3c | 7.6 | 15 |
#!/usr/bin/env python3
"""Download the private R3D SDK tarball for local/CI builds.
Expects a GitHub Release on a **private** repo (default: derek-rein/r3d-sdk-private)
with asset ``R3DSDKv9_2_1-full.tar.gz`` (or override via env).
Auth (first match wins):
* ``R3D_SDK_READ_TOKEN`` / ``GH_TOKEN`` / ``GITHUB_TOKEN``
... | derek-rein/exr-converter | scripts/fetch_r3d_sdk.py | .py | 18cb25a90071e3de | 7.6 | 15 |
#!/usr/bin/env python3
"""Repair OpenColorIO linkage inside a Nuitka standalone / app bundle.
Nuitka often collides the two OCIO shared libraries we ship:
* ``PyOpenColorIO`` (opencolorio wheel) → **2.5.x** — required for the
bundled ACES Studio v4 config (profile 2.5) and modern Foundry Nuke configs.
* ``OpenImag... | derek-rein/exr-converter | scripts/fix_bundle_ocio.py | .py | 644d326cae21703c | 7.6 | 15 |
#!/usr/bin/env python3
"""Copy optional R3D bridge + RED Redistributable libs into a Nuitka dist.
Layout written (private app directory — RED license)::
<bundle>/r3d/libr3d_bridge.{dylib,so,dll}
<bundle>/r3d/REDR3D.* …
<bundle>/r3d/… (other redistributables)
On macOS app bundles, *bundle* is ``Contents/MacOS``... | derek-rein/exr-converter | scripts/install_r3d_into_bundle.py | .py | c8ce048f25e2b22d | 7.6 | 15 |
"""Locate / fetch oiio-python's OpenColorIO_2_4.dll (Windows OIIO dependency).
oiio-python's Windows wheel vendors ``PyOpenColorIO/OpenColorIO_2_4.dll``.
Reinstalling the standalone ``opencolorio`` 2.5 package overwrites that tree and
drops the DLL, so Nuitka builds then fail to LoadLibrary OpenImageIO.pyd.
"""
from ... | derek-rein/exr-converter | scripts/oiio_ocio24.py | .py | 77ad9530dd75bec6 | 7.6 | 15 |
"""Shared helpers for packaging scripts (ASCII logs, macOS junk filters)."""
from __future__ import annotations
import sys
from pathlib import Path
def safe_print(*args: object, file=None, **kwargs) -> None:
"""Print that never crashes on cp1252 Windows CI consoles."""
out = file if file is not None else sy... | derek-rein/exr-converter | scripts/packaging_util.py | .py | 8ba6c8eac54370ba | 7.6 | 15 |
"""Shared discovery of app roots (source checkout vs frozen / Nuitka binary)."""
from __future__ import annotations
import sys
from pathlib import Path
def is_frozen_app() -> bool:
"""True inside a Nuitka / PyInstaller-style binary (not a source venv run)."""
if getattr(sys, "frozen", False) or hasattr(sys,... | derek-rein/exr-converter | src/core/app_paths.py | .py | 5e73462a3829f98d | 7.6 | 15 |
"""Shared error types for the convert pipeline."""
from __future__ import annotations
class ConversionCancelled(RuntimeError):
"""Raised when the user cancels a conversion (GUI Cancel or CLI SIGINT).
Prefer catching this type over matching ``str(exc)`` for cancel detection.
Subclasses :class:`RuntimeErr... | derek-rein/exr-converter | src/core/errors.py | .py | b325b9dcb79b6cc3 | 7.6 | 15 |
from __future__ import annotations
import numpy as np
import OpenImageIO as oiio
def _display_window(spec) -> tuple[int, int, int, int]:
"""Return (x, y, width, height) of the display window from an OIIO ImageSpec.
Falls back to data window dimensions when full_width/full_height are unset.
"""
if sp... | derek-rein/exr-converter | src/core/exr_io.py | .py | 53698a6378e46753 | 7.6 | 15 |
"""Nuke-style frame range parsing and formatting via fileseq.
Reference: https://learn.foundry.com/nuke/content/getting_started/managing_scripts/defining_frame_ranges.html
"""
from __future__ import annotations
import fileseq
def parse_frame_range(spec: str) -> list[int]:
"""Parse a Nuke-style frame range stri... | derek-rein/exr-converter | src/core/framerange.py | .py | c84977c36be7f923 | 7.6 | 15 |
"""Discover local Foundry Nuke installs and their on-disk OCIO configs.
We never redistribute Nuke files — we only *reference* configs that already
exist on the user's machine (under their licensed Nuke installation).
"""
from __future__ import annotations
import os
import platform
import re
from dataclasses import ... | derek-rein/exr-converter | src/core/nuke_discover.py | .py | a65ee11d92b74176 | 7.6 | 15 |
"""Optional oxideav-prores PyO3 bindings for true 12-bit ProRes-compatible MOV.
The native extension (``exr_prores``) links pure-Rust oxideav-prores and writes
``.mov`` in-process — no subprocess sidecar. When the extension is not built
(dev without Rust / maturin), presets are hidden and CLI reports unavailable.
"""
... | derek-rein/exr-converter | src/core/oxideav_prores.py | .py | 346295420fe5e9e1 | 7.6 | 15 |
"""Parallel OCIO + EXR I/O helpers for process *and* thread pools.
Process workers lazily initialize their own OCIO CPUProcessor on first use
since OCIO.Config objects cannot be pickled across process boundaries.
Thread workers share a process-wide cache protected by a lock (Video→EXR
uses a thread pool so decoded fra... | derek-rein/exr-converter | src/core/pool.py | .py | 96230bc05634b60a | 7.6 | 15 |
"""Optional RED R3D / N-RAW decode via the local R3D SDK bridge.
Public API is stable: ``from src.core.r3d import R3DClip, is_available, …``.
"""
from __future__ import annotations
from pathlib import Path
from .clip import (
R3DClip,
R3DClipInfo,
R3DError,
R3DUnavailableError,
probe_r3d,
r3... | derek-rein/exr-converter | src/core/r3d/__init__.py | .py | f892969c0a5365cb | 7.6 | 15 |
"""R3D decode modes, metadata keys, and end-user redistributable notice."""
from __future__ import annotations
# Extensions handled by the R3D SDK (not PyAV).
R3D_SUFFIXES: frozenset[str] = frozenset({".r3d", ".nev"})
# OCIO source-space candidates when decoding IPP2 primary development.
R3D_SRC_COLORSPACE_CANDIDATE... | derek-rein/exr-converter | src/core/r3d/constants.py | .py | cca03c6437e354f1 | 7.6 | 15 |
from __future__ import annotations
import re
from pathlib import Path
import fileseq
from .constants import (
IMAGE_SEQUENCE_EXTS,
image_sequence_ext_priority,
is_image_sequence_ext,
is_scene_referred_image_ext,
)
# **Writes** use ``name.####.ext`` (dot frame pad only). **Reads** accept both
# commo... | derek-rein/exr-converter | src/core/sequence.py | .py | 7279e31c9ea1b714 | 7.6 | 15 |
"""Shared path cleaning / navigation helpers for file browsers and path fields.
Handles Nuke-style pastes (``name.####.exr``), ``file://`` URLs, quoted paths,
and folder resolution for Copy Folder Path / reveal-in-finder actions.
"""
from __future__ import annotations
import re
from pathlib import Path
from urllib.p... | derek-rein/exr-converter | src/gui/browser_path.py | .py | aac78772d573d7ae | 7.6 | 15 |
"""QSettings keys and helpers for input file-browser dialogs.
Video → EXR (``VideoBrowserDialog``) and EXR → Video (``SequenceBrowserDialog``)
persist **separate** layout/session state under ``ui/video_browser_*`` and
``ui/sequence_browser_*``. Window **geometry** (size + position) is **shared**
via ``ui/browser_geome... | derek-rein/exr-converter | src/gui/browser_state.py | .py | 478b2d28e566e6b8 | 7.6 | 15 |
"""Fast browser thumbnails: stills via OpenImageIO, video via PyAV (no OCIO).
Image-sequence grid: decode first frame, box-filter downscale, optional cheap
Rec.709 OETF for scene-referred formats. Video grid: first decoded frame via
PyAV. Returns uint8 RGB for ``QImage``. Safe off the GUI thread.
"""
from __future__ ... | derek-rein/exr-converter | src/gui/browser_thumbs.py | .py | 2ab1d9a11eab41d0 | 7.6 | 15 |
"""Nuke-style viewer gain/gamma slider (shared by slate + sequence player)."""
from __future__ import annotations
import math
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import (
QColor,
QFontDatabase,
QFontMetricsF,
QMouseEvent,
QPainter,
QPen,
)
from PySide6.QtWidgets import QW... | derek-rein/exr-converter | src/gui/nuke_slider.py | .py | a72f96603cf34936 | 7.6 | 15 |
"""Standalone sequence playback window (post-convert Video → EXR Open result)."""
from __future__ import annotations
import logging
from pathlib import Path
from PySide6.QtCore import QSettings, Qt
from PySide6.QtGui import QGuiApplication
from PySide6.QtWidgets import QDialog, QVBoxLayout, QWidget
from ...core.con... | derek-rein/exr-converter | src/gui/player/player_window.py | .py | a10516ad5cf5c2e2 | 7.6 | 15 |
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
from azure.data.tables import TableServiceClient, TableEntity
from azure.data.tables import UpdateMode
from utils import get_flat_date_hour, get_flat_date_full
from io import BytesIO
from dotenv import load_dotenv
import requests
import os
im... | abozaralizadeh/SandBox | AIBlog/azurestorage.py | .py | a9e34ece10764156 | 7.57 | 13 |
import os
import re
import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any, Iterable, List
from AIBlog.azurestorage import get_row, upsert_history, get_last_n_rows, list_edition_keys
from AIBlog.graph import *
from utils import get_flat_date, get_flat_date_hour, parse_flat_date_hour, s... | abozaralizadeh/SandBox | AIBlog/prompt.py | .py | 526100509b77d749 | 7.57 | 13 |
import json
import os
from datetime import datetime
from typing import Any, Dict, List, Optional
from AIOpenProblemSolver.azurestorage import (
get_iteration_slice,
latest_iteration,
parse_iteration_rowkey,
release_iteration_lock,
rowkey_for_date,
save_iteration,
try_acquire_iteration_lock,... | abozaralizadeh/SandBox | AIOpenProblemSolver/prompt.py | .py | 8756893cbf243ec5 | 7.57 | 13 |
"""On-the-fly WebP image proxy for ComicBook panels.
The originals are multi-MB PNGs (1024px wide for square/tall panels, 1536px for wide
ones) in the public blob container; they stay the canonical originals (they're reused
as references when generating later panels). For display we serve a single FULL-
RESOLUTION Web... | abozaralizadeh/SandBox | ComicBook/imageproxy.py | .py | 022a91f256adcccb | 7.57 | 13 |
"""Configuration + constants for GenBox news-anchor video generation.
A separate Azure OpenAI resource (or several) hosts the Sora 2 video deployment, so it
has its own endpoint/key/version env vars (mirroring the existing AZURE_OPENAI_*_DALLE
split).
Sora's video API is asynchronous and job-scoped: `create` returns ... | abozaralizadeh/SandBox | GenBox/newsvideo/config.py | .py | 21e8573c165141ad | 7.57 | 13 |
"""Producer agent: turns the GenBox daily decision text into a structured shot list.
Reuses the OpenAI Agents SDK wiring from ComicBook/agents.py (AsyncAzureOpenAI ->
OpenAIResponsesModel -> Agent -> Runner.run). The agent ONLY emits JSON; the pipeline
executes it deterministically so we keep hard caps on clip count, ... | abozaralizadeh/SandBox | GenBox/newsvideo/producer_agent.py | .py | 7e0172454899e7b4 | 7.57 | 13 |
"""LangSmith tracing helpers for the GenBox news-video / narration pipeline.
``@traceable`` and ``wrap_openai`` are no-ops unless LangSmith tracing is enabled via env
(``LANGCHAIN_TRACING_V2`` / ``LANGSMITH_TRACING``), so applying them is always safe. The
redactors below keep per-resource API keys and large binary pay... | abozaralizadeh/SandBox | GenBox/newsvideo/tracing.py | .py | 54b34f078b12b3d7 | 7.57 | 13 |
"""Text-to-speech via the same Azure OpenAI resources as Sora 2.
The TTS deployment lives on the same endpoints/keys as the Sora pool (just a different
model), so we reuse ``sora_client.next_resource`` for endpoint/key selection and call the
OpenAI v1 audio surface: ``POST {endpoint}/openai/v1/audio/speech``. TTS is a... | abozaralizadeh/SandBox | GenBox/newsvideo/tts_client.py | .py | 92dcda08304516d8 | 7.57 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.