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 |
|---|---|---|---|---|---|---|
"""Module containing objects to align images with respect to a baseline image.
The alignment is based on feature detection. It is possible to use segments of the image.
Finally, corrections are based on single, global translation.
"""
from typing import Optional, Union
import numpy as np
import darsia
class Drif... | pmgbergen/DarSIA | src/darsia/corrections/shape/drift.py | .py | 7b86b87f582ccbf6 | 7.57 | 13 |
"""Perspective map combined with so-called bulge and stretch routines.
The class offers warping as well as calibration routines.
In addition, quick-access is provided for routine-based use of DarSIA.
"""
from typing import Union
import numpy as np
import scipy.optimize as optimize
import darsia
class Generalized... | pmgbergen/DarSIA | src/darsia/corrections/shape/generalizedperspective.py | .py | 6460835ab2bd9f26 | 8.07 | 13 |
"""Module defining how to determine and apply patch-wise defined perspective transform.
"""
import copy
import time
from math import ceil
from typing import Callable
import cv2
import numpy as np
import darsia
class PiecewisePerspectiveTransform:
"""Globally constant, patch-wise defined perspective transform.... | pmgbergen/DarSIA | src/darsia/corrections/shape/piecewiseperspective.py | .py | 5657efca825fb505 | 8.07 | 13 |
"""Module containing objects useful for correcting images wrt rotations
"""
from __future__ import annotations
import itertools
from pathlib import Path
from typing import Union
import numpy as np
from scipy.spatial.transform import Rotation
import darsia
class RotationCorrection(darsia.BaseCorrection):
"""R... | pmgbergen/DarSIA | src/darsia/corrections/shape/rotation.py | .py | abebe724856e0ef0 | 7.57 | 13 |
"""Circles admin."""
# Django
from django.contrib import admin
from django.http import HttpResponse
# Model
from cride.circles.models import Circle
from cride.rides.models import Ride
# Utilities
import csv
from django.utils import timezone
from datetime import datetime, timedelta
@admin.register(Circle)
class Cir... | manwwe/cride | cride/circles/admin.py | .py | 7f295bac703e1ef3 | 7.45 | 7 |
"""Circle invitation managers."""
# Django
from django.db import models
# Utilities
import random
from string import ascii_uppercase, digits, punctuation
class InvitationManager(models.Manager):
"""Invitation manager.
Used to handle code creation.
"""
CODE_LENGTH = 17
def create(self, **kwargs... | manwwe/cride | cride/circles/managers/invitations.py | .py | bc38cace498fb7a5 | 7.45 | 7 |
"""Circle model."""
# Django
from django.db import models
# Utilities
from cride.utils.models import CRideModels
class Circle(CRideModels):
"""Circle model.
A circle is a private group where rides are offered and taken
by its members. To join a circle a user must receive an unique
invitation code f... | manwwe/cride | cride/circles/models/circles.py | .py | 224ded0413bfbf74 | 7.45 | 7 |
"""Circle invitations models."""
# Django
from django.db import models
# Utilities
from cride.utils.models import CRideModels
# Managers
from cride.circles.managers.invitations import InvitationManager
class Invitation(CRideModels):
"""Circle invitation.
A circle invitation is a random text that acts as
... | manwwe/cride | cride/circles/models/invitations.py | .py | bdcb394009e37f1f | 7.45 | 7 |
"""Membership model."""
# Django
from django.db import models
# Utilities
from cride.utils.models import CRideModels
class Membership(CRideModels):
"""Membership model.
A membership is the table that holds the relationship between
a user and a circle.
"""
user = models.ForeignKey('users.User', o... | manwwe/cride | cride/circles/models/memberships.py | .py | 893a4a1307d1d653 | 7.45 | 7 |
"""Circle permission classes."""
# Django REST Framework
from rest_framework.permissions import BasePermission
# Models
from cride.circles.models import Membership
class IsCircleAdmin(BasePermission):
"""Allow access only to circle admins."""
def has_object_permission(self, request, view, obj):
"""... | manwwe/cride | cride/circles/permissions/circles.py | .py | 1c82b9715c9472f5 | 7.45 | 7 |
"""Circles permission classes."""
# Django REST Framework
from rest_framework.permissions import BasePermission
# Models
from cride.circles.models import Membership
class IsActiveCircleMember(BasePermission):
"""Allow access only to circle members.
Expect that the views implementing this permission
have... | manwwe/cride | cride/circles/permissions/memberships.py | .py | 30d20e5bf603bc7b | 7.45 | 7 |
"""Circle serializers"""
# Django REST Framework
from rest_framework import serializers
# Model
from cride.circles.models import Circle
class CircleModelSerializer(serializers.ModelSerializer):
"""Circle model serializer."""
members_limit = serializers.IntegerField(
required=False,
min_value... | manwwe/cride | cride/circles/serializers/circle.py | .py | 70d548c3bdc43264 | 7.45 | 7 |
"""Membership serializers."""
# Django
from django.utils import timezone
# Django REST Framework
from rest_framework import serializers
# Serializers
from cride.users.serializers import UserModelSerializer
# Models
from cride.circles.models import Membership, Invitation
class MembershipModelSerializer(serializers... | manwwe/cride | cride/circles/serializers/memberships.py | .py | aad9aac973d90720 | 7.45 | 7 |
"""Circle views."""
# Django REST Framework
from rest_framework import viewsets, mixins
# Permissions
from rest_framework.permissions import IsAuthenticated
from cride.circles.permissions.circles import IsCircleAdmin
# Filters
from rest_framework.filters import SearchFilter, OrderingFilter
from django_filters.rest_f... | manwwe/cride | cride/circles/views/circles.py | .py | b853b434feb17d54 | 7.45 | 7 |
"""Circle membership views."""
# Django REST Framework
from rest_framework import mixins, viewsets, status
from rest_framework.decorators import action
from rest_framework.generics import get_object_or_404
from rest_framework.response import Response
# Serializers
from cride.circles.serializers.memberships import Mem... | manwwe/cride | cride/circles/views/memberships.py | .py | 39ff4e84669488f4 | 7.45 | 7 |
"""Rides rating model."""
# Django
from django.db import models
# Utilities
from cride.utils.models import CRideModels
class Rating(CRideModels):
"""Ride rating.
Rates are entities that store the rating a user
gave to a ride, it ranges from 1 to 5 and it affects
the ride offerer's overall reputation... | manwwe/cride | cride/rides/models/ratings.py | .py | 41c9c6883a8e1cc5 | 7.45 | 7 |
"""Rides models."""
# Django
from django.db import models
# Utilities
from cride.utils.models import CRideModels
class Ride(CRideModels):
"""Ride model."""
offered_by = models.ForeignKey('users.User', on_delete=models.SET_NULL, null=True)
offered_in = models.ForeignKey('circles.Circle', on_delete=model... | manwwe/cride | cride/rides/models/rides.py | .py | 4280c3bd1c31730f | 7.45 | 7 |
"""Ratings serializers."""
# Django
from django.db.models import Avg
# Django REST Framework
from rest_framework import serializers
# Models
from cride.rides.models import Rating
class CreateRideRatingSerializer(serializers.ModelSerializer):
"""Create ride serializer."""
rating = serializers.IntegerField(... | manwwe/cride | cride/rides/serializers/ratings.py | .py | ff51f518031dd23b | 7.45 | 7 |
"""Rides views."""
# Django REST Framework
from rest_framework import mixins, viewsets, status
from rest_framework.decorators import action
from rest_framework.generics import get_object_or_404
from rest_framework.response import Response
# Permissions
from rest_framework.permissions import IsAuthenticated
from cride... | manwwe/cride | cride/rides/views/rides.py | .py | a11eee47de029db4 | 7.45 | 7 |
import logging
from fastapi import APIRouter, Depends, HTTPException
from fastapi_sqlalchemy import db
from pydantic import BaseModel
from typing import List, Optional
from models.base import User, Pack, PackItem, Trip
from utils.auth import authenticate
from utils.consts import FREE_PACKS_PER_TRIP
from utils.pack_su... | Packstack-Tech/packstack-api | app/api/pack.py | .py | 8398caaa852d2d3a | 7.42 | 6 |
CONVERSION_TO_GRAMS = {"g": 1, "kg": 1000, "oz": 28.3495, "lb": 453.592}
def compute_pack_summary(pack):
"""Compute weight_breakdown and category_weights for a Pack.
All values are returned in grams so the backend stays
unit-preference-agnostic. Clients convert for display.
"""
breakdown = {"base... | Packstack-Tech/packstack-api | app/utils/pack_summary.py | .py | 88d0c2d9c6e99015 | 7.42 | 6 |
"""Server-side username generation.
Usernames are public: the shared-trip endpoint returns the owner's username to
anyone with the link. They must therefore not be derived from the email
address, which is what the social-auth paths used to do -- turning
`someone@example.com` into the public handle `someone`, without e... | Packstack-Tech/packstack-api | app/utils/username.py | .py | 2e7f213799f26320 | 7.42 | 6 |
# -*- coding: utf-8 -*-
"""Functions to help visualize data."""
from math import sqrt
import geopandas
import pandas
from harmonize_wq.wrangle import merge_tables
def print_report(results_in, out_col, unit_col_in, threshold=None):
"""Print a standardized report of changes made.
Parameters
----------
... | USEPA/harmonize-wq | harmonize_wq/visualize.py | .py | cbb82b04f26f683a | 7.65 | 19 |
import pymolpro
import os
import re
import requests
import shutil
import lxml
import sys
subsets = ['MB08-165',
'W4-08',
'G21IP',
'G21EA',
'PA',
'SIE11',
'BH76',
'RSE43',
'G2RC',
'AL2X',
'NBPRC',
'I... | molpro/pymolpro | maintenance/make_GMTKN30.py | .py | 2f351203b42d59ff | 7.5 | 9 |
"""
Axis-aligned bounding box search for an expensive, batch-vectorized 3D
inside/outside oracle.
Given:
- inside(points) -> bool array, where `points` is an (N, 3) numpy array
and the oracle is much more efficient when called on a big batch of
points at once than when called once per point -- and, crucially... | molpro/pymolpro | pymolpro/bounding_box.py | .py | 4022ea6532ffc770 | 7.5 | 9 |
import os
def xyz_to_zmat(xyz: str, algorithm='chemcoord'):
"""
Converts from xyz to z-matrix coordinates.
:param xyz: xyz-file
:param algorithm: algorithm to choose, default is the chemcoord algorithm
:return: The Z matrix as a string, or None in case of unknown algorithm,
:rtype: str
""... | molpro/pymolpro | pymolpro/geometry.py | .py | 909d62c821aa7261 | 7.5 | 9 |
import unittest
import pymolpro
import ase.build
import ase.optimize
class TestASE(unittest.TestCase):
def test_opt(self):
if pymolpro.Project('test').local_molpro_root:
atoms = ase.build.molecule('H2O')
atoms.calc = pymolpro.ASEMolpro(method='df-hf', basis='cc-pVDZ')
... | molpro/pymolpro | pymolpro/test_ase.py | .py | c6b2736209397d58 | 7 | 9 |
import subprocess
import unittest
import pytest
import pymolpro
import os
import shutil
class TestRegistry(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_procedures_registry(self):
proc_reg = pymolpro.procedures_registry()
if proc_reg:
... | molpro/pymolpro | pymolpro/test_registry.py | .py | 6ef118f9fe65e0aa | 7 | 9 |
import discord
from discord import app_commands
from discord.ext import commands
class CInformation(commands.Cog):
"""Info"""
def __init__(self, bot) -> None:
self.bot = bot
self.ctx_avatar = app_commands.ContextMenu(
name="Получить Аватарку",
callback=self.avatar,
... | TiDurak/DebilBot | cogs/context_menu/c_information.py | .py | f05f09faaf320ea6 | 7.48 | 8 |
"""
Implementation of MultipleRaknsums value.
"""
from __future__ import annotations
from collections.abc import Callable
from typing import Any
import numpy as np
import numpy.typing as npt
from mlte.evidence.external import ExternalEvidence
from mlte.validation.validator import Validator
class MultipleRanksums(... | mlte-team/mlte | demo/GardenBuddy/evidence/multiple_ranksums.py | .py | afd1a0898763e3cd | 7.66 | 20 |
import argparse
import logging
import os
import sys
import time
from resource import *
# import garden
import tensorflow as tf
from . import garden
LOG_FILE = "./log.txt"
def setup_log():
# Remove old log.
try:
print("Deleting log")
os.remove(LOG_FILE)
except OSError:
pass
... | mlte-team/mlte | demo/GardenBuddy/utils/model_predict.py | .py | 79a0451de551b923 | 7.66 | 20 |
###documentation
import os
import re
import pandas as pd
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
# set up model info
model = "gpt-4o"
llm = ChatOpenAI(
model="gpt-4o",
temperature=1.0,
max_completion_tokens=2048,
)
# prompt template
prompt_template =... | mlte-team/mlte | demo/ReviewPro/utils/evaluation_helpers.py | .py | 9750aa18360e6b8b | 7.66 | 20 |
"""
Script that handles updating the sample catalog entries with the corresponding demo notebook.
Build mode: Take demo notebook script conversions and put them into the sample catalog
Check mode: Checks that all sample test catalog entries are updated
"""
import copy
import json
import os
import re
import subprocess... | mlte-team/mlte | demo/catalog_entries.py | .py | cc6d51e684482052 | 7.66 | 20 |
"""
Implementation of ConfusionMatrix value.
"""
from __future__ import annotations
from collections.abc import Callable
from io import StringIO
from typing import Any
import numpy as np
import numpy.typing as npt
import pandas as pd
from mlte.evidence.external import ExternalEvidence
from mlte.validation.validator... | mlte-team/mlte | demo/simple/utils/confusion_matrix.py | .py | 369f934ee8a7fb85 | 7.66 | 20 |
"""
demo/train.py
Simple model training script.
"""
import argparse
import logging
import pickle
import sys
from pathlib import Path
import pandas as pd
from sklearn import tree
# Job exit codes
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
# The name of the file in which training data is stored
DATA_FILENAME = "data.csv"
# T... | mlte-team/mlte | demo/simple/utils/train.py | .py | 9ef07f2a9c4ae252 | 7.66 | 20 |
"""
Various file-related utils.
"""
from mlte._private import text
VALID_FILE_REPLACEMENTS = {"/": "___"}
"""Chars that need replacing, and their replacements."""
def make_valid_filename(filename: str) -> str:
"""Cleans the given filename so it is a valid one."""
return text.replace_all(filename, VALID_FILE... | mlte-team/mlte | mlte/_private/file.py | .py | e1e5ebc15e4544c1 | 7.66 | 20 |
"""Host checking utilities."""
def _removeprefix(text: str, prefix: str) -> str:
"""
Remove a prefix from a string.
:param text: The input text
:param prefix: The target prefix
:return: The modified string
"""
if text.startswith(prefix):
return text[len(prefix) :]
return text
... | mlte-team/mlte | mlte/_private/hosts.py | .py | f9331d7cc8b86510 | 7.66 | 20 |
"""
Metaclasses helpers.
"""
from collections.abc import Callable
from typing import Any
def has_callable(type: type, name: str) -> bool:
"""Determine if `type` has a callable attribute with the given name."""
return hasattr(type, name) and callable(getattr(type, name))
def has_callables(type: type, *names... | mlte-team/mlte | mlte/_private/meta.py | .py | b4c15fc574935cf6 | 7.66 | 20 |
from __future__ import annotations
import ast
import importlib
import importlib.resources
import inspect
import json
import os
import re
from collections.abc import Callable, Generator
from types import ModuleType
from typing import Any
import astunparse # type: ignore
def load_class_or_function(
type_path: st... | mlte-team/mlte | mlte/_private/reflection.py | .py | da8d1b6e7b9161a6 | 7.66 | 20 |
"""Internal utilities for serializing code."""
import base64
import typing
from collections.abc import Callable
from typing import Any
import dill # type: ignore
def encode_callable(callable: Callable[..., Any]) -> str:
"""
Encodes the callable as a base64 string.
:param callable: A callable function.... | mlte-team/mlte | mlte/_private/serializing.py | .py | 13962a91941854ce | 7.66 | 20 |
"""Internal utilities for handling text."""
import textwrap
def cleantext(text: str) -> str:
"""
Clean a text string.
:param text: The input text
:type text: str
:return: The cleaned text
:rtype: str
"""
return " ".join(textwrap.dedent(text).strip().split("\n"))
def replace_all(
... | mlte-team/mlte | mlte/_private/text.py | .py | afb5180b34db0bc4 | 7.66 | 20 |
"""Artifact protocol implementation."""
from __future__ import annotations
import abc
import typing
from mlte.artifact.model import (
ArtifactHeaderModel,
ArtifactLevel,
ArtifactModel,
)
from mlte.artifact.type import ArtifactType
from mlte.context.context import Context
from mlte.model.serializable impo... | mlte-team/mlte | mlte/artifact/artifact.py | .py | 38f8ddb84f9a78f0 | 7.66 | 20 |
"""Factory to create artifacts from models."""
from __future__ import annotations
from mlte.artifact.artifact import Artifact
from mlte.artifact.model import ArtifactModel
from mlte.artifact.type import ArtifactType
from mlte.evidence.factory import EvidenceFactory
from mlte.negotiation.artifact import NegotiationCar... | mlte-team/mlte | mlte/artifact/factory.py | .py | 592c48b800063845 | 7.66 | 20 |
"""Model implementation for MLTE artifacts."""
from __future__ import annotations
from pydantic import ConfigDict, Field, model_validator
from strenum import StrEnum
from mlte.artifact.type import ArtifactType
from mlte.evidence.model import EvidenceModel
from mlte.model import BaseModel
from mlte.negotiation.model ... | mlte-team/mlte | mlte/artifact/model.py | .py | f5e044ed58724a3d | 7.66 | 20 |
"""Exception used for authentication issues."""
from __future__ import annotations
from fastapi import HTTPException, Request
from fastapi.responses import JSONResponse
from starlette.exceptions import HTTPException as StarletteHTTPException
from mlte.backend.api import codes
def json_content_exception_handler(
... | mlte-team/mlte | mlte/backend/api/auth/http_auth_exception.py | .py | 1e2648424a720aa4 | 7.66 | 20 |
"""Handling of JWT tokens."""
from __future__ import annotations
import typing
from datetime import datetime, timedelta, timezone
from jose import JWTError, jwt
from mlte.model.base_model import BaseModel
ALGORITHM = "HS256"
"""Token hashing algorithm."""
DEFAULT_EXPIRATION_MINS = 120
"""Default token expiration ... | mlte-team/mlte | mlte/backend/api/auth/jwt.py | .py | 06fbefa3dd53db7f | 7.66 | 20 |
"""Version handling."""
import collections
import re
class Version:
"""
A semver compatible version class.
:param major: version when you make incompatible API changes.
:param minor: version when you add functionality in
a backwards-compatible manner.
:param patch: version when... | tmeckel/pulumi-tf-provider-cookiecutter | utils/version.py | .py | ed686ab3b73d23ac | 7.59 | 14 |
import os
import platform
from pathlib import Path
from pyaml_env import BaseConfig, parse_config
_CONFIG_PATH = Path(__file__).resolve().parent.parent / 'local_config.yaml'
def _resolve_profile(raw: dict) -> str:
'''
Resolve the current hostname to a local_config.yaml profile name.
Checks DEVICE_NAME env var fir... | rohanshad/cmr_toolkit | utils/local_config.py | .py | c13d7d1ee9314272 | 7.45 | 7 |
'''
Script to visualize and plot MRI hdf5 dataset objects
'''
import torch
import matplotlib
import matplotlib.pyplot as plt
import random
import os
import numpy as np
import h5py
import argparse as ap
import glob
#import imageio
#import imageio_ffmpeg
import subprocess
from local_config import get_cfg, get_global_... | rohanshad/cmr_toolkit | utils/plot_dataset.py | .py | 67e9dde306da8f68 | 7.45 | 7 |
import h5py
import os
import glob
from tqdm import tqdm
import argparse as ap
def count_unique_videos(hdf5_file):
'''
Counts the number of unique cine-sequence videos for each anatomical slice
'''
df = h5py.File(hdf5_file, 'r')
views = list(df.keys())
counter = 0
for i in views:
if len(df[i].attrs['slice_f... | rohanshad/cmr_toolkit | utils/video_counter.py | .py | 143095bbcd750d27 | 7.45 | 7 |
import cv2
import numpy as np
def _resize(img): #for debug purposes
width = 400
scale_factor = width / img.shape[1]
height = int(img.shape[0] * scale_factor)
dimension = (width, height)
im = cv2.resize(img, dimension, interpolation = cv2.INTER_AREA)
return im
def debug_threshold(img) -> int:
... | davide710/scanner | src/debug.py | .py | 423065509e959a5a | 7.6 | 15 |
import numpy as np
import cv2
# size of A4 sheet in pixel:
a4_x = 2480
a4_y = 3508
def get_threshold(image, colorized):
'''
when applying cv2.threshold with a high value, many supposed to be white pixels become black.
on the other hand, if the value is low it's likely that text or content will become whit... | davide710/scanner | src/postprocess.py | .py | f3b7d31af32b2f9b | 7.6 | 15 |
import cv2
import numpy as np
def white(image):
'''
function that detects pixel that are supposed to be white
i.e. pixels that have their B, G, and R values close enough
and are bright enough
'''
im = np.array(image)
im_reshaped = np.reshape(im, (-1, 3))
dict = {'B': im_reshaped[:, 0],... | davide710/scanner | src/preprocess.py | .py | 5857e6dfbd308eb4 | 7.6 | 15 |
from logging import getLogger
from abc import ABC, abstractmethod
from assetra.units import RESPONSIVE_UNIT_TYPES, NONRESPONSIVE_UNIT_TYPES
from assetra.system import EnergySystem
from assetra.simulation import ProbabilisticSimulation
from assetra.metrics import ResourceAdequacyMetric
import xarray as xr
LOG = getLo... | ijbd/assetra | assetra/contribution.py | .py | 9b63eb849be87a55 | 7.52 | 10 |
from __future__ import annotations
from datetime import datetime
from logging import getLogger
# external
import numpy as np
import xarray as xr
# package
from assetra.units import NONRESPONSIVE_UNIT_TYPES, RESPONSIVE_UNIT_TYPES
from assetra.system import EnergySystem
LOG = getLogger(__name__)
class ProbabilisticS... | ijbd/assetra | assetra/simulation.py | .py | 8d72c65c51147f97 | 7.52 | 10 |
from __future__ import annotations
from logging import getLogger
from pathlib import Path
from collections import Counter
import errno
import os
# external
import xarray as xr
# package
from assetra.units import (
EnergyUnit,
RESPONSIVE_UNIT_TYPES,
NONRESPONSIVE_UNIT_TYPES,
)
LOG = getLogger(__name__)
... | ijbd/assetra | assetra/system.py | .py | 8568701cc2ad1fb4 | 7.52 | 10 |
import astropy.units as u
import astropy.io as io
import numpy as np
from importlib.resources import files
from .core import Spectrum
from .utils import interpolate
__all__ = ["Filter", "SED", "SEDGrid", "apply_filter", "mag_to_flux"]
class Filter(object):
"""
A photometric filter.
Loads filter metadat... | brackham/speclib | src/speclib/photometry.py | .py | 6d7095a806f7a8d1 | 7.95 | 7 |
#!/usr/bin/env python3
"""
lint-prometheus-scrape-netpol.py — enforce the bidirectional Prometheus-scrape
NetworkPolicy convention documented in the repo-root AGENTS.md.
Background
----------
Prometheus runs default-deny (Ingress + Egress) via `prometheus-default-deny` in
the `monitoring` namespace. For any scrape tar... | prismatic-koi/home-ops | scripts/lint-prometheus-scrape-netpol.py | .py | d08a235836708185 | 7.45 | 7 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/__init__.py | .py | d339dc0fd6902a38 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/adaptor/impl/get_status_messages.py | .py | de6335d34803aed8 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/adaptor/impl/injected_commands_provider.py | .py | 544b890fed3e8c61 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/adaptor/impl/root_source.py | .py | 5e31824e1591320c | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/adaptor/impl/static_info.py | .py | 276e6eb2f0581616 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/adaptor/impl/syc_proxy.py | .py | a8ffbdde3661741c | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/charts/chart_datatypes.py | .py | c1edaae92f2d0f01 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/charts/csv_chartdata.py | .py | 5371a6feb03b9b56 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/charts/plot_functions.py | .py | 3b0f797d1e27b6d7 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/charts/plotdefinition_manager.py | .py | a0b90440ffed318d | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/charts/plotter.py | .py | 6bae261d54b37068 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/client/grpc_transport.py | .py | 6c4ea004676c6220 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/client/services/chart.py | .py | f2c0d4c622a0aeff | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/client/syc_container.py | .py | e31fd43bcaa4d50e | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/client/syc_process.py | .py | 9fc742dbc8b6da41 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/client/variant.py | .py | 9c263c8c71aa2629 | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/examples/downloads.py | .py | 7b03d59109d89f1b | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/native_api/object_path.py | .py | 7e3ea26909e4cd5b | 7.56 | 12 |
# Copyright (C) 2021 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limi... | ansys/pysystem-coupling | src/ansys/systemcoupling/core/participant/manager.py | .py | d6911613e8363937 | 7.56 | 12 |
"""Nox sessions."""
import os
import shlex
import shutil
import sys
from pathlib import Path
from textwrap import dedent
import nox
package = "datadoc_editor"
python_versions = ["3.12", "3.13", "3.14"]
nox.needs_version = ">= 2021.6.6"
nox.options.default_venv_backend = "uv"
nox.options.sessions = [
"pre-commit"... | statisticsnorway/datadoc-editor | noxfile.py | .py | 0eeeb9c991900c2f | 7.54 | 11 |
"""Centralised configuration management for Datadoc."""
from __future__ import annotations
import os
from pathlib import Path
from typing import Literal
from dapla_metadata._shared import enums
from dotenv import load_dotenv
from datadoc_editor.constants import DAPLA_MANUAL_TEXT
from datadoc_editor.frontend.compone... | statisticsnorway/datadoc-editor | src/datadoc_editor/config.py | .py | 24cee1e43cf95d33 | 7.54 | 11 |
"""Callback functions to do with global variables metadata."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from typing import Any
from datadoc_editor import state
from datadoc_editor.frontend.components.builders import AlertTypes
from datadoc_editor.frontend.components.builders... | statisticsnorway/datadoc-editor | src/datadoc_editor/frontend/callbacks/global_variables.py | .py | a3096d7486bdfd74 | 7.54 | 11 |
"""Global variables decorated callback functions should be defined here.
Implementations of the callback functionality should be in other functions in 'global_variables', to enable unit testing.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import dash
from dash import ALL
f... | statisticsnorway/datadoc-editor | src/datadoc_editor/frontend/callbacks/global_variables_callbacks.py | .py | eae70472da8e0efd | 7.54 | 11 |
"""Pseudonymization decorated callback functions should be defined here.
Implementations of the callback functionality should be in other functions (in other files), to enable unit testing.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from dash import MATCH
from dash import... | statisticsnorway/datadoc-editor | src/datadoc_editor/frontend/callbacks/pseudonymization_callbacks.py | .py | c47cdbddc53ad116 | 7.54 | 11 |
"""General decorated callback functions should be defined here.
Implementations of the callback functionality should be in other functions (in other files), to enable unit testing.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from typing import Any
from dash import Dash
fro... | statisticsnorway/datadoc-editor | src/datadoc_editor/frontend/callbacks/register_callbacks.py | .py | 4727eb4d93d62672 | 7.54 | 11 |
"""Components and layout which are not inside a tab."""
from __future__ import annotations
import ssb_dash_components as ssb
from dash import html
from datadoc_editor.frontend.callbacks.utils import get_dataset_path
from datadoc_editor.utils import get_app_version
header = ssb.Header(
[
ssb.Title("Datad... | statisticsnorway/datadoc-editor | src/datadoc_editor/frontend/components/control_bars.py | .py | 107eaaf648991d05 | 7.54 | 11 |
import logging
EXCLUDED_PATHS = ["/healthz", "/_dash-", "/assets"]
class GunicornAccessLoggerHealthProbeFilter(logging.Filter):
"""Filter out any Gunicorn access logs on Liveness or Readiness probes."""
def filter(self, record: logging.LogRecord) -> bool:
"""Filter health probes on the /healthz endp... | statisticsnorway/datadoc-editor | src/datadoc_editor/logging_configuration/gunicorn_access_log_filter.py | .py | caf5dcb933f88d2a | 7.04 | 11 |
"""General utilities."""
from __future__ import annotations
import datetime
import importlib
METADATA_DOCUMENT_FILE_SUFFIX = "__DOC.json"
def running_in_notebook() -> bool:
"""Return True if running in Jupyter Notebook."""
try:
return bool(get_ipython().__class__.__name__ == "ZMQInteractiveShell") ... | statisticsnorway/datadoc-editor | src/datadoc_editor/utils.py | .py | 38c89fa404cccaa7 | 7.54 | 11 |
#! /usr/bin/env python
import os
import shutil
import subprocess
import tempfile
import sys
import logging
import argparse
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
SPHINX_DIR = os.path.join(os.getcwd(), ... | canonical/kafka-k8s-operator | docs/.sphinx/get_vale_conf.py | .py | 8dceca515eb77b7a | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""KafkaClient class library for basic client connections to a Kafka Charm cluster.
`KafkaClient` provides an interface from which to make generic client connections
to a running Kafka Charm cluster. This can be as an adm... | canonical/kafka-k8s-operator | lib/charms/kafka/client.py | .py | 7616575fe36005a4 | 7.48 | 8 |
# Copyright 2023 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | canonical/kafka-k8s-operator | lib/charms/operator_libs_linux/v0/sysctl.py | .py | 1702f234694d56c7 | 7.48 | 8 |
# Copyright 2022 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | canonical/kafka-k8s-operator | lib/charms/rolling_ops/v0/rollingops.py | .py | bd09b1b879bae886 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Charmed Machine Operator for Apache Kafka."""
import logging
import charm_refresh
from charms.data_platform_libs.v0.data_models import TypedCharmBase
from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboar... | canonical/kafka-k8s-operator | src/charm.py | .py | 3c885f8719ac6b39 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Structured configuration for the Kafka charm."""
import logging
import re
from enum import Enum
from typing import Literal
from charms.data_platform_libs.v0.data_models import BaseConfigModel
from pydantic import Fiel... | canonical/kafka-k8s-operator | src/core/structured_config.py | .py | 3501235cdc587410 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Event handlers for Juju Actions."""
import logging
from typing import TYPE_CHECKING
from ops.charm import ActionEvent
from ops.framework import Object
if TYPE_CHECKING:
from charm import KafkaCharm
from event... | canonical/kafka-k8s-operator | src/events/actions.py | .py | 05d236c41d163ba4 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Balancer role core charm logic."""
import logging
from subprocess import CalledProcessError
from typing import TYPE_CHECKING, Literal
from charms.data_platform_libs.v0.data_interfaces import RelationEvent
from ops imp... | canonical/kafka-k8s-operator | src/events/balancer.py | .py | fa0c69f673d19123 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Handler for controller specific logic."""
import logging
from typing import TYPE_CHECKING
from ops import (
LeaderElectedEvent,
Object,
PebbleReadyEvent,
RelationDepartedEvent,
StartEvent,
Upda... | canonical/kafka-k8s-operator | src/events/controller.py | .py | 6d8232e88d9eb34a | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling Kafka OAuth configuration."""
import logging
from typing import TYPE_CHECKING
from charms.hydra.v0.oauth import ClientConfig, OAuthRequirer
from ops.framework import EventBase, Object
from litera... | canonical/kafka-k8s-operator | src/events/oauth.py | .py | c4cb0363e40ad467 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""KafkaProvider class and methods."""
import json
import logging
from typing import TYPE_CHECKING
from charms.data_platform_libs.v0.data_interfaces import (
PROV_SECRET_PREFIX,
REQ_SECRET_FIELDS,
CachedSecre... | canonical/kafka-k8s-operator | src/events/peer_cluster.py | .py | 839cbe054bac602a | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""KafkaProvider class and methods."""
import logging
import subprocess # nosec B404
from typing import TYPE_CHECKING
from charms.data_platform_libs.v1.data_interfaces import (
KafkaRequestModel,
MtlsCertUpdated... | canonical/kafka-k8s-operator | src/events/provider.py | .py | efe858b0c80ce665 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling Apache Kafka in-place upgrades."""
import abc
import dataclasses
import logging
import time
from typing import TYPE_CHECKING
import charm_refresh
from lightkube.core.client import Client
from ligh... | canonical/kafka-k8s-operator | src/events/refresh.py | .py | 275f63282af875bc | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
"""Event Handler for user-defined secret events.
Internal user management could be done by defining secrets
and granting their access to the charm.
The flow for defining secrets and granting access to the charm would be ... | canonical/kafka-k8s-operator | src/events/secrets.py | .py | 73420aa7031a0e3d | 7.48 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.