Aldrimore commited on
Commit
a2db6ba
·
1 Parent(s): b33d8e1

Fix HF Space blank screen and state endpoint bug

Browse files

- Add root GET / endpoint to server.py so HF Space returns 200 instead of 404
- Remove invalid step_count field from FactoryState construction in env.py
- Expand openenv.yaml with version, task descriptions, action/observation space metadata

Files changed (3) hide show
  1. factory_env/env.py +0 -1
  2. openenv.yaml +38 -5
  3. server.py +13 -1
factory_env/env.py CHANGED
@@ -112,7 +112,6 @@ class FactoryEnv(Environment[FactoryAction, FactoryObservation, FactoryState]):
112
  time=self.time,
113
  task=self.task,
114
  late_jobs=self.late_jobs,
115
- step_count=self.time,
116
  )
117
 
118
  def _make_obs(self, reward, done: bool) -> FactoryObservation:
 
112
  time=self.time,
113
  task=self.task,
114
  late_jobs=self.late_jobs,
 
115
  )
116
 
117
  def _make_obs(self, reward, done: bool) -> FactoryObservation:
openenv.yaml CHANGED
@@ -1,9 +1,42 @@
1
  name: factory_env
2
- description: Smart factory scheduling environment
 
 
 
3
 
4
  tasks:
5
- - name: easy
6
- - name: medium
7
- - name: hard
 
 
 
8
 
9
- entry_point: factory_env.env:FactoryEnv
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  name: factory_env
2
+ version: "1.0.0"
3
+ description: Smart factory scheduling environment — assign jobs to machines, handle breakdowns, maximise throughput within deadlines.
4
+
5
+ entry_point: factory_env.env:FactoryEnv
6
 
7
  tasks:
8
+ - name: easy
9
+ description: 2 machines, 3 jobs, no failures, 20 steps
10
+ - name: medium
11
+ description: 4 machines, 7 jobs, 8% failure rate, 30 steps
12
+ - name: hard
13
+ description: 6 machines, 12 jobs, 15% failure rate, 40 steps
14
 
15
+ action_space:
16
+ type: text
17
+ description: "assign_job <job_id> <machine_id> | repair <machine_id> | wait"
18
+
19
+ observation_space:
20
+ type: object
21
+ fields:
22
+ - name: machines
23
+ type: list
24
+ description: List of machines with id, status (idle/busy/broken), current_job
25
+ - name: pending_jobs
26
+ type: list
27
+ description: List of jobs with id, remaining_time, deadline, priority
28
+ - name: completed_jobs
29
+ type: list
30
+ description: Jobs completed this episode
31
+ - name: time
32
+ type: int
33
+ description: Current timestep
34
+ - name: max_steps
35
+ type: int
36
+ description: Episode length
37
+ - name: done
38
+ type: bool
39
+ description: Whether the episode has ended
40
+ - name: reward
41
+ type: float
42
+ description: Reward from the last action
server.py CHANGED
@@ -1,8 +1,9 @@
1
  """
2
  OpenEnv HTTP Server — Smart Factory Scheduling
3
- Routes: GET /health POST /reset POST /step GET /state GET /schema
4
  """
5
  import os
 
6
  from openenv.core import create_app
7
  from factory_env.env import FactoryEnv
8
  from factory_env.models import FactoryAction, FactoryObservation
@@ -16,6 +17,17 @@ app = create_app(
16
  env_name="factory_env",
17
  )
18
 
 
 
 
 
 
 
 
 
 
 
 
19
  if __name__ == "__main__":
20
  import uvicorn
21
  uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
 
1
  """
2
  OpenEnv HTTP Server — Smart Factory Scheduling
3
+ Routes: GET / GET /health POST /reset POST /step GET /state GET /schema
4
  """
5
  import os
6
+ from fastapi.responses import JSONResponse
7
  from openenv.core import create_app
8
  from factory_env.env import FactoryEnv
9
  from factory_env.models import FactoryAction, FactoryObservation
 
17
  env_name="factory_env",
18
  )
19
 
20
+
21
+ @app.get("/")
22
+ def root():
23
+ return JSONResponse({
24
+ "name": "factory_env",
25
+ "description": "Smart Factory Scheduling — OpenEnv RL Environment",
26
+ "tasks": ["easy", "medium", "hard"],
27
+ "endpoints": ["/health", "/reset", "/step", "/state", "/schema", "/docs"],
28
+ })
29
+
30
+
31
  if __name__ == "__main__":
32
  import uvicorn
33
  uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))