Spaces:
Sleeping
Sleeping
Keshavj-13 commited on
Commit ·
f2edda8
1
Parent(s): 13c984e
fix(issue-01,02,10,11,16,17,21,31): lock client-state and metadata contracts
Browse files- README.md +1 -0
- models.py +11 -1
- server/atc_environment.py +4 -4
- tests/test_client_and_metadata_contract.py +40 -0
README.md
CHANGED
|
@@ -86,6 +86,7 @@ The observation model is [ATCOptimizationObservation](models.py). It includes:
|
|
| 86 |
- `steps_remaining`
|
| 87 |
|
| 88 |
State inspection is available through [ATCOptimizationState](models.py) and exposed by `/state`.
|
|
|
|
| 89 |
|
| 90 |
## Reward design
|
| 91 |
|
|
|
|
| 86 |
- `steps_remaining`
|
| 87 |
|
| 88 |
State inspection is available through [ATCOptimizationState](models.py) and exposed by `/state`.
|
| 89 |
+
The state payload includes `active_task_ids` so validators and agents can enumerate all configured tasks.
|
| 90 |
|
| 91 |
## Reward design
|
| 92 |
|
models.py
CHANGED
|
@@ -42,12 +42,22 @@ class Difficulty(str, Enum):
|
|
| 42 |
HARD = "hard"
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
class RunwaySpec(BaseModel):
|
| 46 |
"""Runway configuration available to the controller."""
|
| 47 |
|
| 48 |
runway_id: str = Field(..., description="Runway identifier")
|
| 49 |
allowed_operations: List[OperationType] = Field(
|
| 50 |
-
default_factory=
|
| 51 |
description="Operations permitted on the runway",
|
| 52 |
)
|
| 53 |
hourly_capacity: int = Field(
|
|
|
|
| 42 |
HARD = "hard"
|
| 43 |
|
| 44 |
|
| 45 |
+
DEFAULT_ALLOWED_OPERATIONS = (
|
| 46 |
+
OperationType.ARRIVAL,
|
| 47 |
+
OperationType.DEPARTURE,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def default_allowed_operations() -> List[OperationType]:
|
| 52 |
+
return list(DEFAULT_ALLOWED_OPERATIONS)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
class RunwaySpec(BaseModel):
|
| 56 |
"""Runway configuration available to the controller."""
|
| 57 |
|
| 58 |
runway_id: str = Field(..., description="Runway identifier")
|
| 59 |
allowed_operations: List[OperationType] = Field(
|
| 60 |
+
default_factory=default_allowed_operations,
|
| 61 |
description="Operations permitted on the runway",
|
| 62 |
)
|
| 63 |
hourly_capacity: int = Field(
|
server/atc_environment.py
CHANGED
|
@@ -18,6 +18,7 @@ try:
|
|
| 18 |
PlanSnapshot,
|
| 19 |
TaskDefinition,
|
| 20 |
TaskGrade,
|
|
|
|
| 21 |
)
|
| 22 |
from ..tasks import ordered_tasks, render_task_briefing, task_catalog
|
| 23 |
except ImportError:
|
|
@@ -30,6 +31,7 @@ except ImportError:
|
|
| 30 |
PlanSnapshot,
|
| 31 |
TaskDefinition,
|
| 32 |
TaskGrade,
|
|
|
|
| 33 |
)
|
| 34 |
from tasks import ordered_tasks, render_task_briefing, task_catalog
|
| 35 |
|
|
@@ -185,7 +187,7 @@ class ATCOptimizationEnvironment(
|
|
| 185 |
name="ATC Optimization OpenEnv",
|
| 186 |
description="Realistic air traffic control disruption recovery benchmark.",
|
| 187 |
version="1.0.0",
|
| 188 |
-
author="
|
| 189 |
readme_content=readme_content,
|
| 190 |
)
|
| 191 |
|
|
@@ -220,9 +222,7 @@ class ATCOptimizationEnvironment(
|
|
| 220 |
done=done,
|
| 221 |
)
|
| 222 |
|
| 223 |
-
def _build_summary(
|
| 224 |
-
self, metrics, grades: List[TaskGrade], done: bool
|
| 225 |
-
) -> str:
|
| 226 |
lead_grade = next(
|
| 227 |
(grade for grade in grades if grade.grader_name == "composite_task_grader"),
|
| 228 |
grades[-1],
|
|
|
|
| 18 |
PlanSnapshot,
|
| 19 |
TaskDefinition,
|
| 20 |
TaskGrade,
|
| 21 |
+
TaskMetrics,
|
| 22 |
)
|
| 23 |
from ..tasks import ordered_tasks, render_task_briefing, task_catalog
|
| 24 |
except ImportError:
|
|
|
|
| 31 |
PlanSnapshot,
|
| 32 |
TaskDefinition,
|
| 33 |
TaskGrade,
|
| 34 |
+
TaskMetrics,
|
| 35 |
)
|
| 36 |
from tasks import ordered_tasks, render_task_briefing, task_catalog
|
| 37 |
|
|
|
|
| 187 |
name="ATC Optimization OpenEnv",
|
| 188 |
description="Realistic air traffic control disruption recovery benchmark.",
|
| 189 |
version="1.0.0",
|
| 190 |
+
author="ATC Optimization OpenEnv Contributors",
|
| 191 |
readme_content=readme_content,
|
| 192 |
)
|
| 193 |
|
|
|
|
| 222 |
done=done,
|
| 223 |
)
|
| 224 |
|
| 225 |
+
def _build_summary(self, metrics: TaskMetrics, grades: List[TaskGrade], done: bool) -> str:
|
|
|
|
|
|
|
| 226 |
lead_grade = next(
|
| 227 |
(grade for grade in grades if grade.grader_name == "composite_task_grader"),
|
| 228 |
grades[-1],
|
tests/test_client_and_metadata_contract.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Client/state and metadata contract tests."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from client import ATCOptimizationEnv
|
| 6 |
+
from models import ATCOptimizationState, default_allowed_operations
|
| 7 |
+
from server.atc_environment import ATCOptimizationEnvironment
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def test_client_parse_state_regression() -> None:
|
| 11 |
+
client = ATCOptimizationEnv(base_url="http://127.0.0.1:65535")
|
| 12 |
+
payload = {
|
| 13 |
+
"task_id": "demo",
|
| 14 |
+
"task_title": "Demo Task",
|
| 15 |
+
"seed": 7,
|
| 16 |
+
"max_steps": 4,
|
| 17 |
+
"active_task_ids": ["delhi_monsoon_recovery_easy", "mumbai_bank_balance_medium"],
|
| 18 |
+
}
|
| 19 |
+
parsed = client._parse_state(payload)
|
| 20 |
+
assert isinstance(parsed, ATCOptimizationState)
|
| 21 |
+
assert parsed.seed == 7
|
| 22 |
+
assert "mumbai_bank_balance_medium" in parsed.active_task_ids
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_models_default_factory_for_allowed_operations() -> None:
|
| 26 |
+
defaults = default_allowed_operations()
|
| 27 |
+
assert len(defaults) == 2
|
| 28 |
+
assert defaults[0].value == "arrival"
|
| 29 |
+
assert defaults[1].value == "departure"
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_environment_metadata_and_task_enumeration_contract() -> None:
|
| 33 |
+
env = ATCOptimizationEnvironment()
|
| 34 |
+
metadata = env.get_metadata()
|
| 35 |
+
assert metadata.author == "ATC Optimization OpenEnv Contributors"
|
| 36 |
+
|
| 37 |
+
obs = env.reset(task_id="delhi_monsoon_recovery_easy")
|
| 38 |
+
assert obs.task_id == "delhi_monsoon_recovery_easy"
|
| 39 |
+
assert "bengaluru_irrops_hard" in env.state.active_task_ids
|
| 40 |
+
assert len(env.state.active_task_ids) >= 3
|