repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/setup.py
setup.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/test_functions.py
tests/test_functions.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/test_conformers.py
tests/test_conformers.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/test_watchers.py
tests/test_watchers.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/test_cli.py
tests/test_cli.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/test_api.py
tests/test_api.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/tests/__init__.py
tests/__init__.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/conformers.py
qtsass/conformers.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/importers.py
qtsass/importers.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/api.py
qtsass/api.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/cli.py
qtsass/cli.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/__main__.py
qtsass/__main__.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/__init__.py
qtsass/__init__.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/functions.py
qtsass/functions.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/watchers/api.py
qtsass/watchers/api.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/watchers/polling.py
qtsass/watchers/polling.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/watchers/qt.py
qtsass/watchers/qt.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/watchers/__init__.py
qtsass/watchers/__init__.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
spyder-ide/qtsass
https://github.com/spyder-ide/qtsass/blob/295e295bf3062c24135458ed300a6b7ced8e2ae7/qtsass/watchers/snapshots.py
qtsass/watchers/snapshots.py
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2015 Yann Lanthony # Copyright (c) 2017-2018 Spyder Project Contributors # # Licensed under the terms of the MIT License # (See LICENSE.txt for details) # ---------------------------------------------...
python
MIT
295e295bf3062c24135458ed300a6b7ced8e2ae7
2026-01-05T07:11:18.971368Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/get_default_thread.py
get_default_thread.py
import os def get_default_thread() -> int: """_summary_ Automatically get the default number of threads to use for generation """ count = os.cpu_count() if count is not None: return int(count / 2) else: return 8
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/get_config.py
get_config.py
from ctransformers import Config from request_body import ChatCompletionRequestBody, CompletionRequestBody from get_env import get_env, get_env_or_none from get_default_thread import get_default_thread from log import log from const import DEFAULT_MAX_TOKENS, DEFAULT_CONTEXT_LENGTH THREADS = int(get_env("THREADS", st...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/log.py
log.py
import logging from get_env import get_env from const import DEFAULT_LOG_LEVEL LOGGING_LEVEL = get_env("LOGGING_LEVEL", DEFAULT_LOG_LEVEL) log = logging.getLogger("uvicorn") try: log.setLevel(LOGGING_LEVEL) except ValueError: log.setLevel(DEFAULT_LOG_LEVEL)
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/const.py
const.py
DEFAULT_MAX_TOKENS = "512" DEFAULT_CONTEXT_LENGTH = "4096" DEFAULT_LOG_LEVEL = "INFO"
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/main.py
main.py
"""_summary_ This module contains the main FastAPI application. """ import os from typing import ( Awaitable, Callable, Union, Annotated, ) from fastapi import FastAPI, Depends, HTTPException, Body, Request, status from fastapi.exceptions import RequestValidationError from fastapi.responses import JSO...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/get_model_type.py
get_model_type.py
from get_env import get_env def get_model_type( filename: str, ) -> str: ctransformer_model_type = "llama" filename = filename.lower() # These are also in "starcoder" format # https://huggingface.co/TheBloke/WizardCoder-15B-1.0-GGML # https://huggingface.co/TheBloke/minotaur-15B-GGML if ( ...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/model_generate.py
model_generate.py
from time import time from ctransformers import LLM, Config from log import log def model_generate( prompt: str, model_name: str, llm: LLM, config: Config, ): """_summary_ returns the response body for /chat/completions """ created = time() top_k = config.top_k log.debug("top...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/streamers.py
streamers.py
import json from os import times from ctransformers import LLM, Config from log import log from get_env import get_env from const import DEFAULT_CONTEXT_LENGTH, DEFAULT_LOG_LEVEL def completions_streamer( prompt: str, model_name: str, llm: LLM, config: Config, ): """_summary_ returns a genera...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/request_body.py
request_body.py
from typing import ( Any, Literal, List, Optional, ) from pydantic import BaseModel, Field class CompletionRequestBody(BaseModel): """_summary_ from from https://github.com/abetlen/llama-cpp-python/blob/main/llama_cpp/server/app.py """ prompt: str = Field( default="", descript...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/truncate.py
truncate.py
from get_env import get_env_or_none def truncate(string, beginning=True): """Shorten the given string to the given length. :Parameters: length (int) = The maximum allowed length before truncating. beginning (bool) = Trim starting chars, else; ending. :Return: (str) ex. call: ...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/get_env.py
get_env.py
import os def get_env(key: str, default_value: str): """_summary_ Fallback to default of the env get by key is not set or is empty string """ env = os.environ.get(key) if env is None or len(env) == 0: return default_value else: return env def get_env_or_none(key: str): """...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/response_body.py
response_body.py
from typing import Literal from pydantic import BaseModel class Message(BaseModel): """_summary_ Args: BaseModel (_type_): message in choice """ role: Literal["system", "user", "assistant"] content: str class Choice(BaseModel): """_summary_ Args: BaseModel (_type_): ch...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/examples/openai/stream.py
examples/openai/stream.py
import openai import time openai.api_key = "placeholder_to_avoid_exception" # needed to avoid an exception openai.api_base = "http://localhost:8000/v1" # this is the public address of the ialacol server # Rest are from https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb # # Ex...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
chenhunghan/ialacol
https://github.com/chenhunghan/ialacol/blob/410f6729b6d3a3829fc16b720b0f71af4ec458d2/examples/openai/simple.py
examples/openai/simple.py
import openai openai.api_key = "placeholder_to_avoid_exception" # needed to avoid an exception openai.api_base = "http://localhost:8000/v1" # this is the public address of the ialacol server # create a chat completion chat_completion = openai.ChatCompletion.create( model="pythia-70m-q4_0.bin", messages=[{"role": ...
python
MIT
410f6729b6d3a3829fc16b720b0f71af4ec458d2
2026-01-05T07:11:19.135150Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/test_data.py
test_data.py
import json import os import time from copy import deepcopy from contextlib import ExitStack, contextmanager import importlib from pathlib import Path from unittest.mock import patch import pytest from config import ( EXTERNAL_SPOOL_AMS_ID, EXTERNAL_SPOOL_ID, ) from spoolman_service import augmentTrayDataWithS...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/print_history.py
print_history.py
import os import sqlite3 from datetime import datetime from pathlib import Path DEFAULT_DB_NAME = "3d_printer_logs.db" DB_ENV_VAR = "OPENSPOOLMAN_PRINT_HISTORY_DB" def _default_db_path() -> Path: """Resolve the print history database path, allowing an env override.""" env_path = os.getenv(DB_ENV_VAR) if...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/filament.py
filament.py
# mapping adapted from https://github.com/spuder/OpenSpool/blob/main/firmware/conf.d/automation.yaml from logger import log def generate_filament_brand_code(filament_type, filament_brand, filament_variant): filament_sub_brand = "" filament_brand_code = "" if filament_type == "TPU": if filament_brand == "Bamb...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/logger.py
logger.py
import os import time import re import builtins from datetime import datetime def append_to_rotating_file(file_path: str, text: str, max_size: int = 1_048_576, max_files: int = 5) -> None: """ Appends the given text with a timestamp to a rotating log file. If the file exceeds the maximum size, it is rename...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/spoolman_client.py
spoolman_client.py
import requests from config import SPOOLMAN_API_URL, SPOOL_SORTING import json from logger import append_to_rotating_file, log SPOOLMAN_LOG_FILE = "/home/app/logs/spoolman.log" def _log_spoolman_change(action, spool_id=None, payload=None, status=None): parts = [action] if spool_id is not None: parts.append(...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/filament_usage_tracker.py
filament_usage_tracker.py
import json import math import os import tempfile import xml.etree.ElementTree as ET import zipfile from datetime import datetime, timedelta from pathlib import Path from urllib.parse import urlparse from config import EXTERNAL_SPOOL_AMS_ID, EXTERNAL_SPOOL_ID, TRACK_LAYER_USAGE from spoolman_client import consumeSpool...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/frontend_utils.py
frontend_utils.py
def color_is_dark(bg_color): # Accept only normalized six-digit hex colors (with or without '#'); everything else is safe to treat as light. if not isinstance(bg_color, str): return False color = bg_color.strip() color = color[1:] if color.startswith('#') else color if len(color) != 6: return False ...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/conftest.py
conftest.py
import pytest import test_data import socket @pytest.fixture def unused_tcp_port_factory(): """Return a factory that provides unique, currently unused TCP ports.""" allocated = set() def factory(): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind(("", 0)) ...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/mqtt_bambulab.py
mqtt_bambulab.py
import json import ssl import traceback from threading import Thread from typing import Any, Iterable import paho.mqtt.client as mqtt from config import ( PRINTER_ID, PRINTER_CODE, PRINTER_IP, AUTO_SPEND, EXTERNAL_SPOOL_ID, TRACK_LAYER_USAGE, CLEAR_ASSIGNMENT_WHEN_EMPTY, ) from messages ...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/config.py
config.py
import builtins from functools import partial import os from pathlib import Path from dotenv import load_dotenv # Load environment variables from config.env when present so live runs have access # to printer and Spoolman credentials without manual exports. load_dotenv(Path(__file__).resolve().parent / "config.env") EX...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/spoolman_service.py
spoolman_service.py
import math import re from config import ( PRINTER_ID, EXTERNAL_SPOOL_AMS_ID, EXTERNAL_SPOOL_ID, DISABLE_MISMATCH_WARNING, COLOR_DISTANCE_TOLERANCE, ) from datetime import datetime from zoneinfo import ZoneInfo from pathlib import Path from print_history import update_filament_spool import json imp...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/messages.py
messages.py
GET_VERSION = {"info": {"sequence_id": "0", "command": "get_version"}} PUSH_ALL = {"pushing": {"sequence_id": "0", "command": "pushall"}} AMS_FILAMENT_SETTING = {"print": { "sequence_id": "0", "command": "ams_filament_setting", "ams_id": None, "tray_id": None, "tray_color": None, "nozzle_temp_...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/api_routes.py
api_routes.py
import json import os import traceback from typing import Any, Dict, List, Optional, Tuple from flask import Blueprint, jsonify, request import mqtt_bambulab import spoolman_client import spoolman_service import test_data from config import EXTERNAL_SPOOL_AMS_ID, EXTERNAL_SPOOL_ID, PRINTER_ID, PRINTER_NAME API_VERSI...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/test.py
test.py
import json import re from dotenv import load_dotenv from mqtt_bambulab import processMessage from logger import log load_dotenv() def run_test(): i = 1 with open("mqtt.log", "r", encoding="utf-8") as file: for line in file: cleaned_line = re.sub(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} :: ", "", line....
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/__version__.py
__version__.py
__version__ = '0.2.0'
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tools_3mf.py
tools_3mf.py
import requests import zipfile import tempfile import xml.etree.ElementTree as ET import pycurl import urllib.parse import os import re import time import io from datetime import datetime from config import PRINTER_CODE, PRINTER_IP from urllib.parse import urlparse from logger import log def parse_ftp_listing(line): ...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/app.py
app.py
import json import math import os import traceback import uuid from collections import Counter from flask import Flask, request, render_template, redirect, url_for from config import ( BASE_URL, AUTO_SPEND, SPOOLMAN_BASE_URL, EXTERNAL_SPOOL_AMS_ID, EXTERNAL_SPOOL_ID, PRINTER_NAME, CLEAR_AS...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/wsgi.py
wsgi.py
from app import app import os if __name__ == '__main__': ADHOC_SSL = True if os.getenv('ADHOC_SSL', "").upper() == "FALSE" : ADHOC_SSL = False if ADHOC_SSL: app.run(debug=os.getenv('DEBUG', False), port=os.getenv('PORT', 8443), host=os.getenv('HOST', '0.0.0.0'), ssl_context='adhoc') ...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/scripts/generate_screenshots.py
scripts/generate_screenshots.py
import argparse import asyncio import json import os import subprocess import sys import time from dataclasses import dataclass from pathlib import Path from typing import Any import requests from logger import log # Ensure repository root is importable when executed from the scripts directory REPO_ROOT = Path(__file...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/scripts/export_live_snapshot.py
scripts/export_live_snapshot.py
import argparse import importlib import json import os import sys import time from pathlib import Path from logger import log # Ensure repository root is importable and the working directory matches the project root REPO_ROOT = Path(__file__).resolve().parent.parent if str(REPO_ROOT) not in sys.path: sys.path.inse...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/scripts/init_bambulab.py
scripts/init_bambulab.py
import requests import json from logger import log # Code from https://github.com/greghesp/ha-bambulab/issues/673#issuecomment-2455955428 # Prompt the user for their Bambu Lab username and password bambuUsername = input("Enter your Bambu Lab username: ") bambuPassword = input("Enter your Bambu Lab password: ") # Def...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tests/test_filament_mismatch.py
tests/test_filament_mismatch.py
import json import pytest import spoolman_service as svc def _make_tray(tray_type, tray_sub_brands, tray_id="tray-1"): return { "tray_type": tray_type, "tray_sub_brands": tray_sub_brands, "tray_color": "FFFFFF", "id": tray_id, } def _make_spool(material, extra_type, ams_id=...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tests/test_mqtt_replay.py
tests/test_mqtt_replay.py
import copy import json import logging import os import shutil import tempfile from pathlib import Path import pytest import mqtt_bambulab from filament_usage_tracker import FilamentUsageTracker import tools_3mf import spoolman_client import spoolman_service from config import TRACK_LAYER_USAGE LOG_ROOT = Path(__fi...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tests/test_screenshots.py
tests/test_screenshots.py
import asyncio import os from pathlib import Path import pytest from scripts import generate_screenshots as gs @pytest.mark.screenshots def test_seeded_screenshots(request, unused_tcp_port_factory): """Optionally generate the documentation screenshots via pytest. Run with ``pytest -m screenshots --generate...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tests/test_ams_model_detection.py
tests/test_ams_model_detection.py
import mqtt_bambulab def test_identifies_ams_lite_module(): module = {"name": "ams_f1/0", "product_name": "AMS Lite"} assert mqtt_bambulab.identify_ams_model_from_module(module) == "AMS Lite" def test_identifies_ams_2_pro_module(): module = {"name": "n3f/1", "product_name": "AMS 2 Pro (2)"} assert m...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
drndos/openspoolman
https://github.com/drndos/openspoolman/blob/c45d253a2f102354d43ef16dc316b8b7fe361d73/tests/test_tray_remaining.py
tests/test_tray_remaining.py
from jinja2 import Environment, FileSystemLoader def _render_tray(*, tray_data, ams_models_by_id): env = Environment(loader=FileSystemLoader("templates")) env.globals.update( AUTO_SPEND=False, AMS_MODELS_BY_ID=ams_models_by_id, SPOOLMAN_BASE_URL="http://spoolman", color_is_dark...
python
MIT
c45d253a2f102354d43ef16dc316b8b7fe361d73
2026-01-05T07:11:19.703247Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/make_null.py
bin/make_null.py
from Bio import SeqIO import numpy as np import random import sys AA_ALPHABET_STANDARD_ORDER = 'ARNDCQEGHILKMFPSTWYV' def make_n_random_edits( seq, nedits, min_pos=None, max_pos=None, ): """ min_pos is inclusive. max_pos is exclusive """ alphabet = AA_ALPHABET_STANDAR...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_fitness_results.py
bin/plot_fitness_results.py
from utils import * def load_data(): data = [] fname = 'data/fitness_results.txt' with open(fname) as f: header = f.readline().rstrip().split('\t') proteins = [ field.split(', ')[0] for field in header[1:] ] strains = [ field.split(', ')[1] for field in header[1:] ] for line...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/hiv.py
bin/hiv.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='HIV sequence analysis') parser.add_argument('model_name', type=str, help='Type of language model (e.g., hmm, lstm)') parser.add_argument('--na...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/locations.py
bin/locations.py
country2continent = { 'Afghanistan': 'Asia (Southern)', 'Algeria': 'Africa (Northern)', 'Anhui': 'Asia (Eastern)', 'Argentina': 'America (Southern)', 'Australia': 'Australia', 'Austria': 'Europe', 'Azerbaijan': 'Asia (Western)', 'Bangladesh': 'Asia (Southern)', 'Beijing': 'Asia (East...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/mutation.py
bin/mutation.py
from utils import * from copy import deepcopy def err_model(name): raise ValueError('Model {} not supported'.format(name)) def get_model(args, seq_len, vocab_size, inference_batch_size=1500): if args.model_name == 'hmm': from hmmlearn.hmm import MultinomialHMM model = Multinomia...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/cluster_purity.py
bin/cluster_purity.py
from utils import * def print_purity(metas, entries): for entry in entries: tprint('Calculating purity of {}'.format(entry)) cluster2entry = {} for accession in metas: meta = metas[accession] try: cluster = meta['cluster'] except: ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/cov.py
bin/cov.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='Coronavirus sequence analysis') parser.add_argument('model_name', type=str, help='Type of language model (e.g., hmm, lstm)') parser.add_argume...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/flu.py
bin/flu.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='Flu sequence analysis') parser.add_argument('model_name', type=str, help='Type of language model (e.g., hmm, lstm)') parser.add_argument('--na...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/fitness_energy.py
bin/fitness_energy.py
from utils import * from sklearn.metrics import auc def parse_args(): import argparse parser = argparse.ArgumentParser(description='Benchmark methods') parser.add_argument('method', type=str, help='Benchmarking method to use') parser.add_argument('virus', type=str, ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/cached_semantics.py
bin/cached_semantics.py
from utils import * from sklearn.metrics import auc def compute_p(true_val, n_interest, n_total, n_permutations=10000): null_distribution = [] norm = n_interest * n_total for _ in range(n_permutations): interest = set(np.random.choice(n_total, size=n_interest, ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/reinfection.py
bin/reinfection.py
from utils import * def load_to2020(): seq = str(SeqIO.read('data/cov/cov2_spike_wt.fasta', 'fasta').seq) seq = seq[:779] + 'Q' + seq[780:] muts = [ [ 'L18F', 'A222V', 'D614G', 'Q780E' ], ] mutants = { 4: [] } for i in range(len(muts)): assert(len(muts[i]) == 4) mutabl...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/TreeCluster.py
bin/TreeCluster.py
#!/usr/bin/env python3 from math import log import DisjointSet from queue import PriorityQueue,Queue from treeswift import read_tree_newick from sys import stderr NUM_THRESH = 1000 # number of thresholds for the threshold-free methods to use VERBOSE = False # merge two sorted lists into a sorted list def merge_two_sor...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/hiv_pol.py
bin/hiv_pol.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='HIV sequence analysis') parser.add_argument('model_name', type=str, help='Type of language model (e.g., hmm, lstm)') parser.add_argument('--na...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/fasta2nexus.py
bin/fasta2nexus.py
from Bio import Align, AlignIO, SeqIO, Nexus, Seq from Bio.Alphabet import IUPAC, Gapped import sys seq_set = set() records = AlignIO.read(sys.argv[1], 'fasta', alphabet=Gapped(IUPAC.protein)) new_records = [] for idx in range(len(records)): seq = str(records[idx].seq).replace('J', 'L').replace('B', 'N').replace(...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/fb_model.py
bin/fb_model.py
import torch from esm import Alphabet, FastaBatchedDataset, ProteinBertModel, pretrained class FBModel(object): def __init__(self, name, repr_layer=[-1]): self.name_ = name self.repr_layer_ = repr_layer model, alphabet = pretrained.load_model_and_alphabet(name) model.eval() ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/hmm.py
bin/hmm.py
from hmmlearn.hmm import MultinomialHMM def fit(seqs, n_components=1): MultinomialHMM( n_components=n_components, startprob_prior=1.0, transmat_prior=1.0, algorithm='viterbi', random_state=1, n_iter=100, tol=0.01, verbose=True, params='ste', ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/color_protein.py
bin/color_protein.py
from utils import * import matplotlib def write_color(chain, resi, acq, of): cmap = matplotlib.cm.get_cmap('viridis') of.write('select toColor, resi {} and chain {}\n' .format(resi, chain)) rgb = cmap(acq) of.write('color {}, toColor\n' .format(matplotlib.colors.rgb2hex(rgb)...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/cov_fasta.py
bin/cov_fasta.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='Coronavirus sequence analysis') parser.add_argument('baseline_fasta', help='Baseline sequence') parser.add_argument('target_fasta', help='Sequ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_cluster_purity.py
bin/plot_cluster_purity.py
from utils import * def load_phylo(namespace=None): if namespace is None: name = 'phylo' namespace = '' else: name = namespace namespace = '_' + namespace data = [] with open('target/log/cluster_purity{}.log'.format(namespace)) as f: for line in f: l...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/fb_semantics.py
bin/fb_semantics.py
from utils import * import torch from esm import Alphabet, FastaBatchedDataset, ProteinBertModel, pretrained def predict_sequence_prob_fb( seq, alphabet, model, repr_layers, batch_size=4096, verbose=False ): seqs = [ seq ] labels = [ 'seq0' ] dataset = FastaBatchedDataset(labels, seqs) ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/utils.py
bin/utils.py
from anndata import AnnData from collections import Counter import datetime from dateutil.parser import parse as dparse import errno import math import matplotlib.pyplot as plt import numpy as np import os import pandas as pd import random import scanpy as sc from scipy.sparse import csr_matrix, dok_matrix import scipy...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/fasta2phylip.py
bin/fasta2phylip.py
from Bio import Align, AlignIO, Seq import sys seq_set = set() records = AlignIO.read(sys.argv[1], 'fasta') new_records = [] for idx in range(len(records)): seq = str(records[idx].seq).replace('J', 'L').replace('B', 'N').replace('Z', 'Q') if seq in seq_set: continue seq_set.add(seq) record = r...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/language_model.py
bin/language_model.py
from utils import * import tensorflow as tf from tensorflow.keras import Input from tensorflow.keras.callbacks import ModelCheckpoint from tensorflow.keras.layers import ( concatenate, Activation, Dense, Embedding, LSTM, Reshape) from tensorflow.keras.mixed_precision import experimental as mixed_precision from ten...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/parse_headline_mods.py
bin/parse_headline_mods.py
from utils import * from flair.data import Sentence from flair.models import SequenceTagger import nltk from nltk.corpus import wordnet as wn from pattern3.en import conjugate, singularize info_prefix = 'Original headline: ' def extract_content(line): return (': '.join(' | '.join(line.split(' | ')[1:]) ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_variants.py
bin/plot_variants.py
import matplotlib.pyplot as plt import pandas as pd import sys if __name__ == '__main__': fname = sys.argv[1] df = pd.read_csv(fname, sep='\t') plt.figure(figsize=(4, 6)) plt.scatter( df['Grammaticality'], df['Semantic change'] ) plt.xlabel('Grammaticality') plt.ylabel('Se...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/combinatorial_fitness.py
bin/combinatorial_fitness.py
from utils import Counter, SeqIO from Bio.Seq import translate import numpy as np def load_doud2016(): strain = 'h1' fname = 'data/influenza/escape_doud2018/WSN1933_H1_HA.fa' wt_seq = SeqIO.read(fname, 'fasta').seq seqs_fitness = {} fname = ('data/influenza/fitness_doud2016/' 'Suppl...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/headlines.py
bin/headlines.py
from mutation import * np.random.seed(1) random.seed(1) def parse_args(): import argparse parser = argparse.ArgumentParser(description='Headline analysis') parser.add_argument('model_name', type=str, help='Type of language model (e.g., hmm, lstm)') parser.add_argument('--namesp...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/escape.py
bin/escape.py
from utils import Seq, SeqIO def load_doud2018(survival_cutoff=0.05): pos_map = {} with open('data/influenza/escape_doud2018/pos_map.csv') as f: f.readline() # Consume header. for line in f: fields = line.rstrip().split(',') pos_map[fields[1]] = int(fields[0]) - 1 fna...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_sweep.py
bin/plot_sweep.py
from utils import * if __name__ == '__main__': fname = sys.argv[1] namespace = fname.split('.')[0].split('_')[-1] method_dict = { 'Bepler': 'Bepler and Berger', 'epistatic': 'EVcouplings (epi)', 'independent': 'EVcouplings (ind)', 'Mutation frequency': 'MAFFT MSA', ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/clustal2newick.py
bin/clustal2newick.py
import sys newick = '' with open(sys.argv[1]) as f: for line in f: fields = line.rstrip().split(':') if len(fields) == 1: newick += fields[0] else: prefix, suffix = fields newick += prefix[:30] if suffix != '': newick += ':' ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/parse_semantic_headlines.py
bin/parse_semantic_headlines.py
from utils import * def semantic_headlines(dirname): datasets = [ '1', 'A', '2', 'B' ] responses = [ '1', '2' ] data = [] for dataset in datasets: fname = ('{}/semantic_headlines_labeled_{}.csv' .format(dirname, dataset)) headline_type = {} with open(fname) as ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/escape_energy.py
bin/escape_energy.py
from utils import * from sklearn.metrics import auc def parse_args(): import argparse parser = argparse.ArgumentParser(description='Benchmark methods') parser.add_argument('method', type=str, help='Benchmarking method to use') parser.add_argument('virus', type=str, ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_reinfection.py
bin/plot_reinfection.py
from utils import * def plot_reinfection(namespace='reinfection'): with open('target/cov/reinfection/cache/cov_mut_{}.txt' .format(namespace)) as f: fields = f.readline().rstrip().split() base_prob, base_change = float(fields[2]), float(fields[3]) n_hprob_hchange = 0 ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/newick_reformat.py
bin/newick_reformat.py
import sys newick = '' with open(sys.argv[1]) as f: orig = f.read().rstrip() orig = orig.replace('(', '(\n').replace(',', '\n,\n').replace(')', ')\n') for line in orig.split('\n'): fields = line.rstrip().split(':') if len(fields) == 0: continue elif len(fields) == 1: newick += fields...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/transformer_layers.py
bin/transformer_layers.py
import numpy as np import tensorflow as tf def get_angles(pos, i, d_model): angle_rates = 1 / np.power(10000, (2 * (i//2)) / np.float32(d_model)) return pos * angle_rates def positional_encoding(position, d_model): angle_rads = get_angles(np.arange(position)[:, np.newaxis], np....
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/mammals.py
bin/mammals.py
species2group = { 'Alpaca': 'camelid', 'Anteater': 'anteater', 'Antelope': 'bovid', 'Bat': 'bat', 'Beluga_Whale': 'cetacean', 'Bovine': 'bovid', 'Buffalo': 'bovid', 'Bulbul': 'avian', 'Bustard': 'avian', 'Camel': 'camelid', 'Cat': 'felid', 'Cattle': 'bovid', 'Chicken'...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/DisjointSet.py
bin/DisjointSet.py
#! /usr/bin/env python try: from Queue import Queue except ImportError: from queue import Queue class DisjointSet: '''``DisjointSet`` class, implemented using the Up-Tree data structure for amortized O(1) find and union operations''' def __init__(self, initial=None): '''``DisjointSet`` construct...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/benchmark_subset.py
bin/benchmark_subset.py
from Bio import AlignIO from Bio.Align import MultipleSeqAlignment import sys def msa_subset(ifname, ofname, anchor_id, cutoff=0): align = AlignIO.read(ifname, 'fasta') anchor_idx = [ align[i].id for i in range(len(align)) ].index(anchor_id) anchor = align[anchor_idx] subset = [] ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/plot_escape_results.py
bin/plot_escape_results.py
from utils import * def load_data(): data = [] fname = 'data/escape_results.txt' with open(fname) as f: header = f.readline().rstrip().split('\t') strains = [ field.split()[-1].rstrip(')') for field in header[1:] ] for line in f: fields = line.rstrip().split('\t') ...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
brianhie/viral-mutation
https://github.com/brianhie/viral-mutation/blob/81c80d41671670eb58cc46e957a1b0c4bf14856a/bin/regional_escape.py
bin/regional_escape.py
from utils import * from intervaltree import IntervalTree def load(virus): if virus == 'h1': escape_fname = ('results/flu/semantics/' 'analyze_semantics_flu_h1_bilstm_512.txt') region_fname = 'data/influenza/h1_regions.txt' elif virus == 'h3': escape_fname = ('r...
python
MIT
81c80d41671670eb58cc46e957a1b0c4bf14856a
2026-01-05T07:10:30.718940Z
false
harrisonvanderbyl/rwkvstic
https://github.com/harrisonvanderbyl/rwkvstic/blob/55826c8d0bdf89ba36bc4eb6518fa736aa479913/src/__init__.py
src/__init__.py
python
MIT
55826c8d0bdf89ba36bc4eb6518fa736aa479913
2026-01-05T07:11:22.708425Z
false