Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container snapshots/restore feature and other critical bug fixes #6441

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fcc2bee
Re-enabled devcontainer.json (usefull for windows developers)
kripper Dec 19, 2024
46e5b81
Merge remote-tracking branch 'upstream/main'
kripper Jan 8, 2025
02ca830
Merge remote-tracking branch 'upstream/main'
kripper Jan 21, 2025
331d9a1
Global .gitignore for VS Code
kripper Jan 22, 2025
a8c80a4
Merge remote-tracking branch 'upstream/main'
kripper Jan 22, 2025
65ded25
Fix https://github.com/All-Hands-AI/OpenHands/issues/5569#issuecommen…
kripper Jan 23, 2025
3de310c
Dev Containers support
kripper Jan 23, 2025
116d1e3
Fix https://github.com/All-Hands-AI/OpenHands/issues/6382
kripper Jan 23, 2025
c57c386
Merge remote-tracking branch 'upstream/main'
kripper Jan 23, 2025
35beb18
Fix https://github.com/All-Hands-AI/OpenHands/issues/6440
kripper Jan 23, 2025
b373281
Merge branch 'main' into main
kripper Jan 24, 2025
0afef18
Merge branch 'main' into main
kripper Jan 24, 2025
97465c6
Create docker-snapshots.py
kripper Jan 24, 2025
74acf2b
Add container snapshot/restore support
kripper Jan 25, 2025
cc959ee
Merge branch 'main' into main
kripper Jan 25, 2025
5161a62
Merge remote-tracking branch 'upstream/main'
kripper Jan 25, 2025
d405fd7
Fix for running in app container
kripper Jan 26, 2025
e0f0437
Merge branch 'main' of https://github.com/kripper/OpenHands
kripper Jan 26, 2025
780acd0
chmod +x
Jan 26, 2025
316f6c5
Fix https://github.com/All-Hands-AI/OpenHands/issues/6461
Jan 26, 2025
df368cc
Fix https://github.com/All-Hands-AI/OpenHands/issues/6461
kripper Jan 26, 2025
6fb7631
Removed comments
kripper Jan 30, 2025
a487638
Prevent re-format
kripper Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The files in this directory configure a development container that can be used for development on Windows using Microsoft's "Dev Containers" extension for VS Code.
kripper marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "OpenHands Codespaces",
/* Doesn't work because Dockerfile uses HEREDOCS (currently not supported by Dev Containers)
"build": {
"dockerfile": "../containers/dev/Dockerfile"
},
*/
"image": "mcr.microsoft.com/devcontainers/universal",
kripper marked this conversation as resolved.
Show resolved Hide resolved
"runArgs": [
"--name=openhands-dev-container",
"--network=host"
],
"customizations":{
"vscode":{
"extensions": [
"ms-python.python"
]
}
},
"onCreateCommand": "sh ./.devcontainer/on_create.sh",
"postCreateCommand": "yes | make build",
"postStartCommand": "bash ./.devcontainer/on_run.sh"
}
18 changes: 18 additions & 0 deletions .devcontainer/on_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
sudo apt update
sudo apt install -y netcat
sudo add-apt-repository -y ppa:deadsnakes/ppa
curl -sSL https://install.python-poetry.org | python3.12 -

# WAS working:
#sudo add-apt-repository -y ppa:deadsnakes/ppa \
# && apt-get update \
# && apt-get install -y python3.12 python3.12-venv python3.12-dev python3-pip \
# && ln -s /usr/bin/python3.12 /usr/bin/python

# See: https://github.com/SmartManoj/Kevin/issues/122#issuecomment-2540482254
git config --global --add safe.directory /workspaces/OpenHands

# Global .gitignore for VS Code
echo ".history/" > ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
4 changes: 4 additions & 0 deletions .devcontainer/on_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
#USE_HOST_NETWORK=True nohup bash -c '(litellm --config my-configs/litellm.yaml &) ; make run' &> output.log &
export USE_HOST_NETWORK=True
bash -c '(nohup bash -c "make run") &> output.log'
2 changes: 1 addition & 1 deletion openhands/core/config/sandbox_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ class SandboxConfig(BaseModel):
close_delay: int = Field(default=15)
remote_runtime_resource_factor: int = Field(default=1)
enable_gpu: bool = Field(default=False)
docker_runtime_kwargs: str | None = Field(default=None)
docker_runtime_kwargs: dict | None = Field(default=None)

model_config = {'extra': 'forbid'}
16 changes: 12 additions & 4 deletions openhands/runtime/impl/docker/docker_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,26 @@ def _attach_to_container(self):
self.container = self.docker_client.containers.get(self.container_name)
if self.container.status == 'exited':
self.container.start()

config = self.container.attrs['Config']
for env_var in config['Env']:
if env_var.startswith('port='):
self._host_port = int(env_var.split('port=')[1])
self._container_port = self._host_port
elif env_var.startswith('VSCODE_PORT='):
self._vscode_port = int(env_var.split('VSCODE_PORT=')[1])
else:
# fallback if host network is used
self._container_port = int(self.container.attrs['Args'][9])

self._app_ports = []
for exposed_port in config['ExposedPorts'].keys():
exposed_port = int(exposed_port.split('/tcp')[0])
if exposed_port != self._host_port and exposed_port != self._vscode_port:
self._app_ports.append(exposed_port)
exposed_ports = config.get('ExposedPorts')
if exposed_ports:
for exposed_port in exposed_ports.keys():
exposed_port = int(exposed_port.split('/tcp')[0])
if exposed_port != self._host_port and exposed_port != self._vscode_port:
self._app_ports.append(exposed_port)

self.api_url = f'{self.config.sandbox.local_runtime_url}:{self._container_port}'
self.log(
'debug',
Expand Down