mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* 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>
26 lines
626 B
Python
Executable File
26 lines
626 B
Python
Executable File
#!/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))
|