diff --git a/.gitignore b/.gitignore index aa003ec..2ad261c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,118 @@ -__pycache__/ -*.py[cod] -*$py.class -*.log -.venv/ -venv/ -.DS_Store +# --------------------------------------------------------------------------- +# Credentials and secrets — never commit these. +# +# Note: the remote URL in .git/config may embed a username and password. That +# file is local-only and is never pushed, but it does mean `git remote -v` +# prints your password to the terminal. Prefer a credential helper or a token. +# --------------------------------------------------------------------------- +.env +.env.* +*.env +!.env.example +secrets.json +credentials.json +*.credentials +.netrc +.htpasswd +*.pem +*.key +!*.pub +id_rsa* +id_ed25519* +*.p12 +*.pfx +*_token +*.token +token.txt +auth.json -# persistent telemetry store +# --------------------------------------------------------------------------- +# Local machine state — paths, tuning and service config specific to one host. +# Commit the .example variants instead. +# --------------------------------------------------------------------------- +*.local.json +*.local.sh +settings.local.* +config.local.* +overclock_profiles.local.json +hyperswap.conf +.hyperswap_env + +# --------------------------------------------------------------------------- +# Persistent telemetry store (SQLite + WAL sidecars). +# Grows ~0.4 MB/hour; contains this machine's hardware history, not source. +# --------------------------------------------------------------------------- hyperswap.db hyperswap.db-wal hyperswap.db-shm +*.sqlite +*.sqlite3 +*.db-journal + +# --------------------------------------------------------------------------- +# Logs and captured run output +# --------------------------------------------------------------------------- +*.log +logs/ +manager.log +nohup.out + +# --------------------------------------------------------------------------- +# Benchmark, sweep and profiling artefacts +# --------------------------------------------------------------------------- +sweep_*.json +autotune_*.json +pl_*.json +benchmark_*.json +*.prof +*.pstats +perf.data* + +# --------------------------------------------------------------------------- +# Backups and scratch files (timestamped .bak files have appeared here before) +# --------------------------------------------------------------------------- +*.bak +*.bak-* +*.backup +*.pre-tuning +*.orig +*.rej +*.tmp +*.swp +*.swo +*~ +.#* +scratch/ +tmp/ + +# --------------------------------------------------------------------------- +# Python +# --------------------------------------------------------------------------- +__pycache__/ +*.py[cod] +*$py.class +*.so +.venv/ +venv/ +env/ +.Python +build/ +dist/ +*.egg-info/ +.eggs/ +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ +.coverage +htmlcov/ +.tox/ + +# --------------------------------------------------------------------------- +# Editors and OS +# --------------------------------------------------------------------------- +.vscode/ +.idea/ +*.iml +.DS_Store +Thumbs.db +desktop.ini diff --git a/ram_optimizer.py b/ram_optimizer.py index 0a452ef..e29b782 100644 --- a/ram_optimizer.py +++ b/ram_optimizer.py @@ -27,7 +27,8 @@ logger = logging.getLogger("ram_optimizer") OLLAMA_API_BASE = "http://localhost:11434" COMFY_API_BASE = "http://127.0.0.1:8188" -COMFY_MODELS_DIR = os.environ.get("HYPERSWAP_COMFY_MODELS", "/home/drjones/ComfyUI/models") +COMFY_MODELS_DIR = os.environ.get( + "HYPERSWAP_COMFY_MODELS", os.path.expanduser("~/ComfyUI/models")) OLLAMA_MODEL_DIRS = [ "/usr/share/ollama/.ollama/models", os.path.expanduser("~/.ollama/models"), diff --git a/server.py b/server.py index e89d7d1..4a2fc00 100644 --- a/server.py +++ b/server.py @@ -3,6 +3,7 @@ import asyncio import contextlib import json import logging +import os import signal import time from contextlib import asynccontextmanager @@ -28,7 +29,7 @@ logger = logging.getLogger("model_manager_server") logging.getLogger("httpx").setLevel(logging.WARNING) logging.getLogger("httpcore").setLevel(logging.WARNING) -BASE_DIR = "/home/drjones/unified-model-manager" +BASE_DIR = os.environ.get("HYPERSWAP_BASE_DIR", os.path.dirname(os.path.abspath(__file__))) # ========================================== diff --git a/start_manager.sh b/start_manager.sh index 66ae44f..4417efa 100755 --- a/start_manager.sh +++ b/start_manager.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# Launch the HyperSwap server. Override HYPERSWAP_PYTHON to use a different interpreter. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" -exec /home/drjones/comfy-mcp-venv/bin/python server.py +PYTHON="${HYPERSWAP_PYTHON:-$HOME/comfy-mcp-venv/bin/python}" +[ -x "$PYTHON" ] || PYTHON="$(command -v python3)" +exec "$PYTHON" server.py