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 |
|---|---|---|---|---|---|---|
import pytest
@pytest.mark.skip("New SR TE model is not available")
def test_bgp_sr_te_weighted(api):
"""
Test BGP SRTE Policy configuration applied properly
1) 2 policies with different weights
2) BSID as MPLS label
Validate the configuration against RestPy
"""
BGPV4_SR_TE_TUNNEL = {
... | open-traffic-generator/snappi-ixnetwork | tests/bgp/test_bgp_sr_te_weighted.py | .py | a41918d2b30d0249 | 8.17 | 21 |
from api import Api
from .check import Check
from .logout import Logout
class Auth(Api):
"""Interface for `api/auth` cephapi"""
def __init__(self, url, header, api="api/auth"):
super().__init__(url, api)
self.header = header
self.check = Check(url=url, header=self.header, api=f"{api... | red-hat-storage/cephci | api/cephapi/auth/auth.py | .py | c671367f8fb6badc | 7.75 | 31 |
from api import Api
class Check(Api):
"""Interface for `api/auth/check` cephapi"""
def __init__(self, url, header, api="api/check"):
self.header = header
super().__init__(url, api)
def post(self, token, check_sc=False):
"""Post request method for API
Args:
to... | red-hat-storage/cephci | api/cephapi/auth/check.py | .py | 689d066b64209b5d | 7.75 | 31 |
from api import Api
class Logout(Api):
"""Interface for `api/auth/logout` cephapi"""
def __init__(self, url, api="api/logout"):
super().__init__(url, api)
def post(self, check_sc=False):
"""Post request method for API
Args:
check_sc (bool): Check for status code vali... | red-hat-storage/cephci | api/cephapi/auth/logout.py | .py | c1e14a2e1d342f5e | 7.25 | 31 |
from api import Api
class Crush(Api):
"""Interface for RESTful endpoint `/crush/rule`"""
def __init__(self, url, api="/crush/rule"):
super().__init__(url, api)
def get(self, username, key, check_sc=False):
"""
Get request method for API
Args:
username (str): A... | red-hat-storage/cephci | api/restful/crush.py | .py | 327dd67bc8439c17 | 7.75 | 31 |
from api import Api
class Mon(Api):
"""Interface for RESTful endpoint `/mon`"""
def __init__(self, url, api="/mon"):
super().__init__(url, api)
def get(self, username, key, check_sc=False):
"""
Get request method for API
Args:
username (str): API user
... | red-hat-storage/cephci | api/restful/mon.py | .py | 91bb9fde2ecaa5db | 7.25 | 31 |
from api import Api
class Perf(Api):
"""Interface for RESTful endpoint `/perf`"""
def __init__(self, url, api="/perf"):
super().__init__(url, api)
def get(self, username, key, check_sc=False):
"""
Get request method for API
Args:
username (str): API user
... | red-hat-storage/cephci | api/restful/perf.py | .py | 9ee59163d7a3ab28 | 7.25 | 31 |
from api import Api
class Server(Api):
"""Interface for RESTful endpoint `/server`"""
def __init__(self, url, api="/server"):
super().__init__(url, api)
def get(self, username, key, check_sc=False):
"""
Get request method for API
Args:
username (str): API use... | red-hat-storage/cephci | api/restful/server.py | .py | 9436433b3fac683f | 7.25 | 31 |
"""
Ceph Administrator aka cephadm module is a configuration tool for Ceph cluster.
It allows the users to deploy and manage their Ceph cluster. It also supports all the
operations part of the cluster lifecycle.
Over here, we create a glue between the CLI and CephCI to allow the QE to write test
scenarios for verifyi... | red-hat-storage/cephci | ceph/ceph_admin/__init__.py | .py | 7c358aa273b05b00 | 7.75 | 31 |
from typing import Dict
from ceph.utils import get_node_by_id
from .common import config_dict_to_string
from .typing_ import DaemonProtocol
class AddMixin:
"""Mixin Class for orch daemon add"""
def add(self: DaemonProtocol, config: Dict):
"""
Execute the add method using the object's servic... | red-hat-storage/cephci | ceph/ceph_admin/add.py | .py | 608b1496b65a5233 | 7.75 | 31 |
"""Deploy the alert manager service in the cluster via cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class AlertManager(ApplyMixin, Orch):
"""Manage the alert-manager service."""
SERVICE_NAME = "alertmanager"
def apply(self, config: Dict) -> None:
... | red-hat-storage/cephci | ceph/ceph_admin/alert_manager.py | .py | 6ca066e9d4d3fc60 | 7.75 | 31 |
"""
Represent the ceph orch CLI action 'apply'.
Module to deploy ceph role service(s) using orchestration command
"ceph orch apply <role> [options] --placement '<placements>' "
This is a mixin object and can be applied to the supported service classes.
"""
import re
from typing import Dict
from ceph.utils import ge... | red-hat-storage/cephci | ceph/ceph_admin/apply.py | .py | c60d264bfefbc9ae | 7.75 | 31 |
"""Cephadm ansible module to run playbooks
playbooks supported,
- cephadm-preflight.yaml
- cephadm-purge-cluster.yaml
- cephadm-clients.yaml
"""
import re
from ceph.ceph_admin.common import config_dict_to_string
from utility.log import Log
LOG = Log(__name__)
ANSIBLE_RPM = "ansible-2.9-for-rhel-8-x86_64-rpms"
cl... | red-hat-storage/cephci | ceph/ceph_admin/cephadm_ansible.py | .py | dddb899c9242df4e | 7.75 | 31 |
"""Manage the CephFS Mirror service via the cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class CephfsMirror(ApplyMixin, Orch):
"""Interface to ceph orch <action> rbd-mirror."""
SERVICE_NAME = "cephfs-mirror"
def apply(self, config: Dict) -> None:
... | red-hat-storage/cephci | ceph/ceph_admin/cephfs_mirror.py | .py | d302baca57537514 | 7.75 | 31 |
"""Cephadm orchestration client-keyring operations.
Syntax:
orch client-keyring ls [--format {plain|json|json-pretty|yaml}]
orch client-keyring rm <entity>
orch client-keyring set <entity> <placement> [<owner>] [<mode>]
"""
from .common import config_dict_to_string
from .orch import Orch
class ClientKeyringOpFailur... | red-hat-storage/cephci | ceph/ceph_admin/client_keyring.py | .py | 84020393646cdab3 | 7.75 | 31 |
"""Contains common functions that can used across the module."""
from typing import Dict
def config_dict_to_string(data: Dict) -> str:
"""
Convert the provided data to a string of optional arguments.
Args:
data (Dict): Key/value pairs that are CLI optional arguments
Return:
string... | red-hat-storage/cephci | ceph/ceph_admin/common.py | .py | da6796a103a77e6b | 7.75 | 31 |
"""Manage the Crash service via cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class Crash(ApplyMixin, Orch):
"""Interface to ceph orch <action> crash."""
SERVICE_NAME = "crash"
def apply(self, config: Dict) -> None:
"""
Deploy the Crash se... | red-hat-storage/cephci | ceph/ceph_admin/crash.py | .py | d20f76f3f11c07f4 | 7.75 | 31 |
"""CephADM orchestration Daemon operations."""
from utility.log import Log
from .add import AddMixin
from .common import config_dict_to_string
from .orch import Orch
log = Log(__name__)
class Daemon(AddMixin, Orch):
def op(self, op, config):
"""
Execute the command ceph orch daemon <start|stop|... | red-hat-storage/cephci | ceph/ceph_admin/daemon.py | .py | 6ea887f8ca0b77be | 7.75 | 31 |
"""CephADM orchestration Device operations."""
from time import sleep
from typing import Dict, Optional, Tuple
from ceph.utils import get_node_by_id
from utility.log import Log
from .common import config_dict_to_string
from .orch import Orch
log = Log(__name__)
class Device(Orch):
def zap(self, config: Dict) ... | red-hat-storage/cephci | ceph/ceph_admin/device.py | .py | fc8a9e89ccaa619f | 7.75 | 31 |
"""Manage the Ceph Grafana service via cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class Grafana(ApplyMixin, Orch):
"""Interface to Ceph service Grafana via CLI."""
SERVICE_NAME = "grafana"
def apply(self, config: Dict) -> None:
"""
Depl... | red-hat-storage/cephci | ceph/ceph_admin/grafana.py | .py | 84d7e4e9aa3d8721 | 7.75 | 31 |
"""Module to deploy and manage Ceph's iSCSI service."""
from typing import Dict
from ceph.utils import get_nodes_by_ids
from .apply import ApplyMixin
from .orch import Orch
class ISCSI(ApplyMixin, Orch):
"""Interface to Ceph's iSCSI service via cephadm CLI."""
SERVICE_NAME = "iscsi"
def apply(self, c... | red-hat-storage/cephci | ceph/ceph_admin/iscsi.py | .py | ec5f5e6267c633db | 7.75 | 31 |
"""Module that interfaces with ceph orch ls CLI."""
from typing import Dict, Optional, Tuple
from .common import config_dict_to_string
from .typing_ import OrchProtocol
class LSMixin:
"""CLI that list known services to orchestrator."""
def ls(self: OrchProtocol, config: Optional[Dict] = None) -> Tuple:
... | red-hat-storage/cephci | ceph/ceph_admin/ls.py | .py | 34f384a1a1184d3b | 7.75 | 31 |
"""Manage MDS service via Ceph's cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class MDS(ApplyMixin, Orch):
"""Interface to the MetaDataService."""
SERVICE_NAME = "mds"
def apply(self, config: Dict) -> None:
"""
Deploy the MDS service usin... | red-hat-storage/cephci | ceph/ceph_admin/mds.py | .py | a540e6b31329d37f | 7.75 | 31 |
"""Manage the Manager service via Ceph's cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class Mgr(ApplyMixin, Orch):
"""Manager interface for ceph orch <action> mgr"""
SERVICE_NAME = "mgr"
def apply(self, config: Dict) -> None:
"""
Deploy t... | red-hat-storage/cephci | ceph/ceph_admin/mgr.py | .py | 41a10c3aeac7d093 | 7.75 | 31 |
"""Manage the Monitor service via cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class Mon(ApplyMixin, Orch):
"""Interface to ceph orch <action> mon."""
SERVICE_NAME = "mon"
def apply(self, config: Dict) -> None:
"""
Deploy the Monitor serv... | red-hat-storage/cephci | ceph/ceph_admin/mon.py | .py | e8ee45f1bbf3f272 | 7.75 | 31 |
"""Manage the NFS service via the cephadm CLI."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class NFS(ApplyMixin, Orch):
"""Interface to ceph orch <action> nfs."""
SERVICE_NAME = "nfs"
def apply(self, config: Dict) -> None:
"""
Deploy the NFS service ... | red-hat-storage/cephci | ceph/ceph_admin/nfs.py | .py | 6b6f3a79c051cd7d | 7.75 | 31 |
"""Module to deploy Node-Exporter service and individual daemon(s)."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class NodeExporter(ApplyMixin, Orch):
"""Interface to manage node-exporter service."""
SERVICE_NAME = "node-exporter"
def apply(self, config: Dict) -> Non... | red-hat-storage/cephci | ceph/ceph_admin/node_exporter.py | .py | 56505f0463f49d60 | 7.75 | 31 |
"""Manage the NVMeoF service via ceph-adm CLI."""
from copy import deepcopy
from typing import Dict
from looseversion import LooseVersion
from utility.utils import get_ceph_version_from_cluster
from .apply import ApplyMixin
from .orch import Orch
# Ceph version from which nvmeof apply uses --pool/--group (args) in... | red-hat-storage/cephci | ceph/ceph_admin/nvmeof.py | .py | c61a9c748d693335 | 7.75 | 31 |
"""
Module that interacts with the orchestrator CLI.
Provide the interfaces to ceph orch and in turn manage the orchestration engine.
"""
from datetime import datetime, timedelta
from json import loads
from time import sleep
from dateutil import parser
from ceph.ceph import ResourceNotFoundError
from utility.log im... | red-hat-storage/cephci | ceph/ceph_admin/orch.py | .py | 18ed5e02cc2a16ee | 7.75 | 31 |
"""Manage OSD service via cephadm CLI."""
import datetime
import json
from time import sleep
from typing import Dict
from utility.log import Log
from .apply import ApplyMixin
from .common import config_dict_to_string
from .orch import Orch
LOG = Log(__name__)
class OSDServiceFailure(Exception):
pass
class D... | red-hat-storage/cephci | ceph/ceph_admin/osd.py | .py | 75da0fe11eae2f97 | 7.75 | 31 |
"""Represents the ceph orch CLI action 'pause'.
This module enables the user to perform ceph pause orchestrator operations
using orchestration command
Example:
The orchestrator operations can be paused by using the following command::
ceph orch pause
This module is inherited where orchestrator operation... | red-hat-storage/cephci | ceph/ceph_admin/pause.py | .py | 0fa6325139295f22 | 7.75 | 31 |
"""Module to deploy Prometheus service and individual daemon(s)."""
from typing import Dict
from .apply import ApplyMixin
from .orch import Orch
class Prometheus(ApplyMixin, Orch):
SERVICE_NAME = "prometheus"
def apply(self, config: Dict) -> None:
"""
Deploy the Prometheus service using the... | red-hat-storage/cephci | ceph/ceph_admin/prometheus.py | .py | eb79e22afe9840ce | 7.75 | 31 |
import asyncio
import logging.config
import os
import sys
import typing as t
from signal import Signals
import click
from .app import Darq
from .logs import default_log_config
from .scheduler import run_scheduler
from .utils import import_string
from .version import __version__
from .worker import check_health
from .... | seedofjoy/darq | darq/cli.py | .py | 62f83b067b8ed1a5 | 7.84 | 46 |
import asyncio
import logging
import pickle
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Any
from typing import Callable
from typing import Dict
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Tuple
from ty... | seedofjoy/darq | darq/jobs.py | .py | f9256a9eec64aefb | 7.84 | 46 |
import asyncio
import logging
import typing as t
from datetime import datetime
from .connections import create_pool
from .connections import RedisSettings
from .types import AnyDict
from .utils import poll
from .utils import to_seconds_strict
from .utils import to_unix_ms
if t.TYPE_CHECKING: # pragma: no cover
f... | seedofjoy/darq | darq/scheduler.py | .py | 826dd41d6e79e4a3 | 7.84 | 46 |
#!/usr/bin/env python3
"""
Script to regenerate Sphinx .rst files and build HTML documentation.
This script uses sphinx-apidoc to synchronize .rst files with the current
structure of the neosqlite package. It also checks for orphaned .rst files
that correspond to modules no longer present in the codebase and warns abo... | cwt/neosqlite | docs/regenerate_docs.py | .py | b2e075783b958956 | 7.72 | 26 |
"""
Utilities for distinguishing and renaming ordered and disordered configurations of
multi-sublattice phases.
`OrderingRecord` objects are able to be used for any phase. `OrderingRecords` can be
created automatically for phases modeled with a partitioned order/disorder model through
the `create_ordering_records` met... | pycalphad/scheil | scheil/ordering.py | .py | 14fe3d4864aa4b08 | 7.75 | 30 |
import numpy as np
from scipy.stats import norm
def get_phase_amounts(eq_phases, phase_fractions, all_phases):
"""Return the phase fraction for each phase in equilibrium
Parameters
----------
eq_phases : Sequence[str]
Equilibrium phases
phase_fractions : Sequence[float]
Phase amou... | pycalphad/scheil | scheil/utils.py | .py | c63a2bf89fd4c6d5 | 7.75 | 30 |
import os
import pytest
from pycalphad import Database
DATABASE_DIR = os.path.join(os.path.dirname(__file__), 'databases')
@pytest.fixture(scope="session")
def load_database(request):
"""
Helper fixture to load a database (parameterized by the value of `request`).
"""
db = Database(os.path.join(DATAB... | pycalphad/scheil | tests/fixtures.py | .py | 100ed48e1d290b52 | 8.25 | 30 |
"""Tests for the hypothetical A-B-C system laid out by S.-L. Chen et al. JPEDAV 30(5) (2009) 429-434"""
import os
import numpy as np
from pycalphad import Database, variables as v
from scheil import simulate_scheil_solidification
import pytest
from fixtures import select_database, load_database, DATABASE_DIR
@select... | pycalphad/scheil | tests/test_chen2009.py | .py | 1304f50a6459edf0 | 7.25 | 30 |
"""Admin Client library for the Google Nest SDM API.
This manages administrative tasks for setting up pubsub topics and subscriptions.
This library exists to provide an asyncio interface given that the current pubsub
clients are synchronous.
"""
import asyncio
import logging
import re
from dataclasses import datacla... | allenporter/python-google-nest-sdm | google_nest_sdm/admin_client.py | .py | 65b03b74f7089a23 | 7.93 | 72 |
"""Authentication library, implemented by users of the API.
This library is a simple `aiohttp` that handles authentication when talking
to the API. Users are expected to provide their own implementation that provides
credentials obtained using the standard Google authentication approaches
described at https://develope... | allenporter/python-google-nest-sdm | google_nest_sdm/auth.py | .py | 0c2a04b9aacf8671 | 7.93 | 72 |
"""Traits belonging to camera devices."""
from __future__ import annotations
import datetime
import logging
import urllib.parse as urlparse
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from enum import Enum
from typing import ClassVar
from mashumaro import field_options
from mashumaro... | allenporter/python-google-nest-sdm | google_nest_sdm/camera_traits.py | .py | aafbd1ca1709b89c | 7.93 | 72 |
"""A device from the Smart Device Management API."""
import datetime
import logging
from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field, fields
from typing import Any, Self
from mashumaro import DataClassDictMixin, field_options
from mashumaro.config import BaseConfig
from mashuma... | allenporter/python-google-nest-sdm | google_nest_sdm/device.py | .py | 4d1b8093d87cff05 | 7.93 | 72 |
"""Device Manager keeps track of the current state of all devices."""
from __future__ import annotations
import logging
from collections.abc import Awaitable, Callable
from .device import Device, ParentRelation
from .diagnostics import DEVICE_MANAGER_DIAGNOSTICS as DIAGNOSTICS
from .event import EventMessage, Relati... | allenporter/python-google-nest-sdm | google_nest_sdm/device_manager.py | .py | 70acf267efa67f90 | 7.93 | 72 |
"""Library for traits about devices."""
import datetime
from dataclasses import dataclass, field
from typing import Any, ClassVar
import aiohttp
from mashumaro import field_options
from .traits import BaseTrait, CommandDataClass, TraitType
@dataclass
class ConnectivityTrait(BaseTrait):
"""This trait belongs to... | allenporter/python-google-nest-sdm | google_nest_sdm/device_traits.py | .py | a374fb94b60fe785 | 7.93 | 72 |
"""Diagnostics for debugging."""
from __future__ import annotations
import time
from collections import Counter
from collections.abc import Generator, Mapping
from contextlib import contextmanager
from typing import Any, TypeVar, cast
__all__ = [
"get_diagnostics",
]
class Diagnostics:
"""Information for t... | allenporter/python-google-nest-sdm | google_nest_sdm/diagnostics.py | .py | 6ef09e948a96de91 | 7.93 | 72 |
"""Events from pubsub subscriber."""
from __future__ import annotations
import base64
import binascii
import datetime
import hashlib
import json
import logging
import traceback
from abc import ABC, abstractmethod
from collections.abc import Iterable, Mapping
from dataclasses import dataclass, field
from enum import S... | allenporter/python-google-nest-sdm | google_nest_sdm/event.py | .py | 77ab7271742b2c6b | 7.93 | 72 |
#!/usr/bin/python3
"""Command line tool for the Google Nest Smart Device Management API.
You must configure your device as described:
https://developers.google.com/nest/device-access/get-started
which will give you a project_id, client_id, and client_secret. This tool
will do a one time setup to get an access tok... | allenporter/python-google-nest-sdm | google_nest_sdm/google_nest.py | .py | 024e11ac3ede9f6d | 7.93 | 72 |
"""Library to access the Smart Device Management API."""
from .auth import AbstractAuth
from .device import Device
from .structure import Structure
__all__ = ["GoogleNestAPI"]
STRUCTURES = "structures"
DEVICES = "devices"
NAME = "name"
class GoogleNestAPI:
"""Client library to communicate with the Google Nest ... | allenporter/python-google-nest-sdm | google_nest_sdm/google_nest_api.py | .py | 8096cc15d87ec099 | 7.93 | 72 |
"""Subscriber for the Smart Device Management event based API."""
from __future__ import annotations
import asyncio
import datetime
import enum
import logging
import re
import time
from collections.abc import Awaitable, Callable
from .auth import AbstractAuth
from .device_manager import DeviceManager
from .diagnosti... | allenporter/python-google-nest-sdm | google_nest_sdm/google_nest_subscriber.py | .py | 7d69b143c9ab4219 | 7.93 | 72 |
"""Base model for all nest trait based classes."""
from __future__ import annotations
from collections.abc import Mapping
from dataclasses import dataclass, fields
from typing import Any, Self
from mashumaro import DataClassDictMixin
from mashumaro.config import BaseConfig
TRAITS = "traits"
SDM_PREFIX = "sdm."
@d... | allenporter/python-google-nest-sdm | google_nest_sdm/model.py | .py | f03b2d86ddc7c194 | 7.93 | 72 |
"""Rate limiting utilities."""
import asyncio
import time
from collections.abc import Callable
DEFAULT_DELAYS: tuple[float, ...] = (0.0, 3.0, 10.0, 20.0)
"""Graduated schedule of delays between commands:
- 1st command: Immediate (0s delay).
- 2nd command: 3s spacing (allows short coalescing window for natural multi-t... | allenporter/python-google-nest-sdm | google_nest_sdm/rate_limiter.py | .py | c5a2ae76d8415ea5 | 7.93 | 72 |
"""Decorator for creating a registry of objects."""
from __future__ import annotations
from collections.abc import Callable
from typing import Any, TypeVar
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
class Registry(dict[str, Any]):
"""Registry of items."""
def regist... | allenporter/python-google-nest-sdm | google_nest_sdm/registry.py | .py | b09078f3efaa04f4 | 7.93 | 72 |
"""Subscriber for the Smart Device Management event based API."""
from __future__ import annotations
import asyncio
import datetime
import json
import logging
from collections.abc import AsyncIterable, Awaitable, Callable
from typing import TYPE_CHECKING, Any
from google import pubsub_v1
from .auth import AbstractA... | allenporter/python-google-nest-sdm | google_nest_sdm/streaming_manager.py | .py | 1e80b0e0b75b056f | 7.93 | 72 |
"""Traits for structures / rooms."""
from __future__ import annotations
from collections.abc import Mapping
from dataclasses import dataclass, field
from typing import Any
from mashumaro import field_options
from .model import TraitDataClass
@dataclass
class InfoTrait:
"""This trait belongs to any structure f... | allenporter/python-google-nest-sdm | google_nest_sdm/structure.py | .py | ecc63dcbcf2c46f6 | 7.93 | 72 |
"""Traits for thermostats."""
import asyncio
import logging
from dataclasses import dataclass, field
from typing import Any, ClassVar, Final, Self
import aiohttp
from mashumaro import field_options
from .traits import BaseTrait, CommandDataClass, TraitType
__all__ = [
"ThermostatEcoTrait",
"ThermostatHvacTr... | allenporter/python-google-nest-sdm | google_nest_sdm/thermostat_traits.py | .py | 3a7f9cdfa55a6639 | 7.93 | 72 |
"""Base library for all traits."""
import datetime
import logging
from abc import ABC
from collections.abc import Mapping
from dataclasses import dataclass, field, fields
from enum import StrEnum
from typing import Any
import aiohttp
from mashumaro import DataClassDictMixin
from mashumaro.types import SerializableTyp... | allenporter/python-google-nest-sdm | google_nest_sdm/traits.py | .py | 1cbe6accb881f5c5 | 7.93 | 72 |
"""Library for transcoding mp4 clips."""
import asyncio.subprocess
import logging
import os
from .exceptions import TranscodeException
_LOGGER = logging.getLogger(__name__)
class Transcoder:
"""A worker that processes mp4 clips."""
def __init__(self, ffmpeg_binary: str, path_prefix: str) -> None:
... | allenporter/python-google-nest-sdm | google_nest_sdm/transcoder.py | .py | 7a20dfba90cd8e05 | 7.93 | 72 |
"""Library with functions for manipulating WebRTC requests/responses."""
from enum import StrEnum
class SDPDirection(StrEnum):
"""SDP direction constants."""
SENDRECV = "sendrecv"
SENDONLY = "sendonly"
RECVONLY = "recvonly"
INACTIVE = "inactive"
class SDPMediaKind(StrEnum):
"""SDP media ki... | allenporter/python-google-nest-sdm | google_nest_sdm/webrtc_util.py | .py | 6079469f1d7991a8 | 7.93 | 72 |
"""Fixtures and libraries shared by tests."""
from __future__ import annotations
import logging
import uuid
from abc import ABC
from collections.abc import Awaitable, Callable, Generator
from typing import (
Any,
cast,
)
import aiohttp
import pytest
from aiohttp.test_utils import TestClient, TestServer
from... | allenporter/python-google-nest-sdm | tests/conftest.py | .py | 766d1273e10d2769 | 8.43 | 72 |
"""Tests for doorbell traits."""
from collections.abc import Callable
from typing import Any
from google_nest_sdm.device import Device
def test_doorbell_chime(fake_device: Callable[[dict[str, Any]], Device]) -> None:
device = fake_device(
{
"name": "my/device/name",
"traits": {
... | allenporter/python-google-nest-sdm | tests/test_doorbell_traits.py | .py | e998039b53b35ebe | 7.43 | 72 |
import datetime
from freezegun import freeze_time
from google_nest_sdm.rate_limiter import RateLimiter
def test_rate_limiter_progressive_delays() -> None:
"""Test progressive delay schedule (0s -> 3s -> 10s -> 20s)."""
with freeze_time("2026-08-16 12:00:00") as frozen_time:
limiter = RateLimiter()
... | allenporter/python-google-nest-sdm | tests/test_rate_limiter.py | .py | 87c8af9f22a58804 | 7.43 | 72 |
# Copyright 2020 Michael Still
import importlib
import json
import logging
import os
import uuid as uuid_module
from dataclasses import dataclass
from dataclasses import field
from typing import Any
from typing import Optional
import click
from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grp... | shakenfist/shakenfist | shakenfist/client/ctl.py | .py | 30c4dc1cd70e6520 | 7.78 | 35 |
import json
import os
import re
import shutil
import subprocess
import sys
import time
from shakenfist_utilities import logs # noreorder
from shakenfist.config import config
from shakenfist.exceptions import ListingInterfaceAddressesFailed
LOG, _ = logs.setup(__name__)
CACHED_EXECUTABLES = {}
d... | shakenfist/shakenfist | shakenfist/daemons/privexec/util.py | .py | dc50df41cd38acfb | 7.78 | 35 |
import requests
from shakenfist_ci import base
class TestOpenAPIJS(base.BaseNamespacedTestCase):
def __init__(self, *args, **kwargs):
kwargs['namespace_prefix'] = 'openapijs'
super().__init__(*args, **kwargs)
def test_ui_js(self):
# Ensure we can fetch the UI Javascript
r = re... | shakenfist/shakenfist | shakenfist/deploy/shakenfist_ci/cluster_ci_tests/test_api.py | .py | c4fda6f2bf03e87f | 8.28 | 35 |
# Copyright 2026 Michael Still and contributors
import json
import time
from shakenfist_client import apiclient
from testtools import content
from shakenfist_ci import base
# The two messages which mean a coalescing query matched a row. The
# enqueue-side dedup found a pending sibling and reused it; the
# worker-s... | shakenfist/shakenfist | shakenfist/deploy/shakenfist_ci/cluster_ci_tests/test_coalescing.py | .py | d4dec4c9c209a9f0 | 8.28 | 35 |
import json
import sys
import time
from oslo_concurrency import processutils
from testtools import content
from shakenfist_ci import base
def _exec(cmd):
sys.stderr.write('\n----- Exec: %s -----\n' % cmd)
out, err = processutils.execute(cmd, shell=True)
for line in out.split('\n'):
sys.stderr.wr... | shakenfist/shakenfist | shakenfist/deploy/shakenfist_ci/cluster_ci_tests/test_commandline_network.py | .py | a4bab1820bde221d | 8.28 | 35 |
import json
import time
from testtools import content
from shakenfist_ci import base
from shakenfist_client import apiclient
class TestConsoleLog(base.BaseNamespacedTestCase):
def __init__(self, *args, **kwargs):
kwargs['namespace_prefix'] = 'console'
super().__init__(*args, **kwargs)
def s... | shakenfist/shakenfist | shakenfist/deploy/shakenfist_ci/cluster_ci_tests/test_console_log.py | .py | 067069abb1adc07b | 7.28 | 35 |
# Copyright 2019 Michael Still and contributors
import json
from testtools import content
from shakenfist_ci import base
from shakenfist_ci import database_tier
PER_INSTANCE_FLOOR = 0.05
class TestDatabaseTier(database_tier.DatabaseTierTestsMixin,
base.BaseNamespacedTestCase):
"""The mu... | shakenfist/shakenfist | shakenfist/deploy/shakenfist_ci/cluster_ci_tests/test_database_tier.py | .py | 6e96a737856f1c2a | 8.28 | 35 |
"""
DANDI
=====
The `dandi <https://github.com/dandi/dandi-cli>`_ library provides both a
command line interface (CLI) and a Python API for interacting with `DANDI
Archive <https://dandiarchive.org>`_.
Additional references:
- `Source Git repository <https://github.com/dandi/dandi-cli>`_
- `Library documentation <ht... | dandi/dandi-cli | dandi/__init__.py | .py | 73a65dcd506db943 | 7.72 | 27 |
# This file holds the models used to interface with the deno-compiled BIDS validator
# with the `--json` option. The defined entities in this file share the same names and
# structure as those defined in
# https://github.com/bids-standard/bids-validator/blob/main/src/types/validation-result.ts
# and
# https://github.co... | dandi/dandi-cli | dandi/bids_validator_deno/_models.py | .py | 3dbeeeae6c6b3947 | 7.72 | 27 |
# This file provides definitions to do BIDS validation through the deno-compiled BIDS
# validator, https://pypi.org/project/bids-validator-deno/.
from importlib.metadata import version
import json
from pathlib import Path
import re
from subprocess import CompletedProcess, TimeoutExpired, run
from tempfile import Tempo... | dandi/dandi-cli | dandi/bids_validator_deno/_validator.py | .py | 19338b19666904b9 | 7.72 | 27 |
from enum import Enum
from functools import wraps
import os
import click
from .. import get_logger
lgr = get_logger()
# Aux common functionality
class IntColonInt(click.ParamType):
name = "int:int"
def convert(self, value, param, ctx):
if isinstance(value, str):
v1, colon, v2 = value.... | dandi/dandi-cli | dandi/cli/base.py | .py | 43b66a822f7883cb | 7.72 | 27 |
"""
Commands definition for DANDI command line interface
"""
from datetime import datetime, timezone
import logging
import os
import os.path
import sys
from types import SimpleNamespace
import click
from click_didyoumean import DYMGroup
import platformdirs
from .base import lgr, map_to_click_exceptions
from .. impor... | dandi/dandi-cli | dandi/cli/command.py | .py | 683f7f9117422fd9 | 7.72 | 27 |
import os
import re
from subprocess import PIPE, Popen
import sys
from click.testing import CliRunner
import pytest
from ..cmd_ls import ls
from ..cmd_validate import validate
from ..command import __all_commands__
@pytest.mark.parametrize("command", (ls, validate))
def test_smoke(organized_nwb_dir, command, tmp_pa... | dandi/dandi-cli | dandi/cli/tests/test_command.py | .py | 5300a7baf4d20a9f | 7.22 | 27 |
import os
from pathlib import Path
import subprocess
from click.testing import CliRunner
import numpy as np
import pytest
import zarr
from ..cmd_digest import digest
from ...tests.test_helpers import zarr_format_of
# The on-disk Zarr serialisation format changed between V2 (``.zgroup`` /
# ``.zarray``) and V3 (``zar... | dandi/dandi-cli | dandi/cli/tests/test_digest.py | .py | 4790427569c2d893 | 7.22 | 27 |
"""Constants and configuration for DANDI CLI.
This module defines constants used throughout the DANDI CLI including:
- Metadata field definitions for NWB files
- Known DANDI Archive instances and their configurations
- File organization patterns and BIDS-related constants
- Request timeouts and retry settings
"""
fro... | dandi/dandi-cli | dandi/consts.py | .py | ad6c7e2547c1ea69 | 7.72 | 27 |
"""Classes/utilities for support of a dandiset"""
from __future__ import annotations
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
import os.path
from pathlib import Path, PurePath, PurePosixPath
from typing import TYPE_CHECKING
from dandischema.models import get_schema_version
fro... | dandi/dandi-cli | dandi/dandiset.py | .py | 49bbf22ffc4f63bf | 7.72 | 27 |
# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit
is not available.
To use it, place it into your project codebase to be imported, e.g. copy as
... | dandi/dandi-cli | dandi/due.py | .py | d7cfb5c0b4675a80 | 7.72 | 27 |
"""
.. versionadded:: 0.36.0
`dandi.files` defines functionality for working with local files & directories
(as opposed to remote resources on a DANDI Archive server) that are of interest
to DANDI. The classes for such files & directories all inherit from
`DandiFile`, which has two immediate subclasses: `DandisetMeta... | dandi/dandi-cli | dandi/files/__init__.py | .py | 8bfaf9c0b0d7a369 | 7.72 | 27 |
from __future__ import annotations
from collections.abc import Callable
import os.path as op
from pathlib import Path
from typing import TypeVar
import click
from keyring.backend import KeyringBackend, get_all_keyring
from keyring.core import get_keyring, load_config, load_env
from keyring.errors import KeyringError
... | dandi/dandi-cli | dandi/keyring_utils.py | .py | cc1e3d35793d29c1 | 7.72 | 27 |
from __future__ import annotations
from datetime import datetime
from pathlib import Path
import re
from dandischema import models
from pydantic import ByteSize
from .util import extract_model, get_generator
from .. import get_logger
from ..misctypes import Digest, LocalReadableFile, Readable
from ..utils import get... | dandi/dandi-cli | dandi/metadata/core.py | .py | d3317fa1d5076125 | 7.72 | 27 |
from __future__ import annotations
from datetime import datetime
import os.path
from pathlib import Path
import re
from typing import Any
from dandischema import models
from .core import add_common_metadata, prepare_metadata
from .util import process_ndtypes
from .. import get_logger
from ..consts import metadata_al... | dandi/dandi-cli | dandi/metadata/nwb.py | .py | 7781fcd7e940b125 | 7.72 | 27 |
import numpy as np
from scipy.special import logsumexp
from scipy.stats import gamma, norm
import reciprocalspaceship as rs
def _french_wilson_posterior_quad(Iobs, SigIobs, Sigma, centric, npoints=100):
"""
Compute the mean and std deviation of the French-Wilson posterior using
Chebyshev-Gauss quadrature... | rs-station/reciprocalspaceship | reciprocalspaceship/algorithms/scale_merged_intensities.py | .py | ef303bd219483566 | 7.81 | 40 |
#!/usr/bin/env python
"""
Summarize the contents of a CIF file.
Examples
--------
In order to summarize contents of file.cif::
> rs.cifdump file.cif
If you would like to interactively inspect file.cif in an IPython
shell, use the "--embed" argument::
> rs.cifdump file.cif --embed
If multiple CIF files are ... | rs-station/reciprocalspaceship | reciprocalspaceship/commandline/cifdump.py | .py | 7cda6810d25deab8 | 7.81 | 40 |
#!/usr/bin/env python
"""
Summarize the contents of an MTZ file.
Examples
--------
In order to summarize contents of file.mtz::
> rs.mtzdump file.mtz
If you would like to interactively inspect file.mtz in an IPython
shell, use the "--embed" argument::
> rs.mtzdump file.mtz --embed
If multiple MTZ files are... | rs-station/reciprocalspaceship | reciprocalspaceship/commandline/mtzdump.py | .py | 7eaa0a7f9731c3fa | 7.81 | 40 |
from functools import wraps
from inspect import signature
import gemmi
import numpy as np
import reciprocalspaceship as rs
def inplace(f):
"""
A decorator that applies the inplace argument.
Base function must have a bool param called "inplace" in the call
signature. The position of `inplace` argum... | rs-station/reciprocalspaceship | reciprocalspaceship/decorators.py | .py | b1900f015e5f939c | 7.81 | 40 |
from reciprocalspaceship.dtypes.internals import NumericArray, NumericDtype
class MTZDtype(NumericDtype):
"""Base ExtensionDtype for implementing persistent MTZ data types"""
def __repr__(self) -> str:
return f"{self.name}"
@property
def _is_numeric(self) -> bool:
return True
@c... | rs-station/reciprocalspaceship | reciprocalspaceship/dtypes/base.py | .py | d57e7a5388cab7fc | 7.81 | 40 |
# BSD 3-Clause License
#
# Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
# All rights reserved.
#
# Copyright (c) 2011-2023, Open source contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided th... | rs-station/reciprocalspaceship | reciprocalspaceship/dtypes/integer.py | .py | 202c0a2b60ffb949 | 7.81 | 40 |
import warnings
import gemmi
from reciprocalspaceship import DataSet
from reciprocalspaceship.dtypes.base import MTZDtype
from reciprocalspaceship.utils import in_asu
def from_gemmi(gemmi_mtz):
"""
Construct DataSet from gemmi.Mtz object
If the gemmi.Mtz object contains an M/ISYM column and contains du... | rs-station/reciprocalspaceship | reciprocalspaceship/io/mtz.py | .py | 5b04ed2d148b6a71 | 7.81 | 40 |
import numpy as np
import pandas as pd
import reciprocalspaceship as rs
from reciprocalspaceship.utils.asu import in_asu
from reciprocalspaceship.utils.stats import compute_redundancy
def compute_completeness(
dataset, bins=10, anomalous="auto", dmin=None, unobserved_value=np.nan
):
"""
Compute completen... | rs-station/reciprocalspaceship | reciprocalspaceship/stats/completeness.py | .py | d5033e01cfd5e7c9 | 7.81 | 40 |
import gemmi
import numpy as np
from reciprocalspaceship.decorators import cellify, spacegroupify
from reciprocalspaceship.utils.cell import generate_reciprocal_cell
from reciprocalspaceship.utils.structurefactors import is_absent, is_centric
from reciprocalspaceship.utils.symmetry import apply_to_hkl, phase_shift
# ... | rs-station/reciprocalspaceship | reciprocalspaceship/utils/asu.py | .py | 5b0c6f22afbf4041 | 7.81 | 40 |
import numpy as np
def assign_with_binedges(data, bin_edges, right_inclusive=True):
"""
Assign data using given bin edges. This function assumes that the bin edges
are monotonic, and that the resulting bins contain every entry in `data`.
If the smallest and largest values in `data` exactly match a bi... | rs-station/reciprocalspaceship | reciprocalspaceship/utils/binning.py | .py | 0877f9cfc12c1d28 | 7.81 | 40 |
import numpy as np
from reciprocalspaceship.decorators import cellify
@cellify
def compute_dHKL(H, cell):
"""
Compute the real space lattice plane spacing, d, associated with
miller indices and cell.
Parameters
----------
H : array
An nx3 array of numerical miller indices.
cell :... | rs-station/reciprocalspaceship | reciprocalspaceship/utils/cell.py | .py | 30279b4f21eb3e28 | 7.81 | 40 |
import gemmi
import numpy as np
from reciprocalspaceship.decorators import spacegroupify
def canonicalize_phases(phases, deg=True):
"""
Place phases in the interval between -180 and 180. deg == True implies
degrees; False implies radians.
"""
if deg == True:
return (phases + 180.0) % (2 *... | rs-station/reciprocalspaceship | reciprocalspaceship/utils/phases.py | .py | cf2884f7d6eaf935 | 7.81 | 40 |
import numpy as np
from reciprocalspaceship.dtypes import MTZIntDtype
def add_rfree(dataset, fraction=0.05, ccp4_convention=False, inplace=False, seed=None):
"""
Add an r-free flag to the dataset object for refinement.
R-free flags are used to identify reflections which are not used in automated refineme... | rs-station/reciprocalspaceship | reciprocalspaceship/utils/rfree.py | .py | a8581ea4b39f81d5 | 7.81 | 40 |
from os.path import abspath, dirname, join
import numpy as np
import pandas as pd
import pytest
import reciprocalspaceship as rs
@pytest.fixture(params=["hewl", "hewl_IMEAN_NaN", "hewl_I(+)_NaN"])
def data_hewl_all(data_merged, request):
if request.param == "hewl":
return data_merged
elif request.pa... | rs-station/reciprocalspaceship | tests/algorithms/conftest.py | .py | 375a7b4a40ca9afd | 7.31 | 40 |
import numpy as np
import pytest
import reciprocalspaceship as rs
@pytest.mark.parametrize("inplace", [True, False])
@pytest.mark.parametrize("output_columns", [None, ("I_CALC", "SigI_CALC")])
@pytest.mark.parametrize("test_na", [True, False])
def test_compute_intensity_from_structurefactor(
ref_hewl, inplace, o... | rs-station/reciprocalspaceship | tests/algorithms/test_intensity.py | .py | 59455630b23ad57b | 8.31 | 40 |
import numpy as np
import pytest
import reciprocalspaceship as rs
def test_merge_valueerror(hewl_merged):
"""
Confirm rs.algorithms.merge() raises ValueError when invoked with
merged DataSet
"""
with pytest.raises(ValueError):
merged = rs.algorithms.merge(hewl_merged)
@pytest.mark.param... | rs-station/reciprocalspaceship | tests/algorithms/test_merge.py | .py | 676d2b1d647c575f | 8.31 | 40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.