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
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """KafkaProvider class and methods.""" import json import logging from typing import TYPE_CHECKING from charms.data_platform_libs.v0.data_interfaces import ( PROV_SECRET_PREFIX, REQ_SECRET_FIELDS, CachedSecre...
canonical/kafka-operator
common/single_kernel_kafka/events/peer_cluster.py
.py
3cdea2bfe3206b5c
7.54
11
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """KafkaProvider class and methods.""" import logging import subprocess # nosec B404 from typing import TYPE_CHECKING from charms.data_platform_libs.v1.data_interfaces import ( KafkaRequestModel, MtlsCertUpdated...
canonical/kafka-operator
common/single_kernel_kafka/events/provider.py
.py
e2f77f162844bdbc
7.54
11
# Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Apache Kafka in-place upgrades.""" import abc import dataclasses import logging import time from typing import TYPE_CHECKING import charm_refresh from lightkube.core.client import Client from lightkube.core.exceptions i...
canonical/kafka-operator
common/single_kernel_kafka/events/refresh.py
.py
ecdeabb637f33bb8
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Event Handler for user-defined secret events. Internal user management could be done by defining secrets and granting their access to the charm. The flow for defining secrets and granting access to the charm would be ...
canonical/kafka-operator
common/single_kernel_kafka/events/secrets.py
.py
450dc16461613f1b
7.54
11
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """Handler for TLS/mTLS events.""" import base64 import copy import json import logging import re from typing import TYPE_CHECKING from charms.certificate_transfer_interface.v1.certificate_transfer import ( Certifica...
canonical/kafka-operator
common/single_kernel_kafka/events/tls.py
.py
f6a8dd1f6b86703a
7.54
11
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Kafka machine health.""" import json import logging import subprocess from statistics import mean from typing import TYPE_CHECKING from ops.framework import Object from .core.literals import JVM_...
canonical/kafka-operator
common/single_kernel_kafka/health.py
.py
19050e220ae60352
7.54
11
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """KafkaClient class library for basic client connections to a Kafka Charm cluster. `KafkaClient` provides an interface from which to make generic client connections to a running Kafka Charm cluster. This can be as an adm...
canonical/kafka-operator
common/single_kernel_kafka/lib/v0/client.py
.py
68370fd3b756c70b
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Balancer.""" import json import logging import re import time from subprocess import CalledProcessError from typing import TYPE_CHECKING, Any, cast import requests from ops.pebble import ExecError...
canonical/kafka-operator
common/single_kernel_kafka/managers/balancer.py
.py
089304ba26ad073c
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling operations on Kafka Connect workers.""" import logging import os import re import tempfile import warnings from pathlib import Path from subprocess import CalledProcessError from typing import Patt...
canonical/kafka-operator
common/single_kernel_kafka/managers/connect.py
.py
d0f06ef79313f964
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Kafka Connect configuration.""" import inspect import logging import os from typing import cast from ..core.connect_models import ConnectContext from ..core.literals import ( JMX_EXPORTER_PORT...
canonical/kafka-operator
common/single_kernel_kafka/managers/connect_config.py
.py
cb80f6c84b240be0
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling KRaft Controller.""" import logging import os from subprocess import CalledProcessError from ops.pebble import ExecError from tenacity import retry, stop_after_attempt, wait_fixed from ..core.clu...
canonical/kafka-operator
common/single_kernel_kafka/managers/controller.py
.py
ee6f552c63ad7277
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Kafka Kubernetes resources for a single Kafka pod.""" import json import logging import math import time from functools import cache from lightkube.core.client import Client from lightkube.core.ex...
canonical/kafka-operator
common/single_kernel_kafka/managers/k8s.py
.py
9af2f21ebf41c610
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Apache Kafka SSL principal mappings.""" import logging import re logger = logging.getLogger(__name__) DEFAULT_SSL_PRINCIPAL_MAPPING_RULES = "DEFAULT" class NoMatchingRuleError(Exception): "...
canonical/kafka-operator
common/single_kernel_kafka/managers/ssl_principal_mapper.py
.py
ce16bd30ff180cd1
7.54
11
# Copyright 2023 Canonical Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
canonical/kafka-operator
connect_k8s/lib/charms/data_platform_libs/v0/data_models.py
.py
680d588e176ce6b7
7.54
11
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/_config.py
.py
6a227c4d7d9f1513
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/_database.py
.py
e6a0a94b406fb5ac
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/_docker_commands.py
.py
e69095d371c1a9b0
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/_io.py
.py
e6b4338724c1b311
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/_message_processing.py
.py
9fedccdc0aa81f73
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/src/pixl_cli/main.py
.py
a845aed8958ffd42
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/tests/conftest.py
.py
c42f70ca68a58fe8
7.98
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/tests/test_check_env.py
.py
8fafa407f8c37d2f
7.98
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/tests/test_database_cli_interaction.py
.py
1068516eeb6950b0
7.98
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/tests/test_docker_commands.py
.py
28313b1aa586680e
7.98
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
cli/tests/test_io.py
.py
8331979160ecd24d
7.98
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
hasher/src/hasher/hashing.py
.py
28adcdbabedfb36a
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
hasher/tests/conftest.py
.py
7fdf4d1bb447d4c9
7.98
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
orthanc/orthanc-raw/plugin/pixl.py
.py
a5124fce3e36141a
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/db/models.py
.py
f70fd6ed168208e2
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/db/queries.py
.py
413a4bae7efda325
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
pixl_core/src/core/dicom_tags.py
.py
f14020baaf29cb4d
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/exports.py
.py
3965df8c9d2a011e
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/logging.py
.py
6584ee5fd78b2453
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/patient_queue/_base.py
.py
3ab49d6435ba4bb3
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
SAFEHR-data/PIXL
pixl_core/src/core/patient_queue/message.py
.py
63d1a0d6d3332999
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
pixl_core/src/core/patient_queue/producer.py
.py
f4224eb9b193de09
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
pixl_core/src/core/patient_queue/subscriber.py
.py
52f322e47ab00567
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/project_config/image_operations.py
.py
54eb5c152880b1ea
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/project_config/pixl_config_model.py
.py
778c41166c2fc839
7.48
8
# Copyright (c) 2022 University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
SAFEHR-data/PIXL
pixl_core/src/core/project_config/secrets.py
.py
fc67f6c16eb39351
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/project_config/tag_operations.py
.py
31af3aef59c6e4d1
7.48
8
# Copyright (c) University College London Hospitals NHS Foundation Trust # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
SAFEHR-data/PIXL
pixl_core/src/core/telemetry.py
.py
9261aa9d1b5f6e69
7.48
8
from __future__ import annotations import shutil from pathlib import Path from typing import TYPE_CHECKING from uuid import UUID from lamin_utils import logger from ._connect_instance import _connect_instance, get_owner_name_from_identifier from .core._aws_options import HOSTED_BUCKETS from .core._settings import se...
laminlabs/lamindb-setup
lamindb_setup/_delete.py
.py
af04f7bbfee75d09
7.48
8
from __future__ import annotations import os from django.db import connection from lamin_utils import logger from packaging import version from ._check_setup import _check_instance_setup, disable_auto_connect from .core._settings import settings from .core.django import setup_django # for the django-based synching...
laminlabs/lamindb-setup
lamindb_setup/_migrate.py
.py
852fb0811da09f30
7.48
8
from __future__ import annotations import secrets import string from typing import TYPE_CHECKING from lamin_utils import logger from .core._settings import settings from .core.django import setup_django if TYPE_CHECKING: from uuid import UUID def _base62(n_char: int) -> str: alphabet = string.digits + str...
laminlabs/lamindb-setup
lamindb_setup/_register_instance.py
.py
03f5fd928167e1f1
7.48
8
"""Recovery from an asyncio write-error loop that stalls fsspec transfers. Symptom ------- A cloud transfer stops making progress and asyncio logs, endlessly and at a rate of roughly 100k per second, one of:: Exception in callback _SelectorSocketTransport._write_send() AssertionError: Data should not be empty...
laminlabs/lamindb-setup
lamindb_setup/core/_asyncio_write_spin.py
.py
61f7d201e74bf23a
7.48
8
from __future__ import annotations import logging import os from typing import TYPE_CHECKING, Any from dotenv import dotenv_values from lamin_utils import logger from ._settings_store import system_settings_file if TYPE_CHECKING: from aiobotocore.session import AioSession from upath import UPath HOSTED_REG...
laminlabs/lamindb-setup
lamindb_setup/core/_aws_options.py
.py
812bac64af71bdf7
7.48
8
from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING if TYPE_CHECKING: from uuid import UUID class user_description: email = """User email.""" password = """API key or legacy password.""" uid = """Universal user ID.""" handle = "Unique handle." ...
laminlabs/lamindb-setup
lamindb_setup/core/_settings_user.py
.py
d6df8f0c14254a25
7.48
8
"""The `CanonicalSuffix` class.""" # the main class of this module is re-exported and documented in lamindb.base.types # the location of canonical_suffix.py in lamindb_setup is for internal use # or for developers who want to avoid importing lamindb # this is the same rationale as for the upath.py module in lamindb_set...
laminlabs/lamindb-setup
lamindb_setup/core/canonical_suffix.py
.py
ddced197286d979d
7.48
8
from __future__ import annotations from datetime import datetime, timezone from functools import wraps from typing import TYPE_CHECKING from lamin_utils import logger from lamindb_setup.errors import InstanceLockedException if TYPE_CHECKING: from collections.abc import Callable from typing import ParamSpec,...
laminlabs/lamindb-setup
lamindb_setup/core/cloud_sqlite_locker.py
.py
7cfa42db470abe6f
7.48
8
"""Hashing. .. autosummary:: :toctree: . hash_set hash_file """ from __future__ import annotations import base64 import hashlib import json from concurrent.futures import ThreadPoolExecutor from typing import TYPE_CHECKING import psutil HASH_LENGTH = 22 if TYPE_CHECKING: from collections.abc import...
laminlabs/lamindb-setup
lamindb_setup/core/hashing.py
.py
74885f22e9d080f2
7.48
8
import importlib.metadata import logging import os import stat import textwrap from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from subprocess import Popen from git import Repo from tomlkit import parse from blueapi.config import FORBIDDEN_OWN_REMOTE_URL, ScratchConfig from bl...
DiamondLightSource/blueapi
src/blueapi/cli/scratch.py
.py
4eee78cfdfd534e3
7.57
13
import inspect from collections.abc import Callable, Generator, Mapping from typing import ( Any, Protocol, get_args, get_origin, get_type_hints, runtime_checkable, ) from bluesky.protocols import ( Checkable, Configurable, Flyable, Movable, Pausable, Readable, Stage...
DiamondLightSource/blueapi
src/blueapi/core/bluesky_types.py
.py
3157861dc9d6eb1c
7.57
13
import itertools import logging from abc import ABC, abstractmethod from collections.abc import Callable from typing import Generic, TypeVar #: Event type E = TypeVar("E") #: Subscription token type S = TypeVar("S") LOGGER = logging.getLogger(__name__) class EventStream(ABC, Generic[E, S]): """ Generic rep...
DiamondLightSource/blueapi
src/blueapi/core/event.py
.py
e15bc3c358091849
7.57
13
import enum import logging import os from contextlib import contextmanager from copy import copy import click from graypy import GELFTCPHandler from blueapi.config import LoggingConfig class InstrumentTagFilter(logging.Filter): """Filter to attach instrument and beamline attributes to LogRecords. Attaches ...
DiamondLightSource/blueapi
src/blueapi/log.py
.py
f6446a2caf3123d0
7.57
13
import logging from collections.abc import Mapping from dataclasses import dataclass from functools import cache from multiprocessing.connection import Connection from typing import Any from bluesky.callbacks.tiled_writer import TiledWriter from bluesky_stomp.messaging import StompClient from bluesky_stomp.models impo...
DiamondLightSource/blueapi
src/blueapi/service/interface.py
.py
7f5098f0ab3aadd8
7.57
13
""" The application level sub-protocol used to communicate between the server and client when running plans via websockets """ # Client to server # * Submit task # * Pause # * Resume # * Abort # # Server to client # * Plan not found # * Args not valid # * Server busy # * Event update from typing import Annotated, Any...
DiamondLightSource/blueapi
src/blueapi/service/protocol.py
.py
b88704c059ee2176
7.57
13
import importlib from collections.abc import Callable, Iterable from types import ModuleType from typing import Any def load_module_all(mod: ModuleType) -> Iterable[Any]: """ If __export__ is defined for the module, try importing those functions as plans, else load the global variables exported via the `_...
DiamondLightSource/blueapi
src/blueapi/utils/modules.py
.py
438733cb5f36cabb
7.57
13
import logging from collections.abc import Mapping from pathlib import Path from textwrap import dedent import httpx from pydantic import Field, HttpUrl from blueapi.utils import BlueapiBaseModel LOGGER = logging.getLogger(__name__) class DirectoryPath(BlueapiBaseModel): """ Directory location and associat...
DiamondLightSource/blueapi
src/blueapi/utils/numtracker.py
.py
a056cd34abae7225
7.57
13
from pathlib import Path from event_model import RunStart, RunStop from ophyd_async.core import PathInfo, PathProvider class StartDocumentPathProvider(PathProvider): """A PathProvider that sources from metadata in a RunStart document. This uses metadata from a RunStart document to determine file names and ...
DiamondLightSource/blueapi
src/blueapi/utils/path_provider.py
.py
a4c779ffa26f2466
7.57
13
import json from typing import Any from pydantic import BaseModel from blueapi import utils def serialize(obj: Any) -> Any: """ Pydantic-aware serialization routine that can also be used on primitives. So serialize(4) is 4, but serialize(<model>) is a dictionary. Args: obj: The object t...
DiamondLightSource/blueapi
src/blueapi/utils/serialization.py
.py
94648bad42813be4
7.57
13
from collections.abc import Mapping from enum import StrEnum from typing import Any, Literal, Self from bluesky._vendor.super_state_machine.extras import PropertyMachine, ProxyString from bluesky.run_engine import RunEngineStateMachine from pydantic import Field, PydanticSchemaGenerationError, TypeAdapter from pydanti...
DiamondLightSource/blueapi
src/blueapi/worker/event.py
.py
d20e002dc02f8509
7.57
13
import logging from collections.abc import Mapping from typing import Any from pydantic import BaseModel, Field, TypeAdapter from blueapi.core import BlueskyContext from blueapi.utils import BlueapiBaseModel LOGGER = logging.getLogger(__name__) class Task(BlueapiBaseModel): """ Task that will run a plan ...
DiamondLightSource/blueapi
src/blueapi/worker/task.py
.py
3d0f0865196e1418
7.57
13
"""Documentation generation.""" from collections.abc import Iterator from enum import StrEnum class IterableStrEnum(StrEnum): """Polyfill that also introduces dict-like behavior. Introduces constructors that return a ``Iterator`` object either containing all items, only their names or their values. ...
bakdata/kpops
hooks/gen_docs/__init__.py
.py
577f4f671f9737bb
7.6
15
"""Generates pipeline definition examples from manually written building blocks.""" import sys from pathlib import Path from typing import NamedTuple, cast import structlog import yaml from hooks import ROOT from kpops.components.base_components.kafka_connector import KafkaConnector from kpops.components.base_compon...
bakdata/kpops
hooks/gen_docs/gen_docs_components.py
.py
e11bbd158cde7863
7.6
15
"""Generates the documentation on KPOps environment variables.""" from __future__ import annotations import csv import shutil from collections.abc import Callable from contextlib import suppress from dataclasses import dataclass from pathlib import Path from textwrap import fill from typing import Any, Self from pyd...
bakdata/kpops
hooks/gen_docs/gen_docs_env_vars.py
.py
97d17be48ec508ad
7.6
15
from typing import final import structlog from kpops.component_handlers.helm.helm import Helm from kpops.component_handlers.helm.helm_diff import HelmDiff @final class DryRunHandler: def __init__(self, helm: Helm, helm_diff: HelmDiff, namespace: str) -> None: self._helm = helm self._helm_diff = ...
bakdata/kpops
kpops/component_handlers/helm/dry_run_handler.py
.py
ab49602829f908bd
7.6
15
from collections.abc import Iterable, Iterator from typing import final import structlog from kpops.component_handlers.helm.model import HelmDiffConfig, HelmTemplate from kpops.manifests.kubernetes import KubernetesManifest from kpops.utils.dict_differ import Change, render_diff log = structlog.get_logger("HelmDiff"...
bakdata/kpops
kpops/component_handlers/helm/helm_diff.py
.py
44baad08f1793a29
7.6
15
from collections.abc import Iterator from dataclasses import dataclass from pathlib import Path from typing import ClassVar from pydantic import ConfigDict, Field from typing_extensions import override from kpops.component_handlers.helm.exception import ParseError from kpops.manifests.kubernetes import KubernetesMani...
bakdata/kpops
kpops/component_handlers/helm/model.py
.py
ea8cdc571ff9a661
7.6
15
from kpops.component_handlers.kubernetes.utils import trim from kpops.manifests.kubernetes import K8S_LABEL_MAX_LEN RELEASE_NAME_MAX_LEN = 53 def create_helm_release_name(name: str, suffix: str = "") -> str: """Shortens the long Helm release name. :param name: The Helm release name to be shortened. :par...
bakdata/kpops
kpops/component_handlers/helm/utils.py
.py
405d2de84b63d959
7.6
15
from __future__ import annotations import json from abc import ABC from collections.abc import Generator, Hashable, Sequence from dataclasses import asdict from functools import cached_property from pathlib import Path from typing import Any, ClassVar, Self, TypeVar, cast import pydantic import structlog from pydanti...
bakdata/kpops
kpops/components/base_components/base_defaults_component.py
.py
11c8c58dde834cef
7.6
15
from __future__ import annotations from functools import cached_property from typing import Annotated, Any import pydantic import structlog from pydantic import Field, computed_field from typing_extensions import override from kpops.component_handlers.helm.dry_run_handler import DryRunHandler from kpops.component_ha...
bakdata/kpops
kpops/components/base_components/helm_app.py
.py
48429e0153a71038
7.6
15
from __future__ import annotations from abc import ABC from typing import Any, NoReturn import structlog from pydantic import PrivateAttr, ValidationInfo, field_validator from typing_extensions import override from kpops.component_handlers import get_handlers from kpops.component_handlers.kafka_connect.model import ...
bakdata/kpops
kpops/components/base_components/kafka_connector.py
.py
41029dfa326df28b
7.6
15
from __future__ import annotations import re from abc import ABC from typing import ClassVar import structlog from pydantic import ConfigDict from typing_extensions import override from kpops.components.base_components.pipeline_component import PipelineComponent from kpops.utils.pydantic import CamelCaseConfigModel,...
bakdata/kpops
kpops/components/base_components/kubernetes_app.py
.py
d8e68b83a6c100b3
7.6
15
from enum import StrEnum, auto from typing import Any, ClassVar, NewType from pydantic import ConfigDict, model_validator from kpops.components.base_components.models import TopicName from kpops.utils.pydantic import DescConfigModel class InputTopicTypes(StrEnum): """Input topic types. - INPUT: input topic...
bakdata/kpops
kpops/components/base_components/models/from_section.py
.py
1f441a9b4db64dcc
7.6
15
from __future__ import annotations from typing import ClassVar from pydantic import ConfigDict from kpops.components.base_components.models import ModelName, ModelVersion, TopicName from kpops.components.common.topic import KafkaTopic, TopicConfig from kpops.utils.pydantic import DescConfigModel class ToSection(De...
bakdata/kpops
kpops/components/base_components/models/to_section.py
.py
c3d1b2e839c6f38d
7.6
15
"""End-to-end import benchmark: restore a clean database, then time an import. Restores gbif_alert_bench from gbif_alert_bench_template before every run, so each configuration starts from identical state, then runs import_observations against the given archive and reports a stage breakdown parsed from the command's ow...
riparias/gbif-alert
benchmarks/bench_e2e.py
.py
d34180ef5fe7615b
7.54
11
"""Parse-only benchmark for the DwCA read path used by import_observations. Not part of the test suite. Run the variants back to back, in one sitting, on an idle machine. See README.md for methodology and recorded numbers. Three measurement points: # baseline: 0.16.4, row path PYTHONPATH=. uv run --with "pyt...
riparias/gbif-alert
benchmarks/bench_parse.py
.py
e057c54595968b76
7.54
11
"""Build a smaller DwCA from a GBIF download, for benchmarking at a lower scale. Truncates occurrence.txt to the first N data rows and filters verbatim.txt and multimedia.txt down to the extension rows that reference those core ids, so all three files shrink together. Everything else (meta.xml, metadata.xml, the datas...
riparias/gbif-alert
benchmarks/make_subset.py
.py
ee92ac6561fbd7e7
7.54
11
"""Relabel a throwaway database's species so a given archive actually imports. Why this exists: the most realistic thing to benchmark an import against is a clone of a real database - real observation volume, real users, real alerts, real unseen records. But a real database's species carry the taxon keys of whatever c...
riparias/gbif-alert
benchmarks/remap_species_to_archive.py
.py
c2b519e2e1927bea
7.04
11
import os import subprocess from pathlib import Path import pytest # pytest-playwright installs an asyncio event loop at session scope. # Django detects it and refuses synchronous DB operations by default. # This flag disables that guard - safe in a test context. os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "1" # Tests...
riparias/gbif-alert
conftest.py
.py
98a78b2c15031d7a
8.04
11
from django.conf import settings from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin from django.contrib.gis import admin from django.utils.html import format_html from import_export import resources # type: ignore from import_export.admin import ImportExportModelAdmin # type: ignore from modeltranslat...
riparias/gbif-alert
dashboard/admin.py
.py
567d4b6460eca1ef
7.54
11
"""Authentication helpers for the v2 API.""" from django.http import HttpRequest from django.utils import timezone from ninja.errors import HttpError from ninja.security import HttpBearer from dashboard.models import ApiToken class ApiTokenAuth(HttpBearer): """Authenticate a request from a personal access token ...
riparias/gbif-alert
dashboard/api_v2_auth.py
.py
a40869e5954bf5ca
7.54
11
from django import forms from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.forms import UserCreationForm from django.utils.translation import gettext_lazy as _ from dashboard.models import ObservationComment def _enabled_languages_as_tuple(): """ Return ...
riparias/gbif-alert
dashboard/forms.py
.py
e8ded8773e51f089
7.54
11
"""Helpers to map legacy GBIF backbone taxon keys to COL XR taxon keys. Isolated from the management command so the HTTP call is easy to mock in tests. """ import dataclasses import requests from django.conf import settings COL_XR_CHECKLIST_KEY = settings.GBIF_COL_XR_CHECKLIST_KEY _GBIF_MATCH_URL = "https://api.gbif...
riparias/gbif-alert
dashboard/gbif_taxonomy.py
.py
dc78a84900456494
7.54
11
"""Import-set maintenance-mode tagging and self-heal. `import_observations` puts the site in maintenance mode for the whole import run: it replaces all observations and rebuilds the `hexa_*` materialized views inside one transaction. (The non-concurrent MV rebuild in particular holds an ACCESS EXCLUSIVE lock that woul...
riparias/gbif-alert
dashboard/maintenance.py
.py
0669d5bf7c7a0667
7.54
11
from django.contrib.gis.gdal.feature import Feature from django.contrib.gis.gdal.geometries import MultiPolygon, OGRGeometry import requests from dashboard.models import Dataset # Enough for a single registry lookup, short enough that an unresponsive GBIF # API cannot stall a whole import. _GBIF_API_TIMEOUT_SECONDS ...
riparias/gbif-alert
dashboard/management/commands/helpers.py
.py
ab833e7fe29e5e5b
7.54
11
"""Converts clustered data into pairwise format for CROW1. The script can be used with a CSV file or a directory of CSV files containing data in a format suitable for the cluster version of CROW1. The data will need to contain the following columns: - Cluster ID/number The unique identifier for each cluster, i.e....
ONSdigital/ons-crow
version1_tkinter/utils/cluster_to_pairwise.py
.py
9f4a49be1d7359f9
7.56
12
import hashlib class AssetFingerprinter(object): """ Get a unique hash for an asset file, so that it doesn't stay cached when it changes Usage: in the application template_data.asset_fingerprinter = AssetFingerprinter() where template data is how you pass variables to every ...
alphagov/emergency-alerts-admin
app/asset_fingerprinter.py
.py
3e5b25b7005b3c64
7.5
9
#!/usr/bin/env python import csv import pickle import sys from math import isclose from pathlib import Path import geojson from emergency_alerts_utils.formatters import formatted_list from emergency_alerts_utils.polygons import Polygons from populations import ( CITY_OF_LONDON, MEDIAN_AGE_UK, estimate_num...
alphagov/emergency-alerts-admin
app/broadcast_areas/create-broadcast-areas-db.py
.py
354bdcf5d4d025a8
7.5
9
#!/usr/bin/env python import os from pathlib import Path import geojson from emergency_alerts_utils.formatters import formatted_list from emergency_alerts_utils.polygons import Polygons from repo import BroadcastAreasRepository from rtreelib import RTree from shapely import wkt from shapely.geometry import MultiPolyg...
alphagov/emergency-alerts-admin
app/broadcast_areas/create-postcode-areas-db.py
.py
21cb1bf74fb3d24b
7.5
9
#!/usr/bin/env python import json import sys from math import isclose from pathlib import Path import geojson from emergency_alerts_utils.formatters import formatted_list from emergency_alerts_utils.polygons import Polygons from repo import BroadcastAreasRepository from rtreelib import RTree from shapely import wkt f...
alphagov/emergency-alerts-admin
app/broadcast_areas/create-reppir-areas-db.py
.py
62d1bcfffec302a6
7.5
9
import inspect import json import os from datetime import datetime, timezone from io import BytesIO import boto3 from emergency_alerts_utils.clients.zendesk.zendesk_client import ( EASSupportTicket, ) from emergency_alerts_utils.template import BroadcastMessageTemplate from emergency_alerts_utils.xml.common import...
alphagov/emergency-alerts-api
app/broadcast_message/utils.py
.py
ac9622db93505696
7.5
9
class ClientException(Exception): """ Base Exceptions for sending notifications that fail """ pass class Client(object): """ Base client for sending notifications. """ pass STATISTICS_REQUESTED = "requested" STATISTICS_DELIVERED = "delivered" STATISTICS_FAILURE = "failure" class ...
alphagov/emergency-alerts-api
app/clients/__init__.py
.py
4e4a288c68c99ea1
7.5
9
import logging import boto3 import botocore.exceptions from flask import current_app from app.errors import InvalidRequest logger = logging.getLogger(__name__) class EmailClient: def __init__(self, client=None, sender=None): endpoint = current_app.config["SES_ENDPOINT"] from_address = current_...
alphagov/emergency-alerts-api
app/clients/email_client.py
.py
1c7870fd06500e0c
7.5
9
import functools import itertools import os import uuid import click import flask from flask import current_app, json from sqlalchemy.exc import IntegrityError from app import db from app.dao.broadcast_message_dao import dao_purge_old_broadcast_messages from app.dao.invited_user_dao import delete_invitations_sent_by_...
alphagov/emergency-alerts-api
app/commands.py
.py
bb2e671b32babce0
7.5
9
from datetime import datetime, timezone from emergency_alerts_utils.admin_action import ( ADMIN_ELEVATE_USER, ADMIN_ELEVATION_ACTION_TIMEOUT, ADMIN_STATUS_INVALIDATED, ADMIN_STATUS_PENDING, ) from app.dao.dao_utils import autocommit from app.models import AdminAction def dao_get_pending_valid_admin_...
alphagov/emergency-alerts-api
app/dao/admin_action_dao.py
.py
293ae730ae201df2
7.5
9
import uuid from datetime import datetime, timedelta, timezone from sqlalchemy import func, or_ from app import db from app.dao.dao_utils import autocommit, version_class from app.models import ApiKey @autocommit @version_class(ApiKey) def save_model_api_key(api_key): if not api_key.id: api_key.id = uui...
alphagov/emergency-alerts-api
app/dao/api_key_dao.py
.py
fae43e0602ecd681
7.5
9
import uuid from datetime import datetime, timezone from sqlalchemy import asc, desc from sqlalchemy.orm import aliased from app import db from app.dao.dao_utils import autocommit from app.models import BroadcastMessageEditReasons, User def dao_get_broadcast_message_edit_reasons(service_id, broadcast_message_id): ...
alphagov/emergency-alerts-api
app/dao/broadcast_message_edit_reasons.py
.py
2f30010fc8d6b188
7.5
9
import uuid from datetime import datetime, timezone from sqlalchemy import desc from sqlalchemy.orm import aliased from app import db from app.dao.dao_utils import autocommit from app.models import BroadcastMessageHistory, User def dao_get_broadcast_message_versions(service_id, broadcast_message_id): UserCreate...
alphagov/emergency-alerts-api
app/dao/broadcast_message_history_dao.py
.py
3b31bb3c8e244d28
7.5
9