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 |
|---|---|---|---|---|---|---|
"""Add categories to questions
Revision ID: 23c87f39cb4a
Revises: 103601ff4331
Create Date: 2022-06-27 12:06:46.503887
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "23c87f39cb4a"
down_revision = "103601ff4331"
branch_labels = None
depends_on = None
def upg... | Dosenpfand/matheworkout | migrations/versions/23c87f39cb4a_add_categories_to_questions.py | .py | b5f4bcc814045849 | 7.15 | 1 |
"""empty message
Revision ID: 4a52c0f07c41
Revises: adf1ff424d27
Create Date: 2023-06-15 14:31:10.170735
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "4a52c0f07c41"
down_revision = "adf1ff424d27"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/4a52c0f07c41_.py | .py | 249f24e593c6240e | 7.15 | 1 |
"""empty message
Revision ID: 5663a3aba9dd
Revises: 23c87f39cb4a
Create Date: 2022-08-05 09:18:24.939186
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "5663a3aba9dd"
down_revision = "23c87f39cb4a"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/5663a3aba9dd_.py | .py | e75ac6fe2fb9e6ba | 7.15 | 1 |
"""Add cool learning group db.
Revision ID: 57347e33eb87
Revises: 8214912a9c5a
Create Date: 2022-04-13 09:47:21.000350
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "57347e33eb87"
down_revision = "8214912a9c5a"
branch_labels = None
depends_on = None
def upg... | Dosenpfand/matheworkout | migrations/versions/57347e33eb87_add_cool_learning_group_db.py | .py | f973bd58f2875da0 | 7.15 | 1 |
"""empty message
Revision ID: 6146f25a0ac7
Revises: 8263aeba1cc6
Create Date: 2022-08-31 14:41:26.435174
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6146f25a0ac7"
down_revision = "8263aeba1cc6"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/6146f25a0ac7_.py | .py | 75e56b70e04d8e9c | 7.15 | 1 |
"""empty message
Revision ID: 62a26de10677
Revises: 68bd08372eac
Create Date: 2022-09-05 21:10:04.369582
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "62a26de10677"
down_revision = "68bd08372eac"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/62a26de10677_.py | .py | 773713b212400700 | 7.15 | 1 |
"""empty message
Revision ID: 63ba10a926db
Revises: dda03817eaa7
Create Date: 2022-08-08 22:49:46.964807
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "63ba10a926db"
down_revision = "dda03817eaa7"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/63ba10a926db_.py | .py | 4327c8e45d0259a4 | 7.15 | 1 |
"""Add share_token to assignment
Revision ID: 6562a313095a
Revises: abc5ce433382
Create Date: 2025-01-12 12:25:55.519401
"""
from alembic import op
import sqlalchemy as sa
import secrets
from sqlalchemy.sql import table, column
# revision identifiers, used by Alembic.
revision = '6562a313095a'
down_revision = 'abc5... | Dosenpfand/matheworkout | migrations/versions/6562a313095a_add_share_token_to_assignment.py | .py | 1ec7f3d74b0f82b8 | 7.15 | 1 |
"""empty message
Revision ID: 68bd08372eac
Revises: 6146f25a0ac7
Create Date: 2022-09-04 11:22:54.920502
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "68bd08372eac"
down_revision = "6146f25a0ac7"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/68bd08372eac_.py | .py | 6cb94637ea65dbf9 | 7.15 | 1 |
"""Add video columns to question
Revision ID: 6a107dd0ac49
Revises: 57347e33eb87
Create Date: 2022-05-05 08:59:06.194423
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6a107dd0ac49"
down_revision = "57347e33eb87"
branch_labels = None
depends_on = None
def u... | Dosenpfand/matheworkout | migrations/versions/6a107dd0ac49_add_video_columns_to_question.py | .py | a115a855f15d7965 | 7.15 | 1 |
"""empty message
Revision ID: 6d83a483455a
Revises: 63ba10a926db
Create Date: 2022-08-10 13:03:59.159806
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6d83a483455a"
down_revision = "63ba10a926db"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/6d83a483455a_.py | .py | 0fb385a55a4c5d90 | 7.15 | 1 |
"""empty message
Revision ID: 6d86b42bc14a
Revises: 62a26de10677
Create Date: 2023-03-11 15:23:51.486541
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6d86b42bc14a"
down_revision = "62a26de10677"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/matheworkout | migrations/versions/6d86b42bc14a_.py | .py | 4af9c84f9cf6e4b9 | 7.15 | 1 |
import json
import os
import time
from itertools import chain
from typing import Any
from synapseclient import File
from airflow.decorators import task
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
from airflow.providers.amazon.aws.hooks.rds import RdsHook
from airflow.providers.amazon.aws.hooks.... | Sage-Bionetworks-Workflows/orca-recipes | archived_dags/dag_content/tower_metrics_content.py | .py | de4e36e43748fb49 | 7.24 | 2 |
"""Launches the Agora Nextflow pipeline (nf-agora) on Nextflow Tower, monitors the
workflow until it reaches a terminal state, and notifies collaborators of the
outcome via Slack and email.
Steps:
1. `launch_agora_on_tower`: Launches the pipeline on Nextflow Tower with the
configured params (pipeline, revision, pro... | Sage-Bionetworks-Workflows/orca-recipes | dags/agora_nf.py | .py | 3a73e22cbb55b2e6 | 7.24 | 2 |
"""ALS Knowledge Portal Dataset Collection DAG
This DAG automates the process of creating and maintaining a Synapse Dataset Collection
for the ALS Knowledge Portal. The DAG follows these steps:
1. Fetch data from the C-Path API using an authentication token stored in Airflow Variables
2. Transform the raw data using ... | Sage-Bionetworks-Workflows/orca-recipes | dags/als-kp-dataset-dag.py | .py | 202a5ee6582d2625 | 7.24 | 2 |
"""Shared helpers for sending Synapse message alerts from any DAG.
Synapse delivers messages as email, so this is a dependency-free way for a DAG to
alert people (no SMTP setup required). The main entry points are:
- send_synapse_message - sends a custom message via email to Synapse users.
- synapse_failure_callback ... | Sage-Bionetworks-Workflows/orca-recipes | dags/src/synapse_alerts.py | .py | 183a2de1a0345128 | 7.24 | 2 |
"""Utility functions for various components of the Airflow DAGs."""
import logging
from typing import Optional
from airflow.exceptions import AirflowNotFoundException
from airflow.hooks.base import BaseHook
from airflow.models import Variable
DEFAULT_LOGGER_PREFIX = "sage_airflow"
def get_logger(name: Optional[str... | Sage-Bionetworks-Workflows/orca-recipes | dags/src/utils.py | .py | 112c7322a5aae237 | 7.24 | 2 |
"""This script is used to execute a query on Snowflake and report the results to a
Synapse table. This retrieves data describing the total amount of data hosted in Synapse at the time of execution,
the number of active users in a month, and the number of downloads in a month."""
from dataclasses import dataclass
from... | Sage-Bionetworks-Workflows/orca-recipes | dags/synapse-by-the-numbers-dag.py | .py | 0f9e759bc0cd3c13 | 7.24 | 2 |
"""This script executes a query on Snowflake to retrieve data about project and dataset entities created in the past 7 days and stores the results in a Synapse table.
It is scheduled to run every Monday at 00:00 UTC.
A Note on the `backfill` functionality:
In addition to the fact that this DAG pulls data from the day ... | Sage-Bionetworks-Workflows/orca-recipes | dags/synapse-datasets-created-7-days.py | .py | 205ca8c1e7e205aa | 7.24 | 2 |
"""
This script is used to execute a query on Snowflake and report the results to a
Synapse table. This DAG updates the Trending Projects Snapshots Synapse table
(https://www.synapse.org/Synapse:syn61597055/tables/) every X number of days with the following metrics:
- Top 10 Projects (excluding the Synapse Homepage P... | Sage-Bionetworks-Workflows/orca-recipes | dags/trending-projects-snapshot-dag.py | .py | b3051bcab0a14276 | 7.24 | 2 |
#!/usr/bin/env python3
import sys
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.models import LaunchInfo
from utils import monitor_run, configure_logging
def nextflow_execute_workflow(run_name: str, s3_file: str, cwl_file: str):
"""Launches nf-synstage workflow in Ne... | Sage-Bionetworks-Workflows/orca-recipes | local/iatlas/immune_subtype_classifier/nf_launch.py | .py | 5bf901630bd23d03 | 7.24 | 2 |
#!/usr/bin/env python3
import sys
from typing import List
import pandas as pd
import synapseclient
from synapseclient import File
def syn_login():
syn = synapseclient.Synapse()
syn.login()
return syn
def download_data_files(parent: str, syn: synapseclient.Synapse):
"""downloads all TSV files in pa... | Sage-Bionetworks-Workflows/orca-recipes | local/iatlas/immune_subtype_classifier/prepare_data_sheet.py | .py | b77bb61004c72f4e | 7.24 | 2 |
from orca.services.nextflowtower import NextflowTowerOps
def monitor_run(ops: NextflowTowerOps, run_id: str):
"""Wait until workflow run completes."""
from time import sleep
workflow = ops.get_workflow(run_id)
print(f"Starting to monitor workflow: {workflow.run_name} ({run_id})")
status, is_done... | Sage-Bionetworks-Workflows/orca-recipes | local/iatlas/immune_subtype_classifier/utils.py | .py | 51a6aac14a5b6fb7 | 7.24 | 2 |
#!/usr/bin/env python3
"""
LENS workflow metaflow DAG.
Takes two parameters:
dataset_id: Synapse ID of dataset file to be processed.
s3_prefix: S3 prefix for parent S3 bucket where workflow files will be stored.
Example usage:
```
python3 local/iatlas/lens/lens.py run \
--dataset_id syn58366876... | Sage-Bionetworks-Workflows/orca-recipes | local/iatlas/lens/lens.py | .py | 7be78c8aae052274 | 7.24 | 2 |
import asyncio
from typing import List
import pandas as pd
from metaflow import FlowSpec, Parameter, step
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.models import WorkflowTask
class LogsFlow(FlowSpec):
"""Retrieve execution logs and failure reasons for all
fail... | Sage-Bionetworks-Workflows/orca-recipes | local/mc2/check_nf_logs.py | .py | 3d5c4b02ce980933 | 7.24 | 2 |
import asyncio
import logging
from orca.services.nextflowtower import NextflowTowerOps
logger = logging.getLogger(__name__)
async def monitor_run(ops: NextflowTowerOps, run_id: str):
"""Wait until workflow run completes."""
workflow = ops.get_workflow(run_id)
wf_repr = f"{workflow.run_name} ({run_id})"
... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/utils.py | .py | 84160c24a21b80ff | 7.24 | 2 |
#!/usr/bin/env python3
import asyncio
from dataclasses import dataclass
from pathlib import Path
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.models import LaunchInfo
from utils import monitor_run
async def main():
ops = NextflowTowerOps()
datasets = generate_da... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-358.py | .py | dbeb67b8968b330f | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-390
This workflow was created to run the `nf-core/rnaseq` pipeline for GRCh38 RNASeq data.
"""
import asyncio
import boto3
from synapseclient import Synapse
from dataclasses import dataclass
from pathlib import Path
from orca.services.nextflowtower import NextflowT... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-390-rnaseq-human.py | .py | 49393d89dd8f0f98 | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-523
This workflow was created to run the `nf-core/sarek` pipeline for GRCh38 Whole Genome Sequencing data.
"""
import asyncio
from dataclasses import dataclass
import boto3
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.mod... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-523-sarek-bbsplit.py | .py | 83a9ecd55c77da70 | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-553
This workflow was created to run the `nf-core/sarek` pipeline for GRCh38 Whole Genome Sequencing data.
"""
import asyncio
from dataclasses import dataclass
import boto3
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.mod... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-553-sarek.py | .py | dceedb2320ef7f1a | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-555
This workflow was created to run the `nf-core/sarek` pipeline for GRCh38 Whole Genome Sequencing data.
"""
import asyncio
from dataclasses import dataclass
import boto3
from orca.services.nextflowtower import NextflowTowerOps
from orca.services.nextflowtower.mod... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-555-sarek-human.py | .py | c5f77eba3e556277 | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-560
This workflow was created to run the `nf-core/rnaseq` pipeline for GRCh38 RNASeq data.
"""
import asyncio
import boto3
from synapseclient import Synapse
from dataclasses import dataclass
from pathlib import Path
from orca.services.nextflowtower import NextflowT... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-560-rnaseq-human.py | .py | 2013817b18147c29 | 7.24 | 2 |
"""https://sagebionetworks.jira.com/browse/WORKFLOWS-390
This workflow was created to run the `nf-core/scrnaseq` pipeline for GRCh38 RNASeq data.
To note: In workflows-390 it was found the initial dataset was rnaseq, not single-cell. This
workflow should still work for single-cell data.
"""
import os
import re
import ... | Sage-Bionetworks-Workflows/orca-recipes | local/ntap/workflows-scrnaseq-human.py | .py | d0a7add4780c5410 | 7.24 | 2 |
"""DataCite DOI fetching and storage utilities.
This module provides functionality for retrieving DOI (Digital Object Identifier)
metadata from the DataCite REST API and saving it to compressed NDJSON files.
It handles pagination, retry logic, and efficient streaming to minimize memory usage.
Primary Entrypoint:
... | Sage-Bionetworks-Workflows/orca-recipes | src/datacite/datacite.py | .py | 2e80566e2243fb5a | 7.24 | 2 |
import argparse
import os
import re
from datetime import datetime, timezone
from typing import NamedTuple
import pandas as pd
import synapseclient
import yaml
from snowflake.connector.pandas_tools import write_pandas
from snowflake_utils import get_connection, logger
CLINICAL_SCHEMA = "BPC_CLINICAL_FILES"
CBIOPORTAL... | Sage-Bionetworks-Workflows/orca-recipes | src/genie/genie_bpc_ingestion.py | .py | 3e2c67c05422b79d | 7.24 | 2 |
#!/usr/bin/env python
"""
ELT pipeline for sponsored project clinical data.
Reads YAML config for cohorts, fetches Synapse files, and writes to Snowflake.
"""
import argparse
from datetime import datetime, timezone
import os
import yaml
import pandas as pd
import synapseclient
from snowflake_utils import get_connect... | Sage-Bionetworks-Workflows/orca-recipes | src/genie/genie_sp_ingestion.py | .py | ac21bf31547521dd | 7.24 | 2 |
"""MAIN GENIE ingestion pipeline"""
import argparse
import re
from datetime import datetime, timezone
from typing import Dict, NamedTuple
import pandas as pd
from snowflake.connector.pandas_tools import write_pandas
import synapseclient
import synapseutils as synu
from snowflake_utils import get_connection, logger
... | Sage-Bionetworks-Workflows/orca-recipes | src/genie/main_genie_ingestion.py | .py | fb1b96e2fde1b143 | 7.24 | 2 |
# Pathfinding
import heapq
import itertools
uniqueId = itertools.count()
def aStar(graph, start, goal, h, neighborsOf, IMPASSABLE):
"""
Returns the lowest cost path in a graph from the start to the goal.
If the returned path is empty, then there is no path.
Args:
graph (list): ... | jambolo/python | src/pathfinding.py | .py | 0212b024b4d9f21a | 7 | 0 |
# Licensed under the MIT License
# https://github.com/craigahobbs/schema-markdown/blob/main/LICENSE
"""
Encoding and decoding utilities
"""
from datetime import date, datetime, timezone
from decimal import Decimal
import json
from urllib.parse import quote, unquote
from uuid import UUID
class JSONEncoder(json.JSONE... | craigahobbs/schema-markdown | src/schema_markdown/encode.py | .py | 44e215947965df52 | 7.39 | 5 |
# Licensed under the MIT License
# https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE
"""
MarkdownUp backend API support
"""
from functools import partial
import os
from pathlib import PurePosixPath
import bare_script
from bare_script.include import schema_parse, schema_type_model_validate
from bare_scr... | craigahobbs/markdown-up-py | src/markdown_up/api.py | .py | 16a093ce0e6ec129 | 7 | 0 |
# Licensed under the MIT License
# https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE
"""
The MarkdownUp backend command-line application
"""
import argparse
from functools import partial
import json
import os
import sys
import threading
import webbrowser
from bare_script.include import schema_parse, sc... | craigahobbs/markdown-up-py | src/markdown_up/main.py | .py | a8647a61ee900e9b | 7 | 0 |
"""Validated SQL Server backup and verification command generation."""
import re
from dataclasses import dataclass
_IDENTIFIER = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
@dataclass(frozen=True, slots=True)
class BackupRequest:
database: str
server_path: str
compression: bool = True
checksum: bool = T... | F1-SQL/f1-sql-core | src/f1sql/backup.py | .py | 64fbd2c0490ab210 | 7.24 | 2 |
"""Content-addressed storage for immutable raw source responses."""
from dataclasses import dataclass
from pathlib import Path
from .fingerprint import sha256_bytes
@dataclass(frozen=True, slots=True)
class StoredArtifact:
digest: str
path: Path
size_bytes: int
class ArtifactStore:
"""Store bytes ... | F1-SQL/f1-sql-core | src/f1sql/cache.py | .py | 527255b3b84b132e | 7.24 | 2 |
"""Small, source-neutral contracts shared by every pipeline stage."""
from dataclasses import dataclass
from enum import StrEnum
class PipelineStage(StrEnum):
"""Stages are deliberately finite so manifests can be audited."""
DISCOVER = "discover"
INGEST = "ingest"
NORMALIZE = "normalize"
LOAD = ... | F1-SQL/f1-sql-core | src/f1sql/contracts.py | .py | 314ec8f6df48443a | 7.24 | 2 |
"""Deterministic serialization and content fingerprints."""
import hashlib
import json
from typing import Any
def canonical_json(value: Any) -> str:
"""Serialize JSON-compatible values with stable ordering and separators."""
return json.dumps(
value, ensure_ascii=False, sort_keys=True, separators=("... | F1-SQL/f1-sql-core | src/f1sql/fingerprint.py | .py | a4449de78f4e73a2 | 7.24 | 2 |
"""SQL Server execution boundary for deterministic load plans.
The adapter deliberately depends on a tiny DB-API-like protocol so tests can
exercise transaction behaviour without requiring a live SQL Server instance.
"""
import re
from collections.abc import Callable, Mapping, Sequence
from typing import Any, Protoco... | F1-SQL/f1-sql-core | src/f1sql/sqlserver.py | .py | 866891779d2239a5 | 7.24 | 2 |
from __future__ import with_statement
import logging
from logging.config import fileConfig
from flask import current_app
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python... | Dosenpfand/zug-lol | migrations/env.py | .py | caf91c58bb7fab49 | 7.3 | 3 |
"""empty message
Revision ID: 4dc24a017e3e
Revises: 8ffa33cf23ae
Create Date: 2022-08-29 15:18:21.225770
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4dc24a017e3e"
down_revision = "8ffa33cf23ae"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/zug-lol | migrations/versions/4dc24a017e3e_.py | .py | 57c5907b66772ffb | 7.3 | 3 |
"""empty message
Revision ID: 5c38b4252e9a
Revises: 4dc24a017e3e
Create Date: 2022-11-02 20:18:52.593092
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5c38b4252e9a"
down_revision = "4dc24a017e3e"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/zug-lol | migrations/versions/5c38b4252e9a_.py | .py | 021765ab1bb95f0e | 7.3 | 3 |
"""empty message
Revision ID: 8f1f7de63334
Revises: 5c38b4252e9a
Create Date: 2022-11-02 22:46:46.827432
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8f1f7de63334"
down_revision = "5c38b4252e9a"
branch_labels = None
depends_on = None
def upgrade():
# ... | Dosenpfand/zug-lol | migrations/versions/8f1f7de63334_.py | .py | eb80f65f38e790b5 | 7.3 | 3 |
"""Revert test migration
Revision ID: 8ffa33cf23ae
Revises: d211c9345492
Create Date: 2022-06-23 15:41:00.429393
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8ffa33cf23ae"
down_revision = "d211c9345492"
branch_labels = None
depends_on = None
def upgrade()... | Dosenpfand/zug-lol | migrations/versions/8ffa33cf23ae_revert_test_migration.py | .py | a50cba99bd564bdd | 7.8 | 3 |
"""Test migration
Revision ID: d211c9345492
Revises:
Create Date: 2022-06-23 15:39:46.447630
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "d211c9345492"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto gene... | Dosenpfand/zug-lol | migrations/versions/d211c9345492_test_migration.py | .py | 25116b4d0fccb764 | 7.8 | 3 |
"""Model complexity and selection rules that take it into account.
Complexity has no single definition across estimator families. Here it is
treated as two distinct quantities, deliberately not merged into one index:
- **effective parameters**: how many numbers the model stored after fitting.
Interpretable and dete... | attilalr/nested-cv-analysis | nested_cv_analysis/analysis.py | .py | fda42a2c58bb647a | 7 | 0 |
"""Construction of the pipeline evaluated inside each fold.
This module is the heart of the package. Everything else in
`nested_cv_analysis` evaluates the object returned by :func:`build_pipeline` —
never a bare estimator alongside hand-applied transformations. That choice is
what makes leakage *inexpressible*: becaus... | attilalr/nested-cv-analysis | nested_cv_analysis/pipeline.py | .py | 9a47ee02e269098b | 7 | 0 |
"""Thin wrappers over scikit-learn that accept per-fold transformations.
Each function here builds the pipeline and delegates to scikit-learn. The
delegation is deliberate: `groups`, `error_score`, `params`, multi-metric
scoring, `n_jobs` and `return_train_score` keep working exactly as upstream,
with no reimplementat... | attilalr/nested-cv-analysis | nested_cv_analysis/validation.py | .py | 80697e7b06783df0 | 7 | 0 |
import numpy as np
import pytest
from sklearn.base import BaseEstimator
@pytest.fixture
def clf_data():
"""Separable, balanced classification data."""
from sklearn.datasets import make_classification
return make_classification(
n_samples=120, n_features=8, n_informative=4, n_redundant=0,
... | attilalr/nested-cv-analysis | tests/conftest.py | .py | 62b1d2ac7ad89f68 | 7.5 | 0 |
"""The package's reason to exist: nothing fitted on training data may touch the test.
Each test here compares the correct path against the leaky path, and requires
the two to disagree in the expected direction.
"""
import numpy as np
import pytest
from sklearn.feature_selection import SelectKBest, f_classif
from sklea... | attilalr/nested-cv-analysis | tests/test_leakage.py | .py | 36875dd424e7e3fe | 7.5 | 0 |
"""Without transformations, the package must be indistinguishable from sklearn."""
import numpy as np
import pandas as pd
import pytest
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import KFold, StratifiedKFold
from sklearn.model_se... | attilalr/nested-cv-analysis | tests/test_validation.py | .py | 2ba8fa73881c668c | 7.5 | 0 |
"""Add per_world_pattern table
Revision ID: 33506baa6a28
Revises:
Create Date: 2025-09-07 21:56:52.730654
"""
from typing import Sequence
import sqlalchemy as sa
from alembic import op
import HexBug.db.types
# revision identifiers, used by Alembic.
revision: str = "33506baa6a28"
down_revision: str | Sequence[str]... | object-Object/HexBug | alembic/versions/33506baa6a28_add_per_world_pattern_table.py | .py | 2e841bfd6ac78c32 | 7.35 | 4 |
"""Add unique constraint to per_world_pattern.signature
Revision ID: 3c2581c7e1e3
Revises: 33506baa6a28
Create Date: 2025-09-09 22:36:52.737480
"""
from typing import Sequence
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "3c2581c7e1e3"
down_revision: str | Sequence[str] | None = ... | object-Object/HexBug | alembic/versions/3c2581c7e1e3_add_unique_constraint_to_per_world_.py | .py | 3a24e32961784468 | 7.35 | 4 |
"""Fix per_world_pattern.signature unique constraint to be per-guild instead of global
Revision ID: b83e6ea86a3e
Revises: 3c2581c7e1e3
Create Date: 2025-09-09 23:09:26.393963
"""
from typing import Sequence
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "b83e6ea86a3e"
down_revision... | object-Object/HexBug | alembic/versions/b83e6ea86a3e_fix_per_world_pattern_signature_unique_.py | .py | 3ab3efd5690c50d5 | 7.35 | 4 |
"""Add table for /info usage tracking
Revision ID: edf289098923
Revises: b83e6ea86a3e
Create Date: 2025-09-27 20:22:02.383880
"""
from typing import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "edf289098923"
down_revision: str | Sequence[str] | N... | object-Object/HexBug | alembic/versions/edf289098923_add_table_for_info_usage_tracking.py | .py | fe9bb352f82dd80a | 7.35 | 4 |
# pyright: reportUntypedFunctionDecorator=none, reportFunctionMemberAccess=none
import logging
from discord.ext import commands
from HexBug.core.bot import COGS_MODULE, HexBugContext
from HexBug.core.cog import HexBugCog
from HexBug.utils.collections import partition
from HexBug.utils.discord.commands import paginat... | object-Object/HexBug | bot/src/HexBug/cogs/msg_commands/extensions.py | .py | 6b5868b504256930 | 7.35 | 4 |
# pyright: reportUntypedFunctionDecorator=none, reportFunctionMemberAccess=none
from discord.ext import commands
from HexBug.core.bot import HexBugContext
from HexBug.core.cog import HexBugCog
from HexBug.ui.views.sync import SyncView
class SyncCog(HexBugCog):
"""Owner-only message commands for syncing slash co... | object-Object/HexBug | bot/src/HexBug/cogs/msg_commands/sync.py | .py | 1f1b4a1800e78566 | 7.35 | 4 |
import logging
import sys
from dataclasses import dataclass
from typing import Any, Self, cast
from discord.app_commands import Group
from discord.ext.commands import Cog, CogMeta, GroupCog
from .bot import HexBugBot
logger = logging.getLogger(__name__)
class HexBugCogMeta(CogMeta):
def __new__(cls, *args: Any... | object-Object/HexBug | bot/src/HexBug/core/cog.py | .py | 3d7e258cc6132716 | 7.35 | 4 |
from typing import Any, Self, overload
from discord.app_commands import AppCommandError
from discord.utils import MISSING
from HexBug.utils.discord.embeds import EmbedField
class SilentError(AppCommandError):
"""Base class for exceptions that should be silently caught and ignored."""
class InvalidInputError(A... | object-Object/HexBug | bot/src/HexBug/core/exceptions.py | .py | aef4ba6172e6a5b4 | 7.35 | 4 |
"""
See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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... | Ensembl/ensembl-web-tools-api | app/core/logging.py | .py | 8f4db5132f7a4755 | 7 | 0 |
""" Module for loading a VCF and parsing it into a VepResultsResponse
object as defined in APISpecification"""
from io import StringIO
import subprocess
from pydantic import FilePath
import vcfpy
from vep.models import vcf_results_model as model
TARGET_COLUMNS = [
"Allele",
"AF",
"Consequence",
"Featu... | Ensembl/ensembl-web-tools-api | app/vep/utils/vcf_results.py | .py | 8fe912a542dfa45b | 7 | 0 |
from .apis.apis import api_build
from buildz.base import Base
from buildz import xf, fz, dz
from buildz import log as logz
from .struct import *
from . import tlx
class SimpleAgent(Base):
'''
封装对openai和ollama接口的调用,封装成一样的接口
'''
@staticmethod
def build_conf(conf, log=None, tools=None):
... | buildCodeZ/buildz | aiclient/buildz/aiclient/agent.py | .py | 41b6db834c8657bb | 7 | 0 |
from buildz.base import Base
from buildz import log as logz, dz, xf
import openai
import ollama
import json
from os.path import dirname, join
from . import tlx
from typing import List, Dict, Any, Optional
dp = dirname(__file__)
global_conf = xf.loadf(join(dp, "argx.js"))
def simple_out(obj):
return obj.out()
cla... | buildCodeZ/buildz | aiclient/buildz/aiclient/apix.py | .py | a60b6c686d3f7166 | 7 | 0 |
from typing import List, Dict, Any, Optional
from buildz.base import Base
from buildz import log as logz, dz, xf
import json
class ToolCall(Base):
'''
工具调用对象转化的结构化对象,解析其他库调用模型后获取的工具调用对象,转换成本工具调用对象,方便不同模型库的调用处理
'''
def str(self):
rst = dz.mapsnn(id=self.id, fn=self.fn, args=self.args, type=... | buildCodeZ/buildz | aiclient/buildz/aiclient/structs/toolcall.py | .py | d90e36e216bd4713 | 7 | 0 |
#!/usr/bin/env -S uv run --script --with click,pillow,b2sdk
"""
upload a file to backblaze and return its public (unlisted) url.
by default any file is uploaded as-is under files/, with a timestamp
prefix to avoid collisions. pass --screenshot to instead resize an
image to a large thumbnail, convert it to JPEG, and u... | kleutzinger/dotfiles | scripts/backblaze-upload.py | .py | 76edff7bf533f56a | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "click",
# "requests",
# ]
# ///
"""
Downloads a YouTube video's audio (as mp3, with embedded thumbnail) via
yt-dlp, then uploads it as a soundbite source to bag.kevbot.xyz,
authenticated via API key.
usage:
b... | kleutzinger/dotfiles | scripts/bag-soundbite-upload.py | .py | eaa160841f43b6c5 | 7.3 | 3 |
#!/usr/bin/env python3
"""
Clone from github, except it'll use my personal account credentials instead
this lets me commit / push stuff as my personal acct when i'm on my work computer.
USAGE:
```
python clone_personal.py # clone inside some git folder
python clone_personal.py 'https://github.com/kleutzinger/url-short... | kleutzinger/dotfiles | scripts/clone_personal.py | .py | 1497768dfaa816f6 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "pocketbase",
# "diskcache",
# "click",
# "shortuuid",
# ]
# ///
import json
import os
import sys
import subprocess
from datetime import datetime, timezone
from pathlib import Path
from typing import Dict, L... | kleutzinger/dotfiles | scripts/coconut.py | .py | a80cb5ab3d25b987 | 7.3 | 3 |
import subprocess
import requests
from typing import Any, Callable, Iterable, Optional, TypeVar
import os
import sys
import asyncio
from pprint import pprint
T = TypeVar("T")
def identity(x: T) -> T:
"return the input unchanged"
return x
def fzf_iterable(iterable: Iterable) -> str:
"""
Given an it... | kleutzinger/dotfiles | scripts/common.py | .py | 13e64126c2ef60cc | 7.3 | 3 |
#!/usr/bin/env python
# https://rtpg.co/2020/12/11/dbg-in-python.html
def dbg(result):
"""
Recover the expression giving the result, and then
print a helpful debug statement showing this
"""
import inspect
frame = inspect.stack()[1]
expr = extract_dbg(frame.code_context[0])
filename = ... | kleutzinger/dotfiles | scripts/functions.py | .py | 015d969318c2e646 | 7.3 | 3 |
#!/usr/bin/env python3
"""
[x] cli
[x] extract image 5 seconds in
[x] display image
[x] get image points
[x] click cli
[] connect image
"""
import os
import random
from vodhelper import extract_vid_frame_to_file, get_vod_duration_ms
# python -m pip install opencv-python
import cv2 as cv
import numpy as np
from typing... | kleutzinger/dotfiles | scripts/get_img_coords.py | .py | dcebfeb9c05da8a4 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "pillow",
# ]
# ///
"""
When collaborating with someone over screenshare, the remote person
may want to "point" somewhere at your screen. We give them a grid
to announce the relevant area coordinate-labeled cells.
This... | kleutzinger/dotfiles | scripts/grid_overlay.py | .py | bd6e51c0c723ee34 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script --with click
import http.server
import socketserver
import click
import webbrowser
import time
import threading
class quietServer(http.server.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
pass
@click.command()
@click.argument("port", type=int, default... | kleutzinger/dotfiles | scripts/http-server-silent.py | .py | 3afda50642bee98f | 7.3 | 3 |
#!/usr/bin/env -S uv run --with pywebview,PyGObject
# get arguments from the command line
import sys
import subprocess
import platform
import webview
def desktop_notify(
message: str, title: str = "Notification"
) -> None:
"""Send a desktop notification."""
try:
if platform.system() == "Linux":
... | kleutzinger/dotfiles | scripts/image_selector2.py | .py | 18cdcfcec2ac1656 | 7.3 | 3 |
#!/usr/bin/env python3
"""
this file tests that my computer is in a good state
"""
import os
import psutil
import urllib.request
from subprocess import check_output, run
import shutil
def test_disk_space_not_nearly_full():
free_space = psutil.disk_usage(".")
error_msg = f"Disk space is nearly full: {free_spa... | kleutzinger/dotfiles | scripts/kevtests/test_stuff.py | .py | dc387d10b5ad464a | 7.8 | 3 |
#!/usr/bin/env python3
"""invoke magic spells from magic words inside a file
magic words are defined thusly: (must be all caps)
#__MAGICWORD__# echo 'followed by a shell command'
put something of that format inside a file to set up running that command
additionally, #__file__# will be substituted with the path of t... | kleutzinger/dotfiles | scripts/magic.py | .py | fa84d70de7d97777 | 7.3 | 3 |
# #__JUKEBOX__# /home/kevin/.virtualenvs/++scripts+music-history/bin/python3 #__file__# jukebox
# read sqlite db at music_history.db and parse the data
# https://dfir.pubpub.org/pub/xbvsrjt5/release/1
import os
import sqlite3
import subprocess
import webbrowser
from collections.abc import MutableMapping
from typing im... | kleutzinger/dotfiles | scripts/music-history/main.py | .py | af1d72b399e53cac | 7.3 | 3 |
#!/usr/bin/python3
"""
porting note.sh to python.
USAGE:
./note.py
python note.py
ARGS:
e # (edit) edit this python script
m # (movie) append MOVIE_TEMPLATE to todays note before opening
p # (print) print absolute filepath to today's note
i # (interactive) choose a note from many pre... | kleutzinger/dotfiles | scripts/note.py | .py | 24c4d17aeddb2ace | 7.3 | 3 |
#!/usr/bin/env python
"""
Simple HTTP URL redirector
Shreyas Cholia 10/01/2015
usage: redirect.py [-h] [--port PORT] [--ip IP] redirect_url
HTTP redirect server
positional arguments:
redirect_url
optional arguments:
-h, --help show this help message and exit
--port PORT, -p PORT port to listen on
--... | kleutzinger/dotfiles | scripts/redirect.py | .py | dfb7cb492d7014e4 | 7.3 | 3 |
#!/usr/bin/env python3
"""
# rutorrent.py
This scripts takes a magnet link and initiates a download on your rutorrent
instance via a post request.
## Usage
you have three ways to provide a magnet link to this script, in order of
precedence
1. cli argument
python rutorrent.py '<magnet_link>'
2. clipb... | kleutzinger/dotfiles | scripts/rutorrent.py | .py | a48222f75075ca31 | 7.3 | 3 |
#!/usr/bin/env python3
import json
import os
import subprocess
import tempfile
import shutil
from pprint import pprint
import click
"""
gets files and puts them into the equivalent location in the receiver's home
two commands:
1. sendfiles.py send <file0> <file1> ... <fileN>
2. sendfiles.py rec <code>
use croc
"""
... | kleutzinger/dotfiles | scripts/sendfiles.py | .py | 645fb113c0451a0b | 7.3 | 3 |
#!/usr/bin/env -S uv run --script --with pyperclip
"""
Get bracket table from clipboard and convert it to timestamps for youtube description.
"""
import re
import pyperclip
from datetime import timedelta
input_data = pyperclip.paste()
def rm_empty_lines(text):
return "\n".join(line.strip() for line in text.spli... | kleutzinger/dotfiles | scripts/table2timestamps.py | .py | ba5f496ab67c7644 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "click",
# "trilium_py",
# ]
# ///
from trilium_py.client import ETAPI
import click
import os
import sys
import json
TRILIUM_TOKEN = os.getenv("TRILIUM_TOKEN")
RADIO_NOTE_ID = "m6NTBP3tMMRV"
if not TRILIUM_TOKEN:... | kleutzinger/dotfiles | scripts/tril.py | .py | 19b15ae3c2d85cdc | 7.3 | 3 |
#!/usr/bin/env python3
"""
finds all <script> tags in the HTML files and replaces the src and href attributes with the local file path and downloads the file to a ./static folder
"""
import os
import urllib.request
from bs4 import BeautifulSoup
def process_html_file(file, static_dir="static"):
replacements = No... | kleutzinger/dotfiles | scripts/unCDNify.py | .py | e288ec3e5c041967 | 7.3 | 3 |
"""cli entry point for livingdocs.
Parse command line arguments, invoke proper methods.
"""
import argparse
import logging
import sys
from . import __version__
def main(args=None):
"""Entry point for aidee-living-docs cli.
The .toml entry_point wraps this in sys.exit already so this effectively
become... | aidee-health/aidee-living-docs | src/livingdocs/cli.py | .py | 7af08ef205b5eb29 | 7 | 0 |
"""Implement Formatter functionality for Behave."""
import time
from itertools import chain
from behave.formatter.base import Formatter
from behave.model import Feature
from behave.model import Scenario
from behave.model import Step
class CollectedStep:
"""A BDD Step."""
def __init__(
self,
... | aidee-health/aidee-living-docs | src/livingdocs/collecting_formatter.py | .py | 51ff36585bac817e | 7 | 0 |
"""Create Sphinx compatible feature page."""
import pathlib
import sys
from pathlib import Path # Import Path
from jinja2 import Environment
from jinja2 import FileSystemLoader
from .collecting_formatter import CollectedStep
from .feature_file import load_feature_file
from .feature_file import status_to_style
cur... | aidee-health/aidee-living-docs | src/livingdocs/create_sphinx_feature_file_page.py | .py | ad295e80a51d5b4c | 7 | 0 |
"""Create traceability. Link scenarios with status to user needs."""
import sys
from .collecting_formatter import CollectedScenario
from .feature_file import load_all_feature_files_in_directory
from .feature_file import status_to_style
from .template import convert_template
from .userneeds import load_userneeds_from_... | aidee-health/aidee-living-docs | src/livingdocs/create_trace_page.py | .py | 39eca233f255a144 | 7 | 0 |
"""Module for creating a BDD feature file."""
import json
import sys # Import sys
from pathlib import Path # Import Path
from .collecting_formatter import CollectedFeature
def load_feature_file(feature_path: str):
"""Load a BDD feature file."""
if not Path(feature_path).exists():
print("Unable to ... | aidee-health/aidee-living-docs | src/livingdocs/feature_file.py | .py | 033dc5c59ecaeaf1 | 7 | 0 |
"""Behave JSONFormatter."""
import json
from pathlib import Path # Import Path
from .collecting_formatter import CollectingFormatter
class JSONFormatter(CollectingFormatter):
"""Main class used by Behave framework."""
def __init__(self, stream_opener, config):
super().__init__(stream_opener, confi... | aidee-health/aidee-living-docs | src/livingdocs/json_formatter.py | .py | b7eb7ed46391e52f | 7 | 0 |
'''
Author: BHM-Bob 2262029386@qq.com
Date: 2022-10-19 23:02:16
LastEditors: BHM-Bob
LastEditTime: 2022-10-19 23:02:24
Description:
'''
import glob
import imageio
def create_gif(image_list, gif_name, duration=0.35):
frames = []
for image_name in image_list:
frames.append(imageio.imrea... | BHM-Bob/BA_PY | examples/plot/gif.py | .py | 300b8a5919a70415 | 7.3 | 3 |
'''
Author: BHM-Bob 2262029386@qq.com
Date: 2022-11-04 12:33:19
LastEditors: BHM-Bob 2262029386@qq.com
LastEditTime: 2024-04-09 14:01:51
Description:
'''
import sys
sys.path.append(r'../../../')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import mbapy.plot as plot
plt.rcPa... | BHM-Bob/BA_PY | examples/plot/sci/dev.py | .py | 586dc5f3fd3a9bd4 | 7.3 | 3 |
import os
import re
from functools import lru_cache
from typing import Dict, List
import pandas as pd
if __name__ == '__main__':
from mbapy.file import opts_file
else:
from ..file import opts_file
formula_existence_cache = {}
FORMULA_EXISTENCE_CACHE_PATH = os.path.expanduser(f'~/.mbapy/cache/formula... | BHM-Bob/BA_PY | mbapy/chem/formula.py | .py | bb6265024aec83b7 | 7.3 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.