Somuai12 commited on
Commit
a541c0b
Β·
1 Parent(s): 8cd3fa7

Fix imports for flat deployment structure in HF Spaces

Browse files
inference.py CHANGED
@@ -271,8 +271,8 @@ async def run_direct_baseline() -> Dict:
271
  Run baseline directly using environment and grader imports.
272
  Used by the /baseline endpoint to avoid self-HTTP calls on HF Spaces.
273
  """
274
- from ..server.environment import PolicyEvolverEnvironment
275
- from ..server.grader import grade
276
 
277
  env = PolicyEvolverEnvironment()
278
  use_llm = verify_environment()
 
271
  Run baseline directly using environment and grader imports.
272
  Used by the /baseline endpoint to avoid self-HTTP calls on HF Spaces.
273
  """
274
+ from server.environment import PolicyEvolverEnvironment
275
+ from server.grader import grade
276
 
277
  env = PolicyEvolverEnvironment()
278
  use_llm = verify_environment()
openenv.yaml CHANGED
@@ -10,7 +10,7 @@ tags:
10
  - "AI-safety"
11
 
12
  environment:
13
- module: "policy_evolver_env.server.environment"
14
  class: "PolicyEvolverEnvironment"
15
 
16
  observation_schema:
 
10
  - "AI-safety"
11
 
12
  environment:
13
+ module: "server.environment"
14
  class: "PolicyEvolverEnvironment"
15
 
16
  observation_schema:
server/Dockerfile CHANGED
@@ -17,4 +17,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
17
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
18
 
19
  # Start server
20
- CMD ["uvicorn", "policy_evolver_env.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
 
17
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
18
 
19
  # Start server
20
+ CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]
server/app.py CHANGED
@@ -3,13 +3,13 @@ from __future__ import annotations
3
  from fastapi import FastAPI, HTTPException, Query
4
  from fastapi.responses import JSONResponse
5
  from openenv.core.env_server import create_fastapi_app
6
- from ..models import (
7
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
8
  Observation, Action
9
  )
10
- from .environment import PolicyEvolverEnvironment
11
- from .grader import grade
12
- from .tasks import TASK_REGISTRY
13
  import json
14
 
15
  # Create app via OpenEnv helper β€” pass factory callable, action/obs classes
@@ -58,6 +58,6 @@ async def run_baseline_endpoint():
58
  Runs the LLM baseline (or rule-based fallback) and returns scores for all tasks.
59
  Uses the grader directly instead of HTTP calls to self.
60
  """
61
- from ..inference import run_direct_baseline
62
  results = await run_direct_baseline()
63
  return results
 
3
  from fastapi import FastAPI, HTTPException, Query
4
  from fastapi.responses import JSONResponse
5
  from openenv.core.env_server import create_fastapi_app
6
+ from models import (
7
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
8
  Observation, Action
9
  )
10
+ from server.environment import PolicyEvolverEnvironment
11
+ from server.grader import grade
12
+ from server.tasks import TASK_REGISTRY
13
  import json
14
 
15
  # Create app via OpenEnv helper β€” pass factory callable, action/obs classes
 
58
  Runs the LLM baseline (or rule-based fallback) and returns scores for all tasks.
59
  Uses the grader directly instead of HTTP calls to self.
60
  """
61
+ from inference import run_direct_baseline
62
  results = await run_direct_baseline()
63
  return results
server/environment.py CHANGED
@@ -4,12 +4,12 @@ import uuid
4
  import random
5
  from typing import Optional, Any, Dict
6
  from openenv.core.env_server import Environment
7
- from ..models import (
8
  Action, Observation, State,
9
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
10
  )
11
- from .grader import grade
12
- from .tasks import TASK_REGISTRY
13
 
14
 
15
  class PolicyEvolverEnvironment(Environment[Action, Observation, State]):
 
4
  import random
5
  from typing import Optional, Any, Dict
6
  from openenv.core.env_server import Environment
7
+ from models import (
8
  Action, Observation, State,
9
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
10
  )
11
+ from server.grader import grade
12
+ from server.tasks import TASK_REGISTRY
13
 
14
 
15
  class PolicyEvolverEnvironment(Environment[Action, Observation, State]):
server/grader.py CHANGED
@@ -6,11 +6,11 @@ All functions return float in [0.0, 1.0].
6
  from __future__ import annotations
7
  import re
8
  from typing import Dict, List, Any
9
- from ..models import (
10
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
11
  Observation
12
  )
13
- from .tasks import TASK_REGISTRY
14
 
15
 
16
  # ─────────────────────────────────────────────
 
6
  from __future__ import annotations
7
  import re
8
  from typing import Dict, List, Any
9
+ from models import (
10
  ProposeClarificationAction, ProposeNewRuleAction, EvolveProcessAction,
11
  Observation
12
  )
13
+ from server.tasks import TASK_REGISTRY
14
 
15
 
16
  # ─────────────────────────────────────────────