-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sandbox): Implementation of Sandbox Plugin to Support Jupyter (#…
…1255) * initialize plugin definition * initialize plugin definition * simplify mixin * further improve plugin mixin * add cache dir for pip * support clean up cache * add script for setup jupyter and execution server * integrate JupyterRequirement to ssh_box * source bashrc at the end of plugin load * add execute_cli that accept code via stdin * make JUPYTER_EXEC_SERVER_PORT configurable via env var * increase background cmd sleep time * Update opendevin/sandbox/plugins/mixin.py Co-authored-by: Robert Brennan <accounts@rbren.io> * add mixin to base class * make jupyter requirement a dataclass * source plugins only when >0 requirements * add `sandbox_plugins` for each agent & have controller take care of it * update build.sh to make logs available in /opendevin/logs * switch to use config for lib and cache dir * fix permission issue with /workspace * use python to implement execute_cli to avoid stdin escape issue * wait until jupyter is avaialble * support plugin via copying instead of mounting --------- Co-authored-by: Robert Brennan <accounts@rbren.io>
- Loading branch information
Showing
19 changed files
with
566 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .mixin import PluginMixin | ||
from .requirement import PluginRequirement | ||
|
||
# Requirements | ||
from .jupyter import JupyterRequirement | ||
|
||
__all__ = ['PluginMixin', 'PluginRequirement', 'JupyterRequirement'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
from dataclasses import dataclass | ||
from opendevin.sandbox.plugins.requirement import PluginRequirement | ||
|
||
|
||
@dataclass | ||
class JupyterRequirement(PluginRequirement): | ||
name: str = 'jupyter' | ||
host_src: str = os.path.dirname(os.path.abspath(__file__)) # The directory of this file (sandbox/plugins/jupyter) | ||
sandbox_dest: str = '/opendevin/plugins/jupyter' | ||
bash_script_path: str = 'setup.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import sys | ||
import time | ||
import requests | ||
|
||
# Read the Python code from STDIN | ||
code = sys.stdin.read() | ||
|
||
# Set the default kernel ID | ||
kernel_id = 'default' | ||
|
||
# try 5 times until success | ||
PORT = os.environ.get('JUPYTER_EXEC_SERVER_PORT') | ||
POST_URL = f'http://localhost:{PORT}/execute' | ||
|
||
for i in range(5): | ||
response = requests.post(POST_URL, json={'kernel_id': kernel_id, 'code': code}) | ||
# if "500: Internal Server Error" is not in the response, break the loop | ||
if '500: Internal Server Error' not in response.text: | ||
break | ||
time.sleep(1) | ||
|
||
# Print the response | ||
print(str(response.text)) |
Oops, something went wrong.