Skip to content

Commit df0bad4

Browse files
committed
Fix absmethod in workflow
1 parent 6ad5429 commit df0bad4

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

trinity/common/models/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def prepare(self) -> None:
106106
if response.status_code == 200:
107107
return
108108
except Exception as e:
109-
self.logger.info(f"API server not ready (attempt {i+1}/{max_retries}): {e}")
109+
self.logger.info(f"API server not ready (attempt {i + 1}/{max_retries}): {e}")
110110
await asyncio.sleep(interval)
111111
raise RuntimeError(
112112
f"API server at {self.api_address} not ready after {max_retries} attempts."

trinity/common/workflows/step_wise_workflow.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from abc import abstractmethod
2-
31
import openai
42

53
from trinity.common.experience import Experience
@@ -45,7 +43,6 @@ def run(self) -> list[Experience]:
4543

4644
return experiences
4745

48-
@abstractmethod
4946
def step(self, step_num: int) -> bool:
5047
"""Run a single step of your agent application.
5148
@@ -59,17 +56,16 @@ def step(self, step_num: int) -> bool:
5956
You can use the openai client (`self.client`) to migrate your existing
6057
applications at low cost.
6158
"""
62-
pass
59+
raise NotImplementedError
6360

64-
@abstractmethod
6561
def reward(self, exps: list[Experience], step_num: int) -> float:
6662
"""Calculate the reward for the given experiences at the specified step."""
67-
pass
63+
raise NotImplementedError
6864

6965
@property
70-
@abstractmethod
7166
def max_step_num(self):
7267
"""Return the maximum number of steps in the task."""
68+
raise NotImplementedError
7369

7470
@property
7571
def repeatable(self):
@@ -104,7 +100,6 @@ async def run_async(self) -> list[Experience]:
104100

105101
return experiences
106102

107-
@abstractmethod
108103
async def step_async(self, step_num: int) -> bool:
109104
"""Run a single step of your agent application asynchronously.
110105
@@ -118,12 +113,11 @@ async def step_async(self, step_num: int) -> bool:
118113
You can use the openai client (`self.client`) to migrate your existing
119114
applications at low cost.
120115
"""
121-
pass
116+
raise NotImplementedError
122117

123-
@abstractmethod
124118
async def reward_async(self, exps: list[Experience], step_num: int) -> float:
125119
"""Calculate the reward for the given experiences at the specified step asynchronously."""
126-
pass
120+
raise NotImplementedError
127121

128122

129123
class RewardPropagationWorkflow(Workflow):
@@ -166,7 +160,6 @@ def run(self) -> list[Experience]:
166160
exp.metrics["actual_env_steps"] = step + 1 # +1 because step starts from 0
167161
return experiences
168162

169-
@abstractmethod
170163
def step(self, step_num: int) -> bool:
171164
"""Run a single step of your agent application.
172165
@@ -180,17 +173,16 @@ def step(self, step_num: int) -> bool:
180173
You can use the openai client (`self.client`) to migrate your existing
181174
applications at low cost.
182175
"""
183-
pass
176+
raise NotImplementedError
184177

185-
@abstractmethod
186178
def reward(self, exps: list[Experience]) -> float:
187179
"""Calculate the reward for the given experiences of the entire run."""
188-
pass
180+
raise NotImplementedError
189181

190182
@property
191-
@abstractmethod
192183
def max_step_num(self):
193184
"""Return the maximum number of steps in the task."""
185+
raise NotImplementedError
194186

195187
@property
196188
def repeatable(self):
@@ -227,7 +219,6 @@ async def run_async(self) -> list[Experience]:
227219
exp.metrics["actual_env_steps"] = step + 1 # +1 because step starts from 0
228220
return experiences
229221

230-
@abstractmethod
231222
async def step_async(self, step_num: int) -> bool:
232223
"""Run a single step of your agent application asynchronously.
233224
@@ -241,9 +232,8 @@ async def step_async(self, step_num: int) -> bool:
241232
You can use the openai client (`self.client`) to migrate your existing
242233
applications at low cost.
243234
"""
244-
pass
235+
raise NotImplementedError
245236

246-
@abstractmethod
247237
async def reward_async(self, exps: list[Experience]) -> float:
248238
"""Calculate the reward for the given experiences of the entire run asynchronously."""
249-
pass
239+
raise NotImplementedError

trinity/common/workflows/workflow.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from __future__ import annotations
55

6-
from abc import ABC, abstractmethod
6+
from abc import ABC
77
from dataclasses import asdict, dataclass, field
88
from typing import Any, List, Optional, Type, Union
99

@@ -158,10 +158,6 @@ def set_repeat_times(self, repeat_times, run_id_base):
158158
self.repeat_times = repeat_times
159159
self.run_id_base = run_id_base
160160

161-
@abstractmethod
162-
def run(self) -> List[Experience]:
163-
"""Run workflow and return a list of experiences."""
164-
165161
def process_messages_to_experience(self, messages, reward, info={}) -> Experience:
166162
converted_experience = self.model.convert_messages_to_experience(messages)
167163

0 commit comments

Comments
 (0)