Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
09d6711
reduce calls between screener and evaluation
hobbleabbas Oct 2, 2025
7ffc0c4
set up screener skeleton
hobbleabbas Oct 2, 2025
638804d
remove tests
hobbleabbas Oct 2, 2025
a1ac27f
complete screening finish func
hobbleabbas Oct 3, 2025
865e3b6
wire in new finish screener method
hobbleabbas Oct 3, 2025
29e838b
update finish screening to use agent status"
hobbleabbas Oct 3, 2025
6d20a63
fix
hobbleabbas Oct 3, 2025
4d0d9d3
properly set agent status to waiting
hobbleabbas Oct 3, 2025
4b28420
start skeleton for start screening (incomplete)
hobbleabbas Oct 3, 2025
a6cae8a
complete start eval
hobbleabbas Oct 3, 2025
05c118b
wire in to old model structure
hobbleabbas Oct 3, 2025
5784878
fix str typo
hobbleabbas Oct 3, 2025
4882746
replace start eval with new version
hobbleabbas Oct 3, 2025
e78fb98
fix agent state change mismatch
hobbleabbas Oct 3, 2025
9b9eafb
fix dict state wiring in
hobbleabbas Oct 3, 2025
6e3026a
fix: datetime and other imports
omar-ridges Oct 3, 2025
9470bff
chore: remove local from screener ip list
omar-ridges Oct 3, 2025
fe17350
remove screener, evaluator in upload file
hobbleabbas Oct 3, 2025
d4f38c7
remove most screener funcs
hobbleabbas Oct 3, 2025
dcf1d4d
nuke screenr methods:
hobbleabbas Oct 3, 2025
7c01b73
remove validator from scoring
hobbleabbas Oct 3, 2025
2c064ef
remove most evaluation class calls/imports in files that refer to it
Oct 3, 2025
4e6b2fa
chore: moved startup recovery to model_replacers.py
omar-ridges Oct 3, 2025
644a1ca
fix merge conflict
hobbleabbas Oct 3, 2025
1acae99
remove complete eval handler
hobbleabbas Oct 3, 2025
3671d8c
move api/src/models/evaluation Evaluation fields to functional await …
alex-ridges Oct 3, 2025
043628b
fix type error with UUID types
alex-ridges Oct 3, 2025
e798a17
remove legacy screener support for screener.get_stage method
alex-ridges Oct 3, 2025
ebe6119
add screener broadcast
hobbleabbas Oct 3, 2025
770a84e
fix: circular import and other fixes
omar-ridges Oct 3, 2025
4411f46
add await to async calls
alex-ridges Oct 3, 2025
e2bd9c5
add more await calls
alex-ridges Oct 3, 2025
669e4e8
Fix create_evaluation()
adamridges Oct 3, 2025
39a587b
add printf debugging
alex-ridges Oct 3, 2025
55774a5
fixes
adamridges Oct 3, 2025
0ac5cea
fix match functions
alex-ridges Oct 3, 2025
490fa6e
add .value to enum
alex-ridges Oct 4, 2025
5e2b5e1
agent status print
alex-ridges Oct 4, 2025
86dcd6f
make finish_screening idempotent
alex-ridges Oct 4, 2025
e983950
fix: hook up startup_recovery with new functions
omar-ridges Oct 4, 2025
5085749
modified create_eval db op to accept status input
omar-ridges Oct 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions api/src/backend/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ class AgentStatus(Enum):
scored = "scored" # All evaluations complete
replaced = "replaced" # Replaced by newer version
pruned = "pruned" # Pruned due to low score compared to top agent

# Legacy statuses for backward compatibility during transition
awaiting_screening = "awaiting_screening_1" # Map to stage 1
screening = "screening_1" # Map to stage 1
failed_screening = "failed_screening_1" # Map to stage 1 fail
evaluation = "evaluating" # Map to evaluating (legacy alias)

@classmethod
def from_string(cls, status: str) -> 'AgentStatus':
"""Map database status string to agent state enum"""
Expand All @@ -344,7 +344,6 @@ def from_string(cls, status: str) -> 'AgentStatus':
}
return mapping.get(status, cls.awaiting_screening_1)


class EvaluationStatus(Enum):
waiting = "waiting"
running = "running"
Expand Down
56 changes: 49 additions & 7 deletions api/src/backend/queries/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncpg

from api.src.backend.db_manager import db_operation, db_transaction
from api.src.backend.entities import MinerAgent
from api.src.backend.entities import AgentStatus, MinerAgent
from api.src.utils.models import TopAgentHotkey
from loggers.logging_utils import get_logger

Expand Down Expand Up @@ -139,9 +139,51 @@ async def set_approved_agents_to_awaiting_screening(conn: asyncpg.Connection) ->
return [MinerAgent(**dict(result)) for result in results]

@db_operation
async def get_all_approved_version_ids(conn: asyncpg.Connection) -> List[str]:
"""
Get all approved version IDs
"""
data = await conn.fetch("SELECT version_id FROM approved_version_ids WHERE approved_at <= NOW()")
return [str(row["version_id"]) for row in data]
async def set_agent_status(conn: asyncpg.Connection, version_id: str, status: str):
try:
AgentStatus(status) # Check whether the status we are trying to set to is valid
except ValueError:
logger.error(f"Tried to set agent to invalid status {status!r}")
raise ValueError("Invalid status")

await conn.execute(
"UPDATE miner_agents SET status = $1 WHERE version_id = $2",
status,
version_id
)

@db_operation
async def upload_miner_agent(
conn: asyncpg.Connection,
version_id: str,
miner_hotkey: str,
agent_name: str,
version_num: int,
ip_address: str
):
await conn.execute(
"""
INSERT INTO miner_agents (version_id, miner_hotkey, agent_name, version_num, created_at, status, ip_address)
VALUES ($1, $2, $3, $4, NOW(), 'awaiting_screening_1', $5)
""",
version_id,
miner_hotkey,
agent_name,
version_num,
ip_address
)

@db_operation
async def agent_startup_recovery(conn: asyncpg.Connection):
# Reset agent statuses for multi-stage screening
await conn.execute("UPDATE miner_agents SET status = 'awaiting_screening_1' WHERE status = 'screening_1'")
await conn.execute("UPDATE miner_agents SET status = 'awaiting_screening_2' WHERE status = 'screening_2'")
await conn.execute("UPDATE miner_agents SET status = 'waiting' WHERE status = 'evaluating'")

# Legacy status recovery for backward compatibility
await conn.execute("UPDATE miner_agents SET status = 'awaiting_screening_1' WHERE status = 'screening'")
await conn.execute("UPDATE miner_agents SET status = 'waiting' WHERE status = 'evaluation'") # Legacy alias

@db_operation
async def set_agent_status_by_version_id(conn: asyncpg.Connection, version_id: str, status: str):
await conn.execute("UPDATE miner_agents SET status = $1 WHERE version_id = $2", status, version_id)
6 changes: 5 additions & 1 deletion api/src/backend/queries/agents.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ async def get_agents_by_hotkey(miner_hotkey: str) -> List[MinerAgent]: ...
async def ban_agents(miner_hotkeys: List[str], reason: str) -> None: ...
async def approve_agent_version(version_id: str) -> None: ...
async def set_approved_agents_to_awaiting_screening() -> List[MinerAgent]: ...
async def get_all_approved_version_ids() -> List[str]: ...
async def get_all_approved_version_ids() -> List[str]: ...
async def set_agent_status(version_id: str, status: str): ...
async def upload_miner_agent(version_id: str, miner_hotkey: str, agent_name: str, version_num: int, ip_address: str): ...
async def agent_startup_recovery() -> None: ...
async def set_agent_status_by_version_id(version_id: str, status: str): ...
9 changes: 4 additions & 5 deletions api/src/backend/queries/evaluation_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ async def reset_validator_evaluations(conn: asyncpg.Connection, version_id: str)
WHERE evaluation_id = ANY($1::uuid[])
""", evaluation_ids_to_cancel)






@db_operation
async def cancel_evaluation_runs(conn: asyncpg.Connection, evaluation_id: str):
"""Cancel existing eval runs - e.g. for errored runs or disconnections etc"""
await conn.execute("UPDATE evaluation_runs SET status = 'cancelled' WHERE evaluation_id = $1", evaluation_id)
4 changes: 3 additions & 1 deletion api/src/backend/queries/evaluation_runs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ async def update_evaluation_run_logs(run_id: str, logs: str): ...
async def get_evaluation_run_logs(run_id: str) -> str: ...

async def fully_reset_evaluations(version_id: str): ...
async def reset_validator_evaluations(version_id: str): ...
async def reset_validator_evaluations(version_id: str): ...

async def cancel_evaluation_runs(evaluation_id: str): ...
Loading
Loading