Skip to content

Commit 394b5e5

Browse files
committed
linting fixes
1 parent 6c628a3 commit 394b5e5

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎training/environments/oolong/oolong/env.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
from typing import Any
1010

1111
import dateutil.parser
12+
import rlm_train
1213
import verifiers as vf
1314
from datasets import Dataset, load_dataset
1415

15-
import rlm_train
16-
17-
1816
COMPARISON_PHRASES = ("more common than", "less common than", "same frequency as")
1917

2018

‎training/src/rlm_train/env.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import asyncio
66
import logging
77
import uuid
8-
from typing import Any, Callable
8+
from collections.abc import Callable
9+
from typing import Any
910

1011
import verifiers as vf
1112
from verifiers.types import Messages, State
@@ -17,7 +18,6 @@
1718
build_rlm_system_prompt,
1819
build_user_prompt,
1920
)
20-
2121
from rlm_train.proxy import ClientHandle, SubLLMProxy
2222
from rlm_train.repl.base import ExecResult, ReplBackend
2323
from rlm_train.repl.subprocess import SubprocessReplBackend

‎training/src/rlm_train/proxy.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
import asyncio
66
import inspect
77
import logging
8+
from collections.abc import Awaitable, Callable
89
from dataclasses import dataclass
9-
from typing import Any, Awaitable, Callable, Union
10+
from typing import Any
1011

1112
from aiohttp import web
1213

1314
logger = logging.getLogger(__name__)
1415

1516

16-
FakeQuery = Callable[[str, "Any"], Union[str, Awaitable[str]]]
17-
FakeQueryBatched = Callable[[list[str], "Any"], Union[list[str], Awaitable[list[str]]]]
17+
FakeQuery = Callable[[str, "Any"], str | Awaitable[str]]
18+
FakeQueryBatched = Callable[[list[str], "Any"], list[str] | Awaitable[list[str]]]
1819

1920

2021
@dataclass
@@ -178,7 +179,7 @@ async def _handle_batched(self, request: web.Request) -> web.Response:
178179
if not isinstance(responses, list) or len(responses) != len(prompts):
179180
return web.json_response({"error": "fake_query_batched returned wrong shape"})
180181
if handle.record_call is not None:
181-
for p, r in zip(prompts, responses):
182+
for p, r in zip(prompts, responses, strict=True):
182183
try:
183184
handle.record_call({"model": model, "prompt": p, "response": r})
184185
except Exception:

‎training/src/rlm_train/repl/subprocess.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def start(self, proxy_url: str, rollout_id: str, depth: int = 1) -> None:
5757
self._stderr_task = asyncio.create_task(self._drain_stderr())
5858
try:
5959
init = await asyncio.wait_for(self._read_line(), timeout=self._startup_timeout)
60-
except asyncio.TimeoutError as e:
60+
except TimeoutError as e:
6161
await self.stop()
6262
raise WorkerStartupError(
6363
f"Worker did not produce init line in {self._startup_timeout}s; "
@@ -75,7 +75,7 @@ async def stop(self) -> None:
7575
try:
7676
await self._send({"id": "_shutdown", "type": "shutdown"})
7777
await asyncio.wait_for(self._read_line(), timeout=2.0)
78-
except (BrokenPipeError, ConnectionResetError, asyncio.TimeoutError, WorkerProtocolError):
78+
except (TimeoutError, BrokenPipeError, ConnectionResetError, WorkerProtocolError):
7979
pass
8080
finally:
8181
if self._proc.returncode is None:
@@ -85,7 +85,7 @@ async def stop(self) -> None:
8585
pass
8686
try:
8787
await asyncio.wait_for(self._proc.wait(), timeout=2.0)
88-
except asyncio.TimeoutError:
88+
except TimeoutError:
8989
self._proc.kill()
9090
await self._proc.wait()
9191
if self._stderr_task and not self._stderr_task.done():
@@ -126,7 +126,7 @@ async def _request(self, payload: dict[str, Any]) -> dict[str, Any]:
126126
await self._send(payload)
127127
try:
128128
resp = await asyncio.wait_for(self._read_line(), timeout=self._request_timeout)
129-
except asyncio.TimeoutError as e:
129+
except TimeoutError as e:
130130
await self._kill_worker()
131131
raise WorkerProtocolError(
132132
f"Request {payload.get('type')} exceeded parent watchdog "
@@ -147,7 +147,7 @@ async def _kill_worker(self) -> None:
147147
return
148148
try:
149149
await asyncio.wait_for(self._proc.wait(), timeout=2.0)
150-
except asyncio.TimeoutError:
150+
except TimeoutError:
151151
pass
152152

153153
async def _send(self, payload: dict[str, Any]) -> None:

‎training/src/rlm_train/rubric.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from __future__ import annotations
44

55
import inspect
6-
from typing import Any, Callable
6+
from collections.abc import Callable
7+
from typing import Any
78

89
import verifiers as vf
910
from verifiers.types import State

0 commit comments

Comments
 (0)