* feat: add Runpod serverless image collector pools * fix: prevent worker settings clipping and remove preview copy * fix: initialize worker settings before mounting the form * fix: validate complete serverless requests against 10 MB limit * fix: simplify serverless cards and keep status dots circular * fix: match serverless endpoint box to master card * fix: preserve serverless capacity and recovery across job failures Retain durable reservations until provider termination or explicit recovery, protect unresolved pools and credentials, and add scoped reconciliation. Consolidate lifecycle and secret policies and split prompt/media stages with regression coverage. * fix(serverless): disable Clear saved API key while the worker is enabled The checkbox read "Clear saved API key (disable pool first)", but the panel never defines "pool" and saving with it ticked on an enabled worker was rejected by the backend. - Disable the checkbox while the worker is enabled, with a tooltip saying to turn the worker off first. Also disable it when no key is saved. - Use "worker" instead of "pool" in user-facing serverless errors, the serverless guide and the README entry. * feat(serverless): replace Concurrent jobs with a single Images per run setting - Remove the separate Concurrent jobs field; rename Jobs per run to Images per run (1-16) with a tooltip explaining that Runpod's max workers decides how many GPUs run them. - Backend uses a fixed per-worker limit of 16 outstanding jobs, so all images of a run are submitted at once. Unresolved jobs still count against it. The limit is constant, so it never has to change while jobs are unresolved. - Legacy 'concurrency' in saved configs and older browser tabs is accepted and ignored/dropped; it no longer triggers the busy guard. - Revert the enable toggle and show the reason when the backend rejects it. - Trim a pasted api.runpod.ai/v2/<id> URL to the endpoint ID; plainer endpoint-ID error otherwise. - Confirm before a type change deletes a saved Runpod API key. - Update docs and tests.
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
import os
|
|
import platform
|
|
import uuid
|
|
|
|
import aiohttp
|
|
|
|
from ..utils.network import normalize_host, get_client_session
|
|
from ..utils.logging import debug_log
|
|
|
|
|
|
async def is_local_worker(worker_config):
|
|
"""Check if a worker is running on the same machine as the master."""
|
|
if worker_config.get('type') == 'serverless':
|
|
return False
|
|
host = normalize_host(worker_config.get('host', 'localhost')) or 'localhost'
|
|
if host in ['localhost', '127.0.0.1', '0.0.0.0', ''] or worker_config.get('type') == 'local':
|
|
return True
|
|
|
|
# For cloud workers, check if on same physical host
|
|
if worker_config.get('type') == 'cloud':
|
|
return await is_same_physical_host(worker_config)
|
|
|
|
return False
|
|
|
|
async def is_same_physical_host(worker_config):
|
|
"""Compare machine IDs to determine if worker is on same physical host."""
|
|
try:
|
|
# Get master machine ID
|
|
master_machine_id = get_machine_id()
|
|
|
|
# Fetch worker's machine ID via API
|
|
host = normalize_host(worker_config.get('host', 'localhost')) or 'localhost'
|
|
port = worker_config.get('port', 8188)
|
|
|
|
session = await get_client_session()
|
|
async with session.get(
|
|
f"http://{host}:{port}/distributed/system_info",
|
|
timeout=aiohttp.ClientTimeout(total=5)
|
|
) as resp:
|
|
if resp.status == 200:
|
|
data = await resp.json()
|
|
worker_machine_id = data.get('machine_id')
|
|
return worker_machine_id == master_machine_id
|
|
else:
|
|
debug_log(f"Failed to get system info from worker: HTTP {resp.status}")
|
|
return False
|
|
except Exception as e:
|
|
debug_log(f"Error checking same physical host: {e}")
|
|
return False
|
|
|
|
def get_machine_id():
|
|
"""Get a unique identifier for this machine."""
|
|
# Try multiple methods to get a stable machine ID
|
|
try:
|
|
# Method 1: MAC address-based UUID
|
|
return str(uuid.getnode())
|
|
except Exception:
|
|
try:
|
|
# Method 2: Platform + hostname
|
|
import socket
|
|
return f"{platform.machine()}_{socket.gethostname()}"
|
|
except Exception:
|
|
# Fallback
|
|
return platform.machine()
|
|
|
|
def is_docker_environment():
|
|
"""Check if running inside Docker container."""
|
|
return (os.path.exists('/.dockerenv') or
|
|
os.environ.get('DOCKER_CONTAINER', False) or
|
|
'docker' in platform.node().lower())
|
|
|
|
def is_runpod_environment():
|
|
"""Check if running in Runpod environment."""
|
|
return (os.environ.get('RUNPOD_POD_ID') is not None or
|
|
os.environ.get('RUNPOD_API_KEY') is not None)
|