π OpenHands: AI-Driven Development
client runtime: fix config passing on init; added logging (#3233)
tobitege1166b0e610ea
diff --git a/opendevin/runtime/client/runtime.py b/opendevin/runtime/client/runtime.pyindex 4a5bcea33c..791e57250d 100644--- a/opendevin/runtime/client/runtime.py+++ b/opendevin/runtime/client/runtime.py@@ -1,4 +1,5 @@import asyncio+import copyimport osimport tempfileimport 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 easync 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:returnelse:- 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)@propertydef 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 Nonetry:+ logger.info('Executing command')async with session.post(f'{self.api_url}/execute_action',json={'action': event_to_dict(action)},