Create test_env.py
Browse files- test_env.py +24 -0
test_env.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from server.my_env_environment import MyEnvEnvironment
|
| 2 |
+
from models import IncidentAction
|
| 3 |
+
from graders import get_grader
|
| 4 |
+
|
| 5 |
+
env = MyEnvEnvironment()
|
| 6 |
+
obs = env.reset(task_id=1)
|
| 7 |
+
print("Initial observation:", obs.active_alerts)
|
| 8 |
+
|
| 9 |
+
# Take some actions
|
| 10 |
+
obs = env.step(IncidentAction(action_id=0, task_id=1)) # read_alerts
|
| 11 |
+
print("After read_alerts:", obs.reward)
|
| 12 |
+
|
| 13 |
+
obs = env.step(IncidentAction(action_id=1, task_id=1)) # inspect_logs_api
|
| 14 |
+
print("After inspect_logs:", obs.reward)
|
| 15 |
+
|
| 16 |
+
obs = env.step(IncidentAction(action_id=9, task_id=1)) # restart_api
|
| 17 |
+
print("After restart:", obs.reward)
|
| 18 |
+
|
| 19 |
+
obs = env.step(IncidentAction(action_id=20, task_id=1)) # resolve
|
| 20 |
+
print("After resolve:", obs.reward, obs.done)
|
| 21 |
+
|
| 22 |
+
grader = get_grader(1)
|
| 23 |
+
score = grader(env)
|
| 24 |
+
print("Final score:", score)
|