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
#!/usr/bin/env python3 # Copyright 2023 Ubuntu # See LICENSE file for licensing details. """Integration tests: Alertmanager TLS web endpoint.""" import logging import tempfile from pathlib import Path import jubilant import pytest from helpers import ALERTMANAGER_IMAGE, curl, get_unit_address logger = logging.getLo...
canonical/alertmanager-k8s-operator
tests/integration/test_tls_web.py
.py
7a54b43ad739b524
7.92
6
# Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Integration tests: Alertmanager workload tracing over plain HTTP.""" import logging from pathlib import Path import jubilant from helpers import ( ALERTMANAGER_IMAGE, AM_APP, TEMPO_APP, assert_traces_in_tempo, deploy_tem...
canonical/alertmanager-k8s-operator
tests/integration/test_workload_tracing_http.py
.py
199e5dc98194655b
7.92
6
# Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Integration tests: Alertmanager workload tracing over TLS.""" import logging from pathlib import Path import jubilant from helpers import ( ALERTMANAGER_IMAGE, AM_APP, TEMPO_APP, assert_traces_in_tempo, deploy_tempo_stac...
canonical/alertmanager-k8s-operator
tests/integration/test_workload_tracing_tls.py
.py
7bd6b4a598790c80
7.92
6
#!/usr/bin/env python3 # Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. """Helper functions for writing tests.""" import dataclasses from unittest.mock import patch from ops.testing import Container, Context, Exec, PeerRelation, Relation, State def no_op(*_, **__) -> None: pass def t...
canonical/alertmanager-k8s-operator
tests/unit/helpers.py
.py
5452e0873d138ad5
7.92
6
# Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. from unittest.mock import patch import pytest from helpers import add_relation_sequence, begin_with_initial_hooks_isolated from ops.testing import Context, Relation, State """Some brute-force tests, so that other tests can remain focused.""" ...
canonical/alertmanager-k8s-operator
tests/unit/test_brute_isolated.py
.py
90d392e053c2dbc3
7.92
6
#!/usr/bin/env python3 # Copyright 2026 Canonical Ltd. # See LICENSE file for licensing details. """Unit tests for config change detection.""" import dataclasses import unittest from unittest.mock import MagicMock, patch import ops import pytest from helpers import begin_with_initial_hooks_isolated from ops.pebble i...
canonical/alertmanager-k8s-operator
tests/unit/test_config_changes.py
.py
2dfce475fd331394
7.92
6
#!/usr/bin/env python3 # Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. import textwrap import unittest import ops from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerConsumer from ops.charm import CharmBase from ops.framework import StoredState from ops.testing import Ha...
canonical/alertmanager-k8s-operator
tests/unit/test_consumer.py
.py
9e3851035aeb76d8
7.92
6
#!/usr/bin/env python3 # Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. import logging import unittest from typing import Optional from unittest.mock import patch import ops import yaml from helpers import cli_arg, k8s_resource_multipatch from ops.testing import Harness from alertmanager imp...
canonical/alertmanager-k8s-operator
tests/unit/test_external_url.py
.py
9c98f91f2a6de0c0
7.92
6
#!/usr/bin/env python3 # Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. import logging import unittest from unittest.mock import patch import hypothesis.strategies as st import ops import validators import yaml from helpers import k8s_resource_multipatch from hypothesis import given from ops....
canonical/alertmanager-k8s-operator
tests/unit/test_push_config_to_workload_on_startup.py
.py
deb85f183123b282
7.92
6
# Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """Feature: The workload's scheme is reflected in the pebble command and in relation data. This feature spans: - manifest generation (pebble layer) - schema generation (alertmanager_dispatch provider) The alertmanager server can serve over HTT...
canonical/alertmanager-k8s-operator
tests/unit/test_server_scheme.py
.py
9872548e3158e6f5
7.92
6
import json from common.googleapis import GoogleAPIClient # Youtube video to look up (look at this graph) YOUTUBE_VIDEO_ID = 'sIlNIVXpIns' # Sheet id to look up (DB2019 public sheet) SHEET_ID = '15t-UsfNlP5xUxLTLH-EUjrOYriOvXuNGAPxi_8EZJhU' def youtube(client): client.request('GET', 'https://www.googleapis.com/y...
dbvideostriketeam/wubloader
api_ping/api_ping/main.py
.py
758f774ead9eca88
7.64
18
import datetime import math import os from io import BytesIO import argh from PIL import Image import common from common.segments import extract_frame, parse_segment_path colour_profiles = { 'DBfH_2025':{ 'sky_colours': { 'score': (113, 118, 114), 'day': (83, 204, 200), 'dusk': (202, 144, 169), 'nig...
dbvideostriketeam/wubloader
bus_analyzer/bus_analyzer/extract.py
.py
35a1b9a87c761fc0
7.64
18
import datetime import logging import os import random import signal import time import traceback import argh import gevent.event from gevent.pool import Pool import prometheus_client as prom import common from common import database from common.segments import parse_segment_path, list_segment_files from common.stat...
dbvideostriketeam/wubloader
bus_analyzer/bus_analyzer/main.py
.py
628ee7ceb14fe3cb
7.64
18
from vosk import Model, SpkModel, KaldiRecognizer class BuscribeRecognizer: segments_start_time = None def __init__(self, sample_rate=48000, model_path="model_small", spk_model_path="spk_model"): """Loads the speech recognition model and initializes the recognizer. Model paths are file paths...
dbvideostriketeam/wubloader
buscribe/buscribe/recognizer.py
.py
bfdd60ce90255e8b
7.64
18
"""A group of greenlets running tasks. Each task has a key. If a task with that key is already running, it is not re-run.""" import gevent class KeyedGroup: def __init__(self): self.greenlets = {} def spawn(self, key, func, *args, **kwargs): if key not in self.greenlets: self.greenlets[key] = gevent.spawn...
dbvideostriketeam/wubloader
chat_archiver/chat_archiver/keyed_group.py
.py
598b48fe179974a2
7.64
18
"""A place for common utilities between wubloader components""" import datetime import errno import logging import os import random from signal import SIGTERM from uuid import uuid4 import gevent.event from .segments import get_best_segments, rough_cut_segments, fast_cut_segments, full_cut_segments, parse_segment_pa...
dbvideostriketeam/wubloader
common/common/__init__.py
.py
d16a6b000bdfdd7c
7.64
18
import itertools import gevent.lock class CachedIterator(): """Wraps an iterator. When you iterate over this, it pulls items from the wrapped iterator as needed, but remembers each one. When you iterate over it again, it will re-serve the yielded items in the same order, until it runs out, in which case it start...
dbvideostriketeam/wubloader
common/common/cached_iterator.py
.py
ca1ae14c4d88eef1
7.64
18
import json import logging import os from datetime import datetime, timedelta from common import listdir from common.stats import timed from common.segments import hour_paths_for_range # How long each batch is BATCH_INTERVAL = 60 def format_batch(messages): # We need to take some care to have a consistent orderi...
dbvideostriketeam/wubloader
common/common/chat.py
.py
533f7a51fdef83a7
7.64
18
""" Code shared between components that touch the database. Note that this code requires psycopg2 and psycogreen, but the common module as a whole does not to avoid needing to install them for components that don't need it. """ from contextlib import contextmanager import psycopg2 import psycopg2.sql import psycopg2...
dbvideostriketeam/wubloader
common/common/database.py
.py
f5abb6d1f2b19a96
7.64
18
"""Wrapper code around dateutil to use it more sanely""" # required so we are able to import dateutil despite this module also being called dateutil from __future__ import absolute_import import dateutil.parser import dateutil.tz def parse(timestamp): """Parse given timestamp, convert to UTC, and return naive U...
dbvideostriketeam/wubloader
common/common/dateutil.py
.py
6ea8f73e63e3dfa2
7.64
18
import struct class FixTS(): """Does stream processing on an MPEG-TS stream, adjusting all timestamps in it. The stream will be adjusted such that the first packet starts at the given start_time, with all other packets adjusted to be the same time relative to that packet. In other words, a video that goes from 0...
dbvideostriketeam/wubloader
common/common/fixts.py
.py
bb65811a143e196f
7.64
18
""" Code shared between components to gather stats from flask methods. Note that this code requires flask, but the common module as a whole does not to avoid needing to install them for components that don't need it. """ import functools from flask import request from flask import g as request_store from monotonic im...
dbvideostriketeam/wubloader
common/common/flask_stats.py
.py
19f1bf5cce7f8132
7.64
18
import time import logging import gevent from requests import HTTPError from .requests import InstrumentedSession # Wraps all requests in some metric collection and default timeouts requests = InstrumentedSession() requests.timeout = 30 class GoogleAPIClient(object): """Manages access to google apis and maintain...
dbvideostriketeam/wubloader
common/common/googleapis.py
.py
efba9c30046cac33
7.64
18
import sys from io import BytesIO from PIL import Image from common import database def get_template(dbmanager, name, crop=None, location=None): """Fetch the thumbnail template and any missing parameters from the database""" with dbmanager.get_conn() as conn: query = """ SELECT image, crop, location FROM te...
dbvideostriketeam/wubloader
common/common/images.py
.py
5448a0029ac50cdf
7.64
18
import json import logging import os import re import socket import time import urllib.parse from base64 import b64encode from hashlib import sha256 from uuid import uuid4 import gevent import prometheus_client as prom import requests import urllib3.connection from gevent.pool import Pool from ipaddress import ip_addr...
dbvideostriketeam/wubloader
common/common/media.py
.py
195af050fab3c438
7.64
18
"""Code for instrumenting requests calls. Requires requests, obviously.""" import urllib.parse import requests.sessions import prometheus_client as prom from monotonic import monotonic request_latency = prom.Histogram( 'http_client_request_latency', 'Time taken to make an outgoing HTTP request. ' 'Status = "erro...
dbvideostriketeam/wubloader
common/common/requests.py
.py
6d8bc83f7e949fc5
7.64
18
import logging from .googleapis import GoogleAPIClient class Sheets(object): """Manages Google Sheets API operations""" def __init__(self, client_id, client_secret, refresh_token): self.logger = logging.getLogger(type(self).__name__) self.client = GoogleAPIClient(client_id, client_secret, refresh_token) de...
dbvideostriketeam/wubloader
common/common/sheets.py
.py
e60946041db2e36d
7.64
18
import datetime import math import urllib import zoneinfo from common import dateutil from common.requests import InstrumentedSession UTC = datetime.timezone.utc requests = InstrumentedSession() def parse_shift_time(time_str, timeout=5): """ Parse times in the shift definition. The parser first tries to pars...
dbvideostriketeam/wubloader
common/common/shifts.py
.py
ae44f2972043dfff
7.64
18
import atexit import functools import logging import os import signal import gevent.lock from monotonic import monotonic import prometheus_client as prom # need to keep global track of what metrics we've registered # because we're not allowed to re-register metrics = {} def timed(name=None, buckets=[10.**x for x...
dbvideostriketeam/wubloader
common/common/stats.py
.py
e61ca2666923366a
7.64
18
# -*- coding: utf-8 -*- """ NMChannel module. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source Software Toolkit for A...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_channel.py
.py
55d2e70c0dca4231
7.6
15
# -*- coding: utf-8 -*- """ [Module description]. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source Software Toolkit ...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_epoch.py
.py
6c8255616aa1a3a1
7.6
15
# -*- coding: utf-8 -*- """ Centralized history logging for pyNeuroMatic. Provides NMHistory, a wrapper around Python's logging module that maintains an in-memory history buffer and colorama-colored console output, analogous to Igor Pro's history command window. Part of pyNeuroMatic, a Python implementation of NeuroM...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_history.py
.py
b981c5fc7b79078e
7.6
15
# -*- coding: utf-8 -*- """ NMNotes module. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source Software Toolkit for Acq...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_notes.py
.py
11a572b34c95a6b9
7.6
15
# -*- coding: utf-8 -*- """ [Module description]. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source Software Toolkit ...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_object.py
.py
4f323c9df24daecb
7.6
15
# -*- coding: utf-8 -*- """ NM Tool Registry - Central registry for lazy tool loading. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Inte...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_tool_registry.py
.py
d78d5a529ee7f52c
7.6
15
# -*- coding: utf-8 -*- """ NM Workspace - User workspace configuration management. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integra...
SilverLabUCL/pyNeuroMatic
pyneuromatic/core/nm_workspace.py
.py
3defe6d4c6b9eb9f
7.6
15
# -*- coding: utf-8 -*- """ pyNeuroMatic GUI - Optional graphical interface. This module requires PyQt6. Install with: pip install pyneuromatic[gui] """ # Check if GUI dependencies are available try: from PyQt6 import QtWidgets, QtCore GUI_AVAILABLE = True _GUI_IMPORT_ERROR = None except ImportError a...
SilverLabUCL/pyNeuroMatic
pyneuromatic/gui/__init__.py
.py
d1393796368060ac
7.6
15
# -*- coding: utf-8 -*- """ FolderBrowserWidget - read-only tree view over an NMManager's folder hierarchy. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018...
SilverLabUCL/pyNeuroMatic
pyneuromatic/gui/folder_browser.py
.py
8ed2f52b9eead7af
7.6
15
# -*- coding: utf-8 -*- """ Axograph file format reader. Supports Axograph X files (.axgx) and classic Axograph files (.axgd). Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. References: - NeuroMatic Igor import: NM_ImportAxograph.ipf ...
SilverLabUCL/pyNeuroMatic
pyneuromatic/io/axograph.py
.py
2830ff4c495fc5a4
7.6
15
# -*- coding: utf-8 -*- """ Base utilities for I/O operations. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. """ from __future__ import annotations import re from typing import NamedTuple class ParsedUnits(NamedTuple): """Result of par...
SilverLabUCL/pyNeuroMatic
pyneuromatic/io/base.py
.py
811617fb29f8e38e
7.6
15
# -*- coding: utf-8 -*- """ Igor Pro packed experiment (.pxp) file reader. Reads PXP files created by NeuroMatic in Igor Pro using the igor2 library. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. References: - NeuroMatic Igor: https://...
SilverLabUCL/pyNeuroMatic
pyneuromatic/io/pxp.py
.py
7b43207312c1b265
7.6
15
# -*- coding: utf-8 -*- """ Matplotlib plotting utilities for NMData and NMFolder. Provides three public functions: - :func:`plot_nmdata` — plot a single NMData array. - :func:`plot_folder` — plot all epochs for a given prefix, one subplot per channel, with epochs overlaid. - :func:`plot_channel_data` — shared sub...
SilverLabUCL/pyNeuroMatic
pyneuromatic/tools/nm_plot.py
.py
595e8d4b009e6e6c
7.6
15
# -*- coding: utf-8 -*- """ NM Tool - Base class for analysis tools. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source...
SilverLabUCL/pyNeuroMatic
pyneuromatic/tools/nm_tool.py
.py
56145d6fbef72020
7.6
15
# -*- coding: utf-8 -*- """ [Module description]. Part of pyNeuroMatic, a Python implementation of NeuroMatic for analyzing, acquiring and simulating electrophysiology data. If you use this software in your research, please cite: Rothman JS and Silver RA (2018) NeuroMatic: An Integrated Open-Source Software Toolkit ...
SilverLabUCL/pyNeuroMatic
pyneuromatic/tools/nm_tool_folder.py
.py
b86f17a27f2212dd
7.6
15
import os import numpy as np import pandas as pd import nibabel as nb import pooch from numba import njit from time import time ZENODO_RECORD = "18793343" ZENODO_URL = f"https://zenodo.org/api/records/{ZENODO_RECORD}/files" CACHE_DIR = pooch.os_cache("MTB_task_library") def fetch_task_library(version='V1', atlas='m...
DiedrichsenLab/MultiTaskBattery
MultiTaskBattery/battery.py
.py
e2ce10d43540ed46
7.5
9
# Created 2023: Bassel Arafat, Jorn Diedrichsen, Ince Husain from psychopy import core, event class TTLClock: def __init__(self): """ TTLClock class is used for counting the number of TTL pulses and the time of the last TTL pulse """ self.clock = core.Clock() # self.tt...
DiedrichsenLab/MultiTaskBattery
MultiTaskBattery/ttl_clock.py
.py
063f9c697cd6b515
7.5
9
""" Sphinx extension to auto-generate task descriptions from task_table.tsv. This way we dont have to manually add tasks. The only thing that can be added manually (optional) is media for each task. Just go to images/ and add {task_name}.png, {task_name}_2.png, ... for screenshots, and/or {task_name}.mp4, {task_name}_2...
DiedrichsenLab/MultiTaskBattery
docs/extension/task_docs.py
.py
794823583c095a65
7.5
9
import os import json import numpy as np import pandas as pd import nibabel as nb import pooch # Same Zenodo source as MultiTaskBattery/battery.py ZENODO_RECORD = "18793343" CACHE_DIR = pooch.os_cache("MTB_task_library") VERSION = "V1" ATLAS = "multiatlasHCP" N_DIMS = 8 # MDS dimensions to keep (viewer lets you pick...
DiedrichsenLab/MultiTaskBattery
docs/mds/make_mds_data.py
.py
693fc53504b5a518
7.5
9
"""One-command dependency install for MultiTaskBattery, on any OS. python install.py On Linux this detects your distribution and points pip at the matching prebuilt wxPython wheels (wxPython has none on PyPI for Linux, so a plain pip install would try to compile it from source and fail). On Windows and macOS it i...
DiedrichsenLab/MultiTaskBattery
install.py
.py
080f5b5e6059f409
7.5
9
import os from functools import partial import click from rich.table import Table from PyTM import settings from PyTM.console import console from PyTM.core import data_handler, hook_handler, project_handler, task_handler BASH_SNIPPET = """\ # pytm ambient tracking hook (bash) _pytm_hook_check() { local _pytm_exit=...
wasi0013/PyTM
PyTM/commands/hook.py
.py
9859e6b037d5d6ed
7.63
17
import os import shutil import subprocess from filelock import FileLock, Timeout from PyTM import settings from PyTM.core import data_handler, hook_handler # Commits made by PyTM itself always use this identity, regardless of # whatever (if anything) `git config user.name`/`user.email` resolve to on # the machine — ...
wasi0013/PyTM
PyTM/core/backup_handler.py
.py
55fee9f36cf66463
7.63
17
import json import os import tempfile from filelock import FileLock from PyTM import settings def _default_path(path): """ Resolves the effective path for a data-handler call. Falling back to `settings.data_filepath` here (instead of as a function default) means the current value of `settings.data_f...
wasi0013/PyTM
PyTM/core/data_handler.py
.py
fbd83393e256b62b
7.63
17
import datetime from PyTM import settings def _parse(ts): return datetime.datetime.fromisoformat(ts) def _session_seconds_in_window(session, window_start, window_end, now): """ Seconds of a single session that fall within [window_start, window_end). Adjustment entries written by `task_handler.edit...
wasi0013/PyTM
PyTM/core/digest_handler.py
.py
bed9daa0f4556f8d
7.63
17
import os import subprocess def normalize(path): return os.path.realpath(path) def resolve_project(links, cwd): """ Longest-prefix match of `cwd` against linked directories. `links` is `{normalized_path: project_name}` — `hook link`/`hook unlink` already normalize keys before storing, so only `c...
wasi0013/PyTM
PyTM/core/hook_handler.py
.py
ff337e1353db8097
7.63
17
import datetime from PyTM import settings def calculate_duration(date1, date2): return abs( ( datetime.datetime.fromisoformat(date1) - datetime.datetime.fromisoformat(date2) ).total_seconds() ) def _close_open_session(task, end): """ Closes the most recent op...
wasi0013/PyTM
PyTM/core/task_handler.py
.py
cd47d7562d881557
7.63
17
import json import os import threading import pytest from PyTM import settings from PyTM.core import data_handler def test_init_data(tmpdir): tmp_path = tmpdir.join("pytm-test.json") data_handler.init_data(tmp_path) assert tmp_path.read() == "{}" def test_load_data_exists(tmpdir): tmp_path = tmpdi...
wasi0013/PyTM
tests/core/test_data_handler.py
.py
fc610793728508f9
7.13
17
from PyTM.core import hook_handler def linked(pairs): """ Builds a `links` dict the way `hook link` actually stores one: keys pre-normalized via `hook_handler.normalize`. `resolve_project` relies on that invariant (it only normalizes `cwd`, not the stored keys, to avoid redundant syscalls on its h...
wasi0013/PyTM
tests/core/test_hook_handler.py
.py
4999992492400f0d
8.13
17
import datetime import pytest from PyTM import settings from PyTM.core import task_handler TEST_TIME_NOW = datetime.datetime( 2023, 11, 9, ) @pytest.fixture def patch_datetime_now(monkeypatch): class mydatetime(datetime.datetime): @classmethod def now(cls): return TEST_T...
wasi0013/PyTM
tests/core/test_task_handler.py
.py
618347b4151c1c49
8.13
17
"""Commands to inspect or modify the contents of pseudo potential families.""" import json import click from aiida.cmdline.params import options as options_core from aiida.cmdline.utils import decorators, echo from .params import arguments, options, types from .root import cmd_root @cmd_root.group('family') def cmd...
aiidateam/aiida-pseudo
src/aiida_pseudo/cli/family.py
.py
2336d71be283697b
7.42
6
"""Commands to list instances of `PseudoPotentialFamily`.""" import click from aiida.cmdline.params import options as options_core from aiida.cmdline.utils import decorators, echo from .params import options from .root import cmd_root PROJECTIONS_VALID = ('pk', 'uuid', 'type_string', 'label', 'description', 'count') ...
aiidateam/aiida-pseudo
src/aiida_pseudo/cli/list.py
.py
10d5476c254eee75
7.42
6
"""Command line interface `aiida-pseudo`.""" import click from aiida.cmdline.groups.verdi import VerdiCommandGroup from .params import options class CustomVerdiCommandGroup(VerdiCommandGroup): """Subclass of :class:`aiida.cmdline.groups.verdi.VerdiCommandGroup` for the CLI. This subclass overrides the verbo...
aiidateam/aiida-pseudo
src/aiida_pseudo/cli/root.py
.py
47d1bd4e4defb295
7.42
6
"""Command line interface utilities.""" from contextlib import contextmanager from pathlib import Path from aiida.cmdline.utils import echo __all__ = ('attempt', 'create_family_from_archive') @contextmanager def attempt(message, exception_types=Exception, include_traceback=False): """Context manager to be used ...
aiidateam/aiida-pseudo
src/aiida_pseudo/cli/utils.py
.py
139155239d8e87ca
7.42
6
"""Module for data plugin to represent a pseudo potential in JTH XML format.""" import pathlib import re import typing from .pseudo import PseudoPotentialData __all__ = ('JthXmlData',) REGEX_ELEMENT = re.compile(r"""\s*symbol\s*=\s*['"]\s*(?P<element>[a-zA-Z]{1,2})\s*['"].*""") def parse_element(stream: typing.Bin...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/jthxml.py
.py
53f738713e02e998
7.42
6
"""Base class for data types representing pseudo potentials.""" from __future__ import annotations import io import pathlib import typing from aiida import orm, plugins from aiida.common.constants import elements from aiida.common.exceptions import StoringNotAllowed from aiida.common.files import md5_from_filelike fr...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/pseudo.py
.py
e4bd8fd949296f5f
7.42
6
"""Module for data plugin to represent a pseudo potential in PSF format.""" import pathlib import re import typing from .pseudo import PseudoPotentialData __all__ = ('PsfData',) REGEX_ELEMENT = re.compile(r"""\s*(?P<element>[a-zA-Z]{1}[a-z]?)\s+.*""") def parse_element(stream: typing.BinaryIO): """Parse the co...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/psf.py
.py
2426373c4143c380
7.42
6
"""Module for data plugin to represent a pseudo potential in PSML format.""" import pathlib import re import typing from .pseudo import PseudoPotentialData __all__ = ('PsmlData',) REGEX_ELEMENT = re.compile(r"""\s*(?P<element>[a-zA-Z]{1}[a-z]?)\s+.*""") def parse_element(stream: typing.BinaryIO) -> str: """Par...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/psml.py
.py
37bebd7366c26e2b
7.42
6
"""Module for data plugin to represent a pseudo potential in Psp8 format.""" import pathlib import typing from aiida.common.constants import elements from .pseudo import PseudoPotentialData __all__ = ('Psp8Data',) def parse_element(stream: typing.BinaryIO): """Parse the content of the Psp8 file to determine th...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/psp8.py
.py
92ff4387c5e6de22
7.42
6
"""Module for data plugin to represent a pseudo potential in UPF format.""" import pathlib import re import typing from .pseudo import PseudoPotentialData __all__ = ('UpfData',) REGEX_ELEMENT_V1 = re.compile(r"""(?P<element>[a-zA-Z]{1,2})\s+Element""") REGEX_ELEMENT_V2 = re.compile(r"""\s*element\s*=\s*['"]\s*(?P<el...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/upf.py
.py
11c9e64d08403f19
7.42
6
"""Module for data plugin to represent a pseudo potential in VPS format.""" import pathlib import re import typing from aiida.common.constants import elements from .pseudo import PseudoPotentialData __all__ = ('VpsData',) PATTERN_FLOAT = r'[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?' REGEX_ATOMIC_NUMBER = re.compile(r"...
aiidateam/aiida-pseudo
src/aiida_pseudo/data/pseudo/vps.py
.py
7a9c7027299db628
7.42
6
"""Subclass of ``Group`` that serves as a base class for representing pseudo potential families.""" import re from typing import List, Mapping, Optional, Tuple, Union from aiida.common import exceptions from aiida.common.lang import classproperty, type_check from aiida.orm import Group, QueryBuilder from aiida.plugins...
aiidateam/aiida-pseudo
src/aiida_pseudo/groups/family/pseudo.py
.py
329d0effa161491d
7.42
6
"""Subclass of `PseudoPotentialFamily` designed to represent a PseudoDojo configuration.""" from __future__ import annotations import json import pathlib import re import warnings from typing import ClassVar, NamedTuple, Sequence from aiida.common.exceptions import ParsingError from aiida_pseudo.data.pseudo import J...
aiidateam/aiida-pseudo
src/aiida_pseudo/groups/family/pseudo_dojo.py
.py
05eb0e8ec3a112cf
7.42
6
"""Subclass of ``PseudoPotentialFamily`` designed to represent an SSSP configuration.""" from typing import NamedTuple, Optional, Sequence from aiida_pseudo.data.pseudo import UpfData from ..mixins import RecommendedCutoffMixin from .pseudo import PseudoPotentialFamily __all__ = ('SsspConfiguration', 'SsspFamily') ...
aiidateam/aiida-pseudo
src/aiida_pseudo/groups/family/sssp.py
.py
9e19d9fd21813b6d
7.42
6
"""Mixin that adds support of recommended cutoffs to a ``Group`` subclass, using its extras.""" import warnings from typing import Optional from aiida.common.exceptions import MissingEntryPointError from aiida.common.lang import type_check from aiida.plugins import DataFactory from aiida_pseudo.common.units import U ...
aiidateam/aiida-pseudo
src/aiida_pseudo/groups/mixins/cutoffs.py
.py
1767423cce88cb7d
7.42
6
"""Tests for the :mod:`~aiida_pseudo.cli.params.types` module.""" import click import pytest from aiida_pseudo.cli.params import types from aiida_pseudo.groups.family import PseudoPotentialFamily def test_pseudo_family_type_param_convert(ctx): """Test the `PseudoPotentialFamilyTypeParam.convert` method.""" pa...
aiidateam/aiida-pseudo
tests/cli/params/test_types.py
.py
9ca6b5e38bceb05c
7.92
6
"""Tests for the command `aiida-pseudo family`.""" import json from copy import deepcopy import pytest from aiida.orm import Group from aiida_pseudo.cli.family import cmd_family_cutoffs_set, cmd_family_show from aiida_pseudo.data.pseudo.upf import UpfData from aiida_pseudo.groups.family import CutoffsPseudoPotentialFa...
aiidateam/aiida-pseudo
tests/cli/test_family.py
.py
bababcefdd5aa71b
7.92
6
"""Tests for the command `aiida-pseudo list`.""" from aiida_pseudo.cli import cmd_list from aiida_pseudo.cli.list import PROJECTIONS_VALID from aiida_pseudo.data.pseudo import UpfData from aiida_pseudo.groups.family import PseudoPotentialFamily, SsspFamily def test_list(aiida_profile_clean, run_cli_command, get_pseud...
aiidateam/aiida-pseudo
tests/cli/test_list.py
.py
9fec3f46acea149b
7.92
6
"""Tests for CLI commands.""" from __future__ import annotations import subprocess import click import pytest from aiida_pseudo.cli import cmd_root def recurse_commands(command: click.Command, parents: list[str] | None = None): """Recursively return all subcommands that are part of ``command``. :param comm...
aiidateam/aiida-pseudo
tests/cli/test_root.py
.py
55897b568c8cacf4
7.92
6
"""Test the command line interface utilities.""" import shutil import tarfile import tempfile import pytest from aiida_pseudo.cli.utils import attempt, create_family_from_archive from aiida_pseudo.groups.family import PseudoPotentialFamily @pytest.mark.usefixtures('aiida_profile_clean') @pytest.mark.parametrize(('fm...
aiidateam/aiida-pseudo
tests/cli/test_utils.py
.py
6c5f2db1f2b07092
7.92
6
"""Configuration and fixtures for unit test suite.""" import io import os import pathlib import re import shutil import click import pytest from aiida.plugins import DataFactory from aiida_pseudo.data.pseudo import PseudoPotentialData from aiida_pseudo.groups.family import CutoffsPseudoPotentialFamily, PseudoPotential...
aiidateam/aiida-pseudo
tests/conftest.py
.py
a62f3fc5c703b594
7.92
6
"""Tests that are common to all data plugins in the :py:mod:`~aiida_pseudo.data.pseudo` module.""" import pytest from aiida import plugins def get_entry_point_names(): """Return the registered entry point names for the given common workflow. :param workflow: the name of the common workflow. :param leaf: ...
aiidateam/aiida-pseudo
tests/data/pseudo/test_common.py
.py
388cc40ed351c334
7.92
6
"""Tests for the :py:`~aiida_pseudo.data.pseudo.jthxml` module.""" import io import pathlib import pytest from aiida.common.exceptions import ModificationNotAllowed from aiida_pseudo.data.pseudo import JthXmlData @pytest.fixture def source(request, filepath_pseudos): """Return a pseudopotential, eiter as ``str``...
aiidateam/aiida-pseudo
tests/data/pseudo/test_jthxml.py
.py
8117d4feb6655e51
7.92
6
"""Tests for the :py:mod:`~aiida_pseudo.data.pseudo.pseudo` module.""" import io import pathlib import pytest from aiida.common.exceptions import ModificationNotAllowed, StoringNotAllowed from aiida.common.files import md5_from_filelike from aiida.common.links import LinkType from aiida.orm import CalcJobNode from aii...
aiidateam/aiida-pseudo
tests/data/pseudo/test_pseudo.py
.py
ba0c3be61fb2939e
7.92
6
"""Tests for the :py:`~aiida_pseudo.data.pseudo.psf` module.""" import io import pathlib import pytest from aiida.common.exceptions import ModificationNotAllowed from aiida_pseudo.data.pseudo import PsfData from aiida_pseudo.data.pseudo.psf import parse_element @pytest.mark.parametrize( ('string', 'element'), ...
aiidateam/aiida-pseudo
tests/data/pseudo/test_psf.py
.py
da972ed1fc84d659
7.92
6
"""Tests for the :py:`~aiida_pseudo.data.pseudo.psml` module.""" import io import pathlib import pytest from aiida.common.exceptions import ModificationNotAllowed from aiida_pseudo.data.pseudo import PsmlData @pytest.fixture def source(request, filepath_pseudos): """Return a pseudopotential, eiter as ``str``, ``...
aiidateam/aiida-pseudo
tests/data/pseudo/test_psml.py
.py
0f74ceb22297f371
7.92
6
"""Utilities for modifying Terraform backend configuration.""" import re from pathlib import Path from typing import Union, Optional import hcl2 import lark from leverage._utils import ExitError def set_backend_key(config_file_path: Union[str, Path], key: str) -> None: """ Set or update the backend key in ...
binbashar/leverage
leverage/_backend_config.py
.py
58177f1a3db5ca32
7.66
20
""" Command line arguments and tasks arguments parsing utilities. """ class InvalidArgumentOrderError(RuntimeError): pass class DuplicateKeywordArgumentError(RuntimeError): pass def parse_task_args(arguments): """Parse the arguments for a task and return args and kwargs appropriately Args: ...
binbashar/leverage
leverage/_parsing.py
.py
4a8f22d717fae94c
7.66
20
""" General use utilities. """ from pathlib import Path from subprocess import PIPE, run from typing import List, Optional import hcl2 import lark from click.exceptions import ClickException from configupdater import ConfigUpdater from leverage import logger def clean_exception_traceback(exception): """Del...
binbashar/leverage
leverage/_utils.py
.py
013bf86a2870263e
7.66
20
""" Logging utilities. """ import logging from functools import wraps from rich.console import Console from rich.logging import RichHandler from click import get_current_context _RAW_LOGGING_FORMAT = "%(message)s" _TASK_LOGGING_FORMAT = ( "[bold light_yellow3][ %(build_script)s -[/bold light_yellow3]" "...
binbashar/leverage
leverage/logger.py
.py
ddeb7a31ecce4aaa
7.66
20
import time import json import datetime import webbrowser from typing import Any, Dict, Tuple import boto3 import click from dateutil.tz import tzutc from configupdater import ConfigUpdater from leverage import logger from leverage.path import PathsHandler from leverage.modules.runner import Runner from leverage.modu...
binbashar/leverage
leverage/modules/aws.py
.py
a9470d868487f3d6
7.66
20
import os from enum import Enum from pathlib import Path from dataclasses import dataclass import click import ruamel.yaml import simple_term_menu from leverage import logger from leverage.path import PathsHandler from leverage._utils import ExitError from leverage.modules.aws import aws from leverage.modules.runner ...
binbashar/leverage
leverage/modules/kubectl.py
.py
7aa419d2a5e4a40b
7.66
20
""" Module for managing Leverage projects. """ import re from pathlib import Path from shutil import copy2 from shutil import copytree from shutil import ignore_patterns import click from click.exceptions import Exit from ruamel.yaml import YAML from jinja2 import Environment from jinja2 import FileSystemLoader ...
binbashar/leverage
leverage/modules/project.py
.py
ffb28ffc5585addf
7.66
20
""" Tasks running module. """ import re import click from click.exceptions import Exit from leverage import logger from leverage.tasks import load_tasks from leverage.tasks import list_tasks as _list_tasks from leverage.logger import get_tasks_logger from leverage._parsing import parse_task_args from leverage._p...
binbashar/leverage
leverage/modules/run.py
.py
75c4c5e1851ad7e5
7.66
20
import os import shutil import subprocess from pathlib import Path from typing import Dict, Optional, Tuple, Union from leverage import logger from leverage._utils import ExitError class Runner: """Generic command runner for executing system binaries with environment preservation""" def __init__( sel...
binbashar/leverage
leverage/modules/runner.py
.py
597e6d58c9eaf51a
7.66
20
import subprocess from pathlib import Path from typing import Dict, Optional from click.exceptions import Exit from leverage._utils import ExitError from leverage.modules.runner import Runner class TFRunner(Runner): """Terraform/OpenTofu runner with appropriate installation guidance""" TERRAFORM_INSTALL_UR...
binbashar/leverage
leverage/modules/tfrunner.py
.py
81d7390a0a1972f6
7.66
20
""" Utilities to obtain relevant files' and directories' locations """ from pathlib import Path from subprocess import CalledProcessError from subprocess import PIPE from subprocess import run import hcl2 from leverage._utils import ExitError class NotARepositoryError(RuntimeError): """When you are not run...
binbashar/leverage
leverage/path.py
.py
023187f317b277dc
7.66
20
""" Task loading, Task object definition and task creation decorator. """ import sys import importlib from pathlib import Path from inspect import getmembers from inspect import isfunction from operator import attrgetter import click from click.exceptions import Exit from leverage import __version__ from leverag...
binbashar/leverage
leverage/tasks.py
.py
f2885b91efeb6831
7.66
20
import tempfile import subprocess from pathlib import Path import pytest import click from click.testing import CliRunner from leverage import path as lepath from leverage import conf from leverage._internals import State from leverage._internals import Module from leverage.logger import _configure_logger, _leverage_...
binbashar/leverage
tests/conftest.py
.py
1f37fdc565a2aff7
8.16
20
"""Tests for backend configuration utilities.""" import pytest from leverage._backend_config import set_backend_key, get_backend_key from leverage._utils import ExitError @pytest.fixture def config_without_key(tmp_path): """Create a config.tf file without a backend key.""" config_file = tmp_path / "config.tf...
binbashar/leverage
tests/test_backend_config.py
.py
ffc85cb2891428b1
7.16
20
from pathlib import Path, PosixPath from unittest import mock from unittest.mock import Mock, patch from click.testing import CliRunner from leverage import leverage from leverage.modules.kubectl import _scan_clusters, ClusterInfo def test_scan_clusters(): """ Test that we can find valid metadata.yaml prese...
binbashar/leverage
tests/test_modules/test_kubectl.py
.py
3be6914e1a09720d
8.16
20
from unittest.mock import patch import pytest from leverage import leverage from leverage.modules.tf import has_a_plan_file @pytest.mark.parametrize( "args", [ ([]), (["-migrate-state"]), (["-r1", "-r2"]), ], ) def test_init_arguments(leverage_project, leverage_runner, args): ...
binbashar/leverage
tests/test_modules/test_tf.py
.py
611c5f68f646d1e8
8.16
20