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
"""Unit test for complex_module.core.""" __copyright__ = """ LICENSED INTERNAL CODE. PROPERTY OF IBM. IBM Research Licensed Internal Code (C) Copyright IBM Corp. 2023 ALL RIGHTS RESERVED """ import unittest from tensorlakehouse_openeo_driver.complex_module.core import salutation class CoreTestCase(unittest.TestCase...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/complex_module/tests/test_core.py
.py
c07f2d6f0d5be3ac
8.12
16
import os from typing import Callable, Dict, List, Optional, Tuple import attrs from openeo_driver.server import build_backend_deploy_metadata from openeo_driver.urlsigning import UrlSigner from openeo_driver.users.oidc import OidcProvider from openeo_driver.config import OpenEoBackendConfig class ConfigException(...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/config/geodn_config.py
.py
80bddb32338d8d28
7.62
16
from collections import defaultdict from typing import Any, DefaultDict, Dict, List, Mapping, Optional, Tuple from pystac import Item import xarray as xr from tensorlakehouse_openeo_driver.constants import ( DEFAULT_BANDS_DIMENSION, DEFAULT_X_DIMENSION, DEFAULT_Y_DIMENSION, ) from tensorlakehouse_openeo_dri...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/cog_file_reader.py
.py
447ccede0b9d250e
7.62
16
from typing import Optional import ibm_boto3 from ibm_botocore.config import Config from botocore.exceptions import ClientError import os from pathlib import Path import logging import logging.config from urllib.parse import urlparse from tensorlakehouse_openeo_driver.util.object_storage_util import ( get_credent...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/cos_parser.py
.py
bd921e90f22959fc
7.62
16
import pandas as pd from rasterio.crs import CRS import numpy as np from io import BytesIO from pathlib import Path from datetime import datetime from typing import Any, Dict, List, Optional, Tuple import earthkit from pystac import Asset, Item from scipy.interpolate import griddata import urllib from tensorlakehouse_o...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/grib2_file_reader.py
.py
7ba2b99cb7650782
7.62
16
from datetime import datetime from typing import Any, Dict, List, Optional, Tuple import fsspec from fsspec.implementations.http import HTTPFileSystem from pystac import Asset, Item from tensorlakehouse_openeo_driver.constants import ( DEFAULT_BANDS_DIMENSION, DEFAULT_TIME_DIMENSION, DEFAULT_X_DIMENSION, ...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/netcdf_file_reader.py
.py
fa9e815166a09094
7.62
16
from datetime import datetime from typing import Any, Dict, List, Optional, Tuple from pystac import Item from tensorlakehouse_openeo_driver.file_reader.cloud_storage_file_reader import ( CloudStorageFileReader, ) from openeo_pg_parser_networkx.pg_schema import ParameterReference import xarray as xr class Raster...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/raster_file_reader.py
.py
05184782c0560f30
7.62
16
from pathlib import Path import warnings from datetime import datetime from typing import Any, Dict, List, Optional, Tuple from tensorlakehouse_openeo_driver.constants import ( DEFAULT_BANDS_DIMENSION, DEFAULT_X_DIMENSION, DEFAULT_Y_DIMENSION, logger, ) from tensorlakehouse_openeo_driver.file_reader.clo...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/standard_file_reader.py
.py
a16a6e3341e572e1
7.62
16
from typing import Any, Dict, List, Optional, Tuple from pystac import Asset, Item import xarray as xr from tensorlakehouse_openeo_driver.constants import ( DEFAULT_BANDS_DIMENSION, DEFAULT_X_DIMENSION, DEFAULT_Y_DIMENSION, ) import os from datetime import datetime import logging from tensorlakehouse_opene...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/file_reader/zarr_file_reader.py
.py
e1ace8353b4e9410
7.62
16
from typing import Any, Iterable, Optional from openeo_pg_parser_networkx.process_registry import Process, ProcessRegistry from openeo_driver.processes import ProcessesListing class TensorLakeHouseProcessesListing(ProcessesListing): def to_response_dict(self) -> dict[Any, Any]: resp = super().to_response_...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/geodn_process_registry.py
.py
7a3385c46661eac5
7.62
16
# dir() returns all the imported methods and classes, so by doing this we can list # all methods imported from openeo_process_dask.process_implementation # before = dir() import inspect from typing import Dict from openeo_processes_dask.process_implementations import ( arrays, comparison, core, data_mo...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/get_openeo_process_implementations.py
.py
0e44e43b9035f369
7.62
16
""" Script to start a local server. This script can serve as the entry-point for doing spark-submit. """ import logging import os import sys from asgiref.wsgi import WsgiToAsgi from dask.distributed import Client, LocalCluster import openeo_driver from tensorlakehouse_openeo_driver.tensorlakehouse_backend import ( ...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/local_app.py
.py
4f0957dd796fed61
7.62
16
"""Module functions.""" __copyright__ = """ LICENSED INTERNAL CODE. PROPERTY OF IBM. IBM Research Licensed Internal Code (C) Copyright IBM Corp. 2023 ALL RIGHTS RESERVED """ from dataclasses import dataclass from typing import Callable def hello_world() -> str: """Return Hello World.""" return "Hello World"...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/module.py
.py
54092a46ddaccffc
7.62
16
from datetime import datetime, timedelta import time from typing import List, Optional, Tuple import pytz from tensorlakehouse_openeo_driver.constants import ( SENTINEL_DB_HOST, SENTINEL_DB_NAME, SENTINEL_DB_PASSWORD, SENTINEL_DB_PORT, SENTINEL_DB_USER, logger, ) from tensorlakehouse_openeo_dri...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/pipeline/handler/abstract_sentinel_handler.py
.py
e7c1fd53bc86f233
7.62
16
from typing import List from tensorlakehouse_openeo_driver.constants import ( HLS, KUBEFLOW_PIPELINE_API, NASA_STAC, logger, ) from tensorlakehouse_openeo_driver.model.item import Item from tensorlakehouse_openeo_driver.pipeline.handler.pipeline_handler import ( PipelineHandler, ) from tensorlakehou...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/pipeline/handler/hls_pipeline_handler.py
.py
5a68c9c7e970c69f
7.62
16
from typing import Dict, List, Optional, Tuple from tensorlakehouse_openeo_driver.model.item import Item, make_item from datetime import datetime from tensorlakehouse_openeo_driver.constants import ( STAC_URL, logger, ) from tensorlakehouse_openeo_driver.stac.stac import STAC class PipelineHandler: def _...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/pipeline/handler/pipeline_handler.py
.py
44ac2fed86759b2e
7.62
16
from datetime import datetime from typing import Any, Dict, List, Optional, Union import time import uuid import requests from tensorlakehouse_openeo_driver.constants import logger class KFPClientWrapper: READY_STATUS = [ "Completed", "Failed", "Error", "Skipped", "Succee...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/pipeline/kfpclient.py
.py
17794a7181c02cfa
7.62
16
from abc import ABC, abstractmethod from collections import defaultdict from datetime import datetime from typing import Any, DefaultDict, Dict, List, Optional, Sequence, Tuple, Union from openeo_pg_parser_networkx.pg_schema import ( BoundingBox, TemporalInterval, ) from pystac import Asset, Item import xarray ...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/process_implementations/load_collection.py
.py
aaec5661e12c6bdf
7.62
16
from numbers import Number from pathlib import Path import uuid import dask_geopandas import geopandas import numpy as np import pandas as pd from openeo_driver.save_result import ImageCollectionResult import xarray as xr from typing import Optional from tensorlakehouse_openeo_driver.driver_data_cube import TensorLakeh...
IBM/tensorlakehouse
tensorlakehouse_openeo_driver/save_result.py
.py
bb54c93c0a4d22c4
7.62
16
from django.db import models from uuid import uuid4 from django.contrib.auth.models import ( AbstractBaseUser, BaseUserManager, PermissionsMixin ) class UserManager(BaseUserManager): """Manager for users.""" def create_user(self, email, password=None, **extra_fields): """Create, save and re...
bobur-yusupov/booking-api
accounts/models/models.py
.py
79a9d497a37a9f1a
7.48
8
""" Serializers for the USER APIs Create, Update and Delete users using this serializers. 03.07.2023 """ from django.utils.translation import gettext_lazy as _ from django.contrib.auth import ( get_user_model, authenticate, ) from rest_framework.serializers import ( ModelSerializer, Serializer, ...
bobur-yusupov/booking-api
accounts/serializers/user_api_serializers.py
.py
de38f9e3aab10b32
7.48
8
""" Test for User. """ from django.test import TestCase from django.contrib.auth import get_user_model class UserModelTest(TestCase): """Test cases for User model.""" def test_create_user_with_email_successful(self): email = "test@test.com" password = "1234test" first_name = "Bob" ...
bobur-yusupov/booking-api
accounts/test/test_user.py
.py
62502d4367243c3e
7.98
8
""" Test for Django Admin modification. """ from django.test import TestCase from django.contrib.auth import get_user_model from django.urls import reverse from django.test import Client class AdminSiteTests(TestCase): """Tests for Django admin.""" def setUp(self): """Create a user and client.""" ...
bobur-yusupov/booking-api
accounts/test/test_user_admin.py
.py
91a8f06dcb56226a
7.98
8
""" Views for user authentication user 03.07.2023 """ from rest_framework.generics import ( CreateAPIView, RetrieveUpdateAPIView, ) from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.settings import api_settings from rest_framework.authentication import TokenAuthentication fr...
bobur-yusupov/booking-api
accounts/views/user_auth_view.py
.py
bf7b34d655685ed7
7.48
8
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import os import shutil from typing import Any from hatchling.builders.hooks.plugin.interface import BuildHookInterface class HatchCustomBuildHook(BuildHookInterface): """ This class implements Hatch's [custom build hook] (https://hatch.pyp...
aws-deadline/deadline-cloud-for-blender
hatch_custom_hook.py
.py
844e5ef772a6b2c6
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Script to create platform-specific Deadline Client installers using InstallBuilder.""" import os import sys import shutil import tempfile from typing import Optional from pathlib import Path from common import EvaluationBuildError, run, get_versi...
aws-deadline/deadline-cloud-for-blender
scripts/build_installer.py
.py
1e31f9bd88acea73
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from __future__ import annotations import fnmatch import re import shutil import subprocess import sys from pathlib import Path from tempfile import TemporaryDirectory from typing import Any SUPPORTED_PYTHON_VERSIONS = ["3.10", "3.11", "3.13"] NAT...
aws-deadline/deadline-cloud-for-blender
scripts/depsBundle.py
.py
f483cdcb588cf025
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from __future__ import annotations import logging import os import re import sys import threading import time from typing import Callable from openjd.adaptor_runtime._version import version as openjd_adaptor_version from openjd.adaptor_runtime.adap...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_adaptor/BlenderAdaptor/adaptor.py
.py
62746a8a18cbb9e6
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from __future__ import annotations import os import ctypes import sys from types import FrameType from typing import Optional import bpy # The blender Adaptor adds the `openjd` namespace directory to PYTHONPATH, # so that importing just the adapto...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_adaptor/BlenderClient/blender_client.py
.py
3da8b4cd2d394134
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import bpy import logging from .default_blender_handler import DefaultBlenderHandler _logger = logging.getLogger(__name__) class CyclesHandler(DefaultBlenderHandler): RENDER_ENGINE_NAME = "CYCLES" def set_gpu_device(self, data: dict) -> ...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_adaptor/BlenderClient/render_handlers/cycles_blender_handler.py
.py
fb2fb1a0b16cf5a5
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from __future__ import annotations import logging import os from typing import cast, Optional import bpy # type: ignore _logger = logging.getLogger(__name__) class DefaultBlenderHandler: # Blender 4.2-4.x renamed EEVEE to EEVEE_NEXT, but 5....
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_adaptor/BlenderClient/render_handlers/default_blender_handler.py
.py
0d9c6c50ec29f7a3
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """ Registration of Deadline Cloud Submitter Addon + activate logger """ import logging import sys from typing import Any import bpy from bpy.types import Operator from .update_utils import check_and_show_update_dialog from . import logutil # NOT...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/__init__.py
.py
3795c5f8bcc4b4d3
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """ This file contains the AddonPreferences for the deadline submitter ui. """ from bpy.props import BoolProperty, EnumProperty, StringProperty from bpy.types import AddonPreferences # Addon preferences / layout class DEADLINE_CLOUD_AddonPreferenc...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/addonpreferences.py
.py
20228f9401e888c0
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Set of shortcut functions to query Blender scene data.""" from __future__ import annotations import logging import os from pathlib import Path import bpy from deadline.client.exceptions import DeadlineOperationError _logger = logging.getLogger(...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/blender_utils.py
.py
9b7ce95af42bc3c3
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import logging from logging.handlers import RotatingFileHandler from pathlib import Path from typing import Optional try: from deadline.client import config except ImportError: pass _DEFAULT_FORMATTER = logging.Formatter( fmt="%(asctime...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/logutil.py
.py
b380649222b0abeb
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import os from pathlib import Path import PyOpenColorIO as ocio def get_ocio_path() -> str: return os.environ.get("OCIO", "") def get_ocio_config(filename: str) -> ocio.Config: return ocio.Config.CreateFromFile(filename) def get_ocio_r...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/ocio_utils.py
.py
e896325749f3975b
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from pathlib import Path from typing import Any, Optional, cast import bpy from qtpy.QtCore import Qt # type: ignore from deadline.client import api from deadline.client.config import get_setting, str2bool from deadline.client.job_bundle._yaml imp...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/open_deadline_cloud_dialog.py
.py
1efab9f7f9a0a82b
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """ Sanity checks done on submit or export bundle """ from typing import Union from pathlib import Path import bpy from qtpy import QtWidgets from . import blender_utils from . import scene_settings_widget as ssw def run_sanity_checks(settings, ...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/sanity_checks.py
.py
6ce2550144b78068
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """UI widgets for the Scene Settings tab.""" from __future__ import annotations import logging import os from deadline.client.ui import block_signals from . import blender_utils from .template_filling import BlenderSubmitterUISettings from . impor...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/scene_settings_widget.py
.py
4ab554b7733014b0
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from __future__ import annotations import logging from typing import Any, Optional, cast from deadline.client.api import BaseSubmitter, BaseSubmitterSettings from deadline.client.exceptions import DeadlineOperationError import bpy # type: ignore[i...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/submitter.py
.py
38b84b2b96582aa2
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Functions to fill Blender job templates.""" from __future__ import annotations import dataclasses import json import logging import os import traceback from copy import deepcopy from dataclasses import dataclass, field from pathlib import Path f...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/template_filling.py
.py
f3873318f4a0013c
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Utilities for checking and displaying update notifications.""" import logging from dataclasses import dataclass from deadline.client.api import safe_check_for_updates, UpdateCheckResult, UpdateCheckStatus from deadline.client.ui.dialogs.update_a...
aws-deadline/deadline-cloud-for-blender
src/deadline/blender_submitter/addons/deadline_cloud_blender_submitter/update_utils.py
.py
74ac849b94d7915d
7.65
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import pytest import os import re import shutil import subprocess import sys from pathlib import Path _BLENDER_VERSION_RE = re.compile(r"^Blender (?P<version>\d+\.\d+)\..*$") @pytest.fixture def blender_location() -> Path: # If BLENDER_EXECUT...
aws-deadline/deadline-cloud-for-blender
test/integ/conftest.py
.py
ce9ae221d675f000
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. from pathlib import Path import PIL.Image import numpy as np def assert_all_images_close( expected_image_directory: Path, actual_image_directory: Path, ): """Assert that all images in the expected directory are close to the images in ...
aws-deadline/deadline-cloud-for-blender
test/integ/helpers/image_comparison.py
.py
2f7ed0fb492dc8c4
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import os import subprocess import json import getpass from pathlib import Path from typing import Any def run_command(args: list[str]) -> subprocess.CompletedProcess[bytes]: output = subprocess.run(args, capture_output=True, env=os.environ.co...
aws-deadline/deadline-cloud-for-blender
test/integ/helpers/test_runners.py
.py
3dfad7b617a24ef4
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import os import psutil import time from pathlib import Path import pytest from deadline.blender_adaptor.BlenderAdaptor import BlenderAdaptor @pytest.mark.adaptor class TestAdaptorLifecycle: """ Tests that validate the Blender adaptor can...
aws-deadline/deadline-cloud-for-blender
test/integ/test_adaptor_lifecycle.py
.py
7ead16760abaaf87
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import yaml import os import pytest from pathlib import Path from typing import Any from pytest import FixtureRequest, Mark from .helpers.test_runners import run_blender_submitter_test, is_valid_template @pytest.mark.submitter class TestSubmitter...
aws-deadline/deadline-cloud-for-blender
test/integ/test_blender_submitters.py
.py
54cfcf82c29d1d2d
8.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import json import os import subprocess import tempfile import time from pathlib import Path import pytest @pytest.mark.adaptor class TestDaemonMode: """ Tests that validate the Blender adaptor daemon mode functionality. """ def t...
aws-deadline/deadline-cloud-for-blender
test/integ/test_daemon_mode.py
.py
2a02dd59b9772cf4
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import bpy from pathlib import Path import sys import argparse import os # Blender 5.1+ auto-populates the OCIO env var with its bundled default config. # The submitter treats any OCIO env var as a user-configured custom path, so # under 5.1+ a defa...
aws-deadline/deadline-cloud-for-blender
test/integ/test_scripts/gpu_test/_test_blend.py
.py
c44114553d94dae5
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import bpy from pathlib import Path import sys import argparse import os # Blender 5.1+ auto-populates the OCIO env var with its bundled default config. # The submitter treats any OCIO env var as a user-configured custom path, so # under 5.1+ a defa...
aws-deadline/deadline-cloud-for-blender
test/integ/test_scripts/minimal_test/_test_blend.py
.py
9d92a5330994a279
7.15
19
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. import bpy from pathlib import Path import sys import argparse import os # Blender 5.1+ auto-populates the OCIO env var with its bundled default config. # The submitter treats any OCIO env var as a user-configured custom path, so # under 5.1+ a defa...
aws-deadline/deadline-cloud-for-blender
test/integ/test_scripts/minimal_test_host_requirements/_test_blend.py
.py
20a693bc8480be25
7.15
19
import argparse from typing import cast from tomlkit import dumps, parse from tomlkit.container import Container def update_version(version: str) -> None: pyproject_path = "pyproject.toml" try: # Read the pyproject.toml file with open(pyproject_path) as file: pyproject_content = ...
phantomcyber/splunk-soar-sdk
.github/utils/update_version.py
.py
c7d8cb8629b68596
7.48
8
import itertools from collections.abc import Callable, Iterator, Sequence from typing import Any, Literal, NotRequired from pydantic import ( BaseModel, ConfigDict, Field, ValidationError, model_validator, ) from pydantic.main import IncEx from typing_extensions import TypedDict from soar_sdk.comp...
phantomcyber/splunk-soar-sdk
src/soar_sdk/action_results.py
.py
dea728922b13a111
7.48
8
import json from typing import TYPE_CHECKING from soar_sdk.apis.utils import is_client_authenticated from soar_sdk.exceptions import ActionFailure, SoarAPIError from soar_sdk.logging import getLogger from soar_sdk.shims.phantom.consts import consts as ph_consts from soar_sdk.shims.phantom.json_keys import json_keys as...
phantomcyber/splunk-soar-sdk
src/soar_sdk/apis/artifact.py
.py
776fb95390d204ca
7.48
8
from collections.abc import Generator from typing import Any import httpx def is_client_authenticated(client: httpx.Client) -> bool: """Check whether the httpx client is authenticated to Splunk SOAR via CSRFToken.""" return client.headers.get("X-CSRFToken") is not None def get_request_iter_pages( clien...
phantomcyber/splunk-soar-sdk
src/soar_sdk/apis/utils.py
.py
1d091f99a162c722
7.48
8
from enum import Enum from typing import Any, NotRequired from zoneinfo import ZoneInfo from pydantic import BaseModel, ConfigDict, Field, model_validator from pydantic_core import PydanticUndefined from typing_extensions import TypedDict from soar_sdk.asset_state import AssetState from soar_sdk.compat import remove_...
phantomcyber/splunk-soar-sdk
src/soar_sdk/asset.py
.py
5c52810fe2584f28
7.48
8
import json from collections.abc import Iterator, MutableMapping from contextlib import suppress from typing import Any from soar_sdk.logging import getLogger from soar_sdk.shims.phantom.base_connector import BaseConnector from soar_sdk.shims.phantom.encryption_helper import encryption_helper from soar_sdk.shims.phant...
phantomcyber/splunk-soar-sdk
src/soar_sdk/asset_state.py
.py
fbe6fd974145a3fe
7.48
8
import asyncio import inspect from collections.abc import AsyncGenerator, Coroutine from typing import Any, TypeVar, overload T = TypeVar("T") def is_coroutine(obj: Any) -> bool: # noqa: ANN401 """Returns True if the given object is a coroutine, False otherwise.""" return inspect.iscoroutine(obj) def is_a...
phantomcyber/splunk-soar-sdk
src/soar_sdk/async_utils.py
.py
0f3ed16a02118f22
7.48
8
from __future__ import annotations from collections.abc import Callable from contextlib import contextmanager from hmac import compare_digest from typing import TYPE_CHECKING, Any import httpx from soar_sdk.auth.client import SOARAssetOAuthClient from soar_sdk.auth.httpx_auth import OAuthBearerAuth from soar_sdk.aut...
phantomcyber/splunk-soar-sdk
src/soar_sdk/auth/factories.py
.py
4347b3863fb48d28
7.48
8
from __future__ import annotations import time from abc import ABC, abstractmethod from collections.abc import Callable from typing import TYPE_CHECKING, Any from soar_sdk.auth.client import ( AuthorizationRequiredError, OAuthClientError, SOARAssetOAuthClient, TokenExpiredError, ) from soar_sdk.auth.m...
phantomcyber/splunk-soar-sdk
src/soar_sdk/auth/flows.py
.py
6a148e76bd76f6cf
7.48
8
from __future__ import annotations import base64 from collections.abc import Generator import httpx from soar_sdk.auth.client import SOARAssetOAuthClient from soar_sdk.auth.models import OAuthToken class BasicAuth(httpx.Auth): """HTTPX authentication using HTTP Basic Authentication.""" def __init__(self, ...
phantomcyber/splunk-soar-sdk
src/soar_sdk/auth/httpx_auth.py
.py
6ff95d5e3471a996
7.48
8
from __future__ import annotations import time from enum import StrEnum from pydantic import BaseModel, ConfigDict, Field class OAuthGrantType(StrEnum): """Supported OAuth 2.0 grant types.""" AUTHORIZATION_CODE = "authorization_code" CLIENT_CREDENTIALS = "client_credentials" REFRESH_TOKEN = "refres...
phantomcyber/splunk-soar-sdk
src/soar_sdk/auth/models.py
.py
bd2811a87c7281ad
7.48
8
import typer from soar_sdk import __version__ from soar_sdk.cli.init.cli import convert, init from soar_sdk.cli.manifests.cli import manifests from soar_sdk.cli.package.cli import package from soar_sdk.cli.test.cli import test from soar_sdk.paths import SDK_ROOT CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/cli.py
.py
f4eaa35453e82017
7.48
8
import json from pathlib import Path from pprint import pprint from typing import Annotated import typer from .notice import NoticeGenerator from .processors import ManifestProcessor manifests = typer.Typer() @manifests.command() def display(filename: str) -> None: """Parse and print the contents of a manifest...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/manifests/cli.py
.py
f33d9644813ea5ec
7.48
8
import dataclasses import json from collections.abc import Sequence from pathlib import Path from typing import Any, NamedTuple, cast import pydantic from soar_sdk.action_results import ActionOutput, OutputField, OutputFieldSpecification from soar_sdk.cli.utils import NormalizationResult, normalize_field_name from so...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/manifests/deserializers.py
.py
d3b260e578979cbc
7.48
8
import importlib import json from datetime import UTC, datetime from pathlib import Path from pprint import pprint import toml from packaging.specifiers import SpecifierSet from soar_sdk.app import App from soar_sdk.cli.path_utils import context_directory from soar_sdk.compat import UPDATE_TIME_FORMAT, PythonVersion ...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/manifests/processors.py
.py
b288914db7cb42e7
7.48
8
import itertools from collections.abc import Iterator from logging import getLogger from typing import Any from soar_sdk.action_results import ActionOutput, OutputFieldSpecification from soar_sdk.field_utils import normalize_field_annotation, parse_json_schema_extra from soar_sdk.meta.datatypes import as_datatype from...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/manifests/serializers.py
.py
e586ed683b8eab0c
7.48
8
import asyncio import contextlib import json import os import tarfile import time from datetime import timedelta from io import BytesIO from itertools import chain from pathlib import Path from typing import Annotated import httpx import humanize import typer from rich.console import Console from rich.panel import Pan...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/package/cli.py
.py
262f83a0fc31b98c
7.48
8
import os import sys from collections.abc import Iterator from contextlib import contextmanager from pathlib import Path @contextmanager def add_to_path(path: Path) -> Iterator[None]: """Temporarily add the given path to the head of sys.path. .. note: Any changes made to sys.path outside of this func...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/path_utils.py
.py
689cb77f3c363085
7.48
8
import dataclasses import keyword import re @dataclasses.dataclass class NormalizationResult: """A named tuple to hold the results of field name normalization.""" original: str normalized: str modified: bool def normalize_field_name(field_name: str) -> NormalizationResult: """Converts a field n...
phantomcyber/splunk-soar-sdk
src/soar_sdk/cli/utils.py
.py
18d64b140307fc12
7.48
8
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/client.py
.py
95ac23c27a10b13b
7.5
9
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/client_async.py
.py
6d885630672f509d
7.5
9
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/endpoints/key.py
.py
182f1eed9dbc98a5
7.5
9
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/endpoints/property.py
.py
2ace1d6cf1a132b8
7.5
9
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/endpoints_async/key.py
.py
774e01f985648212
7.5
9
""" The MIT License (MIT) Copyright (c) 2023-Present cxdzc 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 limitation the rights to use, copy, modify, merge...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/endpoints_async/property.py
.py
b9706ad16b2507d0
7.5
9
import inspect from typing import Callable from ..params.map import parameter_map def build_local_params(method_request: Callable, local_vars: dict) -> dict | None: """ Extracts the arguments passed to `method_request` and returns them as a clean dictionary ready for further processing. :param method_requ...
cxdzc/TornAPIWrapper
src/TornAPIWrapper/params/builders.py
.py
5902074a632025e7
7.5
9
""" Preliminary helpers for geometric calculations for PETSIRD data """ # Copyright (C) 2024 - 2025 University College London # # SPDX-License-Identifier: Apache-2.0 import numpy import numpy.typing as npt import petsird def transform_to_mat44( transform: petsird.RigidTransformation, ) -> npt.NDArray[numpy.f...
ETSInitiative/PETSIRD
python/petsird/helpers/geometry.py
.py
ea4b736e51a02a0b
7.59
14
"""Run aiogram next to Django and send Telegram messages through a Redis queue. Importing this package is cheap on purpose: aiogram (and the pydantic stack underneath it) costs most of a second, and a migration container or a test run should not pay that for a bot it never talks to. Every export resolves on first attr...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/__init__.py
.py
4fb1b297834be914
7.63
17
"""A read-only view of the event feed, sized for a table nobody wants to count. Nothing here reads a setting and nothing registers itself: ``admin.autodiscover`` imports this module while the app registry is still loading, and reading settings at import time is the defect 2.0 existed to remove. Registration happens in...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/admin.py
.py
80eb94f08ffcd654
7.63
17
"""Which method names a queued payload is allowed to name. A payload carries the name of the method to call, so without this list the queue could reach anything public on ``Bot``: ``download_file`` writes to the container's filesystem, ``token`` hands out the credential. This lives apart from ``client`` so the delive...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/api.py
.py
28baac8fe126a9a4
7.63
17
"""The Django app that hooks this package into a project's startup. Importing this module has to stay free of side effects: Django imports it while the app registry is still being populated, before settings are safe to read. Everything that needs configuration happens in ``ready()``. """ import logging from django.a...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/apps.py
.py
816b39035674a193
7.63
17
"""The correlation identifier in scope, so a reply inherits the update's id. A handler that answers an update should produce rows joinable to the update that caused it, without every project threading an argument through its own code. A context variable does that: aiogram runs each update's chain in its own task, and ...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/context.py
.py
b6053941c1a02efa
7.63
17
"""Send the event log to its own database, when one is configured. Optional. The writer and the admin always name the alias explicitly, so the log lands in the right database with no router installed at all. What the router adds is ``migrate`` creating the table there, and third-party code reaching the right alias thr...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/dbrouter.py
.py
2669e7d44add8454
7.63
17
"""Named constants for the strings this package treats as data. Every value here is frozen: queued payloads carry serialization tags and user settings carry delivery, serializer, storage and mode names, so changing a value would break in-flight messages and every deployment's ``TELEGRAM_BOT`` block. The classes subcla...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/enums.py
.py
fdcbc775f6d3d8d3
7.63
17
"""What a queued call looks like on the wire. 2.x wrote ``{'function': name, **kwargs}`` and the consumer splatted it straight back into aiogram, so there was nowhere to put an identifier, a timestamp or a version without it arriving at Telegram as an unexpected argument. 3.0 nests the arguments instead. The tagged-J...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/envelope.py
.py
64ccdc2583e03ec8
7.63
17
"""Turning recorded events into rows, on the one thread allowed to do it. This is the only module in the package that touches the ORM, and it is imported from inside the writer thread rather than at module scope — that is what keeps ``recorder`` free of ``django.db``, and therefore keeps ``record()`` legal from a coro...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/eventlog.py
.py
7ae089f32d6fdfd0
7.63
17
"""The registry of event kinds, and the identifier that ties a message together. ``kind`` is an unconstrained ``CharField``: the set of legal values lives here, in Python, so registering one is not a schema change. The cost is that nothing at the database level rejects a typo, which is why the recorder validates again...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/events.py
.py
674c4cea22d3bb0f
7.63
17
"""The exceptions this package raises. They live together, and build their own messages, so that call sites raise a named domain error instead of a bare builtin with a formatted string. """ class DjangoRedisAiogramError(Exception): """Base class for every error this package raises.""" class LoopUnavailableErro...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/exceptions.py
.py
f369f99172251368
7.63
17
"""Answer whether the bot container is doing its job, without booting Django. ``manage.py tgbot_healthcheck`` has always been correct and could not be used: a management command runs ``django.setup()`` first, which populates the app registry and executes every ``AppConfig.ready()`` in the *host* project. Measured in o...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/healthcheck.py
.py
199bc907316fec6c
7.63
17
"""Watching what comes in, through the one hook both update sources pass. Polling and webhook both feed the same ``Dispatcher``, so a single update middleware sees every update exactly once. When the log is off nothing is registered at all — the cost per update is zero rather than one branch. FSM transitions come fro...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/instrumentation.py
.py
69b49465bf26b76d
7.63
17
"""Run the bot: receive updates, and consume the queue Django writes to. This is the long-running process a bot container is built around. It owns two things at once — whatever brings updates in, and the consumer that drains the Redis queue — and has to shut both down cleanly when the container stops. """ import cont...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/management/commands/start_tgbot.py
.py
d4f8028c5d3e936e
7.63
17
"""Answer whether the bot container is doing its job. `docker ps` says the process is up, which is not the same thing: the consumer thread can be dead while polling continues, or Redis can be unreachable, and the container stays "healthy" either way. A wrapper, since 3.1.0, over :mod:`django_redis_aiogram.healthcheck...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/management/commands/tgbot_healthcheck.py
.py
91b4b309dc6571e6
7.63
17
"""Delete event log rows older than the retention window. Nothing on the write path deletes anything, so the table grows until this runs. Schedule it; check ``W006`` says so while the retention is unset. The deletion walks **primary key ranges**, not ``pk__in``. Two reasons, both practical: MySQL rejects ``DELETE ......
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/management/commands/tgbot_prune_events.py
.py
73ad6546b579223a
7.63
17
"""Put a dead worker's in-flight messages back on the queue. A message being sent lives in ``<queue>:processing:<worker>`` until the send finishes, and the worker that put it there reclaims it on its next start. That only works while the name is stable — a container with no ``hostname:`` and no ``WORKER_NAME`` gets a ...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/management/commands/tgbot_reclaim.py
.py
a6b7724f09c7174e
7.63
17
"""Register, inspect or remove the Telegram webhook. Telegram remembers the URL, not your settings file, so switching between polling and webhooks means telling Telegram. `getUpdates` refuses to run while a webhook is registered, which is why `delete` exists. """ from argparse import ArgumentParser from typing import...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/management/commands/tgbot_webhook.py
.py
4560ce1b66fec20f
7.63
17
"""The append-only feed of what the bot did. Django imports this on every ``django.setup()`` — before ``AppConfig.ready()`` and regardless of ``ENABLED`` — so it may not reach aiogram, directly or otherwise, and may not read settings at import time. Rows are inserted and never updated. The stages of one outbound mess...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/models.py
.py
c99511701a70d8c0
7.63
17
"""Turning call arguments into something safe to keep in a row. Deliberately lossy, which is why it is not :func:`~django_redis_aiogram.serializers.encode`. That one is lossless by contract: it base64s a whole ``BufferedInputFile``, so a photo send would arrive in the table as megabytes of base64. Order is fixed and ...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/payloads.py
.py
1f2abdf1d1e790c5
7.63
17
"""The one Redis connection this package shares. Senders, consumers, the FSM heartbeat and the management commands all go through :func:`get_redis`, so a process opens a single connection pool however many of them are running. The connection is built on first use rather than at import, because Django settings are not ...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/redis.py
.py
e39e519df18d42ce
7.63
17
"""Serialization of queued aiogram calls. JSON is the format. Pickle stays behind ``ALLOW_PICKLE`` as the escape hatch for payloads JSON cannot describe, off by default because unpickling the queue makes anything able to write to the Redis list able to execute code in the container. Two aiogram details make plain ``m...
CorneiZeR/django-redis-aiogram
src/django_redis_aiogram/serializers.py
.py
56217f75a4f049a5
7.63
17