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

Bug fixes #6460

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 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
fcab126
Reverted "Add container snapshot/restore support"
Jan 25, 2025
607ee43
Revert "Create docker-snapshots.py"
Jan 25, 2025
57ece7e
Merge branch 'main' into bug-fixes
xingyaoww Jan 29, 2025
9813d19
Merge branch 'main' into bug-fixes
kripper Jan 30, 2025
5600e2b
Removed comments
kripper Jan 30, 2025
4d119d0
Reverted host network fallback hack (not required anymore)
kripper Feb 11, 2025
44cd778
Merge branch 'main' into bug-fixes
kripper Feb 11, 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we already have something like this before but we removed it because it was yet another way to run OpenHands that is not fully supported?
By adding extra ways to run OH, we need them to be maintained and I'm not sure if the current maintainers will want to maintain another way. Unless you add a note that says "This is not officially supported and may not work".

I'll let people like @enyst comment.

Copy link
Contributor Author

@kripper kripper Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. The team decided not to support DevContainer.
I tried the official documentation, but it didn’t work on Windows probably because it requieres you too install a Linux WSL distro + tools on top of WSL. Probably not difficult, but I expected easy instructions to start out of the box, and DevContainers helped here.

DevContainer is simply a definition that specifies which Linux environment to create to make it easier to start developing and debugging OH, especially in Windows. You just open VS Code and it starts the container. When you close VS Code, the container is automatically stopped. You can also start the container manually outside VS Code. It's very simple and handy.
That said, I’m happy to give it support and make it an easier UX for new developers.

Please let me know if you want any further refinements!

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",
"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"
}
12 changes: 12 additions & 0 deletions .devcontainer/on_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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 -

# 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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove devcontainer here

2 changes: 1 addition & 1 deletion openhands/core/config/sandbox_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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'}
15 changes: 10 additions & 5 deletions openhands/runtime/impl/docker/docker_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,26 +306,31 @@ 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])

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',
f'attached to container: {self.container_name} {self._container_port} {self.api_url}',
)

@tenacity.retry(
stop=tenacity.stop_after_delay(120) | stop_if_should_exit(),
stop=tenacity.stop_after_delay(300) | stop_if_should_exit(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this increase?

Suggested change
stop=tenacity.stop_after_delay(300) | stop_if_should_exit(),
stop=tenacity.stop_after_delay(120) | stop_if_should_exit(),

retry=tenacity.retry_if_exception_type(
(ConnectionError, requests.exceptions.ConnectionError)
),
Expand Down
Loading