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 asyncio
import pytest
from arangoasync.errno import DATA_SOURCE_NOT_FOUND, INDEX_NOT_FOUND
from arangoasync.exceptions import (
CollectionChecksumError,
CollectionCompactError,
CollectionConfigureError,
CollectionPropertiesError,
CollectionRecalculateCountError,
CollectionRenameError,
... | arangodb/python-arango-async | tests/test_collection.py | .py | c64036acb171afee | 7.1 | 15 |
"""
Author: TMJ
Date: 2025-01-15 23:01:22
LastEditors: TMJ
LastEditTime: 2026-06-18 19:45:06
Description: 请填写简介
"""
import logging # noqa: I001
import os
import sys
from typing import Any, Literal
from joblib import cpu_count as joblib_cpu_count
from molgr.config import CONFIG as MOLGR_CONFIG
# RDKit must initializ... | gentle1999/MolOP | src/molop/config/__init__.py | .py | 40e004114750320f | 7.45 | 7 |
"""
Author: TMJ
Date: 2026-02-15 20:33:01
LastEditors: TMJ
LastEditTime: 2026-02-15 22:14:01
Description: 请填写简介
"""
from __future__ import annotations
import os
from typing import Any, Protocol, cast
from molop.config import molopconfig, moloplogger
from molop.io import codec_registry
from molop.io.frame_selection i... | gentle1999/MolOP | src/molop/io/_batch_format_transform.py | .py | 579ae6117bbd6d9a | 7.45 | 7 |
"""
Author: TMJ
Date: 2025-07-29 12:36:28
LastEditors: TMJ
LastEditTime: 2026-02-04 16:04:37
Description: 请填写简介
"""
import os
from collections.abc import Sequence
from typing import Any, Literal, Protocol, cast, overload
from pydantic import Field, computed_field
from typing_extensions import Self
from molop.io.base... | gentle1999/MolOP | src/molop/io/base_models/Mixins.py | .py | eda6b0fb5da9645a | 7.45 | 7 |
"""Codec package.
Importing this package MUST NOT implicitly populate the global codec registry.
Builtin registration is co-located with original implementations and loaded via
`molop.io.codecs.catalog.load_builtin_codecs()` as part of lazy activation:
- public `*FileParser.py` modules under `molop.io.logic` register... | gentle1999/MolOP | src/molop/io/codecs/__init__.py | .py | 551a935368922fff | 7.45 | 7 |
"""Codec discovery and activation.
This module is imported only during lazy activation
(`Registry.ensure_default_codecs_registered()`), not at package import time.
Design goals:
- Deterministic behavior across platforms and installs.
- Minimal "linkage" for adding builtin codecs: co-locate registration next to
the ... | gentle1999/MolOP | src/molop/io/codecs/catalog.py | .py | 54a16c8b2cdd8abf | 7.45 | 7 |
"""
Author: TMJ
Date: 2025-07-29 16:53:34
LastEditors: TMJ
LastEditTime: 2026-02-12 20:33:42
Description: 请填写简介
"""
from typing import Literal, cast
from molop.io.base_models.ChemFileFrame import BaseCoordsFrame, _HasCoords
from molop.io.base_models.Mixins import DiskStorageMixin, MemoryStorageMixin
from molop.io.log... | gentle1999/MolOP | src/molop/io/logic/coords/frame_models/SDFFileFrame.py | .py | 2757abbe582716c0 | 7.45 | 7 |
"""
Author: TMJ
Date: 2025-12-14 23:26:19
LastEditors: TMJ
LastEditTime: 2026-02-04 11:46:52
Description: 请填写简介
"""
from typing import cast
from molop.io.base_models.ChemFileFrame import BaseCoordsFrame, _HasCoords
from molop.io.base_models.Mixins import DiskStorageMixin, MemoryStorageMixin
from molop.io.logic.coords... | gentle1999/MolOP | src/molop/io/logic/coords/frame_models/SMIFileFrame.py | .py | e73bd08fc0781fb4 | 7.45 | 7 |
from unittest.mock import patch
from scim2_tester import CheckResult
from scim2_tester import Status
from scim2_cli import cli
def test_nominal(runner, httpserver):
"""Test SCIM compliance test."""
results = [
CheckResult(
status=Status.SUCCESS,
title="test1",
des... | python-scim/scim2-cli | tests/test_test.py | .py | b60715f488458859 | 7 | 9 |
import pytest
from scim2_models import Error
from scim2_models import Resource
from scim2_models import User
from scim2_client import RequestNetworkError
from scim2_client import SCIMRequestError
class UnregisteredResource(Resource):
__schema__ = "urn:test:schemas:UnregisteredResource"
def test_delete_user(htt... | python-scim/scim2-client | tests/test_delete.py | .py | 5f7c691bc97aa1ab | 8.14 | 18 |
import pytest
from scim2_models import Error
from scim2_models import Group
from scim2_models import PatchOp
from scim2_models import PatchOperation
from scim2_models import ResourceType
from scim2_models import User
from scim2_client import RequestNetworkError
from scim2_client import RequestPayloadValidationError
fr... | python-scim/scim2-client | tests/test_modify.py | .py | 221bdb4d4633a02a | 7.14 | 18 |
import math
import matplotlib.pyplot as plt
import os
import subprocess
import tempfile
def get_fig_size(fig_width_cm, fig_height_cm=None):
"""Convert dimensions in centimeters to inches.
If no height is given, it is computed using the golden ratio.
"""
if not fig_height_cm:
golden_ratio = (1 ... | OpenHUTB/.github | docs/src/python/plot_utils.py | .py | 84a3162afcd21476 | 7.5 | 9 |
# python git_commit_stats.py --since "2026-02-27 18:00" --until "2026-03-08 00:00"运行指定时间段的提交统计,结果输出到 commit_stats.csv 文件中。可以通过 --ignore 参数指定一个 JSON 文件,里面包含需要屏蔽的用户(按邮箱或用户名)。如果不指定 --ignore 参数,则默认使用 ignore_users.json 文件作为屏蔽列表。
import subprocess
import argparse
import csv
import json
import os
from collections import Count... | OpenHUTB/.github | src/git_commit_stats.py | .py | cd1e129d01e96440 | 7.5 | 9 |
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
# 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 ... | canonical/k8s-operator | charms/worker/k8s/lib/charms/kubernetes_libs/v0/etcd.py | .py | 87cda7d68d485a1b | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Sync AlertManager rules from an upstream repository.
This script fetches AlertManager rules definitions from a specified version
of the kube-prometheus project and adjusts them for compatibility with
COS.
"""
import logging
import os
import... | canonical/k8s-operator | charms/worker/k8s/scripts/update_alert_rules.py | .py | 95ee73f328235c2f | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Sync Grafana dashboards from an upstream repository.
This script fetches Grafana dashboard definitions from a specified version
of the kube-prometheus project and adjusts them for compatibility with
COS by removing the built-in $prometheus d... | canonical/k8s-operator | charms/worker/k8s/scripts/update_dashboards.py | .py | 0d8a2d2ba5561367 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""K8s Certificates module."""
import logging
from string import Template
from typing import Dict, List, Optional, Protocol, Set, Tuple, Union, cast
import charms.contextual_status as status
import config.bootstrap as bootstrap
import k8sd_api... | canonical/k8s-operator | charms/worker/k8s/src/certificates.py | .py | 4fa81b0042094bfa | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface for Charmed etcd requires relation.
The `CharmedEtcdRequires` class provides an interface to interact with the Charmed etcd relation.
It allows the charm to check the status of the relation, retrieve connection details,
and manage c... | canonical/k8s-operator | charms/worker/k8s/src/charmed_etcd.py | .py | dd844a37249fae77 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Cloud Integration for Canonical k8s Operator."""
import logging
from typing import Mapping, Optional, Union
import charms.contextual_status as status
import ops
from ops.interface_aws.requires import AWSIntegrationRequires
from ops.interfac... | canonical/k8s-operator | charms/worker/k8s/src/cloud_integration.py | .py | 353713e6edc65cfb | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Configuration for kubernetes services.
The format for each file is a set of key-value pairs, where each line contains a key and its value.
"""
import logging
from dataclasses import dataclass
from ... | canonical/k8s-operator | charms/worker/k8s/src/config/arg_files.py | .py | a76daff38113a323 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Bootstrap configuration options."""
import collections
import dataclasses
import ipaddress
import logging
from typing import List, Optional
import charms.contextual_status as context_status
import ... | canonical/k8s-operator | charms/worker/k8s/src/config/bootstrap.py | .py | af2409fd1ccdc4cf | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Cluster configuration options."""
import logging
from typing import Dict, Optional
import literals
import ops
from k8sd_api_manager import (
DNSConfig,
GatewayConfig,
IngressConfig,
... | canonical/k8s-operator | charms/worker/k8s/src/config/cluster.py | .py | cc76fda457967bad | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Parse extra arguments for Kubernetes components."""
from typing import Dict, List, Optional, Union
import literals
import ops
from config.arg_files import FileArgsConfig
from k8sd_api_manager impor... | canonical/k8s-operator | charms/worker/k8s/src/config/extra_args.py | .py | 9ba4b3955506010e | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Accessor for charm config options in the right type."""
from typing import TYPE_CHECKING, Type
import ops
class CharmOption:
"""Enum representing various configuration options for the charms.... | canonical/k8s-operator | charms/worker/k8s/src/config/option.py | .py | c998b9a7304c6c12 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""A module for detecting changes in Juju resources."""
import logging
from hashlib import sha256
from pathlib import Path
import ops
log = logging.getLogger(__name__)
JUJU_RESOURCE_DIR = Path.cwd().... | canonical/k8s-operator | charms/worker/k8s/src/config/resource.py | .py | 1c646311e653970e | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Configuration for containerd.
The format for the hosts.toml file is as follows:
https://github.com/containerd/containerd/blob/main/docs/hosts.md
The format for the config.toml file is as follows:
h... | canonical/k8s-operator | charms/worker/k8s/src/containerd.py | .py | 49b93906e99000b8 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""COS Integration module."""
import logging
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Sequence, Union
import ops
from literals import DATASTORE_TYPE_ETCD
from ops.charm import CharmBase
log = logging.get... | canonical/k8s-operator | charms/worker/k8s/src/cos_integration.py | .py | e67b6a9cddb7e958 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Helper functions to handle endpoints for the charm."""
import logging
import re
from ipaddress import ip_address
from urllib.parse import urlparse, urlunsplit
log = logging.getLogger(__name__)
de... | canonical/k8s-operator | charms/worker/k8s/src/endpoints.py | .py | 2928254abd25f255 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Update status handler for the k8s charm.
This handler is responsible for updating the unit's workload version and status
"""
import logging
from typing import List, Optional, cast
import charms.co... | canonical/k8s-operator | charms/worker/k8s/src/events/update_status.py | .py | d43b85ef9325e34c | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""A module for inspecting a Kubernetes cluster."""
import logging
from pathlib import Path
from typing import List, Optional
import httpx
from lightkube import ApiError, Client, KubeConfig
from lightkube.core.client import LabelSelector
from ... | canonical/k8s-operator | charms/worker/k8s/src/inspector.py | .py | 01aafd95ae6fcbaf | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""Node client module.
this module defines the behaviors around determining the status of a node.
"""
import enum
import subprocess
from pathlib import Path
from k8s.client import kubectl
class Pres... | canonical/k8s-operator | charms/worker/k8s/src/k8s/node.py | .py | 56d96380ef5c4bf2 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Relation kube-control module."""
import logging
from base64 import b64decode
import charms.contextual_status as status
import ops
import yaml
from charms.contextual_status import on_error
from literals import APISERVER_PORT, BOOTSTRAP_NODE_... | canonical/k8s-operator | charms/worker/k8s/src/kube_control.py | .py | 3f0a8eddb7bd6539 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# Learn more at: https://juju.is/docs/sdk
"""A module providing PKI related functionalities."""
import logging
import os
from pathlib import Path
from typing import List, Tuple, Union
from cryptography import x509
from literals import PKI_DIR... | canonical/k8s-operator | charms/worker/k8s/src/pki.py | .py | f8c2df28324364be | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Protocol definitions module."""
from pathlib import Path
from typing import Dict, FrozenSet, List, Tuple
import ops
from charms.interface_external_cloud_provider import ExternalCloudProvider
from charms.reconciler import Reconciler
from con... | canonical/k8s-operator | charms/worker/k8s/src/protocols.py | .py | b746c0aeb1c4f610 | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""EventTimer for scheduling dispatch of juju event on regular intervals."""
import logging
import os
import subprocess
from datetime import timedelta
from pathlib import Path
from typing import Optional, Sequence, TypedDict
import ops
log = ... | canonical/k8s-operator | charms/worker/k8s/src/reschedule.py | .py | 648079dc7925480a | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""A module for upgrading the k8s and k8s-worker charms."""
# NOTE: K8sDependenciesModel below uses the pydantic.v1 compat layer, which relies
# on eager __annotations__. PEP 649 defers those on Python 3.14+ (26.04 base),
# breaking field detec... | canonical/k8s-operator | charms/worker/k8s/src/upgrade.py | .py | 4b28da6f607a468c | 7.54 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Rendering of the test bundles declared by the ``bundle`` marker."""
import logging
import subprocess
from dataclasses import dataclass, field
from functools import cached_property
from itertools import chain
from pathlib import Path
from typi... | canonical/k8s-operator | tests/integration/bundle.py | .py | e0b8094dc4f112c5 | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Introspection of, and setup for, the cloud the tests are running against."""
import functools
import logging
from typing import Optional, Tuple
import jubilant
import pytest
import yaml
from helpers import get_unit_cidrs
from literals import... | canonical/k8s-operator | tests/integration/cloud.py | .py | c083160893824d59 | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Fixtures for the Jubilant-based integration tests."""
import json
import logging
import random
import shlex
import shutil
import string
import subprocess
from pathlib import Path
from typing import Dict, Iterator, List
import jubilant
impor... | canonical/k8s-operator | tests/integration/conftest.py | .py | ea1adb75baeb3b1e | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Aids in testing COS substrate on LXD."""
import gzip
import ipaddress
import json
import logging
import lzma
import re
import shlex
import time
from io import BytesIO
from pathlib import Path
from typing import Optional, Tuple, Union
from lx... | canonical/k8s-operator | tests/integration/cos_substrate.py | .py | 65162ef88643b0bd | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Aid for connecting to grafana instance."""
import base64
import json
import logging
import urllib.request
from typing import Dict, List, Optional
log = logging.getLogger(__name__)
class Grafana:
"""A class to manage interactions with a... | canonical/k8s-operator | tests/integration/grafana.py | .py | d68e5e5be49faf9e | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Synchronous helpers for driving a deployed Canonical Kubernetes cluster with Jubilant."""
import contextlib
import ipaddress
import json
import logging
import shutil
import tempfile
from pathlib import Path
from typing import Any, Dict, Itera... | canonical/k8s-operator | tests/integration/helpers.py | .py | 6552f06d42992fee | 7.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Register a Kubernetes cluster as a Juju cloud.
Replacement for ``pytest_operator.plugin.OpsTest.add_k8s``, which used python-libjuju's
controller facade. Jubilant offers ``add_cloud``/``add_credential``, which take the same
YAML documents th... | canonical/k8s-operator | tests/integration/k8s_cloud.py | .py | 4edeee36c79d1f5e | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Helper for interacting with LXD."""
import dataclasses
import ipaddress
import logging
import shlex
import subprocess
import time
from platform import freedesktop_os_release as os_release
from typing import Any, Dict, List, Optional, Union
fr... | canonical/k8s-operator | tests/integration/lxd_substrate.py | .py | d42aeb0e262fed65 | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Aid for testing promtheus."""
import json
import logging
import urllib.parse
import urllib.request
from typing import List, Optional
log = logging.getLogger(__name__)
class Prometheus:
"""A class for managing interactions with a runnin... | canonical/k8s-operator | tests/integration/prometheus.py | .py | 4d401f47d7b334ae | 8.04 | 11 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Generic test methods for testing Kubernetes storage providers."""
import contextlib
import dataclasses
import logging
from string import Template
from typing import List
import helpers
import jubilant
import yaml
from kubernetes.client impo... | canonical/k8s-operator | tests/integration/storage.py | .py | ba55a054cc17efc7 | 8.04 | 11 |
#!/usr/bin/env python3
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Deploy a Kubernetes cluster using the Juju Terraform provider and a manifest as input.
See https://github.com/canonical/k8s-bundles/blob/main/terraform/README.md
"""
import argparse
import json
import os
import subpro... | canonical/k8s-operator | tests/integration/terraform/setup.py | .py | 9a9ac439da681410 | 8.04 | 11 |
#!/usr/bin/env python3
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
# pylint: disable=duplicate-code
"""Integration tests."""
import logging
import re
import jubilant
import pytest
import storage
from helpers import fast_forward, wait_active
from kubernetes.client import ApiClient, Core... | canonical/k8s-operator | tests/integration/test_ceph.py | .py | 627e257581ca5572 | 8.04 | 11 |
#!/usr/bin/env python3
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Integration tests."""
import json
from typing import Literal
import jubilant
import pytest
from cloud import cloud_arch
from helpers import get_leader, ready_nodes, unit_names, unit_port, wait_active, wait_blocked
#... | canonical/k8s-operator | tests/integration/test_charmed_etcd.py | .py | 3de54d1e5529923a | 8.04 | 11 |
#!/usr/bin/env python3
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Integration tests."""
import contextlib
import json
import logging
import secrets
from pathlib import Path
from typing import Iterator, Optional
import jubilant
import k8s_cloud
import pytest
from cloud import cloud_... | canonical/k8s-operator | tests/integration/test_cos.py | .py | 3a477dfdff77d735 | 8.04 | 11 |
from argparse import ArgumentParser
from glob import glob
from os.path import dirname, exists, join
from shutil import rmtree
from sys import exit
from venv import create
from src.pydeployment import PYEXE, run_command
from src.pydeployment.logger import logger
class BuildPyDeployment:
"""
Class to build PyDe... | pydeployment/pydeployment | build_pydeployment.py | .py | 79476a6dc9f2ee07 | 7.48 | 8 |
from argparse import Namespace
from collections.abc import Callable
from importlib.resources import files
from os import access, chmod, makedirs, W_OK
from os.path import abspath, basename, exists, join
from pathlib import Path
from platform import machine
from shutil import Error as ShutilError, move, rmtree
from stat... | pydeployment/pydeployment | src/pydeployment/build.py | .py | 04d3b458cf827e27 | 7.48 | 8 |
from argparse import ArgumentError, Namespace
from os import environ
from os.path import basename, exists
from sys import argv
from typing import Any, Dict
from dotenv import dotenv_values
from .arg_parser import ArgParser
from .logger import logger
class BuildConfig:
"""
Class to parse build configuration ... | pydeployment/pydeployment | src/pydeployment/build_config.py | .py | 2434f6858fe60ff9 | 7.48 | 8 |
from argparse import Namespace
from glob import glob
from os import makedirs, symlink
from os.path import basename, isdir, join, relpath, splitext
from shutil import copy, make_archive, move
from . import LINUX_DESKTOP_KEYS as KEYS
from .build import Build
class BuildLinux(Build):
"""
Linux build class
... | pydeployment/pydeployment | src/pydeployment/build_linux.py | .py | 18a67219707c10f6 | 7.48 | 8 |
from argparse import Namespace
from glob import glob
from os import sep, symlink
from os.path import basename, dirname, join
from re import sub
from shutil import copy, make_archive, move
from .build import Build
class BuildMacos(Build):
"""
macOS build class
:param config: Configuration dictionary
... | pydeployment/pydeployment | src/pydeployment/build_macos.py | .py | dae702122d46d3dd | 7.48 | 8 |
from argparse import Namespace
from glob import glob
from os.path import abspath, basename, isdir, join
from shutil import copy, make_archive, move
from .build import Build
class BuildWindows(Build):
"""
Windows build class
:param config: Configuration dictionary
:type config: argparse.Namespace
... | pydeployment/pydeployment | src/pydeployment/build_windows.py | .py | aff246167b0dadba | 7.48 | 8 |
from argparse import Namespace
from collections.abc import Callable
from logging import Logger
from os import environ
from os.path import abspath, exists
from pathlib import PosixPath
from platform import system
from typing import Iterator, Optional, Tuple
from pytest import fixture, mark
from _pytest.monkeypatch impo... | pydeployment/pydeployment | tests/conftest.py | .py | fa577b07735b7ac8 | 7.98 | 8 |
from collections.abc import Callable
from os import environ
from typing import Any, Dict, List, Optional, Tuple
from pytest import fixture, mark
from _pytest.monkeypatch import MonkeyPatch
from . import BuildConfig
@mark.order(3)
def test_build_config(build_config: BuildConfig) -> None:
"""
Test BuildConfig... | pydeployment/pydeployment | tests/test_build_config.py | .py | 9f540a54fd35e3d8 | 7.98 | 8 |
# -*- coding: utf-8 -*-
# Copyright 2025-2026 Red Hat, Inc.
#
# 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 applica... | os-net-config/os-net-config | os_net_config/exit_codes.py | .py | 6d76417d5c8bded2 | 7.42 | 6 |
# Copyright 2020 Red Hat, Inc.
#
# 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 writin... | os-net-config/os-net-config | os_net_config/sriov_bind_config.py | .py | 8df9c007ff45a6dd | 7.42 | 6 |
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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
#
# htt... | os-net-config/os-net-config | os_net_config/tests/base.py | .py | 779aa7f22cb6aadf | 7.92 | 6 |
import io
import logging
from collections.abc import Iterator
from typing import BinaryIO
from langchain_community.document_loaders.base import BaseBlobParser
from langchain_community.document_loaders.parsers import PyPDFParser
from langchain_community.document_loaders.parsers.txt import TextParser
from langchain_core... | cccaballero/manolo_bot | manolo_bot/ai/document_loaders.py | .py | e96fdcd8d44090bf | 7.54 | 11 |
import base64
import logging
import aiohttp
from langchain.agents import create_agent
from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_core.tools import BaseTool
from manolo_bot.ai.config import BotConfig
from manolo_bot.a... | cccaballero/manolo_bot | manolo_bot/ai/llmagent.py | .py | aba9a8727af6fa5a | 7.54 | 11 |
import logging
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
from deepagents import create_deep_agent
from deepagents.backends import StateBackend
from deepagents.backends.composite import CompositeBackend
from deepagents.middleware import FilesystemMiddleware, MemoryMiddleware, SkillsMidd... | cccaballero/manolo_bot | manolo_bot/ai/llmdeepagent.py | .py | b5958f8fff40b700 | 7.54 | 11 |
"""MCP Manager for handling Model Context Protocol servers."""
import json
import logging
from langchain_core.tools import BaseTool
from langchain_mcp_adapters.client import MultiServerMCPClient
from manolo_bot.ai.config import BotConfig
logger = logging.getLogger(__name__)
class MCPManager:
"""Manages MCP se... | cccaballero/manolo_bot | manolo_bot/ai/mcp_manager.py | .py | ae4c287b062fc8b2 | 7.54 | 11 |
from __future__ import annotations
import logging
import os
import re
from datetime import datetime
from zoneinfo import ZoneInfo
from ddgs import DDGS
from langchain_community.document_loaders import WebBaseLoader
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import BaseTool, tool
fro... | cccaballero/manolo_bot | manolo_bot/ai/tools.py | .py | 1c525d257d2f5ab7 | 7.54 | 11 |
import os
import tempfile
from envmodel import (
BooleanField,
EnvModel,
FloatField,
IntegerField,
JsonField,
StringField,
StringListField,
)
class Config(EnvModel):
google_api_key = StringField("GOOGLE_API_KEY")
google_api_model = StringField("GOOGLE_API_MODEL", default="gemini-2... | cccaballero/manolo_bot | manolo_bot/config.py | .py | f1aa0b6e859057c4 | 7.54 | 11 |
import os
import shutil
from deepagents.backends.filesystem import FilesystemBackend
from manolo_bot.storage.deep_agent_backends.base import _BOT_UUID_PATTERN, BaseDeepAgentBackend
class FilesystemDeepAgentBackend(BaseDeepAgentBackend):
"""
Filesystem-based implementation of the deep agent filesystem backen... | cccaballero/manolo_bot | manolo_bot/storage/deep_agent_backends/filesystem_backend.py | .py | c4ce07e7caf4d540 | 7.54 | 11 |
import asyncio
from deepagents.backends import StateBackend
from manolo_bot.storage.deep_agent_backends.base import BaseDeepAgentBackend
# Keyed by (bot_uuid, chat_id) to avoid cross-bot leakage when a single
# process serves multiple bots. The chat_id alone is not unique across bots.
_instances: dict[tuple[str, int... | cccaballero/manolo_bot | manolo_bot/storage/deep_agent_backends/memory_backend.py | .py | 7ca6160eb5e8adbd | 7.54 | 11 |
"""Filesystem-based backend for the deep agent's MemoryMiddleware.
Memory is per-chat, durable long-term knowledge (a single ``AGENTS.md`` file)
loaded into the agent's system prompt via ``MemoryMiddleware``. Each chat gets
its own independent memory directory under ``memory_root`` — no information
leaks between chats... | cccaballero/manolo_bot | manolo_bot/storage/deep_agent_backends/memory_filesystem_backend.py | .py | 0d254e54b3daab5b | 7.54 | 11 |
"""Filesystem-based backend for the deep agent's SkillsMiddleware.
Skills are operator-provided, versioned, auditable capability bundles described
by ``SKILL.md`` files. They are *global* (shared across all chats and bot
instances in the same process) and must never be cleared by ``clean_context``
— clearing a filesys... | cccaballero/manolo_bot | manolo_bot/storage/deep_agent_backends/skills_filesystem_backend.py | .py | b864fe373b108ff8 | 7.54 | 11 |
import os
import tempfile
from pathlib import Path
from manolo_bot.storage.documents.base import BaseDocumentStorage
class FileDocumentsStorage(BaseDocumentStorage):
"""
File-based implementation of document storage.
"""
def __init__(self, bot_uuid: str, base_path: str | None = None) -> None:
... | cccaballero/manolo_bot | manolo_bot/storage/documents/file_storage.py | .py | a198e1655b59d48c | 7.54 | 11 |
from manolo_bot.storage.messages.base import BaseMessagesStorage, StorageMessage
_chats = {}
class MemoryMessagesStorage(BaseMessagesStorage):
"""
In-memory implementation of message storage.
"""
def __init__(self, bot_uuid: str, chat_id: int) -> None:
"""
Initializes the memory mess... | cccaballero/manolo_bot | manolo_bot/storage/messages/memory_storage.py | .py | 3347ac01ea7d0d8d | 7.54 | 11 |
import logging
import redis
from manolo_bot.storage.messages.base import (
BaseDBHelper,
BaseMessagesStorage,
StorageMessage,
convert_json_to_message,
get_messages_key,
)
class RedisDBHelper(BaseDBHelper):
"""
Helper class for Redis database operations.
"""
def __init__(self, db... | cccaballero/manolo_bot | manolo_bot/storage/messages/redis_storage.py | .py | 90189bc9c5fbb64b | 7.54 | 11 |
import asyncio
import base64
import datetime
import logging
import telegramify_markdown
from aiogram import Bot
from aiogram.exceptions import TelegramAPIError
from aiogram.types import BufferedInputFile, Message
def get_telegram_file_url(bot_token: str, file_path: str) -> str:
"""
Get the URL for a Telegram... | cccaballero/manolo_bot | manolo_bot/telegram/utils.py | .py | 24d6723af8b7591b | 7.54 | 11 |
import unittest
from unittest.mock import MagicMock
from langchain_core.messages import SystemMessage
from langchain_core.tools import tool
from manolo_bot.ai.llmagent import LLMAgent
from manolo_bot.ai.llmbot import LLMBot
class TestCustomTools(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.m... | cccaballero/manolo_bot | tests/ai_tests/test_custom_tools.py | .py | 2882804e9c73c6d5 | 8.04 | 11 |
import os
import unittest
from unittest.mock import AsyncMock, MagicMock, patch
from manolo_bot.ai.mcp_manager import MCPManager
from manolo_bot.config import Config
class TestMCPManager(unittest.IsolatedAsyncioTestCase):
"""Tests for MCPManager."""
def setUp(self):
"""Set up test fixtures."""
... | cccaballero/manolo_bot | tests/ai_tests/test_mcp_manager.py | .py | 1e19499d04ef0f73 | 7.04 | 11 |
import unittest
import unittest.mock
from datetime import datetime
from unittest.mock import AsyncMock, MagicMock, patch
from zoneinfo import ZoneInfo
from manolo_bot.ai.tools import (
ReadDocumentTool,
TimeResult,
ddgs_search,
extract_youtube_video_id,
get_current_time,
get_search_instructions... | cccaballero/manolo_bot | tests/ai_tests/test_tools.py | .py | f9152865fb040cc9 | 7.04 | 11 |
import os
import shutil
import tempfile
import unittest
from manolo_bot.storage.deep_agent_backends.filesystem_backend import FilesystemDeepAgentBackend
from manolo_bot.storage.deep_agent_backends.memory_backend import MemoryDeepAgentBackend
from manolo_bot.storage.deep_agent_backends.memory_filesystem_backend import ... | cccaballero/manolo_bot | tests/storage_tests/deep_agent_backends/test_backends.py | .py | 403704813e38bffa | 8.04 | 11 |
"""
Wrapper around FileSystemStore to track chunks of objects.
"""
import contextlib
import orjson
import os
import uuid
import logging
from pathlib import Path
from stix2 import FileSystemStore, Bundle
from stix2.serialization import fp_serialize
from collections import defaultdict
from concurrent.futures import Thre... | muchdogesec/cve2stix | cve2stix/chunked_store.py | .py | 4f39993c3de88d7b | 7.59 | 14 |
"""
Contains logic for storing parsed stix objects as chunked bundles.
"""
import orjson
import logging
from pathlib import Path
from collections import defaultdict
from .chunked_store import ChunkedFileSystemStore
from .config import Config
def _bundle_base_path(stix_bundle_path, filename):
"""Resolve the outp... | muchdogesec/cve2stix | cve2stix/stix_store.py | .py | 9716f252b736e35a | 7.59 | 14 |
import pytest
from unittest.mock import patch, MagicMock
from datetime import UTC, datetime, timedelta, timezone
from cve2stix import main
from cve2stix.config import Config, FilterMode
@pytest.fixture(autouse=True)
def celery_always_eager(celery_eager):
"""
Force Celery to run tasks synchronously in tests
... | muchdogesec/cve2stix | tests/src/test_main.py | .py | 226d4f2e00d0f4dc | 8.09 | 14 |
import orjson
import uuid
from pathlib import Path
import pytest
from stix2 import Vulnerability
from cve2stix import stix_store
from cve2stix.config import Config
from cve2stix.chunked_store import ChunkedFileSystemStore
@pytest.fixture
def cfg(tmp_path):
return Config(
file_system=str(tmp_path / "objec... | muchdogesec/cve2stix | tests/src/test_stix_store.py | .py | e4f5810f5b6a04be | 8.09 | 14 |
import pytest
@pytest.fixture(autouse=True, scope="package")
def eager_celery():
from vulmatch.worker.celery import app
app.conf.task_always_eager = True
yield
app.conf.task_always_eager = False
@pytest.fixture
def celery_no_eager():
from vulmatch.worker.celery import app
orig = app.conf.tas... | muchdogesec/vulmatch | tests/full/conftest.py | .py | 36288de173c0766d | 7.04 | 11 |
from unittest.mock import patch
import pytest
from vulmatch.server import models
class TestKBSyncView:
# Assuming JobType.SYNC_KNOWLEDGEBASE is added to vulmatch/server/models.py
def test_update_kb_returns_job(self, client, celery_no_eager):
# Test for capec
resp = client.patch("/api/v1/tas... | muchdogesec/vulmatch | tests/full/other_tests/test_update_kb.py | .py | 660337668fb67982 | 7.04 | 11 |
"""Base Action class for InfraNinja"""
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Dict, List, Type
class Action(ABC):
"""
Base class for all InfraNinja actions.
Actions are the main entry point for infrastructure automation tasks.
Each action... | KalvadTech/infraninja | infraninja/actions/base.py | .py | 5d80f636e2d8f927 | 7.59 | 14 |
"""SSH hardening action"""
from typing import Any
from pyinfra import host
from pyinfra.facts.files import FindInFile
from pyinfra.facts.server import OsRelease
from pyinfra.operations import files, server
from infraninja.actions.base import Action
class SSHHardening(Action):
"""
Comprehensive SSH hardenin... | KalvadTech/infraninja | infraninja/actions/ssh_hardening.py | .py | f2a6bfe45902a238 | 7.59 | 14 |
"""SSH keys deployment action"""
import logging
import time
from typing import Any, List, Optional
import requests
from pyinfra.api import DeployError
from pyinfra.operations import server
from infraninja.actions.base import Action
logger = logging.getLogger(__name__)
# HTTP status codes
HTTP_OK = 200
HTTP_NOT_FOU... | KalvadTech/infraninja | infraninja/actions/ssh_keys.py | .py | 1f649f9233ae56ad | 7.59 | 14 |
"""System update and upgrade action"""
from typing import Any
from pyinfra import host, operations
from pyinfra.api import DeployError
from pyinfra.facts.server import OsRelease
from infraninja.actions.base import Action
class UpdateAndUpgrade(Action):
"""
Update and upgrade system packages across multiple... | KalvadTech/infraninja | infraninja/actions/update_and_upgrade.py | .py | 4b1f9a76ed108d4f | 7.59 | 14 |
import json
import logging
from pyinfra.api.facts import FactBase
logger = logging.getLogger("pyinfra")
class OsRelease(FactBase):
"""
Custom fact to get OS release information by parsing /etc/os-release.
Returns a dictionary with lowercased keys, plus convenience aliases when present.
"""
def ... | KalvadTech/infraninja | infraninja/deploys/info_fetch/custom_facts.py | .py | 4f3905c9ee2808df | 7.59 | 14 |
import json
import logging
from datetime import date, datetime
from pyinfra.api.deploy import deploy
from pyinfra.context import host
from pyinfra.facts.server import (
Groups,
Hostname,
KernelModules,
LinuxName,
Mounts,
Os,
SecurityLimits,
Selinux,
Sysctl,
Users,
)
from infran... | KalvadTech/infraninja | infraninja/deploys/info_fetch/info_fetch.py | .py | 811586edb3ee6c2c | 7.59 | 14 |
"""Base Fact class for InfraNinja"""
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Dict, List, Type
class Fact(ABC):
"""
Base class for all InfraNinja facts.
Facts gather read-only information from servers (OS, hardware, etc.).
Each fact represe... | KalvadTech/infraninja | infraninja/facts/base.py | .py | 9f6489ccce69c445 | 7.59 | 14 |
"""Hardware information fact gathering."""
from pyinfra.facts.hardware import BlockDevices, Cpus, Memory, NetworkDevices
from infraninja.facts.base import Fact, FactResult
class Hardware(Fact):
"""
Gather hardware information from the server.
Collects CPU, memory, block device and network device detail... | KalvadTech/infraninja | infraninja/facts/hardware.py | .py | 97fb7ecf90b6cb2c | 7.59 | 14 |
"""System information fact gathering."""
from pyinfra.facts.server import Arch, Hostname, Kernel, KernelVersion, Os, OsRelease
from infraninja.facts.base import Fact, FactResult
class SystemInfo(Fact):
"""
Gather system information from the server.
Collects OS, hostname, kernel, architecture and releas... | KalvadTech/infraninja | infraninja/facts/system_info.py | .py | 5deca5c5c7f37faa | 7.59 | 14 |
"""Base Inventory class for InfraNinja"""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
class Inventory(ABC):
"""
Base class for all InfraNinja inventories.
Inventories are responsible for fetching and managing server infrastructu... | KalvadTech/infraninja | infraninja/inventories/base.py | .py | e256c06004ca7397 | 7.59 | 14 |
# inventory || coolify.py
import json
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
import requests
from requests.exceptions import RequestException
from infraninja.inventories.base import Inventory
logging.basicConfig(
level=logging.INFO,
forma... | KalvadTech/infraninja | infraninja/inventories/coolify.py | .py | 752e4f116bfa83cb | 7.59 | 14 |
"""Jinn inventory integration"""
import json
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple, Union
import requests
from requests.exceptions import RequestException
from infraninja.inventories.base import Inventory
logging.basicConfig(
level=logging.INF... | KalvadTech/infraninja | infraninja/inventories/jinn.py | .py | 86cddacccb9de1a4 | 7.59 | 14 |
"""
Created on Thu Oct 16 12:00:00 2025
@author: Anna Grim
@email: anna.grim@alleninstitute.org
Code that provides a wrapper for loading data and calling the SkeletMetric
subclasses.
"""
from concurrent.futures import ThreadPoolExecutor, as_completed
from tqdm import tqdm
from zipfile import ZipFile
import numpy a... | AllenNeuralDynamics/segmentation-skeleton-metrics | src/segmentation_skeleton_metrics/evaluate.py | .py | affcabdf19c33656 | 7.52 | 10 |
"""
Created on Mon June 7 12:00:00 2026
@author: Anna Grim
@email: anna.grim@alleninstitute.org
Code for visualizing ground truth graphs and their intersecting fragments.
"""
from scipy.ndimage import binary_dilation
import networkx as nx
import numpy as np
import os
def save_mips(graph_list, output_dir, filenam... | AllenNeuralDynamics/segmentation-skeleton-metrics | src/segmentation_skeleton_metrics/visualization.py | .py | 262a87e575e17c14 | 7.52 | 10 |
"""Repairs for the GPM component."""
from typing import Any, cast
from homeassistant.components.repairs import RepairsFlow
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
class RestartRequiredFixFlow(RepairsFlow):
"""Handler for an issue fixing flow."""
def... | tomasbedrich/gpm | custom_components/gpm/repairs.py | .py | 1b83923ee81ac2cf | 7.52 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.