Skip to content

Commit e8556cd

Browse files
committed
remove extra git config init since it is already done in client.py
1 parent 5fdd04b commit e8556cd

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

opendevin/runtime/client/runtime.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
)
2323
from opendevin.events.action.action import Action
2424
from opendevin.events.observation import (
25-
CmdOutputObservation,
2625
ErrorObservation,
2726
NullObservation,
2827
Observation,
@@ -98,8 +97,6 @@ async def ainit(self, env_vars: dict[str, str] | None = None):
9897
)
9998
logger.info(f'Container initialized with env vars: {env_vars}')
10099

101-
await self._init_git_config()
102-
103100
@staticmethod
104101
def _init_docker_client() -> docker.DockerClient:
105102
try:
@@ -183,16 +180,6 @@ async def _init_container(
183180
await self.close(close_client=False)
184181
raise e
185182

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-
196183
async def _ensure_session(self):
197184
await asyncio.sleep(1)
198185
if self.session is None or self.session.closed:
@@ -204,7 +191,8 @@ async def _ensure_session(self):
204191
wait=tenacity.wait_exponential(multiplier=2, min=4, max=60),
205192
)
206193
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()
208196
async with aiohttp.ClientSession() as session:
209197
async with session.get(f'{self.api_url}/alive') as response:
210198
if response.status == 200:
@@ -218,21 +206,31 @@ async def _wait_until_alive(self):
218206
def sandbox_workspace_dir(self):
219207
return self.config.workspace_mount_path_in_sandbox
220208

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+
221223
async def close(self, close_client: bool = True):
222224
if self.session is not None and not self.session.closed:
223225
await self.session.close()
224226

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
236234
if close_client:
237235
self.docker_client.close()
238236

0 commit comments

Comments
 (0)