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
"""Test fixture for Restricted APIs DNS module with empty overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import ( EXPECTED_ALWAYS_DNS_ZONES, EXPECTED_OVERRIDES_DNS_ZONES, EXPECTED_RESTRICTED_A_RRS, EXPECTED_RESTRICTED_A...
memes/terraform-google-restricted-apis-dns
tests/test_explicit_overrides.py
.py
6a11600db0705955
7.5
0
"""Test fixture for Private APIs DNS module with empty overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import ( EXPECTED_ALWAYS_DNS_ZONES, EXPECTED_OVERRIDES_DNS_ZONES, EXPECTED_PRIVATE_A_RRS, EXPECTED_PRIVATE_AAAA_RRS, ...
memes/terraform-google-restricted-apis-dns
tests/test_explicit_overrides_private.py
.py
2b902a9e95f93e7e
7.5
0
"""Test fixture for Restricted APIs DNS with minimal required values.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_RESTRICTED_A_RRS, EXPECTED_RESTRICTED_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "minima...
memes/terraform-google-restricted-apis-dns
tests/test_minimal.py
.py
793305333c49d4a7
7.5
0
"""Test fixture for Private APIs DNS with minimal required values.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_PRIVATE_A_RRS, EXPECTED_PRIVATE_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "minimal-private...
memes/terraform-google-restricted-apis-dns
tests/test_minimal_private.py
.py
09a743e25c2c78d9
7.5
0
"""Test fixture for Restricted APIs DNS module with multiple VPC networks.""" import pathlib from collections.abc import Callable, Generator from typing import Any, cast import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_RESTRICTED_A_RRS, EXPECTED_RESTRICTED_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAM...
memes/terraform-google-restricted-apis-dns
tests/test_multi_net.py
.py
5dc98e16ec3f266a
7.5
0
"""Test fixture for Private APIs DNS module with multiple VPC networks.""" import pathlib from collections.abc import Callable, Generator from typing import Any, cast import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_PRIVATE_A_RRS, EXPECTED_PRIVATE_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "mult...
memes/terraform-google-restricted-apis-dns
tests/test_multi_net_private.py
.py
42a5730ec785f61f
7.5
0
"""Test fixture for Restricted APIs DNS module with empty overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_ALWAYS_DNS_ZONES as EXPECTED_DNS_ZONES from .conftest import EXPECTED_OVERRIDES_DNS_ZONES as UNEXPECTED_DNS_ZONES ...
memes/terraform-google-restricted-apis-dns
tests/test_no_overrides.py
.py
0f49e806ef250865
7.5
0
"""Test fixture for Private APIs DNS module with empty overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_ALWAYS_DNS_ZONES as EXPECTED_DNS_ZONES from .conftest import EXPECTED_OVERRIDES_DNS_ZONES as UNEXPECTED_DNS_ZONES fro...
memes/terraform-google-restricted-apis-dns
tests/test_no_overrides_private.py
.py
d4c06584e195331b
7.5
0
"""Test fixture for Restricted APIs DNS module with null labels value.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_RESTRICTED_A_RRS, EXPECTED_RESTRICTED_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "null-...
memes/terraform-google-restricted-apis-dns
tests/test_null_labels.py
.py
92ca6d122ce34c7d
7.5
0
"""Test fixture for Private APIs DNS module with null labels value.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_PRIVATE_A_RRS, EXPECTED_PRIVATE_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "null-labels-pr...
memes/terraform-google-restricted-apis-dns
tests/test_null_labels_private.py
.py
51eb94b6db10e123
7.5
0
"""Test fixture for Restricted APIs DNS module null value for overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_ALWAYS_DNS_ZONES as EXPECTED_DNS_ZONES from .conftest import EXPECTED_OVERRIDES_DNS_ZONES as UNEXPECTED_DNS_ZO...
memes/terraform-google-restricted-apis-dns
tests/test_null_overrides.py
.py
01e798471d1bd456
7.5
0
"""Test fixture for Private APIs DNS module null value for overrides.""" import pathlib from collections.abc import Callable, Generator from typing import Any import pytest from .conftest import EXPECTED_ALWAYS_DNS_ZONES as EXPECTED_DNS_ZONES from .conftest import EXPECTED_OVERRIDES_DNS_ZONES as UNEXPECTED_DNS_ZONES...
memes/terraform-google-restricted-apis-dns
tests/test_null_overrides_private.py
.py
ae6e679925d45abf
7.5
0
"""Test fixture for Restricted APIs DNS module with a single VPC network.""" import pathlib from collections.abc import Callable, Generator from typing import Any, cast import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_RESTRICTED_A_RRS, EXPECTED_RESTRICTED_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME...
memes/terraform-google-restricted-apis-dns
tests/test_single_net.py
.py
98ce7c5b97394004
7.5
0
"""Test fixture for Private APIs DNS module with a single VPC network.""" import pathlib from collections.abc import Callable, Generator from typing import Any, cast import pytest from .conftest import EXPECTED_DNS_ZONES, EXPECTED_PRIVATE_A_RRS, EXPECTED_PRIVATE_AAAA_RRS, run_tofu_in_workspace FIXTURE_NAME = "singl...
memes/terraform-google-restricted-apis-dns
tests/test_single_net_private.py
.py
72e9d0ab9951bcd7
7.5
0
from enum import Enum from typing import Union, Optional, List, Tuple, TypedDict, cast from .opencc_pyo3 import ( OpenCC as _OpenCC, ) class OpenccConfig(str, Enum): S2T = "s2t" T2S = "t2s" S2TW = "s2tw" TW2S = "tw2s" S2TWP = "s2twp" TW2SP = "tw2sp" S2HK = "s2hk" HK2S = "hk2s" ...
laisuk/opencc_pyo3
opencc_pyo3/__init__.py
.py
48f45375ba25b187
7.15
1
import ctypes import os import sys from pathlib import Path from typing import List, Set def _detect_platform_folder() -> str: is_64bit = sys.maxsize > 2 ** 32 if sys.platform.startswith(("win32", "cygwin")): arch = "x64" if is_64bit else "x86" return f"win-{arch}" elif sys.platform.star...
laisuk/opencc_pyo3
opencc_pyo3/pdfium_loader.py
.py
f09c8a68fdf5facd
7.15
1
from __future__ import annotations import os import platform import shutil import sys from pathlib import Path from typing import Optional ROOT = Path(os.path.abspath(__file__)).parents[1] SRC = ROOT / "pdfium" DST = ROOT / "opencc_pyo3" / "pdfium" # Decide what you support for packing into wheels KNOWN = { "li...
laisuk/opencc_pyo3
tools/sync_pdfium_for_wheel.py
.py
63bdcdece8385db7
7.15
1
""" Example: Download data from a connected Cass Logger and plot internal IMU data. This script demonstrates how to download binary files from a live device and visualize the on-board accelerometer channels. Workflow -------- 1. ``download_data`` — connects to a Cass Logger over serial, downloads all recorded ``.b...
mcharlesmorrison/cass_logger_dev
examples/download_and_plot_ex.py
.py
370644ffc6183862
7.35
4
""" Example: Load a pre-downloaded binary file and plot suspension potentiometer data. This script shows a simple example of how to load a ``.bin`` file that already exists on disk and visualize the fork and shock potentiometer channels. Workflow -------- 1. ``import_data`` — loads the pre-bundled ``.bin`` file from ...
mcharlesmorrison/cass_logger_dev
examples/load_and_plot_ex.py
.py
a4044967c11847fe
7.35
4
""" Example: Load a pre-downloaded binary file and plot I2C IMU data. Workflow -------- 1. ``import_data`` — loads the pre-bundled ``.bin`` file from the ``examples/data/`` directory and parses it into a DataFrame using ``CassCommands.process_data_file``. 2. ``plot_pot_data`` — Data columns used --------------...
mcharlesmorrison/cass_logger_dev
examples/load_and_plot_i2c_ex.py
.py
4103b4fbb28d7399
7.35
4
"""F001 F001 正文提取(ingest 域)。""" from __future__ import annotations import unittest from pathlib import Path import sys import tempfile import types from pathlib import Path from unittest import mock from tools.common import strip_sha256_prefix from tools.ingest.extractor import TextExtractor from wiki_fixtures impo...
KinChow/MyKnowledge
tests/ingest/test_extractor.py
.py
beebac10deefbb9e
7.5
0
"""F001 F001 URL 抓取策略(ingest 域)。""" from __future__ import annotations import unittest from pathlib import Path import gzip import tempfile from pathlib import Path from tools.ingest.fetcher import URLFetcher, _bounded_decompress from tools.ingest.source_ingestor import SourceIngestor class FetcherTests(unittest.T...
KinChow/MyKnowledge
tests/ingest/test_fetcher.py
.py
61d0fc5760e45ca1
7.5
0
"""F001 front matter 边界(共享基础设施)。""" from __future__ import annotations import unittest from pathlib import Path from tools.front_matter import FrontMatter class FrontMatterTests(unittest.TestCase): def test_front_matter_error_normalization(self): """坏 YAML → front_matter_invalid_yaml;空 front matter → {}...
KinChow/MyKnowledge
tests/test_front_matter.py
.py
3ace3623de8636ab
7.5
0
"""结构守卫:把 review 结论机器化,防止布局硬编码/已删除 API 回潮。 覆盖(来自 F001 二次 review 的 reuse 维度结论): - 布局路径必须收敛到 RepoPaths(paths.py),业务代码不得 self.root 直拼 - sha256_hex 已删除(并入 strip_sha256_prefix/hash_canonical) - extractor 的 stdlib-html fallback 已删除(trafilatura 是唯一 HTML 实现) """ from __future__ import annotations import re import unittest f...
KinChow/MyKnowledge
tests/test_layout.py
.py
674d1ec7377273a5
7.5
0
"""F002 引用解析与引文校验:对应 docs/acceptance/F002-wiki-contract.md 的 AC 条目。""" from __future__ import annotations import json import tempfile import unittest from pathlib import Path from tools.common import canonical_quote, sha256_text, strip_sha256_prefix from tools.front_matter import FrontMatter from tools.validation im...
KinChow/MyKnowledge
tests/validation/test_wiki_resolution.py
.py
b436b3b720363e97
7.5
0
"""F002 domain rule 层:状态组合/kind 分支/矩阵:对应 docs/acceptance/F002-wiki-contract.md 的 AC 条目。""" from __future__ import annotations import json import tempfile import unittest from pathlib import Path from tools.common import canonical_quote, sha256_text, strip_sha256_prefix from tools.front_matter import FrontMatter from...
KinChow/MyKnowledge
tests/validation/test_wiki_rules.py
.py
80a15de331fddaa2
7.5
0
"""F002 schema 层:手写派生字段拒绝/可执行 schema:对应 docs/acceptance/F002-wiki-contract.md 的 AC 条目。""" from __future__ import annotations import json import tempfile import unittest from pathlib import Path from tools.common import canonical_quote, sha256_text, strip_sha256_prefix from tools.front_matter import FrontMatter from ...
KinChow/MyKnowledge
tests/validation/test_wiki_schema.py
.py
8fd94ada1e81a08f
7.5
0
"""F002 门面编排:validate 全链路:对应 docs/acceptance/F002-wiki-contract.md 的 AC 条目。""" from __future__ import annotations import json import tempfile import unittest from pathlib import Path from tools.common import canonical_quote, sha256_text, strip_sha256_prefix from tools.front_matter import FrontMatter from tools.valid...
KinChow/MyKnowledge
tests/validation/test_wiki_validator.py
.py
4d4732f85fe85229
7.5
0
"""Wiki 测试共享 fixture(F002 各模块测试复用)。 从真实产物构造(F001 evidence_anchor 集成测试见 test_wiki_resolution), 避免手写键名与实现同源的自证陷阱。 """ from __future__ import annotations import tempfile import unittest from pathlib import Path from tools.common import canonical_quote, sha256_text, strip_sha256_prefix from tools.front_matter import Fr...
KinChow/MyKnowledge
tests/wiki_fixtures.py
.py
cd388d1db66840ce
7.5
0
"""MyKnowledge 工具共享基础:hash、canonical JSON、原子写与稳定读。 无状态纯函数工具集,供 tools 包各模块经 ``python -m tools.cli`` 统一入口使用。 front matter 与 Vault 锁等有状态对象见 front_matter.py / vault_lock.py。 """ from __future__ import annotations import hashlib import json import os import re import tempfile import unicodedata from pathlib import Path ...
KinChow/MyKnowledge
tools/common.py
.py
085656480ed28970
7
0
"""Markdown YAML front matter 的解析与渲染(python-frontmatter 库薄适配)。 来源:https://github.com/rafaelmardojai/python-frontmatter(MIT License,v1.3.0) 适配层归一库的异常面,保持调用方"仅捕获 ValueError/OSError"契约不变: - 未闭合的 front matter → ValueError("front_matter_unterminated") - 语法损坏的 YAML → ValueError("front_matter_invalid_yaml") - 空 front matter(...
KinChow/MyKnowledge
tools/front_matter.py
.py
63e6f5a4f3b79015
7
0
"""正文提取器:按媒体类型从原始字节提取纯文本。 HTML 提取使用 trafilatura(网页正文提取专用,剔除导航/页脚/侧栏、自动检测 charset);PDF 走 pypdf。注册表分派(match/handler)保持开闭原则。 异常策略:提取失败不降级、不回退——异常归一到结构化错误码 (extractor_unavailable:*/extract_failed:*)暴露给调用方转 blocked, 修复问题优于规避问题;非文章页返回空文本由调用方 source_empty 拒绝。 """ from __future__ import annotations import io from collectio...
KinChow/MyKnowledge
tools/ingest/extractor.py
.py
8ee6989ce1a69b50
7
0
"""Source 请求与已发布 Source 文件的 schema 校验器。 校验规则对应 F001 验收标准的字段级约束(AC-F001-009)与发布后快照一致性。 """ from __future__ import annotations from pathlib import Path from ..common import ( ACQUISITIONS, DOMAINS, SOURCE_TYPES, canonical_quote, safe_id, sha256_text, ) from ..front_matter import FrontMatter ...
KinChow/MyKnowledge
tools/ingest/source_validator.py
.py
a3f9c1a34094b545
7
0
"""Operation 记录仓库:两阶段写操作(preview→apply)的持久化与审计。 Operation 文件写入 ``state/operations/``(0600),审计快照写入 ``audit/operations/``。 """ from __future__ import annotations import json import time import uuid from pathlib import Path from .common import atomic_write, canonical_json, hash_canonical, redact, safe_id from .paths i...
KinChow/MyKnowledge
tools/operation_store.py
.py
a2ed3186050ef20f
7
0
"""仓库布局值对象:集中定义 MyKnowledge 目录结构(对照设计规范 §4 目录树)。 来源:借鉴 cookiecutter.config.Paths(集中路径容器,https://github.com/cookiecutter/cookiecutter) 与 pathlib 组合模式。布局变更只改本类,业务代码只消费命名属性/方法。 目录树(§4,F008 practice 预留不读取): sources/<domain>/ wiki/<domain>/ archive/{text,raw,manifest.jsonl} audit/{operations,validation}/ releas...
KinChow/MyKnowledge
tools/paths.py
.py
42d1ab7c436a6b0b
7
0
"""Wiki 派生字段计算(§6.8):evidence_state/strength/availability/publishable。 纯函数式:输入 metadata/resolution/report/hashes,输出派生字段 dict。 确认与验证报告读取统一经 ``read_json_dict``(fail-closed 类型契约)。 """ from __future__ import annotations import json from pathlib import Path from ..common import canonical_body, hash_canonical, sha256_tex...
KinChow/MyKnowledge
tools/validation/derived.py
.py
738313a84501c1e1
7
0
"""Wiki 引用解析与引文校验(§6.9)。 owner Vault 内解析 source/evidence target、supporting_quotes 逐字校验 (canonical_quote 单一实现 + TextPositionSelector 限定范围 + 子串包含 + LCS 诊断)。纯函数式:输入路径/参数,输出 resolution 数据对象,无实例状态。 """ from __future__ import annotations import difflib from pathlib import Path from ..common import canonical_quote, glob_w...
KinChow/MyKnowledge
tools/validation/resolution.py
.py
b34cccca50fbf4c6
7
0
"""Wiki domain rule 层:状态组合、kind 分支、证据结构、来源矩阵(§6.7/§6.8)。 纯函数式规则:输入 metadata/body,输出 (errors, warnings, resolution)。 不持有实例状态;引用解析委托 resolution 模块(结果沿调用链返回)。 """ from __future__ import annotations import re from pathlib import Path from ..common import canonical_body, glob_without_symlinks from . import resolution P...
KinChow/MyKnowledge
tools/validation/rules.py
.py
869d4d7204bafdfd
7
0
"""Wiki schema 层:可执行 JSON Schema 的加载与执行(F002 AC-F002-007)。 来源:jsonschema 库(https://github.com/python-jsonschema/jsonschema,MIT) 与 config/schemas.yaml registry 分离:本层执行 config/json-schema/wiki-v1.json, 拒绝未知字段、错误 schema version 与手写派生字段;错误为 {"code", "path", "reason"} 结构(字段级、可重放)。 """ from __future__ import annotations i...
KinChow/MyKnowledge
tools/validation/schema.py
.py
2f4c52e9ed2ad1d6
7
0
"""Wiki 契约校验门面:validate 编排与 CLI(F002)。 对外 API 不变(``WikiValidator.validate(wiki_path) -> report``);各层实现 (schema/rules/resolution/derived)在 tools/validation/ 包内解耦,本模块只做编排: 读取 → schema 层 → rules 层 → derived 层,resolution 沿调用链传递。 """ from __future__ import annotations import argparse import json from pathlib import Path ...
KinChow/MyKnowledge
tools/validation/validator.py
.py
0f81ff71ceed3792
7
0
"""Vault 独占写锁:基于 filelock 库的跨平台文件锁。 来源:https://github.com/tox-dev/py-filelock(MIT License,v3.32.4) filelock 在 Unix 上封装 fcntl.flock、Windows 上封装 msvcrt;持锁进程退出 (含崩溃)时内核自动释放锁,无 PID 复用误判,锁文件常驻不删除,不存在 "删除残留锁"的删除-创建竞态。非阻塞获取(timeout=0)失败即 lock_busy。 已知限制(R006):不支持 flock 的文件系统(如部分 NFS)上 filelock 会 静默降级为时间戳软锁,"崩溃自动释放"保证失效、互斥依赖...
KinChow/MyKnowledge
tools/vault_lock.py
.py
38e0a345c8ebbcae
7
0
""" Distributed dataloaders for pretraining. BOS-aligned bestfit: - Every row starts with BOS token - Documents packed using best-fit algorithm to minimize cropping - When no document fits remaining space, crops a document to fill exactly - 100% utilization (no padding), ~35% tokens cropped at T=2048 Comp...
ndluna21/nanochat-ascend
nanochat/dataloader.py
.py
49d44801c83ac502
7.15
1
#!/usr/bin/env python3 """ Unified web chat server - serves both UI and API from a single FastAPI instance. Uses data parallelism to distribute requests across multiple GPUs. Each GPU loads a full copy of the model, and incoming requests are distributed to available workers. Launch examples: - single available GPU (...
ndluna21/nanochat-ascend
scripts/chat_web.py
.py
96d9b2609d250a6e
7.15
1
""" The ARC dataset from Allen AI. https://huggingface.co/datasets/allenai/ai2_arc """ from datasets import load_dataset from tasks.common import Task, render_mc class ARC(Task): def __init__(self, subset, split, **kwargs): super().__init__(**kwargs) assert subset in ["ARC-Easy", "ARC-Challenge"]...
ndluna21/nanochat-ascend
tasks/arc.py
.py
6a51bbd8a6c7d9df
7.15
1
""" Base class for all Tasks. A Task is basically a dataset of conversations, together with some metadata and often also evaluation criteria. Example tasks: MMLU, ARC-Easy, ARC-Challenge, GSM8K, HumanEval, SmolTalk. """ import random class Task: """ Base class of a Task. Allows for lightweight slicing of the ...
ndluna21/nanochat-ascend
tasks/common.py
.py
c6e718cc09addff5
7.15
1
""" CustomJSON task for loading conversations from JSONL files. Each line in the JSONL file should be a JSON array of messages. """ import os import json from tasks.common import Task class CustomJSON(Task): """ Load conversations from a JSONL file. Each line should be a JSON array of message objects with...
ndluna21/nanochat-ascend
tasks/customjson.py
.py
a028d5515e558643
7.15
1
""" GSM8K evaluation. https://huggingface.co/datasets/openai/gsm8k Example problem instance: Question: Weng earns $12 an hour for babysitting. Yesterday, she just did 50 minutes of babysitting. How much did she earn? Answer: Weng earns 12/60 = $<<12/60=0.2>>0.2 per minute. Working 50 minutes, she earned 0.2 x 50 = $<...
ndluna21/nanochat-ascend
tasks/gsm8k.py
.py
e239e235ef0b39c9
7.15
1
""" Evaluate the Chat model on HumanEval dataset. Btw this dataset is a misnomer and has nothing to do with humans. It is a coding benchmark. """ import re from datasets import load_dataset from nanochat.execution import execute_code from tasks.common import Task def extract_imports(prompt): """Extract import sta...
ndluna21/nanochat-ascend
tasks/humaneval.py
.py
706f2c95ace1ce8e
7.15
1
""" The MMLU dataset. https://huggingface.co/datasets/cais/mmlu """ from datasets import load_dataset from tasks.common import Task, render_mc class MMLU(Task): letters = ('A', 'B', 'C', 'D') groups = ('abstract_algebra', 'anatomy', 'astronomy', 'business_ethics', 'clinical_knowledge', 'college_biology', 'co...
ndluna21/nanochat-ascend
tasks/mmlu.py
.py
45eda3c63f9d5c23
7.15
1
""" Task intended to make nanochat better in spelling and counting, for example: "How many r are in strawberry?" -> 3 An interesting part of this task is that we will get the assistant to solve the problem using a combination of manual counting and Python. This is a good problem solving "instinct" to mix into the mod...
ndluna21/nanochat-ascend
tasks/spellingbee.py
.py
d77a9f177b65598d
7.15
1
"""Datatrail Command Line Interface.""" from importlib.metadata import version as package_version import click from click_aliasing import ClickAliasedGroup from rich import console, pretty from dtcli import clear, config, ls, ps, pull, scout, unregistered from dtcli.utilities import utilities pretty.install() termi...
CHIMEFRB/datatrail-cli
dtcli/cli.py
.py
bf900a4f9f13b76b
7.24
2
"""Datatrail CLI Configuration.""" import logging from pathlib import Path from typing import Any, Dict, Optional import click import yaml from click_aliasing import ClickAliasedGroup from mergedeep import merge from rich import print, prompt log = logging.getLogger("config") CONFIG: Path = Path.home() / ".datatrai...
CHIMEFRB/datatrail-cli
dtcli/config.py
.py
dcbead5e4945b955
7.24
2
"""Datatrail Detailed Status Command.""" import logging import os from pathlib import Path import click from requests.exceptions import SSLError from rich.console import Console from rich.table import Table from dtcli.ls import list from dtcli.src import functions from dtcli.utilities import cadcclient from dtcli.ut...
CHIMEFRB/datatrail-cli
dtcli/ps.py
.py
60e4df817e3a690c
7.24
2
"""Datatrail Scout Command.""" import logging from typing import List import click import requests from cadcutils.exceptions import BadRequestException from rich.console import Console from rich.prompt import Confirm from rich.table import Table from dtcli.config import procure from dtcli.ls import list as ls from d...
CHIMEFRB/datatrail-cli
dtcli/scout.py
.py
12a0b7dbb1ea3a98
7.24
2
"""Functions for CLI.""" import logging import os import re import shutil import subprocess import time from collections import Counter from collections.abc import Sequence from pathlib import Path from typing import Any, Dict, List, Optional, Tuple import requests from dtcli.config import procure from dtcli.utiliti...
CHIMEFRB/datatrail-cli
dtcli/src/functions.py
.py
bbbbb6c5bfa177b6
7.24
2
"""Class to facilitate data transfer on CANFAR using the CADC tools.""" import logging import os import sys from concurrent.futures import ThreadPoolExecutor from io import StringIO from multiprocessing import Process # Use the standard library only from typing import Any, Dict, List, Optional, Tuple import cadcutil...
CHIMEFRB/datatrail-cli
dtcli/utilities/cadcclient.py
.py
cb6383de4026a6c9
7.24
2
"""Utility functions.""" import json import logging from typing import Any, Dict, List, Tuple, Union import requests from requests.models import Response from rich.console import Console try: from packaging.version import parse except ImportError: from pip._vendor.packaging.version import parse # Bound ever...
CHIMEFRB/datatrail-cli
dtcli/utilities/utilities.py
.py
43180e62f31080e3
7.24
2
"""Tests for Datatrail CLI.""" from datetime import datetime as dt from typing import Any, Dict, List, Optional import pytest from dtcli.src import functions from dtcli.src.functions import ( find_unregistered_datasets, get_unregistered_dataset, view_results, ) def test_view_results() -> None: """T...
CHIMEFRB/datatrail-cli
tests/test_functions.py
.py
f7d54ec26c7903db
7.74
2
import pytest from dtcli.utilities import utilities def test_split(): test_array = ["a", "b"] split_by = 2 result = utilities.split(test_array, split_by) assert result == [["a"], ["b"]] def test_split_edges(): """Test split() with edge cases like empty list and invalid counts.""" # Empty da...
CHIMEFRB/datatrail-cli
tests/test_utils.py
.py
a6e304d02ce8447d
7.74
2
#!/usr/bin/env python3 # License: MIT # Copyright © 2024 Frequenz Energy-as-a-Service GmbH """Script to migrate existing projects to new versions of the cookiecutter template. This script migrates existing projects to new versions of the cookiecutter template, removing the need to completely regenerate the project fr...
frequenz-floss/frequenz-repo-config-python
.github/cookiecutter-migrate.template.py
.py
7779568e9e4cdf42
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Cookiecutter pre-generation hooks. This module contains the pre-generation hooks for the cookiecutter template. It validates the cookiecutter variables and prints an error message and exits with a non-zero exit code if any of them are invalid. """...
frequenz-floss/frequenz-repo-config-python
cookiecutter/hooks/pre_gen_project.py
.py
fe5daedf560dbb4c
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Local cookiecutter extensions. This module contains local cookiecutter extensions that are useful for generating the project structure. """ import datetime as _datetime import json as _json import os as _os import pathlib as _pathlib import rando...
frequenz-floss/frequenz-repo-config-python
cookiecutter/local_extensions.py
.py
47f12e68758d148e
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Command-line tool to get the current `mike` version information of a repository. For now this tool is designed to be used in GitHub Actions workflows, but it is possible to use it in other environments as well. To do so the `gh` tool should be pro...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/cli/version/mike/info.py
.py
8a1a699c87217b1c
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Sort `mike`'s `version.json` file with a custom order.""" import json import sys from typing import Any, TextIO from .... import github from ....mkdocs.mike import sort_mike_versions def _load_and_sort_versions_from(stream: TextIO) -> dict[str,...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/cli/version/mike/sort.py
.py
0ebf4c0f504822bd
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Utilities to work with GitHub. - [`abort()`][.abort] to print an error message using GitHub Actions commands and exit. - [`require_env()`][.require_env] to get an environment variable or exit with an error if it is not defined. - [`get_tag...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/github.py
.py
e6fa86636e12e51d
7.39
5
# License: MIT # Copyright © 2022 Frequenz Energy-as-a-Service GmbH """Generate the code reference pages. It uses the following `mkdocs` plugins: * `mkdocs-gen-files` to generate the API documentation pages. * `mkdocs-literate-nav` to make use of the generated `SUMMARY.md` file. Based on the recipe at: https://mkdo...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/mkdocs/api_pages.py
.py
8d4f9c731d1717c8
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Tools to work with mike. This module provides these tools: * Building the mike version information from the repository information ([`build_mike_version()`][.build_mike_version]). * Sorting the mike version information `version.json` file ([`...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/mkdocs/mike.py
.py
2656ff116a86e104
7.39
5
# License: MIT # Copyright © 2025 Frequenz Energy-as-a-Service GmbH """Integration between `mkdocstrings` and `macros` extensions to work together. # Introduction To be able to use macros inside docstrings, we need to integrate the `mkdocs-macros` extension into `mkdocstrings`. This module provides the necessary fun...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/mkdocs/mkdocstrings_macros.py
.py
1b37301595600d3d
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Configuration utilities for nox. This module provides utilities to configure the nox sessions. It provides a [`Config`][.Config] and a [`CommandsOptions`][.CommandsOptions] class, which are used to configure the nox sessions. The [`get()`][.get] ...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/nox/config.py
.py
397c30d9e7e9f764
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """General purpose utilities. This module contains general purpose utilities that are used by the other modules in this package. """ import pathlib as _pathlib import tomllib as _tomllib from collections.abc import Iterable, Mapping from typing impo...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/nox/util.py
.py
072b9fef2d88fd6f
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Manages the configuration to generate files from the protobuf files.""" import dataclasses import logging import pathlib import tomllib from collections.abc import Sequence from typing import Any, Self _logger = logging.getLogger(__name__) @dat...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/protobuf.py
.py
c71d5cd09e63e2bf
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Utility to enable linting of code examples in docstrings. Code examples are often wrapped in triple backticks (````python`) within our docstrings. This plugin extracts these code examples and validates them using pylint. The main utility function...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/pytest/examples.py
.py
3c16b7d5b07d00d8
7.89
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Setuptools hooks to build protobuf files. This module contains a setuptools command that can be used to compile protocol buffer files in a project. It also runs the command as the first sub-command for the build command, so protocol buffer files ...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/setuptools/grpc_tools.py
.py
047b7b4a1adadb45
7.39
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Version information for a repository. This module provides the [`RepoVersionInfo`][.RepoVersionInfo] class to get information about the repository version. It handles many scenarios and queries, like: * Is the current commit a tag or a branch? *...
frequenz-floss/frequenz-repo-config-python
src/frequenz/repo/config/version.py
.py
e1b3cd4541a87e10
7.39
5
"""Tests for the dependabot-gprc-fixer script.""" import json import re import runpy import shutil import sys from dataclasses import dataclass from pathlib import Path import pytest FIXER_PATH = ( Path(__file__).resolve().parents[3] / "cookiecutter/scripts/dependabot-grpc-fixer.py" ) PYPROJECT = Path("pypr...
frequenz-floss/frequenz-repo-config-python
tests/cookiecutter/scripts/test_dependabot-grpc-fixer.py
.py
dedeee3825c917aa
7.89
5
# License: MIT # Copyright © 2023 Frequenz Energy-as-a-Service GmbH """Generation tests for cookiecutter.""" import os import pathlib import re import shutil import subprocess import pytest from frequenz.repo import config UPDATE_GOLDEN: bool = os.environ.get("UPDATE_GOLDEN", "").lower() in ( "1", "true", ...
frequenz-floss/frequenz-repo-config-python
tests/integration/test_cookiecutter_generation.py
.py
675d793ab91cd26f
7.89
5
# Copyright 2024 Google LLC # 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, sof...
google-ml-infra/actions
ci_connection/get_labels.py
.py
46b5d49608a79e45
7.24
2
# Copyright 2024 Google LLC # 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, sof...
google-ml-infra/actions
ci_connection/notify_connection.py
.py
3e4f1e52fa4ad9f9
7.24
2
# Copyright 2024 Google LLC # 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, sof...
google-ml-infra/actions
ci_connection/preserve_run_state.py
.py
4c2f44f1059cc3b3
7.24
2
# Copyright 2024 Google LLC # 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, sof...
google-ml-infra/actions
ci_connection/utils.py
.py
8a8d0bdd2cfd49ea
7.24
2
# Copyright 2024 Google LLC # 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, sof...
google-ml-infra/actions
ci_connection/wait_for_connection.py
.py
76750b3e7199111c
7.24
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/src/seed_env/core.py
.py
8b3f15dd84f278fe
7.24
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/src/seed_env/seeder.py
.py
a3a7b5e0aa4960e7
7.24
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/src/seed_env/utils.py
.py
ce418c7605d58614
7.24
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/src/seed_env/uv_utils.py
.py
361e0260723e297e
7.24
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/tests/test_cli.py
.py
a2d727e66a753b0c
7.74
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/tests/test_core.py
.py
3cf9caf5f17c9c34
7.74
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/tests/test_seeder.py
.py
d60dbff08f710daf
7.74
2
""" Copyright 2025 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
google-ml-infra/actions
python_seed_env/tests/test_utils.py
.py
a8572b31cf3a8a7f
7.74
2
from requests import Session class AquilaClient(object): def __init__(self, baseurl): self.session = Session() self.baseurl = baseurl def get_rights_data(self, rights_ids, as_data): """Fetches structured rights statements from Aquila. Args: rights_ids (list): Ide...
RockefellerArchiveCenter/digitized_image_packaging
src/clients.py
.py
6b9f03bb558da006
7
0
class MockResponse(object): """Class used to mock HTTP responses""" def __init__(self, json_data, status_code, **kwargs): """Sets data, status code, and any other data passed in.""" self.json_data = json_data self.status_code = status_code self.text = "v4.0.0" for k in ...
RockefellerArchiveCenter/digitized_image_packaging
tests/helpers.py
.py
f063c7fb4dcf2ef3
7.5
0
"""Run configuration for the BOPOs training pipeline. Defines the typed config dataclasses (:class:`DatasetConfig`, :class:`TrainingConfig`) and the per-run :class:`ConfigManager` factory that maps a dataset key from the command line to its ARFF location, the target label count, and the fixed list of noisy rates / bas...
hxtruong6/pre-order-for-mlc
preorder4mlc/config.py
.py
50beed16ea8624d1
7.3
3
"""Shared constants and enum types. Centralises the base learner names and target metric enums used across :mod:`training_orchestrator`, :mod:`inference_models`, and :mod:`searching_algorithms`, along with the canonical random seed that controls every reproducible split and noise draw in the paper. """ from enum impo...
hxtruong6/pre-order-for-mlc
preorder4mlc/constants.py
.py
058e767cbefc434d
7.3
3
"""Dataset loading, splitting, and noise injection. :class:`Datasets4Experiments` reads multi-label ARFF files, separates X from Y based on whether labels are at the beginning or end of the file (controlled by :data:`TARGET_IN_END_FILE_DATASETS`), and yields k-fold splits with optional symmetric label-flip noise (Bern...
hxtruong6/pre-order-for-mlc
preorder4mlc/datasets4experiments.py
.py
f8cd7c8c6a8bc3e8
7.3
3
"""Uniform estimator interface over scikit-learn and LightGBM backends. :class:`Estimator` is the single adapter every other module talks to; its constructor accepts a :class:`constants.BaseLearnerName` and hides the differences between :class:`sklearn.ensemble.RandomForestClassifier`, :class:`sklearn.ensemble.ExtraTr...
hxtruong6/pre-order-for-mlc
preorder4mlc/estimator.py
.py
6ad917c3a99623f5
7.3
3
"""MILP solver dispatch for BOPOs ILP. Two backends: - "glpk": cvxopt.glpk.ilp (legacy, paper baseline) - "highs": HiGHS via highspy (5-10x faster on Mittelmann MILP benchmark) Both solve the same standard-form MILP and return the same optimal x when the problem has a unique optimum. Selected via env var ``PREOR...
hxtruong6/pre-order-for-mlc
preorder4mlc/solvers.py
.py
5c89c02e12ca2c56
7.3
3
"""Persistence layer for per-fold experiment records. :class:`ExperimentResults` writes pickle files named ``dataset_<name>_noisy_<rate>[_clr|_br|_cc].pkl`` containing the list of per-fold record dicts emitted by :mod:`training_orchestrator`. :class:`ResultProcessor` is the load-side companion: it deserialises the lis...
hxtruong6/pre-order-for-mlc
preorder4mlc/utils/results_manager.py
.py
e572147593a941ad
7.3
3
"""Aggregate per-fold evaluation CSVs into per-dataset summary tables. Reads ``evaluation_<DatasetName>_noisy_<rate>_<algo>.csv`` files written by :mod:`scripts.evaluate` and :mod:`scripts.evaluate_ecc`, then emits one ``<DatasetName>_<PredictionType>_summary.csv`` per dataset containing ``mean +/- std`` cells across ...
hxtruong6/pre-order-for-mlc
preorder4mlc/utils/summarize_metrics.py
.py
16c9f119ac0e90e9
7.3
3
"""Context managers that mute C-level stdout/stderr. Used to suppress the GLPK ILP solver's chatter inside the per-instance search loop in :mod:`searching_algorithms`. Both wrappers operate on the raw file descriptors so they catch output that bypasses Python's ``sys.stdout`` / ``sys.stderr``. """ import contextlib i...
hxtruong6/pre-order-for-mlc
preorder4mlc/utils/suppress.py
.py
fbda7733bdf14c9f
7.3
3
"""Merge per-(repeat, fold) pickle splits into the consolidated form. Each split sbatch job writes a partial pickle named ``dataset_<name>_noisy_<r>[_clr|_br|_cc]_r<R>_f<F>.pkl`` containing the records for one (repeat, fold) cell. This script globs those partials for a single (dataset, noise) cell and concatenates the...
hxtruong6/pre-order-for-mlc
scripts/slurm/merge_split_results.py
.py
f315eb718c29a82d
7.3
3