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 |
|---|---|---|---|---|---|---|
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying... | aws-controllers-k8s/sqs-controller | test/e2e/conftest.py | .py | ba19b750a37ca8ed | 7.04 | 11 |
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying... | aws-controllers-k8s/sqs-controller | test/e2e/fixtures.py | .py | b000b89cf96d83da | 7.04 | 11 |
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying... | aws-controllers-k8s/sqs-controller | test/e2e/sqsqueue.py | .py | 25c8c27c3e90f56e | 7.04 | 11 |
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanyin... | aws-controllers-k8s/sqs-controller | test/e2e/tests/test_queue.py | .py | ae8006335c46109f | 7.04 | 11 |
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanyin... | aws-controllers-k8s/sqs-controller | test/e2e/tests/test_queue_irs.py | .py | 32414431c16abf96 | 8.04 | 11 |
import asyncio
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
import importlib.resources
import os
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import PlainTextResponse
from fastapi.staticfiles import StaticFiles
f... | DigitalSlideArchive/ImageDePHI | imagedephi/gui/app.py | .py | 00e1d44685c8023d | 7.56 | 12 |
from __future__ import annotations
from collections.abc import Generator
from datetime import date, datetime
from pathlib import Path
from typing import TYPE_CHECKING
from uuid import uuid4
import pydicom
from pydicom import valuerep
from pydicom.datadict import keyword_for_tag
from pydicom.dataelem import DataElemen... | DigitalSlideArchive/ImageDePHI | imagedephi/redact/dicom.py | .py | 7e6d6464d112bfcc | 7.56 | 12 |
from __future__ import annotations
import binascii
from pathlib import Path
from typing import TYPE_CHECKING
import tifftools
import tifftools.constants
from imagedephi.rules import (
ConcreteMetadataRule,
FileFormat,
MetadataReplaceRule,
RedactionOperation,
SvsRules,
)
from imagedephi.utils.logg... | DigitalSlideArchive/ImageDePHI | imagedephi/redact/svs.py | .py | 3a953f846a476930 | 7.56 | 12 |
from __future__ import annotations
import binascii
from collections.abc import Generator
from io import BytesIO
from pathlib import Path
import re
from typing import TYPE_CHECKING, Any
from PIL import Image, TiffTags
from PIL.TiffImagePlugin import ImageFileDirectory_v2
import tifftools
import tifftools.constants
fr... | DigitalSlideArchive/ImageDePHI | imagedephi/redact/tiff.py | .py | c8ec82f7ad9154b7 | 7.56 | 12 |
import asyncio
from collections.abc import Callable, Coroutine
from functools import wraps
from typing import Any, ParamSpec, TypeVar
import click
T = TypeVar("T")
P = ParamSpec("P")
def run_coroutine(f: Callable[P, Coroutine[None, None, T]]) -> Callable[P, T]:
"""Decorate an async function to be run in a new e... | DigitalSlideArchive/ImageDePHI | imagedephi/utils/cli.py | .py | 39d4b96028c174ac | 7.56 | 12 |
import ctypes
import sys
def launched_from_frozen_binary() -> bool:
"""Return whether the current program was launched within a frozen binary."""
# https://pyinstaller.org/en/stable/runtime-information.html#run-time-information
return getattr(sys, "frozen", False)
def launched_from_windows_explorer() ->... | DigitalSlideArchive/ImageDePHI | imagedephi/utils/os.py | .py | bf6e78b722855fcb | 7.56 | 12 |
from __future__ import annotations
from collections.abc import Generator
from pathlib import Path
from typing import TYPE_CHECKING
import tifftools
from imagedephi.utils.constants import IMAGE_DEPHI_MAX_IMAGE_PIXELS
if TYPE_CHECKING:
from tifftools.tifftools import IFD
IMAGE_DESCRIPTION_ID = tifftools.constan... | DigitalSlideArchive/ImageDePHI | imagedephi/utils/tiff.py | .py | 941fd0653c1a7679 | 7.56 | 12 |
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
from click.testing import CliRunner
from imagedephi.main import imagedephi
class UsageMock(SimpleNamespace):
"""Mock for shutil.disk_usage namedtuple."""
def __init__(self, free: int) -> None:
super().__init_... | DigitalSlideArchive/ImageDePHI | tests/test_disk_space.py | .py | 485a1e2ecc7c87e9 | 7.06 | 12 |
from inspect import iscoroutinefunction
import click
from click.testing import CliRunner
import pytest
from pytest_mock import MockerFixture
from imagedephi.utils.cli import FallthroughGroup, run_coroutine
def test_utils_cli_run_coroutine(mocker: MockerFixture) -> None:
async_mock = mocker.AsyncMock()
wrap... | DigitalSlideArchive/ImageDePHI | tests/test_utils_cli.py | .py | f30cdd6bcf9f2664 | 7.06 | 12 |
"""
Demo for NonSwayColumn2d.
Purpose
-------
This script is meant to be re-run every time non_sway_column_2d.py (or the base
Column2d / RC section code it depends on) is changed, as a quick sanity check
that nothing was broken. It exercises the main public entry points of
NonSwayColumn2d in a realistic order:
1. B... | denavit/libdenavit-py | examples/non_sway_column_demo.py | .py | 395ef446488cb460 | 7.59 | 14 |
import numpy as np
def camber(x,L,c,camber_type='CircularArc'):
'''
Returns the camber at a position along the length of a beam.
x = Position along the length of the beam where the camber is to be computed
L = Length of the beam
c = Maximum camber (occurs at mid-span, x = L/2)
'''
... | denavit/libdenavit-py | src/libdenavit/camber.py | .py | e840007e0a7d0985 | 7.59 | 14 |
from abc import abstractmethod
from libdenavit.OpenSees import AnalysisResults
from libdenavit import interpolate_list, find_limit_point_in_list
import warnings
class Column2d:
"""
A base class for 2D column models.
"""
def __init__(self, section, length, **kwargs):
"""
Initializes comm... | denavit/libdenavit-py | src/libdenavit/column_2d.py | .py | 0c02180141658eef | 7.59 | 14 |
import bisect
class GoalSeekMonotonic:
'''
A class for perforing a goal seek type analysis. This class only works if
the relationship between the input and output is monotonically increasing
or monotonically increasing.
'''
def __init__(self,target_output,tolerance,tolerance_mode='BothSi... | denavit/libdenavit-py | src/libdenavit/goal_seek.py | .py | d374039c52f50d96 | 7.59 | 14 |
from __future__ import annotations
import nox
nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"
@nox.session
def lint(session: nox.Session) -> None:
"""
Run the linter.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.p... | henryiii/flake8-errmsg | noxfile.py | .py | bb87af28d0a80b56 | 7.63 | 17 |
from __future__ import annotations
import ast
import sys
import pytest
import flake8_errmsg as m
ERR1 = """\
raise Error("that")
raise Error(f"this {that}")
raise Error(1)
raise Error(msg)
"""
def test_err1():
node = ast.parse(ERR1)
results = list(m.ErrMsgASTPlugin(node).run())
assert len(results) ==... | henryiii/flake8-errmsg | tests/test_package.py | .py | 471316fa622058f0 | 7.13 | 17 |
#!/usr/bin/env python3
"""Logging configuration and usage example.
This example demonstrates METAINFORMANT's structured logging system with console and file output, different log levels, and metadata logging.
Usage:
python examples/core/example_logging.py
Output:
output/examples/core/logging_example.log
"""
... | docxology/MetaInformAnt | examples/core/example_logging.py | .py | e939a76f1fd4073e | 7.45 | 7 |
#!/usr/bin/env python3
"""Basic workflow orchestration example.
This example demonstrates METAINFORMANT's workflow utilities for config-based data processing and step-by-step execution.
Usage:
python examples/core/example_workflow.py
Output:
output/examples/core/workflow_results.json
"""
from __future__ imp... | docxology/MetaInformAnt | examples/core/example_workflow.py | .py | 1a883c17e1a67989 | 7.45 | 7 |
#!/usr/bin/env python3
"""DNA phylogenetic analysis example.
This example demonstrates phylogenetic tree construction using METAINFORMANT's phylogeny toolkit, including neighbor-joining and UPGMA methods.
Usage:
python examples/dna/example_phylogeny.py
Output:
output/examples/dna/phylogeny_tree.newick
"""
f... | docxology/MetaInformAnt | examples/dna/example_phylogeny.py | .py | b5629f9b3ec6c84a | 7.45 | 7 |
#!/usr/bin/env python3
"""DNA population genetics example.
This example demonstrates population genetics statistics using METAINFORMANT's population genetics toolkit, including nucleotide diversity, Tajima's D, and other neutrality tests.
Usage:
python examples/dna/example_population.py
Output:
output/exampl... | docxology/MetaInformAnt | examples/dna/example_population.py | .py | 2934c49b8861ad50 | 7.45 | 7 |
#!/usr/bin/env python3
"""DNA sequence processing basics example.
This example demonstrates fundamental DNA sequence operations using METAINFORMANT's DNA sequence analysis toolkit.
Usage:
python examples/dna/example_sequences.py
Output:
output/examples/dna/sequences_analysis.json
"""
from __future__ import ... | docxology/MetaInformAnt | examples/dna/example_sequences.py | .py | 89cc1e8971a13222 | 7.45 | 7 |
#!/usr/bin/env python3
"""Mathematical biology population dynamics example.
This example demonstrates population dynamics modeling using METAINFORMANT's math toolkit.
Usage:
python examples/math/example_dynamics.py
Output:
output/examples/math/dynamics_model.json
"""
from __future__ import annotations
from... | docxology/MetaInformAnt | examples/math/example_dynamics.py | .py | 038f3baa9b2853e7 | 7.45 | 7 |
#!/usr/bin/env python3
"""RNA expression quantification example.
This example demonstrates RNA-seq expression quantification and analysis using METAINFORMANT's RNA analysis toolkit.
Usage:
python examples/rna/example_quantification.py
Output:
output/examples/rna/expression_analysis.json
"""
from __future__ ... | docxology/MetaInformAnt | examples/rna/example_quantification.py | .py | cc30e3dcdf197b59 | 7.45 | 7 |
"""
conftest.py — Shared pytest fixtures for the template bioinformatics project.
All fixtures use real file I/O on temporary directories (Real-Implementation policy).
"""
import shutil
import textwrap
from pathlib import Path
import pytest
import yaml
@pytest.fixture()
def project_root() -> Path:
"""Return th... | docxology/MetaInformAnt | projects/template_bioinformatics_project/tests/conftest.py | .py | ab422aed58616fac | 7.95 | 7 |
#!/usr/bin/env python3
"""Download reference transcriptomes and build kallisto indices for all species.
Reads genome.ftp_url + genome.files.transcriptome_fasta from each species
YAML config, downloads from NCBI FTP, then runs `kallisto index`.
Usage:
python3 scripts/cloud/prep_genomes.py [--config-dir config/amal... | docxology/MetaInformAnt | scripts/cloud/prep_genomes.py | .py | cadb6455cce50c1b | 7.45 | 7 |
#!/usr/bin/env python3
"""
Cross-check consistency between core documentation and source code.
Performs AST-based extraction of functions from Python files and
parses markdown documentation for API signatures, then compares.
"""
import ast
import os
import re
import sys
from collections import defaultdict
from pathlib... | docxology/MetaInformAnt | scripts/core_docs_cross_check.py | .py | 39555e2de8ef3925 | 7.45 | 7 |
#!/usr/bin/env python3
"""DNA analysis workflow orchestrator.
This script provides a comprehensive orchestration layer for DNA analysis workflows,
including sequence processing, composition analysis, quality control, and reporting.
Usage:
python3 scripts/dna/run_dna_analysis.py --input data/dna/sequences.fasta --... | docxology/MetaInformAnt | scripts/dna/run_dna_analysis.py | .py | ef8065073796029f | 7.45 | 7 |
#!/usr/bin/env python3
"""Ecology analysis workflow orchestrator.
This script provides comprehensive orchestration for ecology analysis workflows,
including diversity indices, community composition, beta diversity, ordination,
indicator species analysis, functional ecology, and macroecology.
Usage:
python3 script... | docxology/MetaInformAnt | scripts/ecology/run_ecology_analysis.py | .py | a848b92001c7bd9a | 7.45 | 7 |
#!/usr/bin/env python3
"""Epigenome analysis workflow orchestrator.
This script provides comprehensive orchestration for epigenome analysis workflows,
including methylation analysis, chromatin track processing, and beta value computation.
Usage:
python3 scripts/epigenome/run_epigenome_analysis.py --methylation me... | docxology/MetaInformAnt | scripts/epigenome/run_epigenome_analysis.py | .py | 71d03c73fc3f3e29 | 7.45 | 7 |
"""Stream from the official ElevenLabs SDK over the stream-input WebSocket.
`client.text_to_speech.convert_realtime()` opens
`/v1/text-to-speech/{voice_id}/stream-input`, which ovos-tts-server implements.
The SDK derives the WebSocket URL from `base_url=` but forces the `wss` scheme,
so it cannot reach a plaintext `h... | OpenVoiceOS/ovos-tts-server | examples/elevenlabs_ws_example.py | .py | ffa9c187a1d27e12 | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
import os
import subprocess
import tempfile
import wave
from typing import Tuple
def _is_wav(path: str) -> bool:
"""Return True if the file can be opened as a RIFF WAV."""
try:
with wave.open(path, "rb"):
return True
except (wave.Error, ... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/audio_utils.py | .py | fda8b617d4d5a83e | 7.62 | 16 |
# 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, software
# distributed under the... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/mcp_server.py | .py | b91fb5f693f78e9a | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Amazon Polly-compatible TTS endpoint."""
from typing import Optional
from fastapi import APIRouter, Header
from fastapi.responses import Response
from pydantic import BaseModel, Field
from ovos_tts_server.audio_utils import convert_audio
class PollyRequest(BaseMod... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/amazon_polly.py | .py | b755d98ec65a65c2 | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Azure Cognitive Services TTS-compatible endpoint."""
import re
from starlette.concurrency import run_in_threadpool
from typing import Optional
from fastapi import APIRouter, Header, Request
from fastapi.responses import Response
from ovos_tts_server.audio_utils impo... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/azure_tts.py | .py | 3e58a9bf6b2ecab9 | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Cartesia Sonic-compatible TTS endpoint."""
from typing import Any, Dict, Optional
from fastapi import APIRouter, Header
from fastapi.responses import Response
from pydantic import BaseModel, Field
from ovos_tts_server.audio_utils import convert_audio
class Cartesi... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/cartesia.py | .py | 71976171bbf92e80 | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Coqui TTS-compatible endpoint."""
from typing import Optional
from fastapi import APIRouter, Query
from fastapi.responses import Response
def make_coqui_router(engine) -> APIRouter:
"""Create Coqui TTS-compatible router.
Args:
engine: TTSEngineWrap... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/coqui.py | .py | 2ec0f911a6a64e45 | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Deepgram Aura-compatible TTS endpoint."""
from typing import Optional
from fastapi import APIRouter, Header, Query
from fastapi.responses import Response
from pydantic import BaseModel, Field
from ovos_tts_server.audio_utils import convert_audio
class DeepgramSpea... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/deepgram_aura.py | .py | bec7fbd18c1eafcc | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""Google Cloud TTS-compatible endpoint."""
import base64
from typing import Optional
from fastapi import APIRouter, Header, Query
from pydantic import BaseModel, Field
from ovos_tts_server.audio_utils import convert_audio
class GoogleTTSInput(BaseModel):
"""Synt... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/google_tts.py | .py | 68b043729161f5b1 | 7.62 | 16 |
"""MaryTTS-compatible HTTP endpoints.
Exposes /process, /locales and /voices so apps already speaking MaryTTS can
use any OVOS TTS plugin as a drop-in replacement.
Two routers are exposed:
- `make_marytts_router(engine)` mounts under `/marytts` — consistent with
every other compat router so multiple compat layers c... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/marytts.py | .py | 4597563f11438d9f | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""OpenAI-compatible TTS endpoint."""
from typing import Optional
from fastapi import APIRouter, Header
from fastapi.responses import Response
from pydantic import BaseModel, Field
from ovos_tts_server.audio_utils import convert_audio
class OpenAITTSRequest(BaseModel... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/openai_tts.py | .py | 881ed922cfdda6cd | 7.62 | 16 |
# Licensed under the Apache License, Version 2.0
"""PlayHT-compatible TTS endpoints.
Implements enough of PlayHT's HTTP API for the official ``pyht`` SDK to be
used as a drop-in client: the ``/api/v4/sdk-auth`` inference-coordinates
handshake plus the ``/api/v2/tts/stream`` synthesis endpoint. Point a stock
``pyht.Cli... | OpenVoiceOS/ovos-tts-server | ovos_tts_server/routers/playht.py | .py | 211c878eeb9a4509 | 7.62 | 16 |
"""Shared fixtures for integration tests.
Each integration test runs the compat router(s) behind a real uvicorn
server on a random local port, then drives it with the vendor's official
SDK to prove drop-in compatibility.
Tests skip automatically when the vendor SDK isn't installed; install
them with `pip install -e .... | OpenVoiceOS/ovos-tts-server | test/integration/conftest.py | .py | bbe2627bf74a8810 | 8.12 | 16 |
"""Live test: drive the /azure-tts router against Azure's documented REST
contract.
Azure has two synthesis APIs:
- **REST**: `POST /cognitiveservices/v1` with an SSML body, returns audio
bytes. Documented, supported, widely used in serverless/curl/embedded
contexts. **This is what our router implements.**
- **We... | OpenVoiceOS/ovos-tts-server | test/integration/test_azure_live.py | .py | 767d61b2348ddabe | 7.12 | 16 |
"""Live test: drive the WebSocket synthesis bridge with the official
`azure-cognitiveservices-speech` SDK.
The SDK normally connects to a regional `wss://...tts.speech.microsoft.com`
host. We point it at our local server via `SpeechConfig.from_endpoint`,
giving the SDK a `ws://127.0.0.1:<port>/azure-tts/cognitiveservi... | OpenVoiceOS/ovos-tts-server | test/integration/test_azure_ws_live.py | .py | 8a872506e88e8947 | 8.12 | 16 |
"""Live test: drive the /elevenlabs compat router with the official
`elevenlabs` Python SDK pointed at a uvicorn server in this process.
"""
import pytest
from test.integration.conftest import run_live_server
def _register(app, engine):
from ovos_tts_server.routers.elevenlabs import make_elevenlabs_router
ap... | OpenVoiceOS/ovos-tts-server | test/integration/test_elevenlabs_live.py | .py | 55ab661fafdee259 | 8.12 | 16 |
"""Live test against /google-tts.
The official `google-cloud-texttospeech` SDK builds request URLs from a
**host-only** `api_endpoint` plus a hardcoded `/v1/text:synthesize`
path. It cannot be aimed at a sub-path, so the SDK cannot directly drive
a router mounted under `/google-tts/`.
Two test surfaces here:
1. `Tes... | OpenVoiceOS/ovos-tts-server | test/integration/test_google_live.py | .py | 64937db4b31acdee | 8.12 | 16 |
"""Live test: drive the /marytts router with raw HTTP requests, exactly
as the upstream MaryTTS HTTP API expects.
There's no canonical MaryTTS Python SDK — the upstream `MaryClient` is
Java and Home Assistant / Mycroft community clients all hand-roll HTTP.
This test replays those bare requests against a uvicorn server... | OpenVoiceOS/ovos-tts-server | test/integration/test_marytts_live.py | .py | 58ff243103a7ee02 | 8.12 | 16 |
"""Live test: drive `ovos-tts-plugin-marytts` against our /marytts router.
The plugin is a real OVOS TTS plugin that talks to a real MaryTTS HTTP
server. Pointing its `url` config at our compat router proves we're a
genuine drop-in for upstream MaryTTS — voice discovery + synthesis both
have to round-trip through our ... | OpenVoiceOS/ovos-tts-server | test/integration/test_marytts_ovos_plugin_live.py | .py | 5b38a6f805a8a82c | 8.12 | 16 |
# Licensed under the Apache License, Version 2.0
"""Unit tests for ovos_tts_server.audio_utils.convert_audio."""
import builtins
import io
import os
import sys
import tempfile
import wave
import pytest
from ovos_tts_server.audio_utils import convert_audio
def _write_silent_wav() -> str:
tmp = tempfile.NamedTemp... | OpenVoiceOS/ovos-tts-server | test/unittests/test_audio_utils.py | .py | 21f72434b1de8d53 | 8.12 | 16 |
"""Utilities to read and write from/to an SDF file
Note that this was copied from the sdf-format-support repo. It was copied
here for speed but this and convertFile SHOULD be in a file accessible
by both virtual-screening and the formatter (and possibly others).
An SDF file consists of a series of records... | InformaticsMatters/virtual-screening | conversion_utils.py | .py | 3cec23ec499e0642 | 7.45 | 7 |
#!/usr/bin/env python
# Copyright 2022 Informatics Matters 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 applicab... | InformaticsMatters/virtual-screening | expander.py | .py | 58958f641690275c | 7.45 | 7 |
#!/usr/bin/env python
# Copyright 2022 Informatics Matters 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 applicab... | InformaticsMatters/virtual-screening | fn_expand.py | .py | 34006448b8140624 | 7.45 | 7 |
#!/usr/bin/env python
# Copyright 2022 Informatics Matters 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 applicab... | InformaticsMatters/virtual-screening | fn_find_synthons.py | .py | b6178ca5031a5c36 | 7.45 | 7 |
#!/usr/bin/env python
# Copyright 2022 Informatics Matters 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 applicab... | InformaticsMatters/virtual-screening | fn_synthon_expansion.py | .py | d708111674ed9f19 | 7.45 | 7 |
from itertools import combinations
import re
import json
import pandas as pd
class Metrics():
def __init__(self, runs, ments_already_normalized=True, eval_concepts_and_named_entities=False):
"""
Args:
runs: a list of tuples (name_of_the_run, dataset_type, path_to_the_run_file)
... | informagi/conversational-entity-linking-2022 | eval/results.py | .py | 94bef0c6acdaaeaf | 7.56 | 12 |
import torch
from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
class BERT_MD():
def __init__(self, file_pretrained):
"""
Args:
file_pretrained = "./tmp/ft-conel/"
Note:
The output of self.ner_model(s_input) is like
... | informagi/conversational-entity-linking-2022 | tool/bert_md.py | .py | 28f16dde5a8d05c2 | 7.56 | 12 |
import sys
sys.path.append('s2e_pe')
import pe_data
import importlib
from bert_md import BERT_MD
from rel_ed import REL_ED
from pe import EEMD, PEMD
class ConvEL():
def __init__(self, threshold=0):
self.threshold = threshold
conf = self.ConfigConvEL()
self.bert_md = BERT_MD(conf.file_pretr... | informagi/conversational-entity-linking-2022 | tool/conv_el.py | .py | 762fdcc8957a082b | 7.56 | 12 |
import sys
sys.path.append('./REL')
from REL.entity_disambiguation import EntityDisambiguation
from REL.utils import process_results
from REL.mention_detection import MentionDetection
class REL_ED():
def __init__(self, base_url, wiki_version):
config = {
"mode": "eval",
"model_pat... | informagi/conversational-entity-linking-2022 | tool/rel_ed.py | .py | c94d5c1cdb59ae90 | 7.56 | 12 |
from tokenizers.pre_tokenizers import Whitespace
pre_tokenizer = Whitespace()
TMP_DOC_ID = 'tmp' # temporary doc id
class PreProcess():
"""Create input for PE Linking module
"""
def _error_check(self, conv):
assert type(conv) == list
assert len(conv) > 0, f'conv should be a list of dicts... | informagi/conversational-entity-linking-2022 | tool/s2e_pe/pe_data.py | .py | afd1320e739cdd13 | 7.56 | 12 |
"""
GitHub API client for the sticky PR comment and the check run.
Both are posted from the runner with ${{ github.token }}, so no GitHub credential is ever sent to
StackGuardian.
Note the platform can also post a comment and a check of its own, from sg-run-controller. That
path is gated on `TriggerDetails.type == "g... | StackGuardian/tirith-iac-governance-action | scripts/tirith_action/gh_client.py | .py | 04e44b62f7ffd848 | 7.48 | 8 |
"""
Local policy evaluation -- the credential-free path.
Everything here runs on the runner and talks to nothing. It exists so the action is usable before
anyone has a StackGuardian account: policies committed in the repository are evaluated against the
plan, and the same pull-request comment and check run are posted.... | StackGuardian/tirith-iac-governance-action | scripts/tirith_action/local.py | .py | 1b4a417a07169bd4 | 7.48 | 8 |
"""
The README's inputs table must match `action.yml`.
Written because it did not. `tirith-version` was documented as defaulting to `1.2.0` — a version pin —
while `action.yml` defaulted it to a *branch*, which the same file's description explicitly warned was
a moving ref that "can turn a green pipeline red with noth... | StackGuardian/tirith-iac-governance-action | tests/test_readme_documents_the_real_inputs.py | .py | d5e5ef7115717865 | 7.98 | 8 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Check how long it takes to distribute power."""
import asyncio
import csv
import random
import timeit
from collections.abc import Coroutine
from datetime import timedelta
from typing import Any
from frequenz.channels import Broadcast
from frequen... | frequenz-floss/frequenz-sdk-python | benchmarks/power_distribution/power_distributor.py | .py | 7fe47989e4f36ea8 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""Benchmark the data sourcing actor.
To be able to access the `tests` package we need to adjust the PYTHONPATH.
Usage:
PYTHONPATH=. python benchmark_datasourcing.py <num ev chargers> <num messages per battery>
"""
import argparse
import async... | frequenz-floss/frequenz-sdk-python | benchmarks/timeseries/benchmark_datasourcing.py | .py | a2a1c95340a6a3e4 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""
Benchmarks for the PeriodicFeatureExtractor class.
This module contains benchmarks that are comparing
the performance of a numpy implementation with a python
implementation.
"""
import asyncio
import collections.abc
import contextlib
import logg... | frequenz-floss/frequenz-sdk-python | benchmarks/timeseries/periodic_feature_extractor.py | .py | 2f182bf292f70901 | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Benchmark resampling."""
from collections.abc import Sequence
from datetime import datetime, timedelta, timezone
from timeit import timeit
from frequenz.sdk.timeseries import ResamplerConfig, ResamplerConfig2
from frequenz.sdk.timeseries._resampl... | frequenz-floss/frequenz-sdk-python | benchmarks/timeseries/resampling.py | .py | 0a45110b11987442 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""Memory allocation benchmark for the ringbuffer."""
import argparse
import tracemalloc
from datetime import datetime, timedelta, timezone
import numpy as np
from frequenz.quantities import Quantity
from frequenz.sdk.timeseries import Sample
from ... | frequenz-floss/frequenz-sdk-python | benchmarks/timeseries/ringbuffer_memusage.py | .py | 58dacb34dd71d007 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""Benchmarks the serialization of the `OrderedRingBuffer` class."""
import fnmatch
import os
import time
from datetime import datetime, timedelta, timezone
from typing import Any
import numpy as np
from frequenz.quantities import Quantity
import f... | frequenz-floss/frequenz-sdk-python | benchmarks/timeseries/ringbuffer_serialization.py | .py | b0874bdd3ba79455 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""This module defines macros for use in Markdown files."""
import os
import pathlib
from frequenz.repo.config.mkdocs.mkdocstrings_macros import (
hook_env_with_everything,
slugify,
)
from mkdocs_macros import plugin as macros
def define_e... | frequenz-floss/frequenz-sdk-python | docs/_scripts/macros.py | .py | a00322763ed6acde | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Load shedding actor."""
import asyncio
import random
import sys
import termios
import tty
from dataclasses import dataclass
from datetime import datetime, timezone
from heapq import heappop, heappush
from typing import AsyncGenerator
from unittest... | frequenz-floss/frequenz-sdk-python | examples/load_shedding.py | .py | fb44ec081bc54da0 | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""General purpose async tools."""
import asyncio
import logging
import sys
from abc import ABC
from datetime import timedelta
from typing import Any, Callable, Coroutine
_logger = logging.getLogger(__name__)
async def cancel_and_await(task: async... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/_internal/_asyncio.py | .py | fa1addc6001f5040 | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""General purpose classes for use with channels."""
import abc
import dataclasses
import logging
import traceback
import typing
from frequenz.channels import Broadcast, Receiver
_logger = logging.getLogger(__name__)
T_co = typing.TypeVar("T_co", ... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/_internal/_channels.py | .py | e5208345cd1adda8 | 7.63 | 17 |
# License: MIT
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
"""Graph traversal helpers."""
from __future__ import annotations
from collections.abc import Iterable
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid.component import (
Component,
Componen... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/_internal/_graph_traversal.py | .py | 516688df823ff642 | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Definition of Singleton metaclass."""
from threading import Lock
from typing import Any
class SingletonMeta(type):
"""This is a thread-safe implementation of Singleton."""
_instances: dict[Any, type] = {}
"""The dictionary of instan... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/_internal/_singleton_meta.py | .py | 02cb10e094a32819 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""Actor model implementation."""
import abc
import asyncio
import logging
from datetime import timedelta
from .._internal._asyncio import is_loop_running
from ._background_service import BackgroundService
_logger = logging.getLogger(__name__)
cl... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/actor/_actor.py | .py | 1ff48fe244827965 | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""Background service implementation."""
import abc
import asyncio
import collections.abc
from types import TracebackType
from typing import Any, Self
class BackgroundService(abc.ABC):
"""A background service that can be started and stopped.
... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/actor/_background_service.py | .py | 9a30251178ab2773 | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Base schema for configuration classes."""
import marshmallow
from frequenz.quantities.experimental.marshmallow import QuantitySchema
class BaseConfigSchema(QuantitySchema):
"""A base schema for configuration classes.
This schema provide... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/config/_base_schema.py | .py | 6795289bb6ab5b0b | 7.13 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Read and update logging severity from config."""
import logging
from dataclasses import dataclass, field
from typing import Annotated, Sequence, assert_never
import marshmallow
import marshmallow.validate
from ..actor import Actor
from ._manager... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/config/_logging_actor.py | .py | 7f00c65e9306cfca | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Management of configuration."""
import asyncio
import logging
import pathlib
from collections.abc import Mapping, Sequence
from dataclasses import is_dataclass
from datetime import timedelta
from typing import Any, Final, Literal, TypeGuard, overl... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/config/_manager.py | .py | 1363f71adf3a7a97 | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Read and update config variables."""
import logging
import pathlib
import tomllib
from collections import abc
from collections.abc import Mapping, MutableMapping
from datetime import timedelta
from typing import Any, assert_never
from frequenz.ch... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/config/_managing_actor.py | .py | f9188b1ddcb9ef0a | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Utilities to deal with configuration."""
from collections.abc import Mapping
from typing import Any, ClassVar, Protocol, TypeVar, cast
import marshmallow
from marshmallow import Schema
from marshmallow_dataclass import class_schema
from ._base_s... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/config/_util.py | .py | db3b0c360ed1da3d | 7.63 | 17 |
# License: MIT
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
"""The ComponentMetricRequest class."""
from dataclasses import dataclass
from datetime import datetime
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid.metrics import Metric
from frequenz.sdk.micro... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_data_sourcing/_component_metric_request.py | .py | df3b36347481b18c | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""The DataSourcing Actor."""
from frequenz.channels import Receiver
from ..._internal._channels import ChannelRegistry
from ...actor import Actor
from ._component_metric_request import ComponentMetricRequest
from .microgrid_api_source import Microg... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_data_sourcing/data_sourcing.py | .py | 9ea71c4af714db9d | 7.63 | 17 |
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Manage the data streams for the components of the power distributor."""
import abc
import collections.abc
import logging
import typing
from frequenz.channels import LatestValueCache
from frequenz.client.common.microgrid.components import Componen... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_component_manager.py | .py | 3bb456ffa1466175 | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Manage EV chargers for the power distributor."""
import asyncio
import collections.abc
import logging
from datetime import datetime, timedelta, timezone
from frequenz.channels import (
Broadcast,
LatestValueCache,
Sender,
merge,
... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_ev_charger_manager/_ev_charger_manager.py | .py | 2158deb8d6bb784e | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Power distribution state tracking for ev chargers."""
from dataclasses import dataclass
from datetime import datetime
from typing import Iterable
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import ... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_ev_charger_manager/_states.py | .py | 7911fd5db0c789f8 | 7.63 | 17 |
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
"""Manage PV inverters for the power distributor."""
import asyncio
import collections.abc
import logging
from datetime import timedelta
from frequenz.channels import LatestValueCache, Sender
from frequenz.client.common.microgrid.components import C... | frequenz-floss/frequenz-sdk-python | src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_pv_inverter_manager/_pv_inverter_manager.py | .py | 69b7f3272c38ffcb | 7.63 | 17 |
import inspect
import re
import warnings
from collections.abc import Callable
from pathlib import Path
from typing import (
Annotated,
Any,
Literal,
)
from packaging import version
from pydantic import (
AfterValidator,
BaseModel,
ConfigDict,
Field,
computed_field,
field_validator,
... | exasol/python-toolbox | exasol/toolbox/config.py | .py | a57ef79b7f2d10dc | 7.48 | 8 |
import json
import os
import shutil
import sqlite3
import subprocess # nosec: B404 - risk of subprocess is accepted
import sys
from collections.abc import Iterable
from pathlib import Path
import nox
from nox import Session
from exasol.toolbox.config import BaseConfig
from noxconfig import PROJECT_CONFIG
COVERAGE_D... | exasol/python-toolbox | exasol/toolbox/nox/_artifacts.py | .py | 4d0280c6d4a99216 | 7.48 | 8 |
from __future__ import annotations
import argparse
import json
from pathlib import Path
import nox
from nox import Session
from exasol.toolbox.nox._shared import validate_path_within_root
from exasol.toolbox.util.dependencies.audit import (
PipAuditException,
Vulnerabilities,
get_vulnerabilities,
get... | exasol/python-toolbox | exasol/toolbox/nox/_dependencies.py | .py | 1f5f780b788ec472 | 7.48 | 8 |
from __future__ import annotations
from collections.abc import Iterable
import nox
from nox import Session
from exasol.toolbox.config import BaseConfig
from exasol.toolbox.nox._shared import (
Mode,
get_filtered_python_files,
)
from noxconfig import (
PROJECT_CONFIG,
)
def _code_format(session: Session... | exasol/python-toolbox | exasol/toolbox/nox/_format.py | .py | 228e852559fe0dfe | 7.48 | 8 |
from __future__ import annotations
import sys
from collections.abc import Iterable
from pathlib import Path
import nox
import rich.console
import tomlkit
from nox import Session
from exasol.toolbox.nox._shared import get_filtered_python_files
from exasol.toolbox.util.dependencies.shared_models import PoetryFiles
fro... | exasol/python-toolbox | exasol/toolbox/nox/_lint.py | .py | 7b9513d5631993f3 | 7.48 | 8 |
import argparse
import json
from collections.abc import Iterable
from typing import Any
import nox
from nox import Session
from exasol.toolbox.config import BaseConfig
from noxconfig import (
PROJECT_CONFIG,
)
# The relevant nox sessions will be removed in:
# https://github.com/exasol/python-toolbox/issues/859... | exasol/python-toolbox | exasol/toolbox/nox/_matrix.py | .py | 4ffd70898ee42358 | 7.48 | 8 |
from __future__ import annotations
import argparse
from collections import ChainMap
from collections.abc import (
MutableMapping,
)
from enum import (
Enum,
auto,
)
from pathlib import Path
from typing import Any
from nox import Session
from noxconfig import (
PROJECT_CONFIG,
)
DOCS_OUTPUT_DIR = ".h... | exasol/python-toolbox | exasol/toolbox/nox/_shared.py | .py | 6583f6c8b06467ce | 7.48 | 8 |
from __future__ import annotations
from collections.abc import (
Iterable,
MutableMapping,
)
from pathlib import Path
from typing import Any
import nox
from nox import Session
from exasol.toolbox.config import BaseConfig
from exasol.toolbox.nox._shared import (
_integration_test_context,
_unit_test_c... | exasol/python-toolbox | exasol/toolbox/nox/_test.py | .py | 929c4b1fadcdcdef | 7.98 | 8 |
from __future__ import annotations
import argparse
import nox
from nox import Session
from exasol.toolbox.util.workflows.workflow_orchestrator import (
WORKFLOW_CHOICES,
WorkflowOrchestrator,
)
from noxconfig import PROJECT_CONFIG
def _create_parser(session_name: str) -> argparse.ArgumentParser:
parser... | exasol/python-toolbox | exasol/toolbox/nox/_workflow.py | .py | 80cc854fd8c2570e | 7.48 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.