hirann commited on
Commit
f67248b
·
verified ·
1 Parent(s): ff4146a

Enhance: Comprehensive state() method

Browse files
Files changed (1) hide show
  1. env/core.py +28 -0
env/core.py CHANGED
@@ -321,11 +321,39 @@ class CloudOpsEnvironment:
321
  def state(self) -> Dict[str, Any]:
322
  if self._ep is None:
323
  return {}
 
 
 
 
 
 
 
324
  return {
325
  "episode_id": self._ep.episode_id,
326
  "task_id": self._ep.task_config.task_id,
 
 
327
  "steps": self._ep.steps,
 
328
  "crashed": self._ep.crashed,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  }
330
 
331
  def state(self) -> Dict[str, Any]:
 
321
  def state(self) -> Dict[str, Any]:
322
  if self._ep is None:
323
  return {}
324
+
325
+ latency, error_rate, utilization = self._calculate_metrics(
326
+ self._ep.current_load, self._ep.resources
327
+ )
328
+
329
+ total_cost = sum(r.monthly_cost for r in self._ep.resources)
330
+
331
  return {
332
  "episode_id": self._ep.episode_id,
333
  "task_id": self._ep.task_config.task_id,
334
+ "task_name": self._ep.task_config.name,
335
+ "difficulty": self._ep.task_config.difficulty,
336
  "steps": self._ep.steps,
337
+ "changes_made": self._ep.changes_made,
338
  "crashed": self._ep.crashed,
339
+ "resources": [
340
+ {
341
+ "id": r.id,
342
+ "type": r.type,
343
+ "monthly_cost": r.monthly_cost,
344
+ "cpu_usage": r.cpu_usage,
345
+ "mem_usage": r.mem_usage,
346
+ }
347
+ for r in self._ep.resources
348
+ ],
349
+ "metrics": {
350
+ "total_cost": total_cost,
351
+ "latency_ms": latency,
352
+ "error_rate": error_rate,
353
+ "utilization": utilization,
354
+ },
355
+ "sla": self._ep.task_config.sla,
356
+ "exploration_history": self._ep.exploration_history,
357
  }
358
 
359
  def state(self) -> Dict[str, Any]: