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 |
|---|---|---|---|---|---|---|
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
"""Configurator for ocio_stock_write1.
First half of the Squish ocio_gui case, which submitted the same OCIO scene
once per write node.
"""
def configure(dialog) -> None:
dialog.set_job_name("OCIO Config Job Submission")
dialog.set_job_des... | aws-deadline/deadline-cloud-for-nuke | test/nuke_submitter_ui/test_cases/ocio_stock_write1/input/configure.py | .py | 7e192c7a6b29ef8d | 7.1 | 15 |
# Copyright 2023 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | crossplane/function/logging.py | .py | 65ac2aab7e850738 | 7.56 | 12 |
# Copyright 2025 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | crossplane/function/request.py | .py | 9dc8064f202f04e7 | 7.56 | 12 |
# Copyright 2023 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | crossplane/function/resource.py | .py | 0fd396cb37d03598 | 7.56 | 12 |
# Copyright 2023 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | crossplane/function/response.py | .py | 1f92e7c81053b3a6 | 7.56 | 12 |
# Copyright 2023 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | crossplane/function/runtime.py | .py | d88b391365ee2626 | 7.56 | 12 |
# Copyright 2023 The Crossplane Authors.
#
# 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 ... | crossplane/function-sdk-python | tests/test_runtime.py | .py | e1ef42271706c0a7 | 7.06 | 12 |
from bam_masterdata.checker.masterdata_validator import MasterdataValidator
from bam_masterdata.checker.source_loader import SourceLoader
from bam_masterdata.logger import logger
from bam_masterdata.metadata.entities_dict import EntitiesDict
from bam_masterdata.utils import load_validation_rules
class Masterda... | BAMresearch/bam-masterdata | bam_masterdata/checker/checker.py | .py | dd75cf27ef044d0a | 7.5 | 9 |
import inspect
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from rdflib import Graph
from structlog._config import BoundLoggerLazyProxy
import click
from rdflib import Literal, Namespace
from rdflib.namespace import DC, OWL, RDF, RDFS
from bam_masterdata.utils import import_module
BAM = Namespace("htt... | BAMresearch/bam-masterdata | bam_masterdata/cli/entities_to_rdf.py | .py | c7942fbcd46c7225 | 7.5 | 9 |
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any
class SyncAction(StrEnum):
"""
Synchronization actions when updating the masterdata model in openBIS from bam-masterdata definitions.
Allowed terms are:
- CREATED: something was created new in openBIS
- MODI... | BAMresearch/bam-masterdata | bam_masterdata/openbis/sync.py | .py | 73e69668e9324590 | 7.5 | 9 |
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from bam_masterdata.metadata.entities import CollectionType
if TYPE_CHECKING:
from structlog._config import BoundLoggerLazyProxy
class AbstractParser(ABC):
"""
Example Abstract base class for parsers. Each parser should inherit from th... | BAMresearch/bam-masterdata | bam_masterdata/parsing/parsing.py | .py | e7a71064b4170305 | 7.5 | 9 |
import re
from bam_masterdata.openbis.login import ologin
class UserID:
def __init__(self, url: str = ""):
if not url:
raise ValueError("Missing url to connect to openBIS")
self.openbis = ologin(url=url)
self.users = self.openbis.get_users()
def _split_name(se... | BAMresearch/bam-masterdata | bam_masterdata/utils/users.py | .py | 2f64a496915e0b63 | 7.5 | 9 |
import glob
import importlib.util
import inspect
import json
import os
import re
import shutil
from enum import Enum
from itertools import chain
from typing import TYPE_CHECKING, Any
from bam_masterdata.logger import logger
from bam_masterdata.utils import VALIDATION_RULES_DIR
if TYPE_CHECKING:
from structlog._co... | BAMresearch/bam-masterdata | bam_masterdata/utils/utils.py | .py | 67785a65b249cae2 | 7.5 | 9 |
import os
import pytest
from openpyxl import Workbook
from bam_masterdata.cli.entities_to_excel import entities_to_excel
from bam_masterdata.utils import import_module
@pytest.mark.parametrize(
"module_name, entity_name, entity_headers",
[
(
"collection_types",
"EXPERIMENT_TY... | BAMresearch/bam-masterdata | tests/cli/test_entities_to_excel.py | .py | 8d756dfa1ac6d0e4 | 7 | 9 |
import os
from rdflib import Graph, Literal
from rdflib.namespace import DC, OWL, RDF, RDFS
from bam_masterdata.cli.entities_to_rdf import BAM, entities_to_rdf, rdf_graph_init
from bam_masterdata.logger import logger
def test_rdf_init():
"""
Test the `rdf_graph_init` function.
"""
graph = Graph()
... | BAMresearch/bam-masterdata | tests/cli/test_entities_to_rdf.py | .py | 70c8f3a1d0d61322 | 8 | 9 |
from unittest.mock import MagicMock
from bam_masterdata.cli.run_parser import run_parser, run_parser_with_transactions
from bam_masterdata.logger import log_storage
from tests.conftest import (
TestParser,
TestParserWithObjectReference,
# TestParserWithExistingCode,
# TestParserWithRelationship,
)
de... | BAMresearch/bam-masterdata | tests/cli/test_run_parser.py | .py | ea3201bcfed0567b | 7 | 9 |
import datetime
import logging
import os
import pathlib
import shutil
import traceback
from typing import Any
import pytest
import shortuuid
from _pytest.nodes import Node
from _pytest.reports import TestReport
from _pytest.runner import CallInfo
from _pytest.terminal import TerminalReporter
from kubernetes.dynamic im... | opendatahub-io/opendatahub-tests | conftest.py | .py | 7980aa0c7c27d6f6 | 7 | 9 |
"""Shared utilities for container image check scripts."""
import re
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def get_diff_lines(base: str) -> dict[str, set[int]]:
"""Get added lines per file from git diff against base.
Returns {relative_path: set o... | opendatahub-io/opendatahub-tests | scripts/image_check_utils.py | .py | 0c30795560156ea7 | 7.5 | 9 |
"""Fixtures for body-based routing (BBR) integration tests."""
from collections.abc import Generator
from typing import Any
import pytest
import requests
import structlog
from kubernetes.dynamic import DynamicClient
from ocp_resources.maas_model_ref import MaaSModelRef
from ocp_resources.maas_subscription import MaaS... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/conftest.py | .py | 8d044c39d54d4fdb | 8 | 9 |
"""Tests verifying the EnvoyFilter configuration introduced by the BBR pre-auth ext_proc."""
from typing import Any, Self
import pytest
from kubernetes.dynamic import DynamicClient
from tests.ai_gateway.models_as_a_service.body_base_routing.pre_auth_model_header.utils import (
verify_bbr_envoy_filter_cluster_nam... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/test_bbr_envoy_filter.py | .py | ed13718f9588f82a | 7 | 9 |
"""Smoke tests for BBR payload-processing (post-auth) infrastructure deployment."""
from typing import Self
import pytest
from kubernetes.dynamic import DynamicClient
from tests.ai_gateway.models_as_a_service.body_base_routing.pre_auth_model_header.utils import (
verify_bbr_plugins_configmap_has_expected_plugins... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/test_bbr_post_auth_setup.py | .py | f3a30e48739730c6 | 7 | 9 |
"""Tests verifying BBR pre-auth inference: model name extracted from request body."""
from typing import Any, Self
import pytest
import requests
import structlog
from tests.ai_gateway.models_as_a_service.body_base_routing.pre_auth_model_header.utils import (
assert_bbr_inference_status,
)
from tests.ai_gateway.m... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/test_bbr_pre_auth_inference.py | .py | f7a3e3e0ce1d8592 | 7 | 9 |
"""Tests verifying token rate limiting is enforced on BBR /llm/ inference paths."""
from typing import Any, Self
import pytest
import requests
import structlog
from tests.ai_gateway.models_as_a_service.utils import assert_mixed_200_and_429, build_maas_headers
LOGGER = structlog.get_logger(name=__name__)
BBR_RATE_L... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/test_bbr_rate_limits.py | .py | fb04e75da8315551 | 8 | 9 |
"""Smoke tests for BBR payload-pre-processing infrastructure deployment."""
import pytest
from kubernetes.dynamic import DynamicClient
from tests.ai_gateway.models_as_a_service.body_base_routing.pre_auth_model_header.utils import (
verify_bbr_pre_processing_deployment_ready,
verify_bbr_pre_processing_destinat... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/body_base_routing/pre_auth_model_header/test_bbr_setup.py | .py | 5f2d4711b1bd8454 | 7 | 9 |
import pytest
import structlog
from kubernetes.dynamic import DynamicClient
from ocp_resources.data_science_cluster import DataScienceCluster
from ocp_resources.deployment import Deployment
from utilities.constants import DscComponents
from utilities.general import wait_for_pods_running
LOGGER = structlog.get_logger(... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/component_health/test_maas_api_health_check.py | .py | 527554b5552915cc | 8 | 9 |
from __future__ import annotations
import pytest
import structlog
from kubernetes.dynamic import DynamicClient
from ocp_resources.maas_model_ref import MaaSModelRef
from ocp_resources.namespace import Namespace
from tests.ai_gateway.models_as_a_service.external_model.utils import (
get_httproute,
get_service,... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/external_model/test_external_model_discovery.py | .py | 65d349be770bee9b | 8 | 9 |
from collections.abc import Generator
from typing import Any
import pytest
import requests
import structlog
from kubernetes.dynamic import DynamicClient
from ocp_resources.cron_job import CronJob
from ocp_resources.deployment import Deployment
from ocp_resources.maas_model_ref import MaaSModelRef
from ocp_resources.ma... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/maas_api_key/conftest.py | .py | c5e758de84a84487 | 7 | 9 |
from __future__ import annotations
import pytest
import requests
import structlog
from kubernetes.dynamic import DynamicClient
from tests.ai_gateway.models_as_a_service.maas_api_key.utils import (
get_auth_policy_callback_url,
wait_for_auth_policy_accepted,
)
from tests.ai_gateway.models_as_a_service.utils im... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/maas_api_key/test_api_key_auth_policy_validation.py | .py | 9bd38e406f83ebe8 | 8 | 9 |
import pytest
from kubernetes.dynamic import DynamicClient
from ocp_resources.cluster_role import ClusterRole
from ocp_resources.cluster_role_binding import ClusterRoleBinding
from ocp_resources.deployment import Deployment
from ocp_resources.service_account import ServiceAccount
from pytest_testconfig import config as... | opendatahub-io/opendatahub-tests | tests/ai_gateway/models_as_a_service/maas_cleanup/test_maas_disable_cleanup.py | .py | 2314a0a80295f1ec | 8 | 9 |
import sys
import rich
from rich import progress
from cumulus_library import base_utils, databases, enums, errors, study_manifest
from cumulus_library.template_sql import base_templates
def _execute_drop_queries(
db: databases.DatabaseBackend,
verbose: bool,
view_table_list: list,
progress: progress... | smart-on-fhir/cumulus-library | cumulus_library/actions/cleaner.py | .py | 635207d3dc83ba8e | 7.42 | 6 |
import pathlib
import pandas
import rich
from rich.progress import track
from cumulus_library import base_utils, study_manifest
from cumulus_library.template_sql import base_templates
# Database exporting functions
def reset_counts_exports(
manifest: study_manifest.StudyManifest,
) -> None:
"""
Removes... | smart-on-fhir/cumulus-library | cumulus_library/actions/exporter.py | .py | 10a65ad8100ee388 | 7.42 | 6 |
import typing
import pandas
import pytablewriter
from cumulus_library import base_utils, databases, study_manifest
from cumulus_library.actions import builder
from cumulus_library.template_sql import base_templates
def run_generate_sql(
config: base_utils.StudyConfig,
manifest: study_manifest.StudyManifest,... | smart-on-fhir/cumulus-library | cumulus_library/actions/file_generator.py | .py | 9ed2343db485a298 | 7.42 | 6 |
import pathlib
import tempfile
import zipfile
import pyarrow.parquet
from cumulus_library import base_utils, errors, study_manifest
from cumulus_library.actions import cleaner
from cumulus_library.template_sql import base_templates
def _create_table_from_parquet(
archive: zipfile.ZipFile, file: str, study_name:... | smart-on-fhir/cumulus-library | cumulus_library/actions/importer.py | .py | 424cd66303c719f9 | 7.42 | 6 |
"""Handles pushing data to the aggregator"""
import sys
import zipfile
from pathlib import Path
import requests
import rich
from pandas import read_parquet
from cumulus_library import base_utils, const
def upload_data(
progress_bar: rich.progress.Progress,
file_upload_progress: rich.progress.TaskID,
fi... | smart-on-fhir/cumulus-library | cumulus_library/actions/uploader.py | .py | 6fb9f19dbececea9 | 7.42 | 6 |
"""Class for communicating with the Loinc API"""
import os
import pathlib
import requests
import rich
from cumulus_library import base_utils, errors
BASE_URL = "https://loinc.regenstrief.org/api/v1/"
class LoincApi:
def __init__(self, *, user: str | None = None, password: str | None = None):
"""Create... | smart-on-fhir/cumulus-library | cumulus_library/apis/loinc.py | .py | 54debac3b7ec798e | 7.42 | 6 |
"""Class for communicating with the umls API"""
import os
import pathlib
import requests
from cumulus_library import base_utils, errors
VALID_UMLS_DOWNLOADS = [
"rxnorm-full-monthly-release",
"rxnorm-weekly-updates",
"rxnorm-prescribable-content-monthly-release",
"rxnorm-prescribable-content-weekly-... | smart-on-fhir/cumulus-library | cumulus_library/apis/umls.py | .py | 0e3d5e4fa2575b42 | 7.42 | 6 |
"""Collection of small commonly used utility functions"""
import dataclasses
import datetime
import json
import pathlib
import shutil
import zipfile
from contextlib import contextmanager
import numpy
import pandas
import platformdirs
import pyarrow
import rich
import sqlglot
from rich import progress
from cumulus_li... | smart-on-fhir/cumulus-library | cumulus_library/base_utils.py | .py | 6ff622efb5e7c423 | 7.42 | 6 |
"""Class for generating counts tables from templates"""
import pathlib
import rich
from cumulus_library import BaseTableBuilder, base_utils, errors, study_manifest
from cumulus_library.builders import counts_utils
from cumulus_library.builders.statistics_templates import counts_templates
# Defined here for easy ove... | smart-on-fhir/cumulus-library | cumulus_library/builders/counts_builder.py | .py | ba58a56aafb84ebf | 7.42 | 6 |
"""Local caching of NLP results, to avoid future calls"""
import hashlib
import threading
from collections.abc import Callable
from typing import TypeVar
import cumulus_fhir_support as cfs
Obj = TypeVar("Obj")
# Writes have to be serialized. Every FsPath write made while NLP workers are running must
# take this loc... | smart-on-fhir/cumulus-library | cumulus_library/builders/nlp/caching.py | .py | 3e3b9a30c5c349f0 | 7.42 | 6 |
"""Dispatches NLP prompts across endpoints, on a bounded set of worker threads.
This module spreads those requests over a fixed number of worker threads, each pinned to
one endpoint (an Azure deployment, or the single endpoint that Bedrock and local vLLM offer).
Two properties matter as much as the speedup:
- There a... | smart-on-fhir/cumulus-library | cumulus_library/builders/nlp/dispatch.py | .py | e245e51b5085eab5 | 7.42 | 6 |
"""MLflow experiment tracking for NLP workflows.
MLflow is an optional dependency. Nothing in this module is imported unless tracking is turned
on with --mlflow, and importing mlflow itself is deferred until then.
"""
import contextlib
import datetime
import hashlib
import json
import logging
import types
from collec... | smart-on-fhir/cumulus-library | cumulus_library/builders/nlp/tracking.py | .py | cbdf73e87ad1624c | 7.42 | 6 |
"""Class for generating NLP results"""
import json
import pathlib
import sys
import cumulus_fhir_support as cfs
import jambo
import msgspec
import rich
import cumulus_library
from cumulus_library import base_utils, errors, note_utils
from cumulus_library.builders.nlp import driver, models, tracking, workflow
from cu... | smart-on-fhir/cumulus-library | cumulus_library/builders/nlp_builder.py | .py | b1163dc7caac9f17 | 7.42 | 6 |
"""Builder for creating tables for tracking state/logging changes"""
import pathlib
import tomllib
from cumulus_library import (
BaseTableBuilder,
base_utils,
const,
enums,
study_manifest,
)
from cumulus_library.template_sql import base_templates
class ProtectedTableBuilder(BaseTableBuilder):
... | smart-on-fhir/cumulus-library | cumulus_library/builders/protected_table_builder.py | .py | 6c09a88970cedb48 | 7.42 | 6 |
# Module for generating Propensity Score matching cohorts
import json
import os
import pathlib
import sys
import tomllib
import warnings
from dataclasses import dataclass
import pandas
import rich
from cumulus_library import BaseTableBuilder, StudyManifest, base_utils, databases
from cumulus_library.builders import ... | smart-on-fhir/cumulus-library | cumulus_library/builders/psm_builder.py | .py | 711ab5784ad5d92d | 7.42 | 6 |
from dataclasses import dataclass
from pathlib import Path
from cumulus_library import errors
from cumulus_library.template_sql import base_templates
@dataclass
class CountColumn:
name: str
db_type: str
alias: str
@dataclass(kw_only=True)
class FilterColumn:
name: str
values: list[str]
incl... | smart-on-fhir/cumulus-library | cumulus_library/builders/statistics_templates/counts_templates.py | .py | 187836059800146b | 7.42 | 6 |
"""Collection of jinja template getters for common SQL queries"""
from pathlib import Path
from cumulus_library.errors import CumulusLibraryError
from cumulus_library.template_sql import base_templates
def get_distinct_ids(
columns: list[str],
source_table: str,
join_id: str | None = None,
filter_ta... | smart-on-fhir/cumulus-library | cumulus_library/builders/statistics_templates/psm_templates.py | .py | d3bede1b41188baa | 7.42 | 6 |
"""Builder for generating subsets of RxNorm data from a given valueset"""
import pathlib
from cumulus_library import BaseTableBuilder, base_utils, study_manifest
from cumulus_library.builders.valueset import valueset_utils
from cumulus_library.template_sql import base_templates
class AdditionalRulesBuilder(BaseTabl... | smart-on-fhir/cumulus-library | cumulus_library/builders/valueset/additional_rules_builder.py | .py | 4e6639dbf30831b4 | 7.42 | 6 |
"""Builder for tables from flat files for valueset lookup"""
import csv
import dataclasses
import pathlib
import pandas
from cumulus_library import BaseTableBuilder, base_utils, study_manifest
from cumulus_library.builders.valueset import valueset_utils, vsac
from cumulus_library.template_sql import base_templates
... | smart-on-fhir/cumulus-library | cumulus_library/builders/valueset/static_builder.py | .py | 39302826f7ed7fc7 | 7.42 | 6 |
import dataclasses
import pathlib
from cumulus_library import base_utils, study_manifest
@dataclasses.dataclass(kw_only=True)
class ValuesetConfig:
"""Provides expected values for creating valuesets"""
rules_file: str = None
keyword_file: str = None
table_prefix: str = None
umls_stewards: dict[s... | smart-on-fhir/cumulus-library | cumulus_library/builders/valueset/valueset_utils.py | .py | 98aae0bd0667b28d | 7.42 | 6 |
import pathlib
import sys
import tomllib
from cumulus_library import BaseTableBuilder, base_utils, study_manifest
from cumulus_library.builders.valueset import (
additional_rules_builder,
rxnorm_valueset_builder,
static_builder,
valueset_utils,
)
class ValuesetBuilder(BaseTableBuilder):
"""TableB... | smart-on-fhir/cumulus-library | cumulus_library/builders/valueset_builder.py | .py | 39aaa44ca5701d8c | 7.42 | 6 |
"""Database abstraction layer for AWS Athena
See base.py for design rules of thumb - notably, don't use non-PEP249 database
features, like pyathena's async cursors, to simplify cross-db behavior.
"""
import base64
import collections
import hashlib
import os
import pathlib
from concurrent import futures
import awswra... | smart-on-fhir/cumulus-library | cumulus_library/databases/athena.py | .py | e65a6cdacc70368c | 7.42 | 6 |
"""Base Abstraction layer for interfacing with databases
By convention, to maintain this as a relatively light wrapper layer, if you have
to chose between a convenience function in a specific library (as an example, the
[pyathena to_sql function](https://github.com/laughingman7743/PyAthena/#to-sql))
or using raw sql d... | smart-on-fhir/cumulus-library | cumulus_library/databases/base.py | .py | d6d094141a3705f3 | 7.42 | 6 |
"""Database abstraction layer for DuckDB
See base.py for design rules of thumb.
Since duckdb tends to be more malleable than a cloud-based database, if you
need to paper over differences, it's best to use the connection.create_function
pattern here to get sql flavors in alignment.
"""
import base64
import collection... | smart-on-fhir/cumulus-library | cumulus_library/databases/duckdb.py | .py | eb93f4ab02964c9a | 7.42 | 6 |
import pathlib
import string
import sys
from collections.abc import Iterable
from concurrent import futures
import cumulus_fhir_support
import pyarrow
import pyarrow.dataset
import pyarrow.json
import rich
from cumulus_library import base_utils, db_config, errors
from cumulus_library.databases import athena, base, du... | smart-on-fhir/cumulus-library | cumulus_library/databases/utils.py | .py | 57340e6bc03a2450 | 7.42 | 6 |
"""Holds enums used across more than one module"""
import enum
class LogStatuses(enum.Enum):
DEBUG = "debug"
ERROR = "error"
FINISHED = "finished"
INFO = "info"
RESUMED = "resumed"
STARTED = "started"
WARN = "warn"
class ProtectedTables(enum.Enum):
"""Tables created by cumulus for p... | smart-on-fhir/cumulus-library | cumulus_library/enums.py | .py | 3622b7905f39a271 | 7.42 | 6 |
"""A set of convenience functions for database logging"""
from cumulus_library import (
__version__,
base_utils,
databases,
enums,
errors,
study_manifest,
)
from cumulus_library.template_sql import base_templates, sql_utils
def log_transaction(
*,
config: base_utils.StudyConfig,
m... | smart-on-fhir/cumulus-library | cumulus_library/log_utils.py | .py | da4f71472412247c | 7.42 | 6 |
import argparse
import binascii
import io
import os
import pathlib
from collections.abc import Generator
import cumulus_fhir_support as cfs
import rich
from cumulus_library import base_utils, databases, errors
#########################
# Reading notes from disk
#########################
class NoteSource:
def _... | smart-on-fhir/cumulus-library | cumulus_library/note_utils.py | .py | 7b668452320df842 | 7.42 | 6 |
"""json rpc implement for rtorrent
!! This is not a general propose json-rpc client.
"""
import base64
import json
import threading
from typing import Any
from rtorrent_rpc._transport import Transport
def _bytes_default(obj: Any) -> str:
if isinstance(obj, bytes):
return f"data:;base64,{base64.b64enco... | trim21/rtorrent-rpc | rtorrent_rpc/_jsonrpc.py | .py | 40469d0315637cc1 | 7.45 | 7 |
from __future__ import annotations
from typing import Iterator
__all__ = ["encode_request", "parse_response"]
NULL = b"\x00"
class ProtocolError(Exception):
pass
def encode_request(body: bytes, content_type: str | None = None) -> Iterator[bytes]:
length = len(body)
header_items: list[bytes] = [
... | trim21/rtorrent-rpc | rtorrent_rpc/_scgi.py | .py | 911c5a217943a5ca | 7.45 | 7 |
from __future__ import annotations
import enum
import hashlib
import sys
from pathlib import Path
from typing import Any
from urllib.parse import unquote
import bencode2
__all__ = [
"add_completed_resume_file",
"add_fast_resume_file",
"get_torrent_info_hash",
"parse_comment",
"parse_tags",
]
de... | trim21/rtorrent-rpc | rtorrent_rpc/helper.py | .py | c64d131a085b05c1 | 7.45 | 7 |
#!/usr/bin/env python3
"""Custom scoring/viz wrapper: count annotation files under matched inputs.
Import::
samovar tools import -n counts \\
--exec-path examples/scoring/count_annotations.py --type scoring \\
--inputs '*annotations' --flags "--min-files 0"
"""
from __future__ import annotations
... | ctlab/samovar | examples/scoring/count_annotations.py | .py | c2e5ae4c1cd6648f | 7.48 | 8 |
#!/usr/bin/env python3
"""Assign a constant NCBI taxID to every FASTQ read (default: Homo sapiens, 9606).
This is a dummy classifier used to test custom annotator integration. Output is
two tab-separated columns: sequence ID and taxID (CustomAnnotator format).
"""
from __future__ import annotations
import argparse
i... | ctlab/samovar | src/annotators/constant9606.py | .py | c4b0180a034bc8a1 | 7.48 | 8 |
#!/usr/bin/env python3
import random
from typing import List, Tuple
from pathlib import Path
import argparse
from samovar.seqio import (
fasta_handle,
is_fasta_name,
open_text,
taxid_from_fasta_name,
)
def read_fasta(file_path: str) -> List[Tuple[str, str]]:
"""Read FASTA file (plain or gzipped)... | ctlab/samovar | src/samovar/fasta_processor.py | .py | f01a2e031c856d11 | 7.48 | 8 |
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import roc_curve, auc
from sklearn.multiclass import OneVsRestClassifier
import matplotl... | ctlab/samovar | src/samovar/reprofiling.py | .py | 3386f037f7cf06d5 | 7.48 | 8 |
import os
from typing import Dict, Optional, Tuple
class NCBITaxonomyParser:
"""Lightweight parser for NCBI ``nodes.dmp``.
Stores parent/rank as a hash map instead of loading a full ete3 database.
Used as a fallback (and as a standalone helper) when resolving taxIDs to
a rank such as genus or species... | ctlab/samovar | src/samovar/taxonomy_engine.py | .py | aaa3b66ee5d4b1d0 | 7.48 | 8 |
"""Package version from ``pyproject.toml`` (single source of truth)."""
from __future__ import annotations
import re
from functools import lru_cache
from pathlib import Path
from typing import Optional
_VERSION_RE = re.compile(
r'(?m)^version\s*=\s*["\']([^"\']+)["\']\s*$'
)
def pyproject_path() -> Path:
"... | ctlab/samovar | src/samovar/version.py | .py | 3c936e72db3215fe | 7.48 | 8 |
# One-time notice for users still running the engine copy kept in this repo.
#
# mlcflow >= 1.3.0 bundles its own copy of automation/ and never loads this
# one, so reaching this code means the installed mlcflow predates the
# migration of the engine into mlcflow.
import os
from utils import compare_versions
MIN_MLC... | mlcommons/mlperf-automations | automation/script/deprecation.py | .py | 22586ab6f29dd70e | 7.57 | 13 |
import os
from mlc import utils
from utils import *
import logging
from pathlib import PureWindowsPath, PurePosixPath
import copy
from collections import defaultdict
def generate_doc(self_module, input_params):
"""
Generates the documentation of MLC scripts.
Args:
self_module: Reference to the cu... | mlcommons/mlperf-automations | automation/script/doc.py | .py | 6091e67b615d58a2 | 7.57 | 13 |
import os
import json
from mlc import utils
from utils import *
from pathlib import PureWindowsPath, PurePosixPath, Path
from script.docker_utils import *
import copy
def convert_to_abs_path(path):
if not os.path.isabs(path):
path = os.path.abspath(path)
return path
# gets parent directory if the pat... | mlcommons/mlperf-automations | automation/script/docker_utils.py | .py | e9abbde4745ef978 | 7.57 | 13 |
import os
from mlc import utils
from utils import *
import os
from collections import defaultdict
def display_help(self_module, input_params):
"""
Generates the documentation of MLC scripts.
Args:
self_module: Reference to the current module for internal calls.
input_params: Dictionary co... | mlcommons/mlperf-automations | automation/script/help.py | .py | 105f482544c1d611 | 7.57 | 13 |
from collections import defaultdict
import os
import mlc.utils as utils
from mlc import utils
from utils import *
import logging
from pathlib import PureWindowsPath, PurePosixPath
import time
import copy
from datetime import datetime
from script.script_utils import *
import platform
def remote_run(self_module, i):
... | mlcommons/mlperf-automations | automation/script/remote_run.py | .py | 4e01ea30777a334c | 7.57 | 13 |
"""
abstract backend class
"""
# pylint: disable=unused-argument,missing-docstring
class Backend():
def __init__(self):
self.inputs = []
self.outputs = []
def version(self):
raise NotImplementedError("Backend:version")
def name(self):
raise NotImplementedError("Backend:n... | mlcommons/mlperf-automations | script/app-mlperf-automotive-mlcommons-python/ref/python/backend.py | .py | 8613b6f1cbe7c1ce | 7.57 | 13 |
"""
Pytoch native backend
Extended by Grigori Fursin for the ABTF demo
"""
# pylint: disable=unused-argument,missing-docstring
import torch # currently supports pytorch1.0
import torchvision
import backend
import os
import sys
import importlib
class BackendPytorchNative(backend.Backend):
def __init__(self):
... | mlcommons/mlperf-automations | script/app-mlperf-automotive-mlcommons-python/ref/python/backend_pytorch_native.py | .py | ec07aef64264d6fa | 7.57 | 13 |
from __future__ import annotations
from typing import Protocol, List, TypeVar, Any, Callable, Dict, Union, Optional, Tuple
from pathlib import Path
import numpy as np
from abc import ABC
# Type variables for generics
BrachyPlanType = TypeVar('BrachyPlanType', bound='BrachyPlan')
DwellTimeOptimizerType = TypeVar('Dwell... | engerlab/brachyutils | brachyutils/brachy_types.py | .py | 269c2c99e484cd51 | 7.5 | 9 |
from brachyutils.dose import BrachyUtilsTG43
from brachyutils.planning import BrachyPlan
from brachyutils.geometry import BrachyPhantom
from brachyutils.geometry import BrachyApplicator
from brachyutils.geometry.catheter_utils import DwellPosition
from brachyutils.dose import BrachyDose
from brachyutils.dose.tg43_dose_... | engerlab/brachyutils | brachyutils/dose/tg43s_dose_calculator.py | .py | acf8581a6077089d | 7.5 | 9 |
import numpy as np
import os
import json
from pathlib import Path
from typing import Union, List
# Imports for brachy applicator
from vtk import (
vtkCellArray,
vtkFillHolesFilter,
vtkPoints,
vtkPolyData,
vtkTransform,
vtkTransformPolyDataFilter,
)
from vtk.util import numpy_support
from vtkmodu... | engerlab/brachyutils | brachyutils/geometry/applicator_utils.py | .py | 35ca76ce95dccff0 | 7.5 | 9 |
import numpy as np
from pydantic import BaseModel, computed_field, model_validator, ConfigDict
from typing import List, Union, Any, Optional
import SimpleITK as sitk
import copy
from brachyutils.geometry.catheter_utils.dwell_position import DwellPosition
from brachyutils.geometry.catheter_utils.patch_ai_assisted_brachy... | engerlab/brachyutils | brachyutils/geometry/catheter_utils/catheter.py | .py | 7c15d3b5ce24a61c | 7.5 | 9 |
from pydantic import BaseModel, Field
from numpy.typing import ArrayLike
from typing import List, Tuple, Dict
class Config_Catheter_Rotation(BaseModel):
"""
### Purpose:
- Configuration for angled catheter generation. This will be used in angled_catheter_pairs().
### Attributes:
- `x_angle_max` :... | engerlab/brachyutils | brachyutils/geometry/catheter_utils/config_cathgen.py | .py | f3c5ff259d2f24f7 | 7.5 | 9 |
from typing import ClassVar, List, Union, Any
import numpy as np
import warnings
from pydantic import (BaseModel, ConfigDict, PrivateAttr, computed_field, field_validator, model_validator,
SkipValidation)
import SimpleITK as sitk
from brachyutils.brachy_types import BrachyDose
from opentps.core.da... | engerlab/brachyutils | brachyutils/geometry/catheter_utils/dwell_position.py | .py | 8f3126a2944dc95f | 7.5 | 9 |
import itertools
import SimpleITK as sitk
import numpy as np
def calculate_rotation_matrix(direction, target=np.array([0, 0, 1]), prt:bool=False):
"""
Calculate the rotation matrix to align the direction vector with the target vector.
"""
direction = direction / np.linalg.norm(direction)
target =... | engerlab/brachyutils | brachyutils/geometry/catheter_utils/patch_ai_assisted_brachy/digitization/rotation.py | .py | 264dfebdc8f9e169 | 7.5 | 9 |
from opentps.core.processing.imageProcessing.resampler3D import resampleImage3DOnImage3D
from typing import Literal, Optional, Union, List, Dict
from collections import defaultdict
import numpy as np
from pathlib import Path
from brachyutils.geometry.phantom_utils import BrachyPhantom
# from brachyutils.geometry.phant... | engerlab/brachyutils | brachyutils/geometry/registration_utils/reg_opentps.py | .py | c56aaca3e6aa1abb | 7.5 | 9 |
from pathlib import Path
from typing import Literal, Optional, Union, List, Dict
# from collections import defaultdict
import numpy as np
from brachyutils.geometry.phantom_utils import BrachyPhantom
from brachyutils.geometry.phantom_utils import phantom_with_empty_image_like
from opentps.core.data._transform3D import ... | engerlab/brachyutils | brachyutils/geometry/registration_utils/reg_plastimatch.py | .py | c59a8a923de2bbb5 | 7.5 | 9 |
import numpy as np
from brachyutils.geometry.registration_utils.reg_utils import (
BrachyPhantomRegistration, phantom_with_empty_image_like
)
from brachyutils.geometry.phantom_utils import BrachyPhantom
from pathlib import Path
from typing import Literal, Optional, Union, List, Dict
from opentps.core.processing.ima... | engerlab/brachyutils | brachyutils/geometry/registration_utils/reg_simple_elastix.py | .py | 0249e3050f5f0eb1 | 7.5 | 9 |
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Literal, Optional, Union, List, Dict
from collections import defaultdict
import numpy as np
from brachyutils.geometry.phantom_utils import BrachyPhantom
from brachyutils.geometry.phantom_utils import phantom_with_empty_image_like
from open... | engerlab/brachyutils | brachyutils/geometry/registration_utils/reg_utils.py | .py | 9250cb12f3fef799 | 7.5 | 9 |
from pathlib import Path
import os
import qt
import slicer
from slicer.ScriptedLoadableModule import (
ScriptedLoadableModule,
ScriptedLoadableModuleLogic,
ScriptedLoadableModuleWidget,
)
from slicer.util import VTKObservationMixin
import HomeLib.update_check
import SlicerCustomAppUtilities
# Import to ... | OpenwaterHealth/openlifu-desktop-application | Modules/Scripted/Home/Home.py | .py | 181ac7f408ebd877 | 7.52 | 10 |
#!/usr/bin/env python3
"""
Generate _build_info.py with compile-time git state.
Run this before building/packaging BunnyPad.
"""
import subprocess
import sys
import re
from datetime import datetime
from pathlib import Path
def is_git_dirty() -> bool:
"""Check if repo has uncommitted changes outside languages/."""... | GSYT-Productions/BunnyPad-SRC | prettyfonts/v11-FPL2/PyQt6/generate_build_info.py | .py | 1e8f1164b6933049 | 7.48 | 8 |
#!/usr/bin/env python3
"""Derive the contiguous brain slices the context-adapter figure denoises.
Documentation-only tooling, run by hand. TorchIO fetches IXITiny from a
third-party host, and every ``.. plot::`` executes on every documentation
build, so the download happens once here and the result is committed beside... | pulserver/pulserver | docs/_bench/make_ixi_stack.py | .py | f340b0d7381d7746 | 7.42 | 6 |
#!/usr/bin/env python3
"""Train the denoiser the plug-and-play figures reconstruct with.
Documentation-only tooling, run by hand. It writes a model bundle under
``docs/_models`` that :func:`pulserver.recon.load_model` resolves by name --
the same deployment path a scanner uses, exercised end to end.
The training set ... | pulserver/pulserver | docs/_bench/train_denoiser.py | .py | b9f38d88a5475319 | 7.42 | 6 |
#!/usr/bin/env python3
"""Train the unrolled network the MoDL figure reconstructs with.
Documentation-only tooling, run by hand. It writes a second bundle beside the
plug-and-play denoiser, so the two learned figures show two different things:
a denoiser trained on its own and dropped into an optimizer, and an unroll
... | pulserver/pulserver | docs/_bench/train_unroll.py | .py | dca0ee03dbd24804 | 7.42 | 6 |
#!/usr/bin/env python3
"""Representative-TR waveform and PNS figures for the safety explanations.
Documentation-only tooling: produces the per-sequence figures embedded in
``explanations/safety/pns.md`` and ``explanations/safety/mechanical_resonance.md``.
Not part of the shipped package.
Everything is drawn through t... | pulserver/pulserver | docs/_bench/waveform_plots.py | .py | f153f432b86e9e68 | 7.42 | 6 |
"""Parse the C and C++ headers into the XML the reference is rendered from.
Doxygen is a system package rather than a Python one, so this is the one part
of the documentation that can be missing on an otherwise complete environment.
It is skipped rather than demanded, and the caller decides what to do without
it: the ... | pulserver/pulserver | docs/_doxygen_xml.py | .py | 82c82858dace9c46 | 7.42 | 6 |
"""Sphinx configuration for the Pulserver documentation."""
import re
import site
import sys
import warnings
from pathlib import Path
# ``_figures`` holds the Bloch simulator and plotting helpers the ``.. plot::``
# directives embedded in docstrings import, and ``_doxygen_xml`` the Doxygen
# run the C and C++ referen... | pulserver/pulserver | docs/conf.py | .py | e7e0a3ebd4196bd6 | 7.42 | 6 |
"""The reconstruction half of the zoo: one recon per sampling.
Every module here is installed into :mod:`pulserver.app` and reached from
there. Each is callable, and calling it reconstructs an MRD file::
from pulserver.app import cartesian2D_recon
images = cartesian2D_recon("scan.h5")
There is deliberately ... | pulserver/pulserver | examples/recon/__init__.py | .py | 0cca0f38ed1b33d1 | 7.42 | 6 |
"""Any 2D Cartesian scan, one image per slice and echo.
Calling this module reconstructs an MRD file; ``PLUGIN`` is the same
reconstruction behind the stream contract, driven live by the scanner.
"""
from __future__ import annotations
__all__ = ["PLUGIN", "Cartesian2DRecon"]
from typing import Any
import numpy as ... | pulserver/pulserver | examples/recon/cartesian2D_recon.py | .py | 3e72dab8309618d6 | 7.42 | 6 |
"""Any 3D non-Cartesian scan, one volume per measurement.
Calling this module reconstructs an MRD file; ``PLUGIN`` is the same
reconstruction behind the stream contract, driven live by the scanner.
"""
from __future__ import annotations
__all__ = ["PLUGIN", "NonCartesian3DRecon"]
from typing import Any
from pulse... | pulserver/pulserver | examples/recon/noncartesian3D_recon.py | .py | e6379254ca3f8cd7 | 7.42 | 6 |
"""Any stack of 2D non-Cartesian planes, one volume per measurement.
Calling this module reconstructs an MRD file; ``PLUGIN`` is the same
reconstruction behind the stream contract, driven live by the scanner.
"""
from __future__ import annotations
__all__ = ["PLUGIN", "NonCartesianStackRecon"]
from typing import An... | pulserver/pulserver | examples/recon/noncartesian_stack_recon.py | .py | 6b648b7ae09db617 | 7.42 | 6 |
"""Prospective motion correction from a multi-plane navigator.
Calling this module tracks the head through a recorded navigator file;
``PLUGIN`` is the same tracking behind the stream contract, and ``process``
is what the scanner's real-time port drives it through while the scan runs.
"""
from __future__ import annot... | pulserver/pulserver | examples/recon/pmc_recon.py | .py | 34e5da08ef25d3e6 | 7.42 | 6 |
"""The sequence half of the zoo: one complete sequence per module.
Every module here is installed into :mod:`pulserver.app` and reached from
there -- ``pulserver.app.gre2D_sequence``, whatever directory it was written
in. Each is a worked example of the whole authoring stack: the
:mod:`pulserver.design` modules it com... | pulserver/pulserver | examples/sequence/__init__.py | .py | a33a4ea3f94fda29 | 7.42 | 6 |
import qt
import slicer
import time
import os
import signal
import logging
from pathlib import Path
from OpenLIFULib import ensure_python_requirements_for_module_enter
from OpenLIFULib.util import display_errors
from slicer.ScriptedLoadableModule import *
from slicer.i18n import tr as _
from slicer.i18n import translat... | OpenwaterHealth/SlicerOpenLIFU | OpenLIFUCloudSync/OpenLIFUCloudSync.py | .py | 399db2bbf7b4843d | 7.54 | 11 |
# Standard library imports
from typing import Optional, TYPE_CHECKING
import os
# Third-party imports
import qt
import vtk
# Slicer imports
import slicer
from slicer.ScriptedLoadableModule import *
from slicer.i18n import tr as _
from slicer.i18n import translate
from slicer.parameterNodeWrapper import parameterNodeW... | OpenwaterHealth/SlicerOpenLIFU | OpenLIFUHome/OpenLIFUHome.py | .py | beff8695e193f822 | 7.54 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.