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
"""Locate / reuse the data produced by a previous run.
The most recent `derived` artifact is the single source of truth for the
fetched data. The fetch job refreshes it (on schedule/dispatch and on
pushes/PRs that touch the fetch inputs); every other run, and the Scholar
fallback, reuse it inste... | jhrmnn/jhrmnn.github.io | reuse_data.py | .py | fa6643ed9412f146 | 7 | 0 |
"""The collector protocol: Collector, the supplier/accumulator/combiner/
finisher quadruple mirroring Java's Collector<T,A,R>; _CollectorSink, which
adapts one to the sink protocol; and StreamingCollector, the one collect()
argument that is not a Collector. The factories that build Collectors live in
collectors.py, whi... | carby/snakestream | src/snakestream/collector.py | .py | d7dd06b4ea7b2eee | 7 | 0 |
"""The collector factories: to_list(), grouping_by(), summing_int() and the
rest, each returning a Collector. Java names this pair too - Collector is the
interface, Collectors the class that holds the factories - and the import
edge runs one way, collectors -> collector, never back."""
from __future__ import annotatio... | carby/snakestream | src/snakestream/collectors.py | .py | 92ce4454e46b3420 | 7 | 0 |
def check_comparator_result_type(value: int) -> None:
if type(value) is not int:
raise TypeError(f"comparator must return an int (negative, zero, or positive), not {type(value).__name__}")
def is_new_extremum(sign: int, asc: bool) -> bool:
"""Whether an element that compared as `sign` against the curr... | carby/snakestream | src/snakestream/comparator.py | .py | 839d06e3e4a431fd | 7 | 0 |
class StreamException(Exception):
"""Base of every exception this library raises, so a caller can catch
anything snakestream raised without enumerating the leaves.
Never raised directly - it exists to be caught, not thrown - and derives
from Exception and nothing else. In particular not from ValueError... | carby/snakestream | src/snakestream/exception.py | .py | 68e349d46c972f7c | 7 | 0 |
"""One Op plus one Sink per intermediate operation - filter, map, peek,
sorted, flat_map, distinct, limit, skip, unordered - built on the Op/Sink
protocol sink.py defines. No execution logic lives here: how a chain of these
gets driven, sequentially or racing, is execution.py's job."""
from __future__ import annotatio... | carby/snakestream | src/snakestream/ops.py | .py | 2ea39010ce972e1f | 7 | 0 |
"""The Op/Sink pair: an Op sits in a stream's chain and builds the Sink that
does the per-element work once it is linked into a chain. A Sink implements
one push protocol - begin(state_map), accept(element), end() - plus a
synchronous cancellation_requested() query a driving loop polls to stop
early. IntermediateSink, ... | carby/snakestream | src/snakestream/sink.py | .py | 995c3412886e50cf | 7 | 0 |
from functools import cmp_to_key
from inspect import isawaitable
from typing import Any, cast
from collections.abc import Callable
from snakestream.callable_dispatch import is_async_callable
from snakestream.comparator import check_comparator_result_type
from snakestream.type import AsyncComparator, Comparator
def _... | carby/snakestream | src/snakestream/sort.py | .py | 2bf195ee05b7586e | 7 | 0 |
from __future__ import annotations
import sys
from inspect import isawaitable, iscoroutinefunction
from typing import TYPE_CHECKING, Any, Generic, cast, overload
from collections.abc import AsyncGenerator, AsyncIterable, Awaitable, Coroutine, Iterable
from snakestream.callable_dispatch import _maybe_await, is_async_c... | carby/snakestream | src/snakestream/stream.py | .py | 521ba1ad83585efe | 7 | 0 |
"""Armstrong number + matrix cipher for encrypting text.
Two-level cipher:
Level 1: XOR each byte with a rotating key byte
Level 2: Matrix substitution using nibbles as row/col
"""
from __future__ import annotations
class Nibbles:
"""Byte/nibble utilities."""
@staticmethod
def split(byte: int) -> t... | hey-amanthakur/SteganographyAlgorithm | src/crypto_algo/cipher.py | .py | c44620f283e7fdf0 | 7 | 0 |
"""Command-line interface for crypto_algo steganography.
Usage:
crypto-algo hide <image> <text> -o <output> -k <key>
crypto-algo extract <image> -k <key>
crypto-algo capacity <image>
"""
from __future__ import annotations
import argparse
import getpass
import logging
import sys
from crypto_algo import s... | hey-amanthakur/SteganographyAlgorithm | src/crypto_algo/cli.py | .py | 492802a55b17ed27 | 7 | 0 |
"""High-level API combining cipher + steganography.
Encrypts text with Armstrong/matrix cipher, then hides
the encrypted bytes inside an image using LSB steganography.
"""
from __future__ import annotations
import os
from crypto_algo import steg
from crypto_algo.cipher import Cipher
from crypto_algo.exceptions impo... | hey-amanthakur/SteganographyAlgorithm | src/crypto_algo/processor.py | .py | 7e16eaeb1c528d42 | 7 | 0 |
"""LSB steganography — hide/extract binary data in image pixels.
Uses the 2 least significant bits of each color channel to store data.
"""
from __future__ import annotations
import numpy as np
from PIL import Image
def _bytes_to_bits(data: bytes) -> list[int]:
"""Convert bytes to a list of individual bits."""... | hey-amanthakur/SteganographyAlgorithm | src/crypto_algo/steg.py | .py | c5dbdaa6973d9fb0 | 7 | 0 |
# Importing libraries
import streamlit as st
import requests
from bs4 import BeautifulSoup
from bs4.element import Tag
import base64
import openai
from streamlit.runtime.uploaded_file_manager import UploadedFile
import json
# Creating and Configuring the OpenAI Client
client: openai.OpenAI = openai.OpenAI(a... | saccofrancesco/crosswords | main.py | .py | 208dcd58a5394561 | 7.39 | 5 |
"""Implementation of the Document Collection Class."""
import glob
from .collection import Collection
from ..product import PDS3DocumentProduct
class DocumentCollection(Collection):
"""Class to generate a PDS3 or PDS4 Document Collection.
:param setup: NPB execution setup object
:param bundle: Bundle ob... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/collection/collection_docs.py | .py | ecd4db443af3ea4a | 7.39 | 5 |
"""Implementation of the PDS4 Miscellaneous Collection Class."""
from .collection import Collection
class MiscellaneousCollection(Collection):
"""Class to generate a PDS4 or PDS3 Document Collection.
:param setup: NPB execution setup object
:param bundle: Bundle object
:param kernels: Kernel List ... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/collection/collection_misc.py | .py | 0351547d61b03ace | 7.39 | 5 |
"""PDS Label Class and Child Classes Implementation."""
import logging
import os
from pathlib import Path
from typing import Optional
from ...utils import add_carriage_return, compare_files
class PDSLabel:
"""Class to generate a PDS Label.
:param product: Product to be labeled
"""
_label_extension:... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/label.py | .py | 401af578cc5a0ffb | 7.39 | 5 |
"""Implementation of the PDS3 version of a label for Checksum files.
"""
from pathlib import Path
from .pds3_label import PDS3Label
class ChecksumPDS3Label(PDS3Label):
"""PDS Label child class to a PDS3 Checksum Label.
:param product: Checksum product to label
"""
def __init__(self, product) -> Non... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds3_checksum.py | .py | 338348272a5e8add | 7.39 | 5 |
"""Implementation of the PDS3 version of a label for Index files.
"""
from .pds3_label import PDS3Label
class InventoryPDS3Label(PDS3Label):
"""PDS Label child class to generate a PDS3 Index Label.
:param product: Index Product
:param collection: Collection the product belongs to
"""
def __init_... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds3_inventory.py | .py | 6373b296f6da3307 | 7.39 | 5 |
"""PDS3 version-specific base class for PDS labels."""
from .label import PDSLabel
class PDS3Label(PDSLabel):
"""Version-specific base class for PDS3 labels.
Leaf PDS3 label classes still assign their own PDS3-specific fields
in their own ``__init__``; this class exists so that ``write_label()``
can... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds3_label.py | .py | 2de4c41f57ba6bce | 7.39 | 5 |
"""Implementation of the PDS3 version of a label for SPICE kernel files.
"""
import logging
from pathlib import Path
import spiceypy
from .pds3_label import PDS3Label
from ..exceptions import NPBError
from ...utils import (
ck_coverage,
extract_comment,
format_multiple_values,
spice_exception_handler,... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds3_spice_kernel.py | .py | ff1a96550d2d27ef | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Bundles.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class BundlePDS4Label(PDS4Label):
"""Class to generate a PDS4 Bundle Label.
:param product: Readme product
"""
_mission_reference_type = "bundle_to_investigation"
_target... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_bundle.py | .py | ef615a7f573c5db3 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Checksum files.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class ChecksumPDS4Label(PDS4Label):
"""Class to generate a PDS4 Checksum Label.
:param product: Checksum product to label
"""
_mission_reference_type = "ancillary_to_i... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_checksum.py | .py | a848f61fa6fa5119 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Documents.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class DocumentPDS4Label(PDS4Label):
"""Class to generate a PDS4 Document Label.
:param product: Document product to label (e.g. the SPICEDS product)
:param collection: Collectio... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_document.py | .py | ff8de3b7ae791d76 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Collection Inventory
files.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class InventoryPDS4Label(PDS4Label):
"""Class to generate a PDS4 Collection Inventory Label.
:param product: Inventory Product of the Collection
:param collecti... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_inventory.py | .py | fdf09ecc10c46302 | 7.39 | 5 |
"""PDS4 version-specific base class for PDS labels."""
from typing import Optional, Tuple
from .label import PDSLabel
from ..exceptions import NPBError
class PDS4Label(PDSLabel):
"""Version-specific base class for PDS4 labels.
Adds the PDS4-only fields that used to be gated behind
``if setup.pds_versio... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_label.py | .py | cb52739af16381f3 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Metakernel files.
"""
from pathlib import Path
from .pds4_label import PDS4Label
from ...utils import extension_to_type
class MetaKernelPDS4Label(PDS4Label):
"""Class to generate a PDS4 SPICE Kernel MK Label.
:param product: MK product to label
"""
... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_metakernel.py | .py | 06c78a637a527338 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for Orbit Number (OrbNum)
files.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class OrbnumFilePDS4Label(PDS4Label):
"""Class to generate a PDS4 Orbit Number File Label.
:param product: OrbNum product to label
"""
def __init__(self, ... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_orbnum_file.py | .py | 0b8530b7a11303d7 | 7.39 | 5 |
"""Implementation of the PDS4 version of a label for SPICE kernel files.
"""
from pathlib import Path
from .pds4_label import PDS4Label
class SpiceKernelPDS4Label(PDS4Label):
"""Class to generate a non-MK PDS4 SPICE Kernel Label.
:param product: SPICE Kernel product to be labeled
"""
def __init__(s... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/label/pds4_spice_kernel.py | .py | cce38dc20b3535e9 | 7.39 | 5 |
"""Log Class Implementation."""
from __future__ import annotations
import datetime
import logging
import os
import platform
import shutil
import socket
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .setup import Setup
from ..utils.types.datatypes import PipelineArgs
class Log:
"""Log class to w... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/log.py | .py | 3446517dd139edef | 7.39 | 5 |
"""Implementation of the Product base class."""
import os
from pathlib import Path
from ...utils import checksum_from_label
from ...utils import checksum_from_registry
from ...utils import creation_time
from ...utils import md5
class Product:
"""Class that defines a generic archive product (or file).
Assign... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/product/product.py | .py | 903ca5e2b4aa578a | 7.39 | 5 |
"""Implementation of the SPICE kernel file product class."""
import logging
import os
import shutil
import spiceypy
from .product import Product
from ..exceptions import NPBError
from ...utils import ck_coverage
from ...utils import dsk_coverage
from ...utils import extension_to_type
from ...utils import pck_coverage... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/product/product_kernel.py | .py | 28bf8f96c893c673 | 7.39 | 5 |
"""Implementation of the PDS3 Document product class."""
import logging
import os
from .product import Product
from ...utils import compare_files
from ...utils import string_in_file
class PDS3DocumentProduct(Product):
"""Class that represents a PDS3 Document Product.
:param setup: NPB execution setup object... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/product/product_pds3doc.py | .py | 4ed2b339fc2c7149 | 7.39 | 5 |
"""Implementation of the SPICE DS file product class."""
import difflib
import filecmp
import glob
import logging
import os
import shutil
from datetime import date
from .product import Product
from ..exceptions import NPBError
from ...utils import add_carriage_return
from ...utils import compare_files
class SpicedsP... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/classes/product/product_spiceds.py | .py | 04a00dcda0dac746 | 7.39 | 5 |
"""Decorator module that contains decorator functions."""
import traceback
from functools import wraps
from spiceypy.utils.exceptions import SpiceyPyError
from ..pipeline.runtime import handle_npb_error
def spice_exception_handler(func):
"""SPICE Exception handler.
This function is used as a decorator to c... | NASA-PDS/naif-pds4-bundler | src/pds/naif_pds4_bundler/utils/decorators.py | .py | 46828f80e17edf39 | 7.39 | 5 |
# Copyright 2017 Mycroft AI 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... | OpenVoiceOS/ovos-config | ovos_config/models.py | .py | 86bbd36954a0c4b1 | 7.3 | 3 |
import json
import importlib
from typing import Optional
from ovos_utils.log import LOG, log_deprecation
from os import makedirs
from os.path import join, dirname
from ovos_utils.xdg_utils import xdg_config_home
try:
# TODO: deprecate in 0.0.12, leave only during 0.0.11 life cycle
from ovos_utils.file_utils i... | OpenVoiceOS/ovos-config | ovos_config/utils.py | .py | 21bb5abbff751e58 | 7.3 | 3 |
"""
HyperCTui initialization module.
This module provides constants, helper functions, and configuration settings for the
HyperCT UI application. It includes path definitions, UI styling properties,
and class definitions to organize application structure and data.
"""
import os
from typing import Any, Dict, Union
fr... | ornlneutronimaging/HyperCTui | src/hyperctui/__init__.py | .py | 5502de7e8152fb87 | 7.24 | 2 |
#!/usr/bin/env python
"""
This module provides functionality for retrieving data from the autonomous reconstruction tab.
It contains a Get class that extends the base Get class with specialized methods
for autonomous reconstruction data access.
"""
from hyperctui import EvaluationRegionKeys
from hyperctui.session imp... | ornlneutronimaging/HyperCTui | src/hyperctui/autonomous_reconstruction/get.py | .py | e43f1bf00d0745e1 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for selecting evaluation regions in autonomous reconstruction.
This module provides a dialog interface for users to select, modify, and visualize
evaluation regions for autonomous CT reconstruction tasks. It allows users to define
regions of interest with customizable parameters.
"""
... | ornlneutronimaging/HyperCTui | src/hyperctui/autonomous_reconstruction/select_evaluation_regions.py | .py | b5186fc7257a27d2 | 7.24 | 2 |
#!/usr/bin/env python
"""
Event handler module for HyperCTui application.
This module provides event handling for UI interactions, including tab changes,
button clicks, and UI state management for the HyperCTui application.
"""
from loguru import logger
from qtpy.QtCore import QRect
from hyperctui import UiSizeLarge... | ornlneutronimaging/HyperCTui | src/hyperctui/event_handler.py | .py | 01d45b7264bfb13d | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for initializing the HyperCTui graphical user interface.
This module provides functionality for setting up the GUI components including
status bars, widgets, tables, tabs, and PyQtGraph visualization elements.
"""
import os
import numpy as np
import pandas as pd
import pyqtgraph as p... | ornlneutronimaging/HyperCTui | src/hyperctui/initialization/gui_initialization.py | .py | d5bdac7377553b32 | 7.24 | 2 |
#!/usr/bin/env python
"""
Log management module for HyperCTui application.
This module provides log viewing, management, and handling capabilities
through the LogLauncher, Log and LogHandler classes.
"""
import os
from typing import Any, Optional
from loguru import logger
from qtpy import QtGui
from qtpy.QtGui impor... | ornlneutronimaging/HyperCTui | src/hyperctui/log/log_launcher.py | .py | f732adaf227fd5c4 | 7.24 | 2 |
#!/usr/bin/env python
"""
Parent module providing base class functionality for hierarchical components.
This module defines the Parent class which implements a parent-child
relationship structure used throughout the application.
"""
from typing import Optional
class Parent:
"""
A base class that implements ... | ornlneutronimaging/HyperCTui | src/hyperctui/parent.py | .py | 8c4a273362640f00 | 7.24 | 2 |
"""
Pre-autonomous monitoring module for HyperCTui.
This module provides status indicators and color representations for
monitoring operations in the HyperCTui application.
"""
from typing import Final
from qtpy import QtGui
class DataStatus:
"""
Constants representing various statuses of data processing.
... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_autonomous_monitor/__init__.py | .py | 600598ca91172300 | 7.24 | 2 |
#!/usr/bin/env python
"""
Event handling module for pre-autonomous monitoring.
This module provides functionality to monitor and handle events related to
observation (OB) and projection data processing, including checking the status
of expected data folders, updating UI tables, and managing file movement to
final loca... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_autonomous_monitor/event_handler.py | .py | 4cba5051362b77c8 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for handling the initialization of pre-autonomous monitoring.
This module provides functionality to set up the UI and data structures
for monitoring open beam (OB) and projection data acquisition during
pre-autonomous data collection.
"""
import os
from typing import Any, List, Option... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_autonomous_monitor/initialization.py | .py | 3d3369a73ee99b7a | 7.24 | 2 |
#!/usr/bin/env python
"""
Monitor module for pre-autonomous processing.
This module provides functionality to monitor the pre-processing steps
of the autonomous data reduction pipeline, including tracking OBs (open beam)
and projection data, displaying their status, and providing preview capabilities
for log files and... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_autonomous_monitor/monitor.py | .py | 2757f046a55968f4 | 7.24 | 2 |
"""
Pre-processing monitor module.
This module provides status tracking and color coding for monitoring
pre-processing tasks in the HyperCTui application.
"""
from typing import Final
from qtpy import QtGui
class DataStatus:
"""
Data processing status constants.
This class defines string constants rep... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_processing_monitor/__init__.py | .py | ea3adc72c3d0c276 | 7.24 | 2 |
#!/usr/bin/env python
"""
Initialization module for pre-processing monitor.
This module handles the setup and initialization of the monitoring interface
for open beam (OB) acquisition and projection data preprocessing.
It populates tables with status information and configures the UI components.
"""
import os
from ty... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_processing_monitor/initialization.py | .py | b0694a48180180c4 | 7.24 | 2 |
#!/usr/bin/env python
"""
Monitor module for pre-processing operations in HyperCTui.
This module provides a GUI window for monitoring the status of open beam (OB) images
and projections (0 degree and 180 degrees) during the pre-processing stage of CT
data acquisition and processing.
"""
import logging
import os
from ... | ornlneutronimaging/HyperCTui | src/hyperctui/pre_processing_monitor/monitor.py | .py | 6c80b49515e1af87 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for handling events related to rotation center calculations and visualization.
This module provides functionality to calculate and display the rotation center
of tomographic images using either TomoPy algorithms or user-defined values.
"""
from typing import Any, Optional, Union
impo... | ornlneutronimaging/HyperCTui | src/hyperctui/rotation_center/event_handler.py | .py | a21651faddc05a3c | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for handling rotation center operations in HyperCTui.
This module provides functionality for manipulating and displaying
rotation center images for CT reconstruction.
"""
from typing import Any, Optional
import numpy as np
class RotationCenter:
"""
Class for managing rotati... | ornlneutronimaging/HyperCTui | src/hyperctui/rotation_center/rotation_center.py | .py | 2e7da1d1516ac94f | 7.24 | 2 |
"""
Session management module for HyperCTui.
This module provides constants and default values used across the application
to maintain session state and configuration.
"""
class SessionKeys:
"""
Constants defining session dictionary keys.
Attributes
----------
config_version : str
Key fo... | ornlneutronimaging/HyperCTui | src/hyperctui/session/__init__.py | .py | e62070b205302c00 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for launching a dialog that prompts users to load a previous session.
This module contains the LoadPreviousSessionLauncher class which handles the UI
and logic for allowing users to decide whether to load a previous session or
start a new one.
"""
import os
from typing import Any, Opt... | ornlneutronimaging/HyperCTui | src/hyperctui/session/load_previous_session_launcher.py | .py | d329895d93305921 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for handling the creation of new HyperCT sessions.
This module provides a dialog interface for users to create a new session
by selecting instrument and IPTS information.
"""
import os
from typing import Optional
import numpy as np
from qtpy.QtWidgets import QDialog
from hyperctui i... | ornlneutronimaging/HyperCTui | src/hyperctui/session/new_session.py | .py | 466b884fe593f7b7 | 7.24 | 2 |
#!/usr/bin/env python
"""
Event handler module for the Open Beam setup interface.
This module contains event handling logic for the Open Beam (OB) setup interface
in the HyperCTui application. It manages user interactions such as IPTS selection,
OB folder browsing, acquisition start, and selecting OB files for process... | ornlneutronimaging/HyperCTui | src/hyperctui/setup_ob/event_handler.py | .py | 9677f48761cc73d7 | 7.24 | 2 |
#!/usr/bin/env python
"""
This module provides event handling for the setup projections part of the HyperCTui application.
It manages run title changes and ensures unique filenames in the MCP folders.
"""
import logging
import os
from typing import Optional, Tuple
from hyperctui.parent import Parent
from hyperctui.ut... | ornlneutronimaging/HyperCTui | src/hyperctui/setup_projections/event_handler.py | .py | fdc69343602beb05 | 7.24 | 2 |
#!/usr/bin/env python
"""
Module for retrieving data from UI elements in the projections setup component.
This module provides functionality for getting values from UI input fields
and formatted labels related to run titles in the projection setup interface.
"""
from hyperctui.utilities.get import Get as MasterGet
... | ornlneutronimaging/HyperCTui | src/hyperctui/setup_projections/get.py | .py | b4cfc2b872d9ec6a | 7.24 | 2 |
#!/usr/bin/env python
"""Utility functions for array and list operations.
This module provides helper functions for common operations on arrays and lists,
such as finding the closest element to a value or formatting lists for display.
Functions
---------
get_nearest_index : Find the index of the closest value in an a... | ornlneutronimaging/HyperCTui | src/hyperctui/utilities/array.py | .py | 2fe152d92f5a0450 | 7.24 | 2 |
#!/usr/bin/env python
"""
Configuration handling module for HyperCTui application.
This module provides functionality for loading, parsing, and managing configuration
settings from JSON files. It handles main application configuration, reconstruction
configurations, and sets up the logging system.
"""
import json
imp... | ornlneutronimaging/HyperCTui | src/hyperctui/utilities/config_handler.py | .py | ce40790a8ea9bf7c | 7.24 | 2 |
"""Strict startup configuration loaded from the fixed Codespace YAML path."""
from __future__ import annotations
import posixpath
from pathlib import Path, PurePosixPath
from typing import Annotated, Literal, Self
import yaml
from pydantic import (
AfterValidator,
BaseModel,
BeforeValidator,
ConfigDi... | curoky/devspace | controller/config.py | .py | 019964b57ac7dd7e | 7 | 0 |
"""Codespace container semantics layered over the Podman engine.
This module owns the control-plane-specific translation: reserved environment
injection (``SSHD_PORT``/``SSHD_BIND``), the reserved workspace mount, default
secret ownership (``5230:5230``, ``0o400``) and canonical labels. The reusable
container primitiv... | curoky/devspace | controller/container.py | .py | 2de75e8d5d632c71 | 7 | 0 |
"""Codespace resource identity and API models."""
from __future__ import annotations
import hashlib
import re
from dataclasses import dataclass
from typing import TYPE_CHECKING, Annotated, Literal
from urllib.parse import quote
from pydantic import AfterValidator, BaseModel, ConfigDict, Field
if TYPE_CHECKING:
... | curoky/devspace | controller/models.py | .py | 3e715a57e291879d | 7 | 0 |
"""Thread-safe process-local operation state."""
from __future__ import annotations
from threading import Lock
from controller.models import Operation, OperationStatus, environment_id
class OperationStore:
"""Keep the current operation for each project instance on each host."""
def __init__(self) -> None:... | curoky/devspace | controller/operations.py | .py | 8f253504638f45fa | 7 | 0 |
"""Pydantic models for the supported Compose service subset."""
from __future__ import annotations
import re
from typing import Annotated, Literal, Self
from pydantic import (
AfterValidator,
BaseModel,
BeforeValidator,
ConfigDict,
Field,
model_validator,
)
from controller.runtime.compose.sy... | curoky/devspace | controller/runtime/compose/models.py | .py | 17804919e0962230 | 7 | 0 |
"""Normalize supported Compose short syntaxes before Pydantic validation."""
from __future__ import annotations
def normalize_volumes(value: object) -> object:
"""Expand ``source:target[:ro|rw]`` bind mounts."""
if not isinstance(value, list):
return value
return [_normalize_volume(item) for item... | curoky/devspace | controller/runtime/compose/syntax.py | .py | 25b5e59ba268bb37 | 7 | 0 |
"""Provider-neutral Podman image, container and exec primitives.
This module holds no control-plane knowledge: it exposes reusable container
engine operations (image pull, container run, exec, logs, removal and a helper
container to delete a directory) that callers drive with already-resolved
parameters. Codespace-spe... | curoky/devspace | controller/runtime/engine.py | .py | 045101f7fae01ceb | 7 | 0 |
"""Provider-neutral remote command execution and atomic local file writes.
These primitives carry no Codespace layout knowledge: :func:`run_host` runs one
command over an SSH route (either a configured SSH host or a Podman Machine),
and :func:`write_atomic`/:func:`ensure_mode` manage local files with strict
permission... | curoky/devspace | controller/runtime/remote.py | .py | 938ce1cdead8541d | 7 | 0 |
"""Podman clients and SSH routes for remote hosts and local Podman machines."""
from __future__ import annotations
import contextlib
import json
import shutil
import subprocess
import tempfile
import time
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from pathlib import Path
from thr... | curoky/devspace | controller/runtime/transport.py | .py | 1ee66be23f448b66 | 7 | 0 |
import logging
import os
from typing import Any, ClassVar
class Config:
REQUIRED_ENV_VARS = (
"TIMDEX_ALMA_EXPORT_BUCKET_ID",
"TIMDEX_S3_EXTRACT_BUCKET_ID",
"WORKSPACE",
)
OPTIONAL_ENV_VARS = ()
GIS_SOURCES = ("gismit", "gisogm")
INDEX_ALIASES: ClassVar = {
"geo": ... | MITLibraries/timdex-pipeline-lambdas | lambdas/config.py | .py | d21b5b4a07c0ce42 | 7 | 0 |
# ruff: noqa: S608
import json
import logging
import uuid
from copy import deepcopy
from dataclasses import asdict, dataclass
from datetime import UTC, datetime
from typing import Literal
from timdex_dataset_api.dataset import TIMDEXDataset
from lambdas import alma_prep, commands, errors, helpers
from lambdas.config... | MITLibraries/timdex-pipeline-lambdas | lambdas/format_input.py | .py | 952e9f2a05cf6721 | 7 | 0 |
# ruff: noqa: S608
import contextlib
import logging
from datetime import UTC, datetime, timedelta
from typing import TYPE_CHECKING
import boto3
import pandas as pd
from duckdb import CatalogException
from timdex_dataset_api.dataset import TIMDEXDataset
from lambdas import errors
from lambdas.config import Config
if... | MITLibraries/timdex-pipeline-lambdas | lambdas/helpers.py | .py | a155b31bfa344617 | 7 | 0 |
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
from tgbot.config import app_config
from tgbot.services.db_api.db_models import db_gino
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = co... | vad-ii-k/Timetable_SPBU_bot | alembic_migrations/env.py | .py | 9864e0b3d72351c5 | 7.35 | 4 |
"""add_is_bot_blocked_field
Revision ID: d9ac61bb65f9
Revises: b351ee68c259
Create Date: 2023-08-31 10:37:45.946370
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "d9ac61bb65f9"
down_revision = "b351ee68c259"
branch_labels = None
depends_on = None
def upgrad... | vad-ii-k/Timetable_SPBU_bot | alembic_migrations/versions/d9ac61bb65f9_add_is_bot_blocked_field.py | .py | 48250637a19fdd23 | 7.35 | 4 |
""" Setting configs for the bot from environment variables """
from dataclasses import dataclass
from aiogram import Bot
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from environs import Env
@dataclass(slots=True, frozen=True)
class DbConfig:
"""Postgres database c... | vad-ii-k/Timetable_SPBU_bot | tgbot/config.py | .py | b2d618d5b7c158ec | 7.35 | 4 |
""" Middlewares """
import asyncio
from contextlib import suppress
from typing import Any, Awaitable, Callable
from aiogram import BaseMiddleware
from aiogram.dispatcher.flags import get_flag
from aiogram.exceptions import TelegramForbiddenError
from aiogram.types import CallbackQuery, Message, TelegramObject
from ai... | vad-ii-k/Timetable_SPBU_bot | tgbot/middlewares/action.py | .py | 31b26e8563b483f2 | 7.35 | 4 |
from typing import Any
from aiogram.types import TelegramObject, User
from aiogram.utils.i18n import I18nMiddleware
from tgbot.services.db_api.db_commands import database
class LanguageI18nMiddleware(I18nMiddleware):
"""Custom [I18nMiddleware](https://docs.aiogram.dev/en/dev-3.x/utils/i18n.html#i18nmiddleware)"... | vad-ii-k/Timetable_SPBU_bot | tgbot/middlewares/language_18n.py | .py | 77ec4511f6152715 | 7.35 | 4 |
from typing import Any, Awaitable, Callable
from aiogram import BaseMiddleware
from aiogram.types import CallbackQuery
from aiogram.utils.i18n import gettext as _
from cashews import cache
class ThrottlingMiddleware(BaseMiddleware):
"""
Middleware for flood control
It is needed to handle too frequent bu... | vad-ii-k/Timetable_SPBU_bot | tgbot/middlewares/throttling.py | .py | 9e36234dc139ff61 | 7.35 | 4 |
""" Functional work with the database """
from datetime import time
from aiogram import types
from sqlalchemy import asc, func
from tgbot.services.db_api.db_models import Group, MainScheduleInfo, Settings, User
from tgbot.services.schedule.data_classes import UserType
class DBCommands:
"""Database commands for... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/db_api/db_commands.py | .py | c6580c7ac4dd619a | 7.35 | 4 |
""" Database Model definition """
from gino import Gino
from sqlalchemy import BigInteger, Boolean, Column, Date, ForeignKey, Index, Integer, Sequence, String, Time, func
from sqlalchemy.dialects import registry
from tgbot.config import app_config
# setuptools>=82 убрал pkg_resources; SQLAlchemy 1.3 (GINO) иначе не ... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/db_api/db_models.py | .py | 82e2e4230073f925 | 7.35 | 4 |
""" Statistical work with the database """
from sqlalchemy import asc
from tgbot.services.db_api.db_models import MainScheduleInfo, Settings, User, db_gino
from tgbot.services.statistics import UserStatistics
class DBStatistics:
"""Commands for getting statistics from the database"""
@staticmethod
asyn... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/db_api/db_statistics.py | .py | c047f254269d95e3 | 7.35 | 4 |
""" Module for converting a schedule into an image """
import os
import uuid
from datetime import date, timedelta
from pathlib import Path
from itertools import groupby
from typing import Literal
from aiogram.types import BufferedInputFile
from babel.dates import format_date
from jinja2 import Environment, FileSystem... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/image_converter.py | .py | cd04f29d19a00b6a | 7.35 | 4 |
""" Initial filling of groups for searching by name """
import asyncio
import logging
from pathlib import Path
from typing import Callable, Coroutine
from aiohttp import ClientError, ClientSession
from aiohttp_socks import ProxyConnectionError, ProxyConnector, ProxyError
from tgbot.config import app_config
from tgbo... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/initial_filling_of_groups.py | .py | 807ed14d3d68893c | 7.35 | 4 |
""" Auxiliary functions for getting a schedule """
from datetime import date, timedelta
from aiogram.utils.i18n import get_i18n
from babel.dates import format_date
async def get_schedule_weekday_header(day: date, general_location: str = None) -> str:
"""
:param day:
:param general_location:
:return... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/schedule/helpers.py | .py | 759902f8230df318 | 7.35 | 4 |
""" Module for getting bot statistics """
import csv
from dataclasses import dataclass
from datetime import date, time
@dataclass(slots=True, frozen=True)
class UserStatistics:
"""Dataclass for user statistics"""
username: str
start_date: date
is_student: bool
schedule_name: str | None
daily... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/statistics.py | .py | c24903c5079cd082 | 7.35 | 4 |
""" Timetable API request """
import asyncio
import logging
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from random import shuffle
from aiogram.client.session import aiohttp
from aiohttp import ClientResponse, ClientSession
from aiohttp_socks import ProxyConnector, ProxyError... | vad-ii-k/Timetable_SPBU_bot | tgbot/services/timetable_api/api_request.py | .py | 4c92de974fe442ab | 7.35 | 4 |
import sys
import time
from datetime import datetime
from zoneinfo import ZoneInfo
import streamlit as st
from rq import Worker, Queue
from rq.job import Job, JobStatus
from rq.registry import (
StartedJobRegistry,
FinishedJobRegistry,
FailedJobRegistry,
DeferredJobRegistry,
ScheduledJobRegistry,
... | stewart-lab/fast_km | src/dashboard.py | .py | 089c974951e86c1a | 7.15 | 1 |
import os
import re
import gzip
import xml.etree.ElementTree as ET
from src.documents.document import Document
delim = '\t'
year_regex = r"(?<!\d)(?:1\d\d\d|20\d\d)(?!\d)"
def read_xml_content(local_filename: str) -> str:
if os.path.exists(local_filename):
with open(local_filename, 'rb') as f:
... | stewart-lab/fast_km | src/documents/xml_parsing.py | .py | 51e8f6fa9afb1bcb | 7.15 | 1 |
import nltk
from src.documents.document import Document
word_tokenizer = nltk.RegexpTokenizer(r"\w+") # remove all non-word characters
word_tokenizer_lop = nltk.RegexpTokenizer(r"\w+|[&|()]") # keep logical operators as separate tokens
logical_operators = ['&', '|', '(', ')']
def sanitize_term_for_search(term: str, k... | stewart-lab/fast_km | src/indexing/indexing_util.py | .py | 71702e0b40a0b935 | 7.15 | 1 |
from pydantic import BaseModel
from rq import Queue
from rq.job import Job, JobStatus
from rq.registry import StartedJobRegistry
from src.redis_conn import redis_conn
from src.jobs.index_corpus.job import run_indexing_job
_low_priority_queue = Queue('LOW', redis_conn)
_medium_priority_queue = Queue('MEDIUM', redis_con... | stewart-lab/fast_km | src/jobs/job_queue.py | .py | 697a4c021fd3356a | 7.15 | 1 |
import multiprocessing
from rq import Worker
from src.redis_conn import redis_conn
def run_workers(low: int, medium: int, high: int, indexing: int):
queue_names = []
queue_names += ['LOW'] * low
queue_names += ['MEDIUM'] * medium
queue_names += ['HIGH'] * high
queue_names += ['INDEXING'] * indexing... | stewart-lab/fast_km | src/jobs/workers.py | .py | 65cbbe96b4fcfaf0 | 7.15 | 1 |
import sys
import os
import ftplib
import json
import time
import requests
from postmarker.core import PostmarkClient
from src.documents.xml_parsing import read_xml_content, parse_xml_content
from src.global_vars import data_dir, fastapi_port
port = fastapi_port
km_url = 'http://localhost:' + str(port) + '/api/kinderm... | stewart-lab/fast_km | src/populate_db.py | .py | 3c3f6de7abbae8a2 | 7.15 | 1 |
"""Top-level package for casmsocial.
Keep package import lightweight so downstream code and tests can safely do
``import casmsocial`` without triggering model registration or MPI-heavy
imports.
Note: Heat risk models have been moved to the ``wake-county-heat-risk`` package.
"""
from casmsocial.sim_time import SimTim... | ccgsem/casmsocial | casmsocial/__init__.py | .py | 430ad1a4f21ac4dd | 7.15 | 1 |
"""Main module."""
import sys
from loguru import logger
from mpi4py import MPI
from repast4py.parameters import create_args_parser, init_params
from casmsocial.factory import ModelNotFoundError, Models, load_models
def _param_enabled(value, default: bool = False) -> bool:
"""Parse common truthy values from con... | ccgsem/casmsocial | casmsocial/__main__.py | .py | 008b2dba97e68726 | 7.15 | 1 |
from __future__ import annotations
from dataclasses import astuple, dataclass
from typing import Any, TypeAlias
@dataclass(slots=True)
class Act:
"""Names a place that a person will go to at a particular time."""
person_id: int
activity_id: int
activity_sequence: int
starttime_min: int
endti... | ccgsem/casmsocial | casmsocial/activities.py | .py | 424a4eed690a4db2 | 7.15 | 1 |
"""Optional live Arrow Flight observation server for an in-progress CasmPop run.
Speaks Apache Arrow Flight, which ships inside the ``pyarrow`` wheel and is
already a hard dependency of casmsocial. Nothing here needs a lazy import or
an optional extra: importing this module never requires anything beyond what
casmsoci... | ccgsem/casmsocial | casmsocial/arrow_server.py | .py | aefb784b29e3c4db | 7.15 | 1 |
"""
Author: Jon Cline
Created: 09 Dec 2024
Defining the artificial social model for the Artificial Societies project
"""
from loguru import logger
from mpi4py import MPI
from casmsocial.casmpop import AgentLogger, CasmPop
from casmsocial.factory import Models
from casmsocial.person import Person, PersonData
from cas... | ccgsem/casmsocial | casmsocial/citysim/citysocialmodel.py | .py | daf77a0fecaaabda | 7.15 | 1 |
"""CASMSocial model for Colorado Front Range event-level schedules."""
from __future__ import annotations
from loguru import logger
from mpi4py import MPI
from casmsocial.casmpop import AgentLogger, CasmPop
from casmsocial.factory import Models
from casmsocial.person import Person, PersonData
from casmsocial.place i... | ccgsem/casmsocial | casmsocial/citysim/colorado_front_range_schedule_model.py | .py | d23aee6ead50236f | 7.15 | 1 |
"""MPI-backed communication routing for place-based agent messaging."""
from __future__ import annotations
from collections.abc import Iterable
from dataclasses import asdict
from uuid import uuid4
from loguru import logger
from casmsocial.communication.types import AckMessage, CommMessage, MessageIntent
class Co... | ccgsem/casmsocial | casmsocial/communication/manager.py | .py | 885cf0a5ceedd928 | 7.15 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.