Skip to content

Commit 729ec92

Browse files
committed
Refactor timeout handling in context manager; update test to reduce avg_step_timeout and rename test function
1 parent 54c4681 commit 729ec92

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/agentlab/experiments/exp_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def _episode_timeout(exp_arg: ExpArgs, avg_step_timeout=60):
4949
def timeout_manager(seconds: int = None):
5050
"""Context manager to handle timeouts."""
5151

52-
seconds = max(1, int(seconds)) # make sure seconds is at least 1
53-
52+
if isinstance(seconds, float):
53+
seconds = max(1, int(seconds)) # make sure seconds is at least 1
54+
5455
if seconds is None or sys.platform == "win32":
5556
try:
5657
logger.warning("Timeouts are not supported on Windows.")

tests/experiments/test_launch_exp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _test_launch_system(backend="ray", cause_timeout=False):
3131
avg_step_timeout = 0.5
3232
else:
3333
wait_time = 0
34-
avg_step_timeout = 30
34+
avg_step_timeout = 10
3535

3636
exp_args_list = []
3737
for seed in range(3):
@@ -91,7 +91,7 @@ def test_launch_system_ray():
9191
_test_launch_system(backend="ray")
9292

9393

94-
def test_timeout_ray():
94+
def _test_timeout_ray():
9595
_test_launch_system(backend="ray", cause_timeout=True)
9696

9797

@@ -120,7 +120,7 @@ def test_4o_mini_on_miniwob_tiny_test():
120120

121121

122122
if __name__ == "__main__":
123-
test_timeout_ray()
123+
_test_timeout_ray()
124124
# test_4o_mini_on_miniwob_tiny_test()
125125
# test_launch_system_ray()
126126
# test_launch_system_sequntial()

0 commit comments

Comments
 (0)