arjeet commited on
Commit
5ba223e
·
1 Parent(s): f0639ce

toml update

Browse files
Files changed (8) hide show
  1. client.py +0 -32
  2. inference.py +0 -2
  3. main.py +1 -1
  4. models.py +0 -12
  5. pyproject.toml +2 -0
  6. server/__init__.py +0 -2
  7. server/app.py +0 -3
  8. server/cust_env_environment.py +0 -24
client.py CHANGED
@@ -4,12 +4,6 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """
8
- Doc Sweeper Environment Client.
9
-
10
- This module provides the client for connecting to a Doc Sweeper Environment server
11
- via WebSocket for persistent sessions.
12
- """
13
 
14
  from __future__ import annotations
15
 
@@ -22,30 +16,12 @@ from models import DocAction, DocObservation, DocState
22
 
23
 
24
  class DocSweeperEnv(EnvClient[DocAction, DocObservation, DocState]):
25
- """
26
- Client for Doc Sweeper Environment.
27
-
28
- This client maintains a persistent WebSocket connection to the environment
29
- server, enabling efficient multi-step interactions with lower latency.
30
-
31
- Example:
32
- >>> with DocSweeperEnv(base_url="http://localhost:8000") as client:
33
- ... result = client.reset()
34
- ... print(result.observation.terminal_feedback)
35
- ...
36
- ... result = client.step(DocAction(tool_name="open", path="/docs/setup.md"))
37
- ... print(result.observation.file_content)
38
- """
39
 
40
  def _step_payload(self, action: DocAction) -> Dict[str, Any]:
41
  """
42
- Convert DocAction to JSON payload for step request.
43
 
44
  Args:
45
  action: DocAction instance with tool parameters.
46
-
47
- Returns:
48
- Dictionary representation suitable for JSON encoding.
49
  """
50
  return {
51
  "tool_name": action.tool_name,
@@ -57,13 +33,9 @@ class DocSweeperEnv(EnvClient[DocAction, DocObservation, DocState]):
57
 
58
  def _parse_result(self, payload: Dict[str, Any]) -> StepResult[DocObservation]:
59
  """
60
- Parse server response into StepResult[DocObservation].
61
-
62
  Args:
63
  payload: JSON response from server.
64
 
65
- Returns:
66
- StepResult with DocObservation.
67
  """
68
  obs_data = payload.get("observation", {})
69
 
@@ -85,13 +57,9 @@ class DocSweeperEnv(EnvClient[DocAction, DocObservation, DocState]):
85
 
86
  def _parse_state(self, payload: Dict[str, Any]) -> DocState:
87
  """
88
- Parse server response into DocState object.
89
-
90
  Args:
91
  payload: JSON response from /state endpoint.
92
 
93
- Returns:
94
- DocState object with environment state information.
95
  """
96
  return DocState(
97
  episode_id=payload.get("episode_id", ""),
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
 
 
 
 
 
 
7
 
8
  from __future__ import annotations
9
 
 
16
 
17
 
18
  class DocSweeperEnv(EnvClient[DocAction, DocObservation, DocState]):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  def _step_payload(self, action: DocAction) -> Dict[str, Any]:
21
  """
 
22
 
23
  Args:
24
  action: DocAction instance with tool parameters.
 
 
 
25
  """
26
  return {
27
  "tool_name": action.tool_name,
 
33
 
34
  def _parse_result(self, payload: Dict[str, Any]) -> StepResult[DocObservation]:
35
  """
 
 
36
  Args:
37
  payload: JSON response from server.
38
 
 
 
39
  """
40
  obs_data = payload.get("observation", {})
41
 
 
57
 
58
  def _parse_state(self, payload: Dict[str, Any]) -> DocState:
59
  """
 
 
60
  Args:
61
  payload: JSON response from /state endpoint.
62
 
 
 
63
  """
64
  return DocState(
65
  episode_id=payload.get("episode_id", ""),
inference.py CHANGED
@@ -1,5 +1,3 @@
1
- """Inference script for the Doc Sweeper Environment."""
2
-
3
  import os
4
  import json
5
  import time
 
 
 
1
  import os
2
  import json
3
  import time
main.py CHANGED
@@ -1,5 +1,5 @@
1
  def main():
2
- print("Hello from cust-env!")
3
 
4
 
5
  if __name__ == "__main__":
 
1
  def main():
2
+ print("Hello from DocSweeper!")
3
 
4
 
5
  if __name__ == "__main__":
models.py CHANGED
@@ -4,13 +4,6 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """
8
- Data models for Doc Sweeper Environment.
9
-
10
- This module defines the Action, Observation, and State types for the documentation
11
- maintenance tasks via the OpenEnv interface.
12
- """
13
-
14
  from __future__ import annotations
15
 
16
  from typing import Dict, List, Optional
@@ -21,8 +14,6 @@ from pydantic import Field
21
 
22
  class DocAction(Action):
23
  """
24
- Action for Doc Sweeper environment.
25
-
26
  Attributes:
27
  tool_name: The command to run ('open', 'edit', 'grep', 'done').
28
  path: File path for opening or editing.
@@ -40,7 +31,6 @@ class DocAction(Action):
40
 
41
  class DocObservation(Observation):
42
  """
43
- Observation for Doc Sweeper environment.
44
 
45
  Attributes:
46
  active_file: Currently opened file path.
@@ -62,8 +52,6 @@ class DocObservation(Observation):
62
 
63
  class DocState(State):
64
  """
65
- State for Doc Sweeper environment.
66
-
67
  Attributes:
68
  episode_id: Unique ID for the current task session.
69
  step_count: Number of actions taken.
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
 
 
 
 
 
 
 
7
  from __future__ import annotations
8
 
9
  from typing import Dict, List, Optional
 
14
 
15
  class DocAction(Action):
16
  """
 
 
17
  Attributes:
18
  tool_name: The command to run ('open', 'edit', 'grep', 'done').
19
  path: File path for opening or editing.
 
31
 
32
  class DocObservation(Observation):
33
  """
 
34
 
35
  Attributes:
36
  active_file: Currently opened file path.
 
52
 
53
  class DocState(State):
54
  """
 
 
55
  Attributes:
56
  episode_id: Unique ID for the current task session.
57
  step_count: Number of actions taken.
pyproject.toml CHANGED
@@ -13,3 +13,5 @@ dependencies = [
13
  "pydantic>=2.12.5",
14
  "uvicorn>=0.42.0",
15
  ]
 
 
 
13
  "pydantic>=2.12.5",
14
  "uvicorn>=0.42.0",
15
  ]
16
+ [project.scripts]
17
+ server = "server.app:main"
server/__init__.py CHANGED
@@ -4,8 +4,6 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """Cust Env environment server components."""
8
-
9
  from .cust_env_environment import DocSweeperEnvironment
10
 
11
  __all__ = ["DocSweeperEnvironment"]
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
 
 
7
  from .cust_env_environment import DocSweeperEnvironment
8
 
9
  __all__ = ["DocSweeperEnvironment"]
server/app.py CHANGED
@@ -4,8 +4,6 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """FastAPI application for the Doc Sweeper Environment."""
8
-
9
  from openenv.core.env_server import create_app
10
  import uvicorn
11
 
@@ -17,7 +15,6 @@ from .cust_env_environment import DocSweeperEnvironment
17
  app = create_app(DocSweeperEnvironment, DocAction, DocObservation, env_name="doc_sweeper")
18
 
19
  def main():
20
- """Entry point for the OpenEnv multi-mode deployment."""
21
  uvicorn.run("server.app:app", host="0.0.0.0", port=8000)
22
 
23
  if __name__ == '__main__':
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
 
 
7
  from openenv.core.env_server import create_app
8
  import uvicorn
9
 
 
15
  app = create_app(DocSweeperEnvironment, DocAction, DocObservation, env_name="doc_sweeper")
16
 
17
  def main():
 
18
  uvicorn.run("server.app:app", host="0.0.0.0", port=8000)
19
 
20
  if __name__ == '__main__':
server/cust_env_environment.py CHANGED
@@ -4,13 +4,6 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- """
8
- Doc Sweeper Environment for OpenEnv.
9
-
10
- This module provides an environment where an agent navigates a virtual file system
11
- to fix outdated documentation, broken links, and deprecated configurations.
12
- """
13
-
14
  import uuid
15
  from typing import Dict, List
16
 
@@ -20,12 +13,6 @@ from models import DocAction, DocObservation, DocState
20
 
21
 
22
  class DocSweeperEnvironment(Environment):
23
- """
24
- Doc Sweeper environment implementing the OpenEnv interface.
25
-
26
- Simulates a Virtual File System (VFS) of markdown and config files. The agent
27
- must find and replace deprecated patterns without destructive behavior.
28
- """
29
 
30
  def __init__(
31
  self,
@@ -33,8 +20,6 @@ class DocSweeperEnvironment(Environment):
33
  max_steps: int = 30,
34
  ):
35
  """
36
- Initialize the Doc Sweeper environment.
37
-
38
  Args:
39
  task: Task to run - "version_bump", "config_migration", or "broken_links".
40
  max_steps: Maximum allowed actions before forced termination.
@@ -48,8 +33,6 @@ class DocSweeperEnvironment(Environment):
48
 
49
  def reset(self, **kwargs):
50
  """
51
- Initialize a new task episode.
52
-
53
  Returns:
54
  Initial observation of the virtual file system.
55
  """
@@ -86,13 +69,8 @@ class DocSweeperEnvironment(Environment):
86
 
87
  def step(self, action: DocAction):
88
  """
89
- Execute an action and return the resulting state.
90
-
91
  Args:
92
  action: The tool action to execute (open, edit, grep, done).
93
-
94
- Returns:
95
- Observation with reward and done flag.
96
  """
97
  if self._state is None:
98
  raise RuntimeError("Environment not initialized. Call reset() first.")
@@ -159,7 +137,6 @@ class DocSweeperEnvironment(Environment):
159
  return -0.1
160
 
161
  def _evaluate_final_grade(self) -> float:
162
- # Simplified deterministic grader for example purposes
163
  text = "".join(self._state.vfs.values())
164
  if self._task == "version_bump":
165
  target_count = text.count("v2.0.0")
@@ -189,5 +166,4 @@ class DocSweeperEnvironment(Environment):
189
 
190
  @property
191
  def state(self):
192
- """Return the current episode state."""
193
  return self._state
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
 
 
 
 
 
 
 
7
  import uuid
8
  from typing import Dict, List
9
 
 
13
 
14
 
15
  class DocSweeperEnvironment(Environment):
 
 
 
 
 
 
16
 
17
  def __init__(
18
  self,
 
20
  max_steps: int = 30,
21
  ):
22
  """
 
 
23
  Args:
24
  task: Task to run - "version_bump", "config_migration", or "broken_links".
25
  max_steps: Maximum allowed actions before forced termination.
 
33
 
34
  def reset(self, **kwargs):
35
  """
 
 
36
  Returns:
37
  Initial observation of the virtual file system.
38
  """
 
69
 
70
  def step(self, action: DocAction):
71
  """
 
 
72
  Args:
73
  action: The tool action to execute (open, edit, grep, done).
 
 
 
74
  """
75
  if self._state is None:
76
  raise RuntimeError("Environment not initialized. Call reset() first.")
 
137
  return -0.1
138
 
139
  def _evaluate_final_grade(self) -> float:
 
140
  text = "".join(self._state.vfs.values())
141
  if self._task == "version_bump":
142
  target_count = text.count("v2.0.0")
 
166
 
167
  @property
168
  def state(self):
 
169
  return self._state