22
22
)
23
23
from opendevin .events .action .action import Action
24
24
from opendevin .events .observation import (
25
- CmdOutputObservation ,
26
25
ErrorObservation ,
27
26
NullObservation ,
28
27
Observation ,
@@ -98,8 +97,6 @@ async def ainit(self, env_vars: dict[str, str] | None = None):
98
97
)
99
98
logger .info (f'Container initialized with env vars: { env_vars } ' )
100
99
101
- await self ._init_git_config ()
102
-
103
100
@staticmethod
104
101
def _init_docker_client () -> docker .DockerClient :
105
102
try :
@@ -183,16 +180,6 @@ async def _init_container(
183
180
await self .close (close_client = False )
184
181
raise e
185
182
186
- async def _init_git_config (self ):
187
- action = CmdRunAction (
188
- 'git config --global user.name "opendevin" && '
189
- 'git config --global user.email "[email protected] "'
190
- )
191
- logger .info (f'Setting git config: { action } ' )
192
- obs : Observation = await self .run_action (action )
193
- assert isinstance (obs , CmdOutputObservation )
194
- assert obs .exit_code == 0 , f'Failed to set git config: { obs } '
195
-
196
183
async def _ensure_session (self ):
197
184
await asyncio .sleep (1 )
198
185
if self .session is None or self .session .closed :
@@ -204,7 +191,8 @@ async def _ensure_session(self):
204
191
wait = tenacity .wait_exponential (multiplier = 2 , min = 4 , max = 60 ),
205
192
)
206
193
async def _wait_until_alive (self ):
207
- logger .info ('Reconnecting session' )
194
+ logger .info ('Waiting for the runtime to be alive...' )
195
+ self ._print_container_logs ()
208
196
async with aiohttp .ClientSession () as session :
209
197
async with session .get (f'{ self .api_url } /alive' ) as response :
210
198
if response .status == 200 :
@@ -218,21 +206,31 @@ async def _wait_until_alive(self):
218
206
def sandbox_workspace_dir (self ):
219
207
return self .config .workspace_mount_path_in_sandbox
220
208
209
+ def _print_container_logs (self , tail : int = 1000 , debug : bool = False ):
210
+ try :
211
+ container = self .docker_client .containers .get (self .container_name )
212
+ logs = container .logs (tail = tail ).decode ('utf-8' )
213
+ if debug :
214
+ logger_fn = logger .debug
215
+ else :
216
+ logger_fn = logger .info
217
+ logger_fn (
218
+ f'==== Container logs ====\n { logs } \n ==== End of container logs ===='
219
+ )
220
+ except docker .errors .NotFound :
221
+ pass
222
+
221
223
async def close (self , close_client : bool = True ):
222
224
if self .session is not None and not self .session .closed :
223
225
await self .session .close ()
224
226
225
- containers = self .docker_client .containers .list (all = True )
226
- for container in containers :
227
- try :
228
- if container .name .startswith (self .container_name_prefix ):
229
- logs = container .logs (tail = 1000 ).decode ('utf-8' )
230
- logger .debug (
231
- f'==== Container logs ====\n { logs } \n ==== End of container logs ===='
232
- )
233
- container .remove (force = True )
234
- except docker .errors .NotFound :
235
- pass
227
+ self ._print_container_logs (tail = 1000 , debug = True )
228
+ container = self .docker_client .containers .get (self .container_name )
229
+ try :
230
+ if container .name .startswith (self .container_name_prefix ):
231
+ container .remove (force = True )
232
+ except docker .errors .NotFound :
233
+ pass
236
234
if close_client :
237
235
self .docker_client .close ()
238
236
0 commit comments