mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-08-08 05:15:46 +00:00
fix(scripts): replace bare except clauses with specific exception types (#77)
Replace 30+ bare `except:` and `except: pass` patterns across 17 files with specific exception types (OSError, ValueError, etc.) and add logging so errors are no longer silently swallowed. Changes by category: Infrastructure (surface/main.py): - GPU/process probes now catch FileNotFoundError | SubprocessError Application scripts: - API fetchers (finalize_database, final_push, bulk_10x) now catch URLError | JSONDecodeError | KeyError | OSError and print to stderr - Hardware probes (unified_hardware_surface, swarm_transport_layer) catch OSError | ValueError for /proc/meminfo reads - Backend availability checks (prover_backend_interface, hot_swap_manager) catch requests.RequestException and log at debug/warning - Code inspector (swarm_system_inspector) catches OSError | UnicodeDecodeError for file reads - Model fallback (map_all_equations) now logs the intermediate error - Minor: gpu_pist_compress → RuntimeError | ZeroDivisionError, mathlib_to_parquet → ValueError, moe_utils → OSError, quandela_remote → OSError | IndexError, topology inline scripts → ImportError, consolidate_language_databases → UnicodeDecodeError All touched files pass py_compile. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
This commit is contained in:
parent
9cdd47d290
commit
fcfaef17f3
17 changed files with 91 additions and 44 deletions
|
|
@ -6,8 +6,11 @@ import json
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
app = FastAPI(title="Sovereign Surface")
|
app = FastAPI(title="Sovereign Surface")
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
|
|
@ -37,7 +40,8 @@ def get_gpu_load():
|
||||||
res = subprocess.check_output(["nvidia-smi", "--query-gpu=utilization.gpu,memory.used,power.draw", "--format=csv,noheader,nounits"])
|
res = subprocess.check_output(["nvidia-smi", "--query-gpu=utilization.gpu,memory.used,power.draw", "--format=csv,noheader,nounits"])
|
||||||
util, mem, power = res.decode().strip().split(",")
|
util, mem, power = res.decode().strip().split(",")
|
||||||
return {"util": int(util), "mem": int(mem), "power": float(power)}
|
return {"util": int(util), "mem": int(mem), "power": float(power)}
|
||||||
except:
|
except (FileNotFoundError, subprocess.SubprocessError, ValueError) as exc:
|
||||||
|
logger.debug("nvidia-smi unavailable: %s", exc)
|
||||||
return {"util": 0, "mem": 0, "power": 0}
|
return {"util": 0, "mem": 0, "power": 0}
|
||||||
|
|
||||||
@app.get("/api/telemetry")
|
@app.get("/api/telemetry")
|
||||||
|
|
@ -49,8 +53,8 @@ async def get_telemetry():
|
||||||
res = subprocess.check_output(["ps", "-ef"])
|
res = subprocess.check_output(["ps", "-ef"])
|
||||||
if b"derive_hyper_equation.py" in res:
|
if b"derive_hyper_equation.py" in res:
|
||||||
is_deriving = True
|
is_deriving = True
|
||||||
except:
|
except (FileNotFoundError, subprocess.SubprocessError) as exc:
|
||||||
pass
|
logger.debug("ps probe failed: %s", exc)
|
||||||
|
|
||||||
# Statistical ETC: If deriving and GPU is pinned, estimate ~3-5 mins total
|
# Statistical ETC: If deriving and GPU is pinned, estimate ~3-5 mins total
|
||||||
etc = "Calculating..."
|
etc = "Calculating..."
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Targets under-filled equations first. Runs until 10x achieved or 6 hour timeout.
|
||||||
Writes incrementally so crash-tolerant.
|
Writes incrementally so crash-tolerant.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sqlite3, urllib.request, urllib.parse, json, time, os, re, random, sys
|
import sqlite3, urllib.error, urllib.request, urllib.parse, json, time, os, re, random, sys
|
||||||
|
|
||||||
DB = "/home/allaun/physics_equations.db"
|
DB = "/home/allaun/physics_equations.db"
|
||||||
|
|
||||||
|
|
@ -79,7 +79,8 @@ def cr(q, mx=5):
|
||||||
t=(i.get("title",[""])or[""])[0];y=i.get("created",{}).get("date-parts",[[0]])[0][0]
|
t=(i.get("title",[""])or[""])[0];y=i.get("created",{}).get("date-parts",[[0]])[0][0]
|
||||||
doi=i.get("DOI","");jn=(i.get("container-title",[""])or[""])[0]
|
doi=i.get("DOI","");jn=(i.get("container-title",[""])or[""])[0]
|
||||||
if t:o.append((t[:250],y,"Crossref",doi,jn))
|
if t:o.append((t[:250],y,"Crossref",doi,jn))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"crossref query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def oa(q, mx=5):
|
def oa(q, mx=5):
|
||||||
|
|
@ -94,7 +95,8 @@ def oa(q, mx=5):
|
||||||
if i.get("primary_location")and i["primary_location"].get("source"):
|
if i.get("primary_location")and i["primary_location"].get("source"):
|
||||||
jn=i["primary_location"]["source"].get("display_name","")
|
jn=i["primary_location"]["source"].get("display_name","")
|
||||||
if t:o.append((t[:250],y,"OpenAlex",doi,jn))
|
if t:o.append((t[:250],y,"OpenAlex",doi,jn))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"openalex query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def s2(q, mx=5):
|
def s2(q, mx=5):
|
||||||
|
|
@ -107,7 +109,8 @@ def s2(q, mx=5):
|
||||||
for p in d.get("data",[]):
|
for p in d.get("data",[]):
|
||||||
e=p.get("externalIds",{})or{};jn=p.get("journal",{})or{}
|
e=p.get("externalIds",{})or{};jn=p.get("journal",{})or{}
|
||||||
o.append((p.get("title","")[:250],p.get("year")or 0,"S2",e.get("DOI",""),jn.get("name","")))
|
o.append((p.get("title","")[:250],p.get("year")or 0,"S2",e.get("DOI",""),jn.get("name","")))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"s2 query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def ep(q, mx=5):
|
def ep(q, mx=5):
|
||||||
|
|
@ -121,7 +124,8 @@ def ep(q, mx=5):
|
||||||
t=i.get("title","");y=int(i.get("firstPublicationDate","0")[:4]) if i.get("firstPublicationDate") else 0
|
t=i.get("title","");y=int(i.get("firstPublicationDate","0")[:4]) if i.get("firstPublicationDate") else 0
|
||||||
doi=i.get("doi","");jn=i.get("journalTitle","")
|
doi=i.get("doi","");jn=i.get("journalTitle","")
|
||||||
if t:o.append((t[:250],y,"EuropePMC",doi,jn))
|
if t:o.append((t[:250],y,"EuropePMC",doi,jn))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"europepmc query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
# ================================================================
|
# ================================================================
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ def extract_sqlite_data(db_path: str) -> List[Dict[str, Any]]:
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
try:
|
try:
|
||||||
row_dict[key] = value.decode('utf-8', errors='ignore')
|
row_dict[key] = value.decode('utf-8', errors='ignore')
|
||||||
except:
|
except (UnicodeDecodeError, ValueError):
|
||||||
row_dict[key] = str(value)
|
row_dict[key] = str(value)
|
||||||
else:
|
else:
|
||||||
row_dict[key] = value
|
row_dict[key] = value
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Final push — target the last 6 sub-2.0 domains. Short & dense."""
|
"""Final push — target the last 6 sub-2.0 domains. Short & dense."""
|
||||||
|
|
||||||
import sqlite3, urllib.request, urllib.parse, json, time, os
|
import sqlite3, sys, urllib.error, urllib.request, urllib.parse, json, time, os
|
||||||
|
|
||||||
DB = "/home/allaun/physics_equations.db"
|
DB = "/home/allaun/physics_equations.db"
|
||||||
conn = sqlite3.connect(DB)
|
conn = sqlite3.connect(DB)
|
||||||
|
|
@ -42,7 +42,8 @@ def cr(q,mx=5):
|
||||||
t=(i.get("title",[""])or[""])[0];y=i.get("created",{}).get("date-parts",[[0]])[0][0]
|
t=(i.get("title",[""])or[""])[0];y=i.get("created",{}).get("date-parts",[[0]])[0][0]
|
||||||
doi=i.get("DOI","");jn=(i.get("container-title",[""])or[""])[0]
|
doi=i.get("DOI","");jn=(i.get("container-title",[""])or[""])[0]
|
||||||
if t:o.append((t[:250],y,"CR",doi,jn))
|
if t:o.append((t[:250],y,"CR",doi,jn))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"crossref query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def oa(q,mx=5):
|
def oa(q,mx=5):
|
||||||
|
|
@ -57,7 +58,8 @@ def oa(q,mx=5):
|
||||||
if i.get("primary_location")and i["primary_location"].get("source"):
|
if i.get("primary_location")and i["primary_location"].get("source"):
|
||||||
jn=i["primary_location"]["source"].get("display_name","")
|
jn=i["primary_location"]["source"].get("display_name","")
|
||||||
if t:o.append((t[:250],y,"OA",doi,jn))
|
if t:o.append((t[:250],y,"OA",doi,jn))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"openalex query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def s2(q,mx=5):
|
def s2(q,mx=5):
|
||||||
|
|
@ -70,7 +72,8 @@ def s2(q,mx=5):
|
||||||
for p in d.get("data",[]):
|
for p in d.get("data",[]):
|
||||||
e=p.get("externalIds",{})or{};jn=p.get("journal",{})or{}
|
e=p.get("externalIds",{})or{};jn=p.get("journal",{})or{}
|
||||||
o.append((p.get("title","")[:250],p.get("year")or 0,"S2",e.get("DOI",""),jn.get("name","")))
|
o.append((p.get("title","")[:250],p.get("year")or 0,"S2",e.get("DOI",""),jn.get("name","")))
|
||||||
except:pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"s2 query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
tasks=[(d,q)for d,qs in FINAL.items()for q in qs]
|
tasks=[(d,q)for d,qs in FINAL.items()for q in qs]
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,15 @@ Finalize physics database — all remaining TODOs.
|
||||||
6. Integrity check
|
6. Integrity check
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
import urllib.error
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -73,7 +78,8 @@ def crossref(q, mx=5):
|
||||||
y = i.get("created", {}).get("date-parts", [[0]])[0][0]
|
y = i.get("created", {}).get("date-parts", [[0]])[0][0]
|
||||||
doi = i.get("DOI", "")
|
doi = i.get("DOI", "")
|
||||||
if t: o.append((t[:250], y, doi))
|
if t: o.append((t[:250], y, doi))
|
||||||
except: pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"crossref query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def openalex(q, mx=5):
|
def openalex(q, mx=5):
|
||||||
|
|
@ -88,7 +94,8 @@ def openalex(q, mx=5):
|
||||||
y = i.get("publication_year") or 0
|
y = i.get("publication_year") or 0
|
||||||
doi = i.get("doi", "")
|
doi = i.get("doi", "")
|
||||||
if t: o.append((t[:250], y, doi))
|
if t: o.append((t[:250], y, doi))
|
||||||
except: pass
|
except (urllib.error.URLError, json.JSONDecodeError, KeyError, OSError) as exc:
|
||||||
|
print(f"openalex query failed: {exc}", file=sys.stderr)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
# Fetch papers for each open problem, update description
|
# Fetch papers for each open problem, update description
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class SystemMonitor:
|
||||||
return 0.0
|
return 0.0
|
||||||
try:
|
try:
|
||||||
return torch.cuda.memory_allocated() / torch.cuda.max_memory_allocated()
|
return torch.cuda.memory_allocated() / torch.cuda.max_memory_allocated()
|
||||||
except:
|
except (RuntimeError, ZeroDivisionError):
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def gpu_free_mb(self):
|
def gpu_free_mb(self):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import perceval as pcvl
|
import perceval as pcvl
|
||||||
import os
|
import os
|
||||||
from .backends import VirtualSubstrateBackend
|
from .backends import VirtualSubstrateBackend
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# (Assuming PercevalGeometryShaverBackend is already here)
|
# (Assuming PercevalGeometryShaverBackend is already here)
|
||||||
|
|
||||||
class QuandelaRemoteBackend(VirtualSubstrateBackend):
|
class QuandelaRemoteBackend(VirtualSubstrateBackend):
|
||||||
|
|
@ -16,8 +19,8 @@ class QuandelaRemoteBackend(VirtualSubstrateBackend):
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("QUANDELA_API_KEY"):
|
if line.startswith("QUANDELA_API_KEY"):
|
||||||
token = line.split("=")[1].strip()
|
token = line.split("=")[1].strip()
|
||||||
except:
|
except (OSError, IndexError) as exc:
|
||||||
pass
|
logger.debug("Failed to read .env for QUANDELA_API_KEY: %s", exc)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
raise ValueError("QUANDELA_API_KEY not found in .env")
|
raise ValueError("QUANDELA_API_KEY not found in .env")
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ Version: 1.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
import psutil
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -27,6 +28,8 @@ from typing import Dict, List, Optional, Any, Callable
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ModelTier(Enum):
|
class ModelTier(Enum):
|
||||||
"""Model capability tiers for swap decisions."""
|
"""Model capability tiers for swap decisions."""
|
||||||
|
|
@ -312,7 +315,8 @@ class HotSwapManager:
|
||||||
else:
|
else:
|
||||||
resources["used_vram_gb"] = 0.0
|
resources["used_vram_gb"] = 0.0
|
||||||
resources["available_vram_gb"] = 12.0
|
resources["available_vram_gb"] = 12.0
|
||||||
except:
|
except (requests.RequestException, ValueError, KeyError) as exc:
|
||||||
|
logger.warning("Failed to query Ollama for VRAM info: %s", exc)
|
||||||
resources["used_vram_gb"] = 0.0
|
resources["used_vram_gb"] = 0.0
|
||||||
resources["available_vram_gb"] = 0.0
|
resources["available_vram_gb"] = 0.0
|
||||||
|
|
||||||
|
|
@ -492,8 +496,8 @@ class HotSwapManager:
|
||||||
for callback in self.callbacks:
|
for callback in self.callbacks:
|
||||||
try:
|
try:
|
||||||
callback(event)
|
callback(event)
|
||||||
except:
|
except Exception as exc:
|
||||||
pass
|
logger.error("Swap event callback failed: %s", exc)
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ Equation List:
|
||||||
try:
|
try:
|
||||||
res = client.chat(messages, model="deepseek-r1:32b")
|
res = client.chat(messages, model="deepseek-r1:32b")
|
||||||
content = res["message"]["content"]
|
content = res["message"]["content"]
|
||||||
except:
|
except Exception as exc:
|
||||||
|
print(f"Error using deepseek-r1:32b: {exc}")
|
||||||
print("Falling back to deepseek-r1:8b...")
|
print("Falling back to deepseek-r1:8b...")
|
||||||
res = client.chat(messages, model="deepseek-r1:8b")
|
res = client.chat(messages, model="deepseek-r1:8b")
|
||||||
content = res["message"]["content"]
|
content = res["message"]["content"]
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ def get_mathlib_domain(file_path: Path) -> str:
|
||||||
try:
|
try:
|
||||||
relative = file_path.relative_to(MATHLIB_SRC_ROOT)
|
relative = file_path.relative_to(MATHLIB_SRC_ROOT)
|
||||||
return relative.parts[0] if len(relative.parts) > 1 else "Core"
|
return relative.parts[0] if len(relative.parts) > 1 else "Core"
|
||||||
except:
|
except ValueError:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
def ingest_mathlib():
|
def ingest_mathlib():
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ Supports multiple model backends: Ollama, Unsloth, Thoth, OpenAI, etc.
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
import json
|
import json
|
||||||
|
|
||||||
class ProverBackend(ABC):
|
class ProverBackend(ABC):
|
||||||
|
|
@ -60,7 +63,8 @@ class OllamaBackend(ProverBackend):
|
||||||
try:
|
try:
|
||||||
response = requests.get(f"{self.base_url}/api/tags", timeout=5)
|
response = requests.get(f"{self.base_url}/api/tags", timeout=5)
|
||||||
return response.status_code == 200
|
return response.status_code == 200
|
||||||
except:
|
except Exception as exc:
|
||||||
|
logger.debug("Ollama backend unavailable: %s", exc)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_name(self) -> str:
|
def get_name(self) -> str:
|
||||||
|
|
@ -222,7 +226,8 @@ class ThothBackend(ProverBackend):
|
||||||
try:
|
try:
|
||||||
response = requests.get(f"{self.endpoint}/health", timeout=5)
|
response = requests.get(f"{self.endpoint}/health", timeout=5)
|
||||||
return response.status_code == 200
|
return response.status_code == 200
|
||||||
except:
|
except Exception as exc:
|
||||||
|
logger.debug("Thoth backend unavailable: %s", exc)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_name(self) -> str:
|
def get_name(self) -> str:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ This script performs I/O operations (file discovery, JSON serialization)
|
||||||
and delegates all analysis decisions to the swarm agents.
|
and delegates all analysis decisions to the swarm agents.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
@ -17,6 +18,8 @@ from dataclasses import dataclass, asdict
|
||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Import from enhanced_integrated_swarm
|
# Import from enhanced_integrated_swarm
|
||||||
sys.path.insert(0, str(Path(__file__).parent))
|
sys.path.insert(0, str(Path(__file__).parent))
|
||||||
from enhanced_integrated_swarm import (
|
from enhanced_integrated_swarm import (
|
||||||
|
|
@ -212,8 +215,8 @@ class SwarmSystemInspector:
|
||||||
swarm_confidence=0.9,
|
swarm_confidence=0.9,
|
||||||
agent_recommendations=["Complete all placeholder proofs", "Remove sorry statements"]
|
agent_recommendations=["Complete all placeholder proofs", "Remove sorry statements"]
|
||||||
))
|
))
|
||||||
except:
|
except (OSError, UnicodeDecodeError) as exc:
|
||||||
pass
|
logger.warning("Cannot read Lean file %s: %s", code_file.path, exc)
|
||||||
|
|
||||||
elif code_file.language == 'python':
|
elif code_file.language == 'python':
|
||||||
# Python-specific issues (shim violations)
|
# Python-specific issues (shim violations)
|
||||||
|
|
@ -247,8 +250,8 @@ class SwarmSystemInspector:
|
||||||
swarm_confidence=0.7,
|
swarm_confidence=0.7,
|
||||||
agent_recommendations=["Check naming conventions", "Use camelCase for Lean"]
|
agent_recommendations=["Check naming conventions", "Use camelCase for Lean"]
|
||||||
))
|
))
|
||||||
except:
|
except (OSError, UnicodeDecodeError) as exc:
|
||||||
pass
|
logger.warning("Cannot read Python file %s: %s", code_file.path, exc)
|
||||||
|
|
||||||
elif code_file.language == 'rust':
|
elif code_file.language == 'rust':
|
||||||
# Rust-specific issues
|
# Rust-specific issues
|
||||||
|
|
@ -268,8 +271,8 @@ class SwarmSystemInspector:
|
||||||
swarm_confidence=0.8,
|
swarm_confidence=0.8,
|
||||||
agent_recommendations=["Document unsafe invariants", "Minimize unsafe code"]
|
agent_recommendations=["Document unsafe invariants", "Minimize unsafe code"]
|
||||||
))
|
))
|
||||||
except:
|
except (OSError, UnicodeDecodeError) as exc:
|
||||||
pass
|
logger.warning("Cannot read Rust file %s: %s", code_file.path, exc)
|
||||||
|
|
||||||
# Calculate overall quality score
|
# Calculate overall quality score
|
||||||
quality_score = swarm_state.overall_system_score
|
quality_score = swarm_state.overall_system_score
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ Usage:
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
@ -30,6 +31,8 @@ from enum import Enum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Add paths
|
# Add paths
|
||||||
sys.path.insert(0, '/home/allaun/Documents/Research Stack/scratch/exploit_recovery/5-Applications/tools-scripts/mining')
|
sys.path.insert(0, '/home/allaun/Documents/Research Stack/scratch/exploit_recovery/5-Applications/tools-scripts/mining')
|
||||||
sys.path.insert(0, str(Path(__file__).parent))
|
sys.path.insert(0, str(Path(__file__).parent))
|
||||||
|
|
@ -354,7 +357,8 @@ class SwarmTransportLayer:
|
||||||
# Detect CPU cores
|
# Detect CPU cores
|
||||||
try:
|
try:
|
||||||
capabilities['cpu_cores'] = os.cpu_count() or 4
|
capabilities['cpu_cores'] = os.cpu_count() or 4
|
||||||
except:
|
except OSError as exc:
|
||||||
|
logger.debug("Failed to detect CPU cores: %s", exc)
|
||||||
capabilities['cpu_cores'] = 4
|
capabilities['cpu_cores'] = 4
|
||||||
|
|
||||||
# Detect memory
|
# Detect memory
|
||||||
|
|
@ -365,7 +369,8 @@ class SwarmTransportLayer:
|
||||||
mem_kb = int(line.split()[1])
|
mem_kb = int(line.split()[1])
|
||||||
capabilities['memory_gb'] = mem_kb / (1024 * 1024)
|
capabilities['memory_gb'] = mem_kb / (1024 * 1024)
|
||||||
break
|
break
|
||||||
except:
|
except (OSError, ValueError) as exc:
|
||||||
|
logger.debug("Failed to read /proc/meminfo: %s", exc)
|
||||||
capabilities['memory_gb'] = 8
|
capabilities['memory_gb'] = 8
|
||||||
|
|
||||||
self.node_capabilities = capabilities
|
self.node_capabilities = capabilities
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ try:
|
||||||
torch_ver = torch.__version__
|
torch_ver = torch.__version__
|
||||||
cuda = torch.cuda.is_available()
|
cuda = torch.cuda.is_available()
|
||||||
gpu_name = torch.cuda.get_device_name(0) if cuda else None
|
gpu_name = torch.cuda.get_device_name(0) if cuda else None
|
||||||
except:
|
except ImportError:
|
||||||
torch_ver = None; cuda = False; gpu_name = None
|
torch_ver = None; cuda = False; gpu_name = None
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
|
|
@ -423,7 +423,7 @@ try:
|
||||||
print(json.dumps({"gpu": name, "vram_gib": round(mem, 1), "ready": True}))
|
print(json.dumps({"gpu": name, "vram_gib": round(mem, 1), "ready": True}))
|
||||||
else:
|
else:
|
||||||
print(json.dumps({"gpu": None, "ready": False}))
|
print(json.dumps({"gpu": None, "ready": False}))
|
||||||
except:
|
except ImportError:
|
||||||
print(json.dumps({"gpu": None, "ready": False, "error": "no torch"}))
|
print(json.dumps({"gpu": None, "ready": False, "error": "no torch"}))
|
||||||
"""
|
"""
|
||||||
results = distribute_task(gpu_probe)
|
results = distribute_task(gpu_probe)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ Design:
|
||||||
Task that the scheduler routes to CPU or GPU based on data locality
|
Task that the scheduler routes to CPU or GPU based on data locality
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -35,6 +36,8 @@ from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Tuple, Optional, Callable, Iterator
|
from typing import Dict, List, Tuple, Optional, Callable, Iterator
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Optional GPU imports (graceful degradation)
|
# Optional GPU imports (graceful degradation)
|
||||||
try:
|
try:
|
||||||
import torch
|
import torch
|
||||||
|
|
@ -81,8 +84,8 @@ class HardwareTopology:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith('MemTotal:'):
|
if line.startswith('MemTotal:'):
|
||||||
return int(line.split()[1]) / (1024**2)
|
return int(line.split()[1]) / (1024**2)
|
||||||
except:
|
except (OSError, ValueError) as exc:
|
||||||
pass
|
logger.debug("Failed to read MemTotal: %s", exc)
|
||||||
return 30.0
|
return 30.0
|
||||||
|
|
||||||
def _ram_available_gb(self) -> float:
|
def _ram_available_gb(self) -> float:
|
||||||
|
|
@ -91,15 +94,16 @@ class HardwareTopology:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith('MemAvailable:'):
|
if line.startswith('MemAvailable:'):
|
||||||
return int(line.split()[1]) / (1024**2)
|
return int(line.split()[1]) / (1024**2)
|
||||||
except:
|
except (OSError, ValueError) as exc:
|
||||||
pass
|
logger.debug("Failed to read MemAvailable: %s", exc)
|
||||||
return 17.0
|
return 17.0
|
||||||
|
|
||||||
def _disk_free_gb(self) -> float:
|
def _disk_free_gb(self) -> float:
|
||||||
try:
|
try:
|
||||||
stat = os.statvfs('/')
|
stat = os.statvfs('/')
|
||||||
return (stat.f_bavail * stat.f_frsize) / (1024**3)
|
return (stat.f_bavail * stat.f_frsize) / (1024**3)
|
||||||
except:
|
except OSError as exc:
|
||||||
|
logger.debug("Failed to read disk stats: %s", exc)
|
||||||
return 600.0
|
return 600.0
|
||||||
|
|
||||||
def summary(self) -> dict:
|
def summary(self) -> dict:
|
||||||
|
|
@ -192,8 +196,8 @@ class UnifiedMemory:
|
||||||
self.vram_current_mb += size_mb
|
self.vram_current_mb += size_mb
|
||||||
self._db_update(data_hash, size_mb, "vram")
|
self._db_update(data_hash, size_mb, "vram")
|
||||||
return
|
return
|
||||||
except:
|
except (RuntimeError, TypeError) as exc:
|
||||||
pass # Fall through to RAM
|
logger.debug("VRAM store failed, falling back to RAM: %s", exc)
|
||||||
|
|
||||||
# RAM
|
# RAM
|
||||||
if self.ram_current_mb + size_mb > self.ram_max_mb:
|
if self.ram_current_mb + size_mb > self.ram_max_mb:
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ def install_to_cache(source_path, destination_filename=None):
|
||||||
if not os.path.exists(compile_location):
|
if not os.path.exists(compile_location):
|
||||||
try:
|
try:
|
||||||
os.makedirs(compile_location)
|
os.makedirs(compile_location)
|
||||||
except:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
current_file = os.path.abspath(source_path)
|
current_file = os.path.abspath(source_path)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ Translates virtual GPU topology into measurable, real-world benchmarks:
|
||||||
Provides concrete numbers that validate the 9.12x expansion factor.
|
Provides concrete numbers that validate the 9.12x expansion factor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
|
@ -23,6 +24,8 @@ from dataclasses import dataclass
|
||||||
from typing import Dict, List, Any, Tuple
|
from typing import Dict, List, Any, Tuple
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Import infrastructure
|
# Import infrastructure
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "4-Infrastructure" / "infra"))
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "4-Infrastructure" / "infra"))
|
||||||
|
|
@ -100,7 +103,8 @@ class VirtualGPUTestbench:
|
||||||
)
|
)
|
||||||
# Parse transfer stats if present
|
# Parse transfer stats if present
|
||||||
tx_rx_present = "tx" in result.stdout.lower() or "rx" in result.stdout.lower()
|
tx_rx_present = "tx" in result.stdout.lower() or "rx" in result.stdout.lower()
|
||||||
except:
|
except (FileNotFoundError, subprocess.SubprocessError) as exc:
|
||||||
|
logger.debug("tailscale status probe failed: %s", exc)
|
||||||
tx_rx_present = False
|
tx_rx_present = False
|
||||||
|
|
||||||
# Aggregate across 6 nodes
|
# Aggregate across 6 nodes
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue