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
from specula import cpuArray from specula.base_data_obj import BaseDataObj from astropy.io import fits def cut_modes(matrix, start_mode=None, nmodes=None, idx_modes=None, modes_on_first_axis=True): """ Cut the an influence function (or an inverse one) to a subset of modes. Parameters ---------- ...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/ifunc_inv.py
.py
0e0f5f9e3a51a1e2
8.02
10
from seeing.integrator import evaluateFormula, cpulib from symao.turbolence import createTurbolenceFormulary, ft_phase_screen0 from specula.base_data_obj import BaseDataObj from specula import ASEC2RAD, RAD2ASEC, cpuArray, np turbolenceFormulas = createTurbolenceFormulary() def seeing_to_r0(seeing, wvl=500.e-9): ...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/infinite_phase_screen.py
.py
605b8e89d400cfdd
8.02
10
from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class Intensity(BaseDataObj): """ Intensity field data object. """ def __init__(self, dimx: int, dimy: int, target_device_idx: int=None, ...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/intensity.py
.py
5ca608d1b0a1492f
8.02
10
from astropy.io import fits from specula import cpuArray from specula.data_objects.electric_field import ElectricField class Layer(ElectricField): """ Layer data object. This object represents a layer in the atmosphere for wavefront propagation simulations. It inherits from the ElectricField class and...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/layer.py
.py
180d27f0070e289d
8.02
10
import numpy as np from astropy.io import fits from specula.lib.make_xy import make_xy from specula.base_data_obj import BaseDataObj class Lenslet(BaseDataObj): """ Lenslet data object. This class holds the information about the lenslet array, such as the number of lenses and their positions. ""...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/lenslet.py
.py
d185afe05fe4045f
8.02
10
from astropy.io import fits from specula import cpuArray from specula.data_objects.ifunc_inv import cut_modes from specula.base_data_obj import BaseDataObj class M2C(BaseDataObj): """ Modal to Command (M2C) matrix data object. This class holds the M2C matrix, which is used to convert modal coefficients ...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/m2c.py
.py
605e689dfb754eb4
8.02
10
from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class Phasescreen(BaseDataObj): """ Phasescreen field data object. """ def __init__(self, dimx: int, dimy: int, L0: float, seed:...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/phasescreen.py
.py
d4cd224f0e3b9b91
8.02
10
from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class Pixels(BaseDataObj): """ Pixels data object. Holds a 2d array of pixels, which can be signed or unsigned. The number of bits per pixel can be set, up to 64 bits. """ def __init__(self,...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/pixels.py
.py
4eed0afc554cfbfb
8.02
10
import numpy as np from astropy.io import fits from specula.base_data_obj import BaseDataObj from specula import cpuArray class PupData(BaseDataObj): """ Pupil data object. This class holds the information about the pupils of a Pyramid WFS (or a Zernike WFS). PupData includes an ind_pup array with the...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/pupdata.py
.py
ab033a31cf558a9c
8.02
10
import warnings from astropy.io import fits from specula.data_objects.layer import Layer from specula.lib.make_mask import make_mask from specula.data_objects.simul_params import SimulParams from specula import cpuArray class Pupilstop(Layer): """ Pupil stop data object. This class holds the information...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/pupilstop.py
.py
7657a6a178577dd0
8.02
10
import numpy as np from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class Recmat(BaseDataObj): """ Reconstruction matrix data object. This class holds the information about the reconstruction matrix, which maps slopes to modes. The reconstruction...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/recmat.py
.py
addb69811616e351
8.02
10
from specula.base_data_obj import BaseDataObj from typing import List class SimulParams(BaseDataObj): """ Simulation Parameters data object. This class holds the parameters of the simulation, such as pixel size, time step, total time, zenith angle, etc. """ def __init__(self, p...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/simul_params.py
.py
ae6a85260f959356
8.02
10
from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj from specula.base_value import BaseValue class Slopes(BaseDataObj): """ Slopes data object. Holds a slopes vector, which can be interleaved (XYXYXY...) or not (XXX...YYY...). X and Y slopes can be a...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/slopes.py
.py
814fe9533b236afb
8.02
10
import numpy as np from astropy.io import fits from specula.base_data_obj import BaseDataObj from specula.lib.n_phot import n_phot from specula import ASEC2RAD degree2rad = np.pi / 180. class Source(BaseDataObj): """ Source data object. Holds the properties of a source, such as polar coordinates, magnit...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/source.py
.py
3233e82ea19bce68
8.02
10
import os from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class SpatioTempArray(BaseDataObj): """ Spatio-temporal array data object. This class holds a multi-dimensional spatio-temporal array with an associated time vector. Input arrays can have ...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/spatio_temp_array.py
.py
f98cb402a8535a65
8.02
10
import math import numpy as np from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class SubapData(BaseDataObj): """ Subaperture data object. This class holds the information about the subapertures, i.e. the indices of the pixels belonging to each s...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/subap_data.py
.py
a42799e5013f7c22
8.02
10
from astropy.io import fits from specula import cpuArray from specula.base_data_obj import BaseDataObj class TimeHistory(BaseDataObj): """ Time history data object. This class holds the time history of a variable, such as the seeing value, during the simulation. The time history is stored as a 1D ar...
ArcetriAdaptiveOptics/SPECULA
specula/data_objects/time_history.py
.py
b11a45b4b74d4750
8.02
10
import matplotlib.pyplot as plt from specula.scalar_values import IntValue from specula.base_processing_obj import BaseProcessingObj from specula.base_processing_obj import OutputDesc def runningOnNotebook(): try: from IPython import get_ipython return get_ipython() is not None and 'IPKernelApp' i...
ArcetriAdaptiveOptics/SPECULA
specula/display/base_display.py
.py
8eea9253b668d220
8.02
10
import matplotlib import numpy as np matplotlib.use('Agg') # Memory backend, no GUI from matplotlib.figure import Figure dataplotter_cache = {} class DataPlotter(): ''' Plot any kind of data in a memory backend ''' def __init__(self, disp_factor=1, histlen=200, wsize=(400, 300), yrange=(-10, 10), ti...
ArcetriAdaptiveOptics/SPECULA
specula/display/data_plotter.py
.py
bea5384c25bdcc1f
8.02
10
import numpy as np from specula import cpuArray from specula.display.base_display import BaseDisplay from specula.connections import InputValue from specula.data_objects.electric_field import ElectricField from symao.turbolence import ft_ft2 class DoublePhaseDisplay(BaseDisplay): def __init__(self, ...
ArcetriAdaptiveOptics/SPECULA
specula/display/double_phase_display.py
.py
c0e22721bcfdde8b
8.02
10
import numpy as np from specula.display.base_display import BaseDisplay from specula.connections import InputValue from specula.base_value import BaseValue from specula import cpuArray class ModesDisplay(BaseDisplay): def __init__(self, title='Modes Display', figsize=(6, 3), ...
ArcetriAdaptiveOptics/SPECULA
specula/display/modes_display.py
.py
f4f28bcd665d618d
8.02
10
import numpy as np from specula import cpuArray from specula.display.base_display import BaseDisplay from specula.connections import InputValue from specula.data_objects.electric_field import ElectricField class PhaseDisplay(BaseDisplay): def __init__(self, title='Phase Display', ...
ArcetriAdaptiveOptics/SPECULA
specula/display/phase_display.py
.py
d505f9edade88c10
8.02
10
import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as mcolors from specula import xp from specula import cpuArray from specula.display.base_display import BaseDisplay from specula.connections import InputValue from specula.data_objects.pixels import Pixels from specula.data_objects.subap_dat...
ArcetriAdaptiveOptics/SPECULA
specula/display/pixels_display.py
.py
d27ef48ae7e4c15d
8.02
10
import numpy as np import matplotlib.colors as mcolors from specula import cpuArray from specula.display.base_display import BaseDisplay from specula.connections import InputValue from specula.base_value import BaseValue class PsfDisplay(BaseDisplay): def __init__(self, title='PSF Display', ...
ArcetriAdaptiveOptics/SPECULA
specula/display/psf_display.py
.py
cc73f601322716d1
8.02
10
"""Produce the public OpenAPI document served at docs.rapidata.ai/openapi.json. The combined spec under ``openapi/schemas/`` is the contract the SDK is generated from, but it carries the internal ``rabbitdata.ch`` host and an inaccurate title. Rewrite those to the public ``rapidata.ai`` host (which already serves the ...
RapidataAI/rapidata-python-sdk
scripts/build_public_openapi.py
.py
c1959fc82a4e97f8
7.63
17
""" Visualization backend for Pyroelectricity measurements using the Keithley 6517B. Handles real-time data plotting and formatting. """ import pandas as pd import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import os import tkinter from tkinter import filedialog def select_file(): # I...
prathameshnium/PICA-Python-Instrument-Control-and-Automation
pica/keithley/k6517b/Pyroelectricity/Instrument_Control/PyroDataVisualization_Simple_Instrument_Control.py
.py
9973d1c76733aa7c
7.56
12
#!/usr/bin/env python3 """Pre-sync hook that aborts the sync while a named process is running. Syncing while the Unreal editor is open lets p4 replace assets the editor still has loaded, so the editor keeps working against files that no longer match what is on disk. This hook blocks the sync until it is closed. Insta...
neoboid/git-p4son
examples/hooks/pre-sync/block-while-running.py
.py
feadf177942ff1fc
7.5
9
""" Changelist alias utilities for git-p4son. Stores named aliases for changelist numbers in .git-p4son/changelists/<name>. """ import os import re from . import CONFIG_DIR from .log import log RESERVED_KEYWORDS = frozenset({'last-synced', 'head', 'branch'}) # Allowed characters: ASCII letters, digits, hyphen, un...
neoboid/git-p4son
git_p4son/changelist_store.py
.py
13c18305a0a8f9ce
7.5
9
""" Configuration management for git-p4son. Reads and writes per-repo config stored in .git-p4son/config.toml. """ import os import re import tomllib from . import CONFIG_DIR _BARE_KEY_RE = re.compile(r'^[A-Za-z0-9_-]+$') # Placeholder allowed in a stored depot root, substituted with the live # Perforce client (wo...
neoboid/git-p4son
git_p4son/config.py
.py
ea0d5eea76db8885
7.5
9
"""User hook discovery and execution.""" import os import sys from pathlib import Path from . import CONFIG_DIR from .common import RunResult, run from .config import load_config from .log import log DEFAULT_WINDOWS_ASSOCIATIONS: dict[str, list[str]] = { '.ps1': [ 'powershell.exe', '-NoProfile', '-Execut...
neoboid/git-p4son
git_p4son/hooks.py
.py
57af090bf84ae7b1
7.5
9
""" Init command implementation for git-p4son. Sets up a new git repository inside a Perforce workspace with an initial commit containing .gitignore. """ import argparse import os import shutil from .common import CommandError, run, run_with_output from .config import ( WORKSPACE_PLACEHOLDER, expand_depot_ro...
neoboid/git-p4son
git_p4son/init.py
.py
dde2f1dfbdac3fa7
7.5
9
""" List-changes command implementation for git-p4son. """ import argparse from .git import get_commit_subjects_since from .log import log def get_enumerated_commit_lines_since(base_branch: str, workspace_dir: str, start_number: int = 1) -> list[str]: """Get enumerated commit lines from git log since base branch...
neoboid/git-p4son
git_p4son/list_changes.py
.py
7f8262b8035286d0
7.5
9
""" Structured output module for git-p4son. All user-facing output goes through the module-level `log` singleton. This centralises formatting, verbosity filtering, and future color support. """ import shutil import sys import threading from datetime import timedelta # Heading prefix — single constant, easy to change...
neoboid/git-p4son
git_p4son/log.py
.py
78fdc2d006b12030
7.5
9
""" Review command implementation for git-p4son. Automates the interactive rebase workflow by generating a rebase todo file with exec lines that run git p4son new/update for each commit. """ import argparse import os import shlex import subprocess from . import CONFIG_DIR from .changelist_store import alias_exists, v...
neoboid/git-p4son
git_p4son/review.py
.py
7bfa225a66ca0e63
7.5
9
""" Local, per-user state for git-p4son. Stored in .git-p4son/state.toml, which is kept out of version control (unlike config.toml, which carries shared repo setup). State here reflects a single user's workspace and preferences, e.g. dismissed warnings. """ import os from . import CONFIG_DIR from .config import load...
neoboid/git-p4son
git_p4son/state.py
.py
2ee3d4d31406c129
7.5
9
#!/usr/bin/env python3 """Bump the version of git-p4son. Two-step workflow: 1. bump-version.py [patch|minor|major] — bump version files, generate changelog 2. (edit CHANGELOG.md if desired) 3. bump-version.py --finalize — commit and tag """ import argparse import re import subprocess import sys from...
neoboid/git-p4son
scripts/bump-version.py
.py
93d361617efaeae1
7.5
9
"""Shared test helpers for git_p4son tests.""" from git_p4son.common import RunResult def make_run_result(returncode=0, stdout=None, stderr=None, elapsed=None): """Factory for RunResult objects. Args: returncode: Process return code (default 0). stdout: List of stdout lines (default empty). ...
neoboid/git-p4son
tests/helpers.py
.py
67b6e74f5146e7b6
8
9
"""Shared CLI parsing helpers for variable and fallback definitions. Used by both ``ref register`` and ``model register`` commands. """ from __future__ import annotations import shlex from typing import Any import click from openbench.util.names import ( AmbiguousNameError, get_mapping_key_case_insensitive...
zhongwangwei/OpenBench
src/openbench/cli/_parsing.py
.py
497d8faaa3a1feaf
7.59
14
"""Shared navigation helpers for interactive CLI workflows.""" from __future__ import annotations from collections.abc import Callable, Sequence from typing import Any import click class BackRequested(Exception): """Return control to the previous interactive step.""" class _BackAwareType(click.ParamType): ...
zhongwangwei/OpenBench
src/openbench/cli/_wizard.py
.py
f66cf1ec89ca3f88
7.59
14
"""openbench cache commands.""" from __future__ import annotations import json from pathlib import Path import click def _format_bytes(size: int) -> str: value = float(size) for unit in ("B", "KiB", "MiB", "GiB"): if value < 1024 or unit == "GiB": return f"{value:.1f} {unit}" if unit !=...
zhongwangwei/OpenBench
src/openbench/cli/cache.py
.py
f109b3e5c47079cf
7.59
14
"""openbench ref commands.""" from pathlib import Path import click from openbench.cli import _display, _optimize, _profile_rescue, _ref_commands, _register, _scan, _scan_support from openbench.cli._options import TIM_RES_TYPE, expand_existing_directory, expand_path from openbench.cli._parsing import FALLBACK_OPTION...
zhongwangwei/OpenBench
src/openbench/cli/data.py
.py
abae0a7dc321552d
7.59
14
"""OpenBench CLI entry point. Uses lazy command loading to avoid importing all submodules at startup. """ import importlib import click from openbench import __version__ class LazyGroup(click.Group): """Click group that lazily loads subcommands on first use.""" COMMAND_MAP = { "run": "openbench.c...
zhongwangwei/OpenBench
src/openbench/cli/main.py
.py
2cd38df9bd43bf45
7.59
14
"""``openbench registry`` — inspect and re-sparse the user registry overlay. The user overlay (``~/.openbench/...``) deep-merges on top of the bundled catalog and should contain only sparse deltas. A bloated overlay (e.g. a legacy full snapshot) silently shadows bundled fixes. These commands make that visible and let ...
zhongwangwei/OpenBench
src/openbench/cli/registry_cmd.py
.py
9c1d2a9459c1d788
7.59
14
"""OpenBench configuration schema defined as dataclasses. Each section of openbench.yaml maps to a dataclass with typed fields and sensible defaults. The top-level OpenBenchConfig holds everything. """ from __future__ import annotations from dataclasses import dataclass, field from pathlib import PurePosixPath, Pure...
zhongwangwei/OpenBench
src/openbench/config/schema.py
.py
dd6b76574c51ecc2
7.59
14
"""Small persistent user settings for OpenBench CLI behavior.""" from __future__ import annotations import os from pathlib import Path from tempfile import NamedTemporaryFile from typing import Any import yaml SETTINGS_FILE_NAME = "settings.yaml" USER_CONFIG_DIR_NAME = ".openbench" def resolve_home_dir() -> Path:...
zhongwangwei/OpenBench
src/openbench/config/user_settings.py
.py
7216dec4e122e1e9
7.59
14
"""Common comparison-processing helpers split out of comparison.py.""" from __future__ import annotations import gc import logging import os import sys import xarray as xr from joblib import Parallel from openbench.util.netcdf import write_netcdf_atomic as _write_netcdf_atomic def _comparison_attr(name: str, fall...
zhongwangwei/OpenBench
src/openbench/core/_comparison_common.py
.py
a36a14a564088aba
7.59
14
# -*- coding: utf-8 -*- """Shared helpers for comparison processing. Kept outside the large ``comparison.py`` orchestration class so filename, station-alignment, and atomic-write behavior can be reviewed independently. """ from __future__ import annotations from contextlib import contextmanager import logging import...
zhongwangwei/OpenBench
src/openbench/core/_comparison_helpers.py
.py
88770284fd645d6e
7.59
14
import shutil from datetime import datetime, timezone from enum import Enum from pathlib import Path from typing import Any from loguru import logger from luxonis_ml.nn_archive import is_nn_archive from luxonis_ml.nn_archive.config import Config as NNArchiveConfig from luxonis_ml.nn_archive.config_building_blocks impo...
luxonis/modelconverter
modelconverter/cli/utils.py
.py
86c74bf91a4acf39
7.59
14
import re from abc import ABC, abstractmethod from collections.abc import Iterable from pathlib import Path from typing import Any, TypeAlias import polars as pl from loguru import logger from modelconverter.utils import is_hubai_model_variant_available, resolve_path Configuration: TypeAlias = dict[str, Any] class...
luxonis/modelconverter
modelconverter/packages/base_benchmark.py
.py
c2cea50eec771bdf
7.59
14
import os from pathlib import Path, PurePosixPath from typing import Final from luxonis_ml.utils.registry import Registry def in_docker() -> bool: """Whether this process runs inside a modelconverter container.""" return "IN_DOCKER" in os.environ def get_cache_dir() -> Path: """Returns the hidden, auto...
luxonis/modelconverter
modelconverter/utils/constants.py
.py
fa081c26163f01d7
7.59
14
import os from contextvars import ContextVar from pathlib import Path from luxonis_ml.utils import LuxonisFileSystem from modelconverter.utils.constants import SHARED_DIR, in_docker # Base directory against which relative local paths are resolved when they do # not exist as-is. It is set to the directory of the acti...
luxonis/modelconverter
modelconverter/utils/filesystem_utils.py
.py
7abeec20548cf83e
7.59
14
import re from pathlib import Path from loguru import logger def _normalize_underscores(s: str) -> str: return re.sub(r"_+", "_", s) def sanitize_net_name(name: str, with_suffix: bool = False) -> str: """Sanitize net name or path. If input is a path, only sanitize the basename. If input is a name, ...
luxonis/modelconverter
modelconverter/utils/general.py
.py
67cfb3b04dd2a27b
7.59
14
from hubai_sdk import HubAIClient from hubai_sdk.errors import ResourceNotFoundError from hubai_sdk.utils.environ import environ as hubai_sdk_environ from modelconverter.utils.environ import environ def create_hubai_client() -> HubAIClient: """Create an authenticated HubAI SDK client using ModelConverter setting...
luxonis/modelconverter
modelconverter/utils/hubai_utils.py
.py
d61901613e44870a
7.59
14
def make_default_layout(shape: list[int]) -> str: """Creates a default layout for the given shape. Tries to guess most common layouts for the given shape pattern. Otherwise, uses the first free letter of the alphabet for each dimension. Example: >>> make_default_layout([1, 3, 256, 256]) ...
luxonis/modelconverter
modelconverter/utils/layout.py
.py
c5b948d33c869a92
7.59
14
from collections.abc import Iterable, Iterator from pathlib import Path import ml_dtypes import numpy as np import onnx from onnx.external_data_helper import ExternalDataInfo, uses_external_data def ensure_onnx_helper_compatibility() -> None: helper = onnx.helper def _convert_scalar( value: float, d...
luxonis/modelconverter
modelconverter/utils/onnx_compatibility.py
.py
4711d9d4dffd99c7
7.59
14
""" orion.ack_providers.base Abstract base class for ACK providers. """ from abc import ABC, abstractmethod from typing import List, Dict, Any, Optional class AckProvider(ABC): """ Abstract base class for acknowledgment providers. Providers are responsible for retrieving and creating acknowledgments ...
cloud-bulldozer/orion
orion/ack_providers/base.py
.py
64089907b4e3b5ce
7.52
10
""" orion.ack_providers.file_provider File-based ACK provider using YAML files. """ import os from typing import List, Dict, Any, Optional import yaml from orion.ack_providers.base import AckProvider from orion.config import load_ack from orion.logger import SingletonLogger class FileAckProvider(AckProvider): ...
cloud-bulldozer/orion
orion/ack_providers/file_provider.py
.py
ba466e4ef719f544
7.52
10
"""Module for Generic Algorithm class""" from abc import ABC, abstractmethod import pandas as pd from otava.series import Series, Metric class Algorithm(ABC): # pylint: disable = too-many-arguments, too-many-instance-attributes """Generic Algorithm class for algorithm factory""" def __init__( self, ...
cloud-bulldozer/orion
orion/algorithms/algorithm.py
.py
8e73923d444958d1
7.52
10
""" Algorithm Factory to choose avaiable algorithms """ import pandas as pd import orion.constants as cnsts from .edivisive import EDivisive from .edivisive import OrigEDivisive from .isolationforest import IsolationForestWeightedMean from .cmr import CMR class AlgorithmFactory: # pylint: disable= too-few-public-meth...
cloud-bulldozer/orion
orion/algorithms/algorithmFactory.py
.py
fedd0066480e872b
7.52
10
"""Original E-Divisive Algorithm from apache_otava""" from otava.series import AnalysisOptions from orion.algorithms.edivisive.edivisive import EDivisive class OrigEDivisive(EDivisive): """Original E-Divisive algorithm variant. Overrides the analysis options to use the original E-Divisive changepoint de...
cloud-bulldozer/orion
orion/algorithms/edivisive/origEdivisive.py
.py
19f9b8c9a9d203f7
7.52
10
""" Logger as a common package """ import logging import sys class SingletonLogger: """Singleton logger to set logging at one single place Returns: _type_: _description_ """ instance = {} def __new__(cls, debug: int, name: str): if (not cls.instance) or name not in cls.instance...
cloud-bulldozer/orion
orion/logger.py
.py
e19c2bfce67ad0d0
7.52
10
"""AnalysisResult dataclass and standalone utility functions.""" from dataclasses import dataclass, field from itertools import groupby from typing import Dict, List import pandas as pd from otava.series import Series, ChangePoint, ChangePointGroup @dataclass class AnalysisResult: # pylint: disable=too-many-instance...
cloud-bulldozer/orion
orion/pipeline/analysis_result.py
.py
0c7a21cf15d07abb
7.52
10
"""Formatter classes for Orion output.""" import orion.constants as cnsts from .base import BaseFormatter from .json_formatter import JsonFormatter from .text_formatter import TextFormatter from .junit_formatter import JUnitFormatter class FormatterFactory: # pylint: disable=too-few-public-methods """Factory for...
cloud-bulldozer/orion
orion/pipeline/formatters/__init__.py
.py
8bc7426527ce6764
7.52
10
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
cloud-bulldozer/orion
orion/reporting/report.py
.py
5b319e89e7fc47e5
7.52
10
""" orion.reporting.standalone Module for generating standalone regression reports from orion JSON output files. """ import json import os from orion.logger import SingletonLogger from .summary import print_regression_summary # Box-drawing characters for report formatting _BOX_TOP_LEFT = "\u2554" _BOX_TOP_RIGHT = "...
cloud-bulldozer/orion
orion/reporting/standalone.py
.py
596ce6c03dcb2708
7.52
10
""" Regression summary formatting. Prints changepoint details: affected metrics, PRs, and GitHub context. Used by both the normal orion run output and the standalone --report mode. """ from tabulate import tabulate def print_regression_summary(regression_data) -> None: """Print regression summary: affected metr...
cloud-bulldozer/orion
orion/reporting/summary.py
.py
db29f8cfd3bcca14
7.52
10
# pylint: disable=protected-access """Tests for CMR direction filtering in _analyze().""" import pandas as pd import pytest from orion.algorithms.cmr.cmr import CMR def _make_test_config(): return { "name": "test-cmr", "uuid_field": "uuid", "version_field": "ocpVersion", } def _make...
cloud-bulldozer/orion
orion/tests/test_cmr_direction.py
.py
f4b39c923906298a
8.02
10
""" Test that _attach_viz_to_jira scopes attachments per PR. The fix (main.py) calls auto_create_jira_issues once per PR and stores results in issue_keys_by_test_pull_by_pr keyed by pr_num. Each PR's viz files are then attached only to that PR's JIRA issues. CodeRabbit review: https://github.com/cloud-bulldozer/orion...
cloud-bulldozer/orion
orion/tests/test_jira_viz_attachment.py
.py
e4914de5d9e36ffd
8.02
10
""" Gitlint extra rule to validate that the message title is of the form "<gitmoji>(<scope>) <subject>" """ from __future__ import unicode_literals import re import requests from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation class GitmojiTitle(LineRule): """ This rule will enforce that e...
suitenumerique/drive-migrator
gitlint/gitlint_emoji.py
.py
ec4dc0bfb62192d4
7.45
7
"""API endpoints""" from django.core.exceptions import ValidationError from rest_framework import exceptions as drf_exceptions from rest_framework import views as drf_views from rest_framework.exceptions import APIException as ExistingAPIException from rest_framework.status import HTTP_403_FORBIDDEN def exception_ha...
suitenumerique/drive-migrator
src/backend/core/api/__init__.py
.py
07c8adfbcc394272
7.45
7
"""A JSONField for DRF to handle serialization/deserialization.""" import json from rest_framework import serializers class JSONField(serializers.Field): """ A custom field for handling JSON data. """ def to_representation(self, value): """ Convert the JSON string to a Python diction...
suitenumerique/drive-migrator
src/backend/core/api/fields.py
.py
1fedf91ebfd94eb5
7.45
7
"""Available destinations endpoint.""" from rest_framework.response import Response from rest_framework.views import APIView from core.api.permissions import IsAuthenticated from core.backends.destination import DestinationRegistry class AvailableDestinationsAPIView(APIView): """Return the list of destinations ...
suitenumerique/drive-migrator
src/backend/core/api/views/available_destinations.py
.py
38ea4d3d3d00ec44
7.45
7
# pylint: skip-file """Development views.""" from django.conf import settings from django.http import Http404, HttpResponse from core.destinations.resana.resana_backend import ResanaBackend from core.models import Workspace from core.sources.osmose.osmose_backend import OsmoseFolder, OsmoseManager from ...processing....
suitenumerique/drive-migrator
src/backend/core/api/views/dev.py
.py
4251a0c478e3f96d
7.45
7
from django.conf import settings from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView class MigrationConfigApiView(APIView): """Expose migration-related settings the frontend needs to display to users.""" permission_clas...
suitenumerique/drive-migrator
src/backend/core/api/views/migration_config.py
.py
1cdceaca66b2afb1
7.45
7
"""Synchronize API view.""" from rest_framework.response import Response from rest_framework.views import APIView from core.api import APIException from core.api.permissions import IsAuthenticated from core.backends.source import SourceManager from core.models import FeatureFlag from core.sources.resana.token_manager ...
suitenumerique/drive-migrator
src/backend/core/api/views/synchronize.py
.py
aa56a62033c98801
7.45
7
"""Workspaces viewsets""" from django.forms.fields import UUIDField from django_filters.rest_framework import DjangoFilterBackend, FilterSet from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.response import Response from ...destinations.resana.resana_backend import R...
suitenumerique/drive-migrator
src/backend/core/api/views/workspaces.py
.py
813e0b51c1cff23c
7.45
7
from django.conf import settings from django_celery_results.models import TaskResult from rest_framework.response import Response from rest_framework.views import APIView from core.sources.osmose.serializers import WorkspaceSerializer from ...destinations.drive.drive_backend import DriveUserTokenBackend from ...dest...
suitenumerique/drive-migrator
src/backend/core/api/views/workspaces_process.py
.py
965b28771059f00c
7.45
7
from rest_framework import ( decorators, mixins, pagination, viewsets, ) from rest_framework.response import Response from core import models from . import permissions, serializers class Pagination(pagination.PageNumberPagination): """Pagination to display no more than 100 objects per page sorte...
suitenumerique/drive-migrator
src/backend/core/api/viewsets.py
.py
41536073b09e6be9
7.45
7
"""Authentication Backends for the core app.""" from datetime import timedelta from django.core.exceptions import SuspiciousOperation from django.utils import timezone from django.utils.translation import gettext_lazy as _ import requests from mozilla_django_oidc.auth import ( OIDCAuthenticationBackend as Mozill...
suitenumerique/drive-migrator
src/backend/core/authentication/backends.py
.py
6dfdd9825330fc40
7.45
7
"""Authentication Views for the People core app.""" from urllib.parse import urlencode from django.contrib import auth from django.core.exceptions import SuspiciousOperation from django.http import HttpResponseRedirect from django.urls import reverse from django.utils import crypto from mozilla_django_oidc.utils imp...
suitenumerique/drive-migrator
src/backend/core/authentication/views.py
.py
7c00e2a0351e4886
7.45
7
"""Abstract destination backend interface and destination registry.""" from abc import ABC, abstractmethod from django.conf import settings from django.utils.module_loading import import_string class AbstractDestinationBackend(ABC): """ Contract for any platform that can receive a migrated workspace. `...
suitenumerique/drive-migrator
src/backend/core/backends/destination.py
.py
a2a9a80314c78ed0
7.45
7
"""Abstract source backend interface, source data types, and source manager.""" from abc import ABC, abstractmethod from dataclasses import dataclass, field from django.conf import settings from django.utils.module_loading import import_string from core.models import Workspace @dataclass class SourceFile: """A...
suitenumerique/drive-migrator
src/backend/core/backends/source.py
.py
5a12f43816534aba
7.45
7
"""ArchiveDestinationBackend — wraps ArchiveManager and implements AbstractDestinationBackend.""" import csv import os from django.conf import settings from django.utils.translation import gettext_lazy as _ from core.backends.destination import AbstractDestinationBackend from core.mails_manager import MailsManager f...
suitenumerique/drive-migrator
src/backend/core/destinations/archive/backend.py
.py
0e8fb95f51c1ecbb
7.45
7
"""DriveDestinationBackend — uploads a workspace to La Suite Drive.""" import csv import os from django.conf import settings from django.utils.translation import gettext_lazy as _ from core.backends.destination import AbstractDestinationBackend from core.destinations.drive.drive_backend import ( DriveServiceAcco...
suitenumerique/drive-migrator
src/backend/core/destinations/drive/backend.py
.py
b2fdfcd3cb5c7ac8
7.45
7
"""DriveBackend — HTTP client for La Suite Drive API.""" import logging import time from datetime import timedelta from django.conf import settings from django.utils import timezone import requests from celery.utils.log import get_task_logger from requests.exceptions import ConnectionError as RequestsConnectionError...
suitenumerique/drive-migrator
src/backend/core/destinations/drive/drive_backend.py
.py
0ac622334feb5174
7.45
7
"""ResanaDestinationBackend — wraps ResanaBackend and implements AbstractDestinationBackend.""" import csv import os from core.backends.destination import AbstractDestinationBackend from core.destinations.resana.resana_backend import ResanaBackend from core.models import Workspace class ResanaDestinationBackend(Abs...
suitenumerique/drive-migrator
src/backend/core/destinations/resana/backend.py
.py
407118061db0764f
7.45
7
"""Symmetric encryption helpers for sensitive fields stored in the database.""" from django.conf import settings from cryptography.fernet import Fernet def _fernet() -> Fernet: key = settings.OIDC_TOKENS_ENCRYPTION_KEY return Fernet(key.encode() if isinstance(key, str) else key) def encrypt_token(value: s...
suitenumerique/drive-migrator
src/backend/core/encryption.py
.py
c44a2b633dfff8c7
7.45
7
# ruff: noqa: S311 """ Core application factories """ from django.conf import settings from django.contrib.auth.hashers import make_password import factory.fuzzy from faker import Faker from core import models class UserFactory(factory.django.DjangoModelFactory): """A factory to random users for testing purpose...
suitenumerique/drive-migrator
src/backend/core/factories.py
.py
c32acdf656ae9bac
7.45
7
from django.conf import settings from django.contrib.sites.models import Site from django.core import mail from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ from celery.utils.log import get_task_logger from core.backends.source import SourceManager from core.mo...
suitenumerique/drive-migrator
src/backend/core/mails_manager.py
.py
64d7a4a158dd7989
7.45
7
"""Command to refresh workspaces resana status via pooling jobs status""" import sys import time from pathlib import Path from django.core.management.base import BaseCommand LIVENESS_FILE = Path("/tmp/celery_worker_heartbeat") # noqa: S108 class Command(BaseCommand): """Command to check the liveness of Celery"...
suitenumerique/drive-migrator
src/backend/core/management/commands/celery_liveness.py
.py
49220020568e4ad5
7.45
7
"""Build optional cython modules.""" import logging import os from distutils.command.build_ext import build_ext from typing import Any _LOGGER = logging.getLogger(__name__) try: from setuptools import Extension except ImportError: from distutils.core import Extension TO_CYTHONIZE = ["src/bleak_esphome/back...
Bluetooth-Devices/bleak-esphome
build_ext.py
.py
0f9fb9dbf3f039fd
7.5
9
"""Bluetooth cache for esphome.""" from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING from lru import LRU # pylint: disable=no-name-in-module if TYPE_CHECKING: from collections.abc import MutableMapping from bleak.backends.service import BleakGATTS...
Bluetooth-Devices/bleak-esphome
src/bleak_esphome/backend/cache.py
.py
b82251cbf7ea1ed7
7.5
9
"""Bluetooth device models for esphome.""" from __future__ import annotations import asyncio import logging from dataclasses import dataclass, field from typing import TYPE_CHECKING from bleak_retry_connector import Allocations from bluetooth_data_tools import int_to_bluetooth_address from .cache import ESPHomeBlue...
Bluetooth-Devices/bleak-esphome
src/bleak_esphome/backend/device.py
.py
db9c99c7b06d9ae2
7.5
9
"""Bluetooth scanner for esphome.""" from __future__ import annotations import asyncio import logging import math from typing import TYPE_CHECKING, Any from aioesphomeapi import ( APIClient, APIConnectionError, BluetoothLEAdvertisement, BluetoothLERawAdvertisementsResponse, BluetoothScannerMode, ...
Bluetooth-Devices/bleak-esphome
src/bleak_esphome/backend/scanner.py
.py
76626b5b42a3c7ae
7.5
9
"""Bluetooth support for esphome.""" from __future__ import annotations import logging from functools import partial from typing import TYPE_CHECKING from aioesphomeapi import APIClient, BluetoothProxyFeature, DeviceInfo from habluetooth import HaBluetoothConnector, get_manager from .backend.client import ESPHomeCl...
Bluetooth-Devices/bleak-esphome
src/bleak_esphome/connect.py
.py
d5c6bf6ff806bba3
7.5
9
from __future__ import annotations import asyncio import logging from typing import TYPE_CHECKING, TypedDict import habluetooth from aioesphomeapi import APIClient, ReconnectLogic import bleak_esphome from ._cancellation import is_spurious_cancellation if TYPE_CHECKING: from collections.abc import Callable ...
Bluetooth-Devices/bleak-esphome
src/bleak_esphome/connection_manager.py
.py
7c1b4253c47dbe60
7.5
9
from typing import Any from bleak.backends.scanner import BLEDevice BLE_DEVICE_DEFAULTS = { "name": None, "details": None, } def generate_ble_device( address: str | None = None, name: str | None = None, details: Any | None = None, **kwargs: Any, ) -> BLEDevice: """Generate a BLEDevice wi...
Bluetooth-Devices/bleak-esphome
tests/__init__.py
.py
bb72ba68de732618
7
9
"""Importable helpers and constants for ``tests/backend``.""" from __future__ import annotations import asyncio from contextlib import contextmanager from typing import TYPE_CHECKING, Any from unittest.mock import Mock, patch from bleak import BleakClient from bleak.backends.device import BLEDevice from bleak_espho...
Bluetooth-Devices/bleak-esphome
tests/backend/_helpers.py
.py
71101f5836e93b8d
8
9
"""Tests for ESPHomeBluetoothCache.""" from __future__ import annotations from bleak.backends.service import BleakGATTServiceCollection from bleak_esphome.backend.cache import MAX_CACHED_SERVICES, ESPHomeBluetoothCache def test_get_gatt_services_cache_miss_returns_none() -> None: """An unknown address yields `...
Bluetooth-Devices/bleak-esphome
tests/backend/test_cache.py
.py
7ab463fb990b4117
7
9
from unittest.mock import AsyncMock, Mock, patch import pytest from aioesphomeapi import ( APIClient, APIVersion, BluetoothProxyFeature, DeviceInfo, ReconnectLogic, ) from bleak_retry_connector import BleakSlotManager from bluetooth_adapters import AdapterDetails, BluetoothAdapters from habluetooth...
Bluetooth-Devices/bleak-esphome
tests/conftest.py
.py
97ddb0fbf47f6956
8
9