From 1166b0e610eaa56796490fe6e2465bb91bc38042 Mon Sep 17 00:00:00 2001 From: tobitege Date: Sat, 3 Aug 2024 04:37:38 +0200 Subject: [PATCH] client runtime: fix config passing on init; added logging (#3233) --- opendevin/runtime/client/runtime.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opendevin/runtime/client/runtime.py b/opendevin/runtime/client/runtime.py index 4a5bcea33c..791e57250d 100644 --- a/opendevin/runtime/client/runtime.py +++ b/opendevin/runtime/client/runtime.py @@ -1,4 +1,5 @@ import asyncio +import copy import os import tempfile import uuid @@ -49,6 +50,7 @@ class EventStreamRuntime(Runtime): plugins: list[PluginRequirement] | None = None, container_image: str | None = None, ): + self.config = copy.deepcopy(config) super().__init__( config, event_stream, sid, plugins ) # will initialize the event stream @@ -136,12 +138,15 @@ class EventStreamRuntime(Runtime): if mount_dir is not None: volumes = {mount_dir: {'bind': sandbox_workspace_dir, 'mode': 'rw'}} + logger.info(f'Mount dir: {sandbox_workspace_dir}') else: logger.warn( 'Mount dir is not set, will not mount the workspace directory to the container.' ) volumes = None + logger.info(f'run_as_devin: `{self.config.run_as_devin}`') + container = self.docker_client.containers.run( self.container_image, command=( @@ -170,26 +175,25 @@ class EventStreamRuntime(Runtime): raise e async def _ensure_session(self): + await asyncio.sleep(1) if self.session is None or self.session.closed: self.session = aiohttp.ClientSession() return self.session @tenacity.retry( stop=tenacity.stop_after_attempt(10), - wait=tenacity.wait_exponential(multiplier=2, min=4, max=600), + wait=tenacity.wait_exponential(multiplier=2, min=4, max=60), ) async def _wait_until_alive(self): + logger.info('Reconnecting session') async with aiohttp.ClientSession() as session: async with session.get(f'{self.api_url}/alive') as response: if response.status == 200: return else: - logger.error( - f'Action execution API is not alive. Response: {response}' - ) - raise RuntimeError( - f'Action execution API is not alive. Response: {response}' - ) + msg = f'Action execution API is not alive. Response: {response}' + logger.error(msg) + raise RuntimeError(msg) @property def sandbox_workspace_dir(self): @@ -278,12 +282,14 @@ class EventStreamRuntime(Runtime): f'Action {action_type} is not supported in the current runtime.' ) + logger.info('Awaiting session') session = await self._ensure_session() await self._wait_until_alive() assert action.timeout is not None try: + logger.info('Executing command') async with session.post( f'{self.api_url}/execute_action', json={'action': event_to_dict(action)},