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 |
|---|---|---|---|---|---|---|
"""Actually Download Assets."""
import contextlib
import time
from pathlib import Path
from typing import TYPE_CHECKING
import aiohttp
from anyio import Path as AsyncPath
from botocore.exceptions import ClientError as S3ClientError
from archivepodcast.instances.path_cache import local_file_cache, s3_file_cache
from ... | kism/archivepodcast | src/archivepodcast/downloader/asset_downloader.py | .py | 6c0536ecacbd3ea7 | 7.15 | 1 |
"""Download and process podcast feeds and media files."""
# and return xml that can be served to download them
import re
import time
import xml.etree.ElementTree as ET
from http import HTTPStatus
import aiohttp
from archivepodcast.constants import XML_ENCODING
from archivepodcast.instances.health import health
from ... | kism/archivepodcast | src/archivepodcast/downloader/downloader.py | .py | 09dfb1cedc76296f | 7.15 | 1 |
"""Helpers for downloader module."""
import asyncio
import contextlib
import datetime
import random
import shutil
import sys
from email.utils import parsedate_to_datetime
from pathlib import Path
from typing import TYPE_CHECKING
import ffmpeg
from archivepodcast.constants import AP_SELF_TEST
from archivepodcast.util... | kism/archivepodcast | src/archivepodcast/downloader/helpers.py | .py | 87057f2f463d7e39 | 7.15 | 1 |
"""Instances for ArchivePodcast application."""
from typing import TYPE_CHECKING
from pydantic import BaseModel
from archivepodcast.utils.logger import get_logger
if TYPE_CHECKING:
from pathlib import Path
from archivepodcast.config import ArchivePodcastConfig
logger = get_logger(__name__)
_conf_cache: A... | kism/archivepodcast | src/archivepodcast/instances/config.py | .py | b941f5c76dfd16dd | 7.15 | 1 |
"""Helper for application paths, and its instance."""
from pathlib import Path
from archivepodcast.constants import APP_DIRECTORY
from archivepodcast.instances.path_cache import local_file_cache
from archivepodcast.utils.lfs_check import check_lfs_objects
class AppPathsHelper:
"""Helper for application paths.""... | kism/archivepodcast | src/archivepodcast/instances/path_helper.py | .py | 5cc6c0a00a741105 | 7.15 | 1 |
"""Response helpers and archiver lifecycle for the ArchivePodcast app."""
import asyncio
import datetime
import os
import signal
import threading
import time
from http import HTTPStatus
from typing import TYPE_CHECKING, Any
from fastapi.responses import FileResponse, HTMLResponse, Response
from archivepodcast.archiv... | kism/archivepodcast | src/archivepodcast/instances/podcast_archiver.py | .py | f7c5a77b6596a73c | 7.15 | 1 |
"""API routes for ArchivePodcast."""
import signal
from http import HTTPStatus
from fastapi import APIRouter
from fastapi.responses import JSONResponse
from archivepodcast.instances.health import health
from archivepodcast.instances.podcast_archiver import (
get_ap,
reload_config,
)
from archivepodcast.insta... | kism/archivepodcast | src/archivepodcast/routers/api.py | .py | a765c8debe83f4c4 | 7.15 | 1 |
"""Routes for static files and special routes like robots.txt and favicon.ico."""
from fastapi import APIRouter, Response
from archivepodcast.instances.podcast_archiver import (
send_ap_cached_webpage,
)
router = APIRouter(include_in_schema=False)
@router.get("/robots.txt")
def send_robots() -> Response:
"... | kism/archivepodcast | src/archivepodcast/routers/static.py | .py | f1746e0b34d97ef6 | 7.15 | 1 |
"""Webpage routes for ArchivePodcast."""
from http import HTTPStatus
from fastapi import APIRouter, Response
from fastapi.responses import RedirectResponse
from archivepodcast.instances.podcast_archiver import (
generate_404,
get_about_page_exists,
send_ap_cached_webpage,
)
from archivepodcast.utils.logg... | kism/archivepodcast | src/archivepodcast/routers/webpages.py | .py | 813ee9a120f2404c | 7.15 | 1 |
"""FastAPI app factory for the ArchivePodcast web server."""
import os
import tempfile
import time
from contextlib import asynccontextmanager
from pathlib import Path
from typing import TYPE_CHECKING
from fastapi import FastAPI, Request, Response
from fastapi.routing import APIRoute
from rich.traceback import install... | kism/archivepodcast | src/archivepodcast/run_webapp.py | .py | 3adb9a7ce2265730 | 7.15 | 1 |
"""Module for local file caching functionality."""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
class LocalFileCache:
"""Class representing a local file cache."""
def __init__(self) -> None:
"""Initialise the local file cache."""
self._files: list[Path] | ... | kism/archivepodcast | src/archivepodcast/utils/file_cache.py | .py | 889fb4a30c40fbf1 | 7.15 | 1 |
"""Health monitoring for archivepodcast components."""
import contextlib
import datetime
import os
from email.utils import parsedate_to_datetime
from pathlib import Path
from typing import TYPE_CHECKING, Self
from pydantic import BaseModel
from archivepodcast.constants import PROGRAM_VERSION
from archivepodcast.util... | kism/archivepodcast | src/archivepodcast/utils/health.py | .py | 7b381c49c9a67fe4 | 7.15 | 1 |
"""Startup self-check that Git LFS assets were actually fetched, not left as pointer stubs."""
import os
from typing import TYPE_CHECKING
from archivepodcast.utils.logger import get_logger
if TYPE_CHECKING:
from pathlib import Path
logger = get_logger(__name__)
# https://github.com/git-lfs/git-lfs/blob/main/do... | kism/archivepodcast | src/archivepodcast/utils/lfs_check.py | .py | 4aa09354b66fcdfa | 7.15 | 1 |
"""Log messages for ArchivePodcast."""
from datetime import datetime
from typing import TYPE_CHECKING
from archivepodcast.constants import OUR_TIMEZONE, PROGRAM_NAME_WITH_FULL_VERSION
if TYPE_CHECKING:
import logging
from aiohttp import ClientError
def get_time_str() -> str:
"""Get the current time as... | kism/archivepodcast | src/archivepodcast/utils/log_messages.py | .py | 2aeea5a7d4eb54d2 | 7.15 | 1 |
"""Logging configuration for archivepodcast."""
import logging
import os
from logging import StreamHandler
from logging.handlers import RotatingFileHandler
from pathlib import Path
from typing import Any, Self, cast
from pydantic import BaseModel, field_validator, model_validator
from rich.console import Console
from... | kism/archivepodcast | src/archivepodcast/utils/logger.py | .py | debf5a5dbc0bf89f | 7.15 | 1 |
"""Profiler Utility."""
from typing import Any
from pydantic import BaseModel
class EventLastTime(BaseModel):
"""Flat record of each event's last duration in seconds, keyed by path."""
times: dict[str, float] = {}
def set_event_time(self, path: str, duration: float) -> None:
"""Record the last... | kism/archivepodcast | src/archivepodcast/utils/profiler.py | .py | a14caef94827c8a4 | 7.15 | 1 |
"""Helper utilities for archivepodcast."""
import time
from datetime import UTC, datetime
from typing import TYPE_CHECKING
from aiobotocore.session import get_session
from botocore.exceptions import ClientError
from pydantic import BaseModel
from archivepodcast.instances.config import get_ap_config_s3_client
from .... | kism/archivepodcast | src/archivepodcast/utils/s3.py | .py | 2d53d2148f789c8e | 7.15 | 1 |
"""Fin CLI entrypoint.
We deliberately do our own argv dispatch (rather than a pure Typer app) because
command resolution is dynamic: a sub-command may be a reserved system command
*or* contributed by a plug discovered at runtime. Help is rendered by
:mod:`fincli.help` for both the top-level overview and per-command p... | sharanvelu/fin | fincli/__main__.py | .py | bb6e46cc4fe3879b | 7 | 0 |
"""The canonical, agent-agnostic instruction content for a project.
One markdown body is built here from the project's resolved plugs;
``targets.py`` renders it into each agent's file format. The plug command
tables are generated from ``FinPlug.commands()`` metadata in resolution order
(``FIN_APP`` first, then ``FIN_P... | sharanvelu/fin | fincli/agents/content.py | .py | 7b5b3e8338ea159d | 7 | 0 |
"""Write generated agent files into a project, merging shared files safely.
Fin-owned files are (re)written whole. Shared files (``AGENTS.md``,
``.github/copilot-instructions.md``) are only ever touched inside a marker
block, so hand-written content around it survives every re-run.
"""
from __future__ import annotati... | sharanvelu/fin | fincli/agents/installer.py | .py | cfdc6ddc0ce6c2b0 | 7 | 0 |
"""Reserved (system) commands.
These are owned by Fin and never delegated to plugs. The `up` command in
particular only *reads information* from plugs — it never lets a plug execute
container actions. Each reserved command is registered in
:data:`RESERVED_COMMANDS` via the :func:`reserved` decorator.
"""
from __futur... | sharanvelu/fin | fincli/commands/__init__.py | .py | ef7fd2f07629179c | 7 | 0 |
"""Install user-provided CA certificates into running containers.
Fin lets you drop trusted CA certs into ``~/.fin/certs`` (``Config.certs_dir()``)
— the same per-user root that already holds ``config.json`` and ``registry.db``.
Any ``.pem`` / ``.crt`` file found there is copied into a container that *opted
in* (``Con... | sharanvelu/fin | fincli/core/certs.py | .py | d20fe006a41c17e6 | 7 | 0 |
"""Auto-create the project database inside the running asset DB container.
On ``fin up`` Fin reads the project's ``DB_*`` env and, if the target database
does not yet exist in the shared engine, creates it. Only MySQL and Postgres
are handled; other ``DB_CONNECTION`` values are skipped silently.
The create runs *insi... | sharanvelu/fin | fincli/core/database.py | .py | 59ab5cc3900663b9 | 7 | 0 |
"""Fin-specific exceptions and a decorator that renders them cleanly.
Expected failures never surface as a raw Python traceback. Command functions
raise :class:`FinError` (or its subclasses); the :func:`handle_errors`
decorator catches those plus the common Docker SDK exceptions and renders a
friendly Rich panel, then... | sharanvelu/fin | fincli/core/errors.py | .py | bd1fe9d43a5016ad | 7 | 0 |
"""Interactive exec sessions inside a container (bash, sh, tinker, …).
The high-level ``container.exec_run`` helper only *streams output* — it never
attaches the local stdin to the exec, so an interactive shell can never receive
keystrokes (typing ``exit`` does nothing; the process hangs until Ctrl+C).
This module us... | sharanvelu/fin | fincli/core/interactive.py | .py | bba6fd1a6b47fa52 | 7 | 0 |
"""Turns plug ContainerSpecs into running containers.
This is where Fin acts *on behalf of* plugs: a plug only ever returns a
:class:`~fincli.plugs.base.ContainerSpec`; the orchestrator is the sole code
path that attaches the standard labels, wires Traefik routing, mounts the
project directory, and calls Docker. Plugs... | sharanvelu/fin | fincli/core/orchestrator.py | .py | f36ef1c863b06850 | 7 | 0 |
"""The built-in Traefik proxy — always available, not a plug.
Routing is driven entirely by container labels (the Docker provider), so once
the proxy is running, starting any web-exposed container with Traefik labels is
enough to route it. The proxy reads the Docker socket to watch for those labels.
"""
from __future... | sharanvelu/fin | fincli/core/proxy.py | .py | 002cedc10e6d2ca6 | 7 | 0 |
"""Persisted, system-wide toggle store (JSON at ``~/.fin/config.json``).
Currently tracks which asset plugs are enabled to auto-start with ``fin up``.
Kept deliberately tiny and dependency-free so it is safe to read/write often.
"""
from __future__ import annotations
import json
from typing import Any
from fincli.c... | sharanvelu/fin | fincli/core/store.py | .py | 24f8ee2a63b3ebc2 | 7 | 0 |
"""Readiness waiting for freshly-started asset containers.
A just-started database engine accepts the container as *running* well before
it can accept client connections. Doing DB presence/creation work in that gap
fails or warns spuriously. This module polls a cheap in-container readiness
probe until the engine answe... | sharanvelu/fin | fincli/core/wait.py | .py | 13b2a9ec8a391c66 | 7 | 0 |
"""Remote plug catalog — plain-HTTPS fetches against the fin-plugs repo.
The fin-plugs repository stores every plug as one file (``plugs/<name>.py``)
on its master branch, and its release workflow publishes a generated
``catalog.json`` as an asset of each release. Installing fetches the plug
file straight from ``raw.g... | sharanvelu/fin | fincli/plugs/catalog.py | .py | 1791fc4397deccd6 | 7 | 0 |
"""Execution context handed to plug command handlers.
A plug command must not reach into globals; everything it needs to act on the
user's behalf is provided here: the parsed project env, the resolved primary
container name, and small helpers to exec inside the primary container.
Plugs *describe* and *delegate* — the... | sharanvelu/fin | fincli/plugs/context.py | .py | e8fcd4d0d5f3151d | 7 | 0 |
"""Plugin loader — discovers and instantiates plugs via importlib.
Discovery model — one shape, a flat directory of single-file plugs:
PLUGS_DIR/
<plug_name>.py → defines a FinPlug subclass
For development, symlink the fin-plugs repo's ``plugs/`` directory to
``PLUGS_DIR`` (``ln -s <fin-plugs repo>/pl... | sharanvelu/fin | fincli/plugs/loader.py | .py | 222e382937364203 | 7 | 0 |
"""Command resolution: reserved → FIN_APP → FIN_PLUGS → GLOBAL.
When a sub-command is run, Fin searches in this order:
1. Reserved (system) commands — owned by Fin, never delegated.
2. The primary app plug named by ``FIN_APP`` (a.k.a. ``FIN_PLUG``).
3. The auxiliary plugs listed in ``FIN_PLUGS`` (comma-separated).
4.... | sharanvelu/fin | fincli/resolver.py | .py | 6fc4c4b00cdf6044 | 7 | 0 |
"""The single Rich Console instance plus standard message helpers.
Per Fin's output standards, *all* terminal output flows through this module.
Nothing outside ``fincli/ui`` should call ``print()`` directly.
Message conventions:
success → ``✓`` green error → ``✗`` red
warning → ``⚠`` yellow info ... | sharanvelu/fin | fincli/ui/console.py | .py | 0d00f6033f4768a3 | 7 | 0 |
"""Spinner / progress helpers for long-running operations.
Usage::
from fincli.ui.spinners import fin_spinner
with fin_spinner("Pulling image..."):
client.images.pull("traefik:v3.6")
The context manager wraps Rich's transient status so the spinner disappears
once the work completes, leaving the surr... | sharanvelu/fin | fincli/ui/spinners.py | .py | eb7d1ad36eb555bd | 7 | 0 |
# This code can be put in any Python module, it does not require IPython
# itself to be running already. It only creates the magics subclass but
# doesn't instantiate it yet.
import subprocess
from IPython.core.magic import (
Magics,
cell_magic,
line_cell_magic,
line_magic,
magics_class,
)
# The... | bravmi/dotfiles | ipython/extensions/lang.py | .py | 04cb1f873f7f250c | 7.24 | 2 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import mock
import pytest
from gluetool.action import Action
from gluetool.tests.conftest import fixture_enable_logger, fixture_enable_logger_propagate, fixture_log # noqa
from gluetool_modules_framework.tests import patch_s... | testing-farm/gluetool-modules | conftest.py | .py | 039421bd72bd3352 | 7.5 | 0 |
#!/usr/bin/env python
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
"""
Generate RST files documenting modules.
"""
import inspect
import os
import sys
import re
import six
import gluetool
LOGGER = gluetool.log.Logging.setup_logger()
OUTPUT_DIR = 'docs/source'
MOD_TE... | testing-farm/gluetool-modules | docs/generate-module-page.py | .py | 328bf79e5c177c7f | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import importlib
try:
import ipdb
except ImportError:
pass
import gluetool
from typing import Optional
class Debug(gluetool.Module):
"""
Break into ipdb debugger during pipeline execution.
By default the... | testing-farm/gluetool-modules | gluetool_modules_framework/development/debug.py | .py | a44a444366974f87 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import gluetool
from typing import Dict, List, Optional, Any # noqa
class BrewBuildOptions(gluetool.Module):
"""
Create options for ``/distribution/install/brew-build task``.
This task is being used to install b... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/brew_build_task_params.py | .py | 6bdd967841042155 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import sentry_sdk
import gluetool
import gluetool_modules_framework.libs
from gluetool.log import ContextAdapter
from typing import Optional, Any, Dict # noqa
class ColdStore(gluetool.Module):
"""
Provides - and ... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/coldstore.py | .py | e8f54629c6851b2c | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import gluetool
import gluetool_modules_framework.libs
from typing import Dict # noqa
class Dashboard(gluetool.Module):
"""
Provides - and logs - "dashboard" URL - an URL somewhere in the wild that, when opened,
... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/dashboard.py | .py | d71316e1952999a3 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
"""
Allow modules to inject enviroment variables via EnvInject module
"""
import gluetool
import six
from gluetool.log import format_dict
from typing import TYPE_CHECKING, List, Dict, Optional # noqa
DEFAULT_PROPS_FILE = 'env... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/envinject.py | .py | 7726eccafefd2713 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import gluetool
from gluetool.log import log_dict
# Type annotations
from typing import Any, Callable, Dict, List, Optional, NamedTuple, Tuple # noqa
#: Represents an event handler, with its arguments
#:
#: :ivar callable c... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/events.py | .py | 1acbd55555668134 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import gluetool
from gluetool.utils import PatternMap
from gluetool.glue import GlueError
from gluetool.result import Ok
from gluetool_modules_framework.libs.guest_setup import guest_setup_log_dirpath, GuestSetupStage, SetupGue... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/guest_setup_order.py | .py | 3231c4e463b2c4e9 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import tempfile
import gluetool
from gluetool.result import Result
from typing import Any, Optional, List, Set, Union # noqa
DEFAULT_RETRY_TIMEOUT = 30
DEFAULT_RETRY_TICK = 10
class HideSecrets(gluetool.Module):
"""
... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/hide_secrets.py | .py | 3b79f32b29b70ca1 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import os
import gluetool
from uuid import uuid4
from gluetool.action import Action
from gluetool.log import log_dict
from gluetool.result import Ok, Error
from gluetool_modules_framework.libs.artifacts import DEFAULT_DOWNLOAD... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/install_koji_build_execute.py | .py | f7914641e66df5d6 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import json
import gluetool
from gluetool.log import log_dict
from gluetool.utils import Command
from gluetool import GlueError
from gluetool_modules_framework.libs.sut_installation import check_ansible_sut_installation
# Type... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/install_mbs_build.py | .py | 4078cc540400a8c0 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import json
import os
import re
import gluetool
from gluetool.action import Action
from gluetool.log import log_dict
from gluetool.result import Ok, Error
from gluetool.utils import Command, normalize_shell_option, render_templ... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/install_mbs_build_execute.py | .py | 683a5ce0c5fea518 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import os
import gluetool
class JenkinsBuildName(gluetool.Module):
"""
Use Jenkins REST API to change build name.
"""
name = 'jenkins-build-name'
description = 'Set Jenkins build name.'
supported_dry... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/jenkins/jenkins_build_name.py | .py | 6ac3ebc2aa024655 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import collections
import logging
import six
import gluetool
# Type annotations
from typing import Any, List, Dict, Union, TYPE_CHECKING # noqa
if six.PY2:
logging_name_to_level = logging_level_to_name = logging._levelN... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/notes.py | .py | 0cb87114ff1e4bac | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import os
from contextlib import nullcontext
import psutil
import signal
import six
from gluetool import Failure, Module
from gluetool.log import log_dict
from gluetool.utils import cached_property, normalize_bool_option, norm... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/oom.py | .py | 66ccca851a54f4eb | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import datetime
from requests.models import Response
import gluetool
from gluetool.glue import GlueError
from gluetool.result import Result
from gluetool.utils import requests, wait
from gluetool_modules_framework.testing.test... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/reportportal.py | .py | db682ba6668cba37 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import smtplib
import socket
import six
from email.mime.text import MIMEText
import gluetool
from gluetool import utils
# Type annotations
from typing import TYPE_CHECKING, List # noqa
import gluetool_modules_framework.libs.m... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/smtp.py | .py | 7132fd8fcb4d9456 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import os
from datetime import datetime
import gluetool
from gluetool import Failure
from gluetool import GlueCommandError
from gluetool import GlueError
from gluetool.utils import Command
from gluetool_modules_framework.libs.... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/upload_results.py | .py | 42beb0a51bf6beeb | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import requests
import gluetool
# Type annotations
from typing import Optional # noqa
class URLShortener(gluetool.Module):
"""
Provides shared function for shortening URLs.
It can also be used to sanitize URLs... | testing-farm/gluetool-modules | gluetool_modules_framework/helpers/url_shortener.py | .py | e052dcfeee026ea0 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
# Note: this module is named 'bugzilla' - same as python-bugzilla module.
# Python 3 uses absolute imports by default, avoiding the naming conflict.
from collections import defaultdict, namedtuple
from requests.exceptions impo... | testing-farm/gluetool-modules | gluetool_modules_framework/infrastructure/bugzilla.py | .py | 851f42363b6fde14 | 7 | 0 |
# Copyright Contributors to the Testing Farm project.
# SPDX-License-Identifier: Apache-2.0
import collections
import re
import requests
import six
import gluetool
from gluetool.utils import cached_property, dict_update, render_template
from gluetool.log import log_dict, log_blob
# Type annotations
from typing impor... | testing-farm/gluetool-modules | gluetool_modules_framework/infrastructure/copr.py | .py | 068e5ad07746c0cd | 7 | 0 |
import contextlib
import json
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
from util import logger
HOT_STOCK_URL = "https://xueqiu.com/service/screener/screen?category=CN&exchange=sh_sz&areacode=&indcode=&order_by=symbol&order=desc&page=1&size=30&only_count=0¤t=... | SnailDev/quantitative-investment | core.py | .py | d2687aa6352c02c1 | 7.24 | 2 |
from pathlib import Path
from kalm_benchmark.evaluation.scanner_manager import ScannerBase
from kalm_benchmark.utils.constants import RunUpdateGenerator, UpdateType
from kalm_benchmark.utils.scan_utils import (
ScanStrategy,
determine_scan_strategy,
resolve_scanner_tool,
validate_scan_configuration,
)
... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/benchmark.py | .py | 1c3dfacc27aade29 | 7.35 | 4 |
import os
from datetime import datetime
from pathlib import Path
from typing import Optional
# Silence Node.js version warning from cdk8s/jsii (Find it annoying; no effect on functionality)
os.environ.setdefault("JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION", "1")
import typer
from kalm_benchmark import benchmark
from... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/cli.py | .py | cd508546d438dc6b | 7.35 | 4 |
import uuid
from pathlib import Path
import re
from ..scanner.scanner_evaluator import CheckResult
from .ccss_models import MisconfigurationFinding, SourceType
class CCSSConverter:
"""Converts between existing CheckResult format and new CCSS data models.
Provides static methods for transforming scanner outp... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/ccss/ccss_converter.py | .py | 62c8bb94329a3983 | 7.35 | 4 |
import json
import sqlite3
import uuid
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from loguru import logger
from ...utils.config import get_config
from .ccss_models import (
CCSSEvaluationRun,
MisconfigurationFinding,
ScannerCCSSAlignment,
SourceType,
... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/ccss/ccss_database.py | .py | adc705652e60064f | 7.35 | 4 |
import statistics
from loguru import logger
from ..scanner.scanner_evaluator import CheckResult
from .ccss_converter import CCSSConverter
from .ccss_database import CCSSDatabase
from .ccss_models import MisconfigurationFinding, ScannerCCSSAlignment, SourceType
class CCSSService:
"""Main service for CCSS functio... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/ccss/ccss_service.py | .py | 2b698f7d018e0ec1 | 7.35 | 4 |
import bisect
from dataclasses import dataclass
import yaml
@dataclass
class K8sObject:
name: str
kind: str
namespace: str | None = None
class FileIndex:
"""Creates an index of all the objects within a YAML file.
Provides efficient access to YAML objects within a multi-document file
using ... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/file_index.py | .py | aa535506eb35d369 | 7.35 | 4 |
import json
import re
from pathlib import Path
from typing import Optional
import pandas as pd
from kalm_benchmark.utils.constants import UpdateType
from kalm_benchmark.utils.path_normalization import normalize_kics_path
from ...utils.eval_utils import get_path_to_line
from .scanner_evaluator import (
CheckCateg... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner/kics.py | .py | df573c2b73ed00aa | 7.35 | 4 |
from pathlib import Path
from typing import Optional
import pandas as pd
from .scanner_evaluator import CheckCategory, CheckResult, CheckStatus, ScannerBase
run_in_cluster = False
local_run_cmd = (
"docker run --pid=host -v /etc:/etc:ro -v -t aquasec/kube-bench:latest --json /var/results.json --version 1.22 run"... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner/kube_bench.py | .py | fbebe883c3108107 | 7.35 | 4 |
import re
from dataclasses import dataclass, fields
import pandas as pd
from .scanner_evaluator import (
CheckCategory,
CheckResult,
CheckStatus,
RunUpdateGenerator,
ScannerBase,
)
CASE_PATTERN = re.compile(r"(?<!^)(?=[A-Z])")
@dataclass
class AlertObject:
priority: str
kind: str
na... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner/kubiscan.py | .py | 7bf8ad8e81392ab2 | 7.35 | 4 |
import json
import os
import shlex
import subprocess
from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import auto
from pathlib import Path
from typing import Generator, Optional, Union
from loguru import logger
from strenum import LowercaseStrEnum, StrEnum
from ...utils.constants import... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner/scanner_evaluator.py | .py | 3efcbbbfc26c159f | 7.35 | 4 |
from typing import Tuple
from loguru import logger
from kalm_benchmark.utils.path_normalization import normalize_snyk_path
from ...utils.eval_utils import (
fix_path_to_current_environment,
get_difference_in_parent_path,
)
from ..file_index import FileIndex
from .scanner_evaluator import CheckResult, CheckSt... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner/snyk.py | .py | d5493dd4a48a513a | 7.35 | 4 |
import difflib
import importlib
import pkgutil
from typing import Optional
from loguru import logger
import kalm_benchmark.evaluation.scanner as scanner_ns
from .scanner.scanner_evaluator import ScannerBase
class ScannerManager:
"""Plugin-based manager for security scanner tools.
Automatically discovers a... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner_manager.py | .py | 04e0250f110b93cb | 7.35 | 4 |
from kalm_benchmark.evaluation.ccss.ccss_models import MisconfigurationFinding, SourceType
from loguru import logger
from kalm_benchmark.utils.helm_metrics import create_helm_evaluation_summary
from ..utils.constants import (
DEFAULT_DATABASE_RETENTION_RUNS,
DEFAULT_PERFORMANCE_HISTORY_LIMIT,
)
from .ccss.ccs... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/evaluation/scanner_service.py | .py | 48c14d10159b4262 | 7.35 | 4 |
from cdk8s import Chart
from constructs import Construct
from ..utils.data.validation import sanitize_kubernetes_name as sanitize_name
from kalm_benchmark.utils.scoring import ccss_severity_from_base_score
from .cdk8s_imports import k8s
from .constants import MAIN_NS, CheckKey, CheckStatus
class Check(Chart):
""... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/manifest_generator/check.py | .py | 4f666776759ed5c9 | 7.35 | 4 |
from pathlib import Path
from cdk8s import App, Chart, YamlOutputType
from constructs import Construct
from kalm_benchmark.manifest_generator.check import Meta
from .cdk8s_imports import k8s
from .constants import MAIN_NS, UNRESTRICTED_NS
from .gen_namespaces import (
SetupBenchmarkNamespace,
gen_namespace_r... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/manifest_generator/gen_manifests.py | .py | 89162705fe50f4a4 | 7.35 | 4 |
from constructs import Construct
from loguru import logger
from .cdk8s_imports import k8s
class NetworkPolicy(Construct):
"""
A cdk8s building block wrapping a Kubernetes NetworkPolicy
"""
def __init__(
self,
scope: Construct,
name: str,
meta: k8s.ObjectMeta,
... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/manifest_generator/network_policy.py | .py | 0657c895217acb96 | 7.35 | 4 |
import re
from typing import Any
def sanitize_name(name: str, max_len: int = 253) -> str:
"""
Valid resource names must be valid DNS subdomain names as defined in RFC 1123
See: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
:param name: the string which will be sanitized
... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/manifest_generator/utils.py | .py | e68a0777ea3ea04f | 7.35 | 4 |
from constructs import Construct
from ..cdk8s_imports import k8s
from ..constants import (
AppArmorProfile,
ContainerConfig,
PodSchedulingConfig,
PodSecurityConfig,
SeccompProfile,
SeccompProfileForPSP,
)
from ..rbac import ServiceAccount
from ..utils import ensure_list
def _create_container_... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/manifest_generator/workload/pod_base.py | .py | 2dbb522a0efc0c5c | 7.35 | 4 |
import altair as alt
import pandas as pd
import streamlit as st
from kalm_benchmark.utils.data.normalization import (
normalize_scanner_name as _normalize_scanner_name,
)
PERFORMANCE_CONFIG = {
"medals": ["🥇", "🥈", "🥉"],
"color_thresholds": [
(0.8, "#28a745", "excellent"),
(0.6, "#ffc10... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/ui/analytics/performance_utils.py | .py | 1ebefae11d8e8b59 | 7.35 | 4 |
import streamlit as st
from loguru import logger
from kalm_benchmark.evaluation.evaluation import (
Col,
EvaluationSummary,
Metric,
create_summary,
evaluate_scanner,
)
from kalm_benchmark.utils.constants import CUSTOM_CHECKS_LABEL
from kalm_benchmark.utils.helm_benchmark_mapper import (
create_... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/ui/analytics/scanner_evaluation.py | .py | d8ed22e00720db0f | 7.35 | 4 |
import pandas as pd
import streamlit as st
from loguru import logger
from kalm_benchmark.ui.visualization.chart_utils import create_severity_pie_chart
from kalm_benchmark.utils.constants import (
EXCELLENT_COLOR,
EXCELLENT_SCORE_THRESHOLD,
GOOD_COLOR,
GOOD_SCORE_THRESHOLD,
NEEDS_IMPROVEMENT_COLOR,
... | dynatrace-oss/Kalm-Benchmark | kalm_benchmark/ui/components.py | .py | 39c181264110a677 | 7.35 | 4 |
from dataclasses import dataclass, field
from functools import cached_property, lru_cache
import heapq
from typing import List, Set, Dict, Tuple
from sowpods import SOWPODS
import string
@dataclass(frozen = True)
class Letterboxed():
puzzle_string: str
dictionary: Tuple[str] = field(default_factory=lambda: tu... | simeydk/letterboxed | letterboxed.py | .py | b0036925bfcb8aca | 7.15 | 1 |
import os, json
import requests
from bs4 import BeautifulSoup
def json_to_file(data, filename: str) -> None:
location = os.path.split(filename)[0]
os.makedirs(location, exist_ok=True)
with open(filename, 'w') as f:
f.write(json.dumps(data, indent=2))
def fetch(url: str) -> str:
return reques... | simeydk/letterboxed | src/scrape.py | .py | d944b5d598157829 | 7.15 | 1 |
import datetime
import math
import pandas
import torch
from typing import Union
from ufc_almanac.globals import (
MATCHUP_DAYS_SINCE_LAST_FIGHT_SIZE,
MATCHUP_FIGHTER_PROFILE_FEATURE_SIZE,
MATCHUP_STATIC_FEATURE_SIZE,
METHOD_RECORD_FEATURE_SIZE,
OUTCOME_LABELS,
OUTCOME_METHOD_LABELS,
RECENCY... | Sam-Armstrong/UFC-Almanac | ufc_almanac/data/utils.py | .py | b4adc99d4fa5f289 | 7.39 | 5 |
import os
FIGHTER_DATA_CSV = "data/FighterData.csv"
RESULTS_CSV = "data/FightResults.csv"
STATS_CSV = "data/FightStats.csv"
STANDARD_TRAINING_DATA_PATH = "data/StandardTrainingData.pt"
TRANSFORMER_STANDARD_TRAINING_DATA_PATH = "data/TransformerTrainingData.pt"
CHECKPOINTS_DIR = "artifacts/checkpoints"
CORE_TRANSFORME... | Sam-Armstrong/UFC-Almanac | ufc_almanac/globals.py | .py | 5900162baf643fd6 | 7.39 | 5 |
from pathlib import Path
import torch
from typing import Optional, Union
from ufc_almanac.globals import CHECKPOINTS_DIR
def get_device() -> torch.device:
"""
Get the device to use for training and inference.
"""
if torch.cuda.is_available():
return torch.device("cuda")
elif torch.backend... | Sam-Armstrong/UFC-Almanac | ufc_almanac/helpers.py | .py | 02fc7b33b239d3aa | 7.39 | 5 |
from pathlib import Path
import torch
from typing import Any, Optional, Union
from ufc_almanac.globals import NUM_CLASSES
def is_modern_transformer_checkpoint(state_dict: dict[str, torch.Tensor]) -> bool:
"""
Return True when a checkpoint matches the current transformer architecture.
"""
return "stat... | Sam-Armstrong/UFC-Almanac | ufc_almanac/inference/utils.py | .py | 383fd9db00cfb742 | 7.39 | 5 |
import math
import torch
import torch.nn as nn
from ufc_almanac.globals import (
MATCHUP_FEATURE_SIZE,
MAX_FIGHTS,
NUM_CLASSES,
TRANSFORMER_FIGHT_FEATURE_SIZE,
TRANSFORMER_STATIC_FEATURE_SIZE,
)
DAYS_PER_YEAR = 365.25
def sinusoidal_encoding(values: torch.Tensor, d_model: int) -> torch.Tensor:
... | Sam-Armstrong/UFC-Almanac | ufc_almanac/models/transformer.py | .py | ee788939da0ec0d3 | 7.39 | 5 |
import datetime
import os
import pandas
from ufc_almanac.globals import RESULTS_CSV, STATS_CSV, VERBOSE
# Local #
def _parse_csv_date(date_text: str) -> datetime.date:
"""Parse a stored fight date such as '20/11/2021'."""
return datetime.datetime.strptime(str(date_text).strip(), "%d/%m/%Y").date()
def _par... | Sam-Armstrong/UFC-Almanac | ufc_almanac/scraping/utils.py | .py | 2b7ede3e62967cdd | 7.39 | 5 |
from pathlib import Path
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from tqdm import tqdm
from typing import Any, Union
from ufc_almanac.globals import (
MATCHUP_UNNORMALIZED_INDICES,
STANDARD_TRAINING_DATA_PATH,
TRANSFORMER_UNNORMALIZED_INDICES,
... | Sam-Armstrong/UFC-Almanac | ufc_almanac/training/utils.py | .py | ea23afadd2fc8334 | 7.39 | 5 |
"""Build the Skene mirrors, once, out of band.
Every line in the suite except ClickBench-parquet runs on Skene, including JOB
and H2O — which upstream ship as rows, not files, so the format was always the
harness's choice and is now made once here rather than differing per benchmark.
The conversion is opteryx-core's ... | mabel-dev/wrenchy-bench | corpus/convert.py | .py | 48360222b3e624f7 | 7 | 0 |
"""Per-query resource telemetry: peak RSS, CPU time, block I/O, faults.
Stdlib only, no third-party imports, so this file can be vendored straight
into `opteryx-core/tests/performance/` and imported by the runners without
touching that repo's zero-dependency rule.
Two ways in:
* ``Probe`` — wraps a single query in... | mabel-dev/wrenchy-bench | harness/probe.py | .py | a077a44dba5a5662 | 7 | 0 |
"""Fold a run bundle into the committed history, detect regressions, write the site data.
Deliberately compares against the JSON history committed in this repo rather
than querying opteryx.benchmarks.telemetry. The suite must not depend on the
thing it measures: the weeks you most want the numbers are exactly the week... | mabel-dev/wrenchy-bench | harness/report.py | .py | ecdac33633e3a791 | 7 | 0 |
"""Drive the seven lines and write the run bundle.
Runs on the benchmark box. Each line is a separate `bench_runner.py` process —
a fresh interpreter and a fresh allocator arena per line, so one line's
fragmentation cannot be charged to the next. Lines run strictly serially: two
benchmarks sharing 16 vCPU measure each... | mabel-dev/wrenchy-bench | harness/run_suite.py | .py | ac40e97bfef42ed3 | 7 | 0 |
"""Launch the weekly benchmark instance. Fired by EventBridge Scheduler.
Replaces the GitHub Actions launch job. The point is not fewer parts — it is
roughly parts-neutral — but that nothing outside this AWS account can start an
EC2 instance in it. There is no OIDC provider and no external principal with
`ec2:RunInsta... | mabel-dev/wrenchy-bench | infra/lambda/launch.py | .py | 2b66726d6c6c267e | 7 | 0 |
"""Local (Ollama) skill/competency extraction pipeline.
Synchronous loop — no Batch API. For each posting that needs extraction, ask the
local model to fill the JobSkills schema (enforced via Ollama's structured-output
`format`), validate the result with Pydantic, stamp provenance we own, and bulk-
write in chunks. Re... | ryq99/linkedin-jobs-scraper | info_extractor/src/extract.py | .py | c9898969e83bbefa | 7.39 | 5 |
"""Prompt assembly for skill/competency extraction.
Pure functions only (no network/DB) so they're trivially unit-testable. Allowed
values for every categorical field come from the schema enums — one vocabulary,
defined once in schema.py — so the prompt can never drift from what JobSkills
will actually validate.
Smal... | ryq99/linkedin-jobs-scraper | info_extractor/src/prompt.py | .py | 901e9b79fe8ffcb5 | 7.39 | 5 |
"""Typed record extracted from a job_description by the info_extractor.
One JobSkills per posting, keyed by job_id back to the scraped `jobs` table.
JobSkills is a Pydantic model (not a stdlib dataclass) because it validates
untrusted LLM output: the enum-typed fields reject values Claude invents, and
`model_json_sche... | ryq99/linkedin-jobs-scraper | info_extractor/src/schema.py | .py | 14f98b52e6889a79 | 7.39 | 5 |
"""SQLite persistence for extracted JobSkills.
Writes one `job_skills` row per posting into the shared `data/jobs.db`: the
scraper owns `jobs`, this module owns `job_skills`, keyed `job_id` back to it.
Reads `jobs.job_description` via raw SQL (no import of the scraper's schema) so
the component stays self-contained.
"... | ryq99/linkedin-jobs-scraper | info_extractor/src/store.py | .py | b047ded160ac2f2e | 7.39 | 5 |
#!/usr/bin/env python3
"""One-time migration of historical v1 scrapes (8 columns) to the current schema.
Usage: python scripts/backfill_v1.py {tag|archive|fetch|transform|seed|s3-up|hf-push|card|all}
Phases are resumable and idempotent. Raw data is never destroyed: S3 originals
are archived to raw_v1/ first and the p... | ryq99/linkedin-jobs-scraper | job_scraper/scripts/backfill_v1.py | .py | 4f221fa68c73e92a | 7.39 | 5 |
"""Playwright session management: persistent profile, request blocking, tracing."""
import logging
from playwright.sync_api import BrowserContext, Page, sync_playwright
import config
log = logging.getLogger("browser")
# No scrapeable text in these; blocking them cuts page weight dramatically.
# Logo URLs survive: ... | ryq99/linkedin-jobs-scraper | job_scraper/src/browser.py | .py | d832b76cd7925172 | 7.39 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.