Skip to content

Commit 1166b0e

Browse files
authored
client runtime: fix config passing on init; added logging (#3233)
1 parent a1fec39 commit 1166b0e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

opendevin/runtime/client/runtime.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import copy
23
import os
34
import tempfile
45
import uuid
@@ -49,6 +50,7 @@ def __init__(
4950
plugins: list[PluginRequirement] | None = None,
5051
container_image: str | None = None,
5152
):
53+
self.config = copy.deepcopy(config)
5254
super().__init__(
5355
config, event_stream, sid, plugins
5456
) # will initialize the event stream
@@ -136,12 +138,15 @@ async def _init_container(
136138

137139
if mount_dir is not None:
138140
volumes = {mount_dir: {'bind': sandbox_workspace_dir, 'mode': 'rw'}}
141+
logger.info(f'Mount dir: {sandbox_workspace_dir}')
139142
else:
140143
logger.warn(
141144
'Mount dir is not set, will not mount the workspace directory to the container.'
142145
)
143146
volumes = None
144147

148+
logger.info(f'run_as_devin: `{self.config.run_as_devin}`')
149+
145150
container = self.docker_client.containers.run(
146151
self.container_image,
147152
command=(
@@ -170,26 +175,25 @@ async def _init_container(
170175
raise e
171176

172177
async def _ensure_session(self):
178+
await asyncio.sleep(1)
173179
if self.session is None or self.session.closed:
174180
self.session = aiohttp.ClientSession()
175181
return self.session
176182

177183
@tenacity.retry(
178184
stop=tenacity.stop_after_attempt(10),
179-
wait=tenacity.wait_exponential(multiplier=2, min=4, max=600),
185+
wait=tenacity.wait_exponential(multiplier=2, min=4, max=60),
180186
)
181187
async def _wait_until_alive(self):
188+
logger.info('Reconnecting session')
182189
async with aiohttp.ClientSession() as session:
183190
async with session.get(f'{self.api_url}/alive') as response:
184191
if response.status == 200:
185192
return
186193
else:
187-
logger.error(
188-
f'Action execution API is not alive. Response: {response}'
189-
)
190-
raise RuntimeError(
191-
f'Action execution API is not alive. Response: {response}'
192-
)
194+
msg = f'Action execution API is not alive. Response: {response}'
195+
logger.error(msg)
196+
raise RuntimeError(msg)
193197

194198
@property
195199
def sandbox_workspace_dir(self):
@@ -278,12 +282,14 @@ async def run_action(self, action: Action) -> Observation:
278282
f'Action {action_type} is not supported in the current runtime.'
279283
)
280284

285+
logger.info('Awaiting session')
281286
session = await self._ensure_session()
282287
await self._wait_until_alive()
283288

284289
assert action.timeout is not None
285290

286291
try:
292+
logger.info('Executing command')
287293
async with session.post(
288294
f'{self.api_url}/execute_action',
289295
json={'action': event_to_dict(action)},

0 commit comments

Comments
 (0)