Skip to content

Commit 187b040

Browse files
committed
Add dev version of code runner tool.
1 parent 28b70f8 commit 187b040

3 files changed

Lines changed: 2976 additions & 561 deletions

File tree

docs/setup.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ The below is the minimal subset of changes that `--privileged=true` does that is
6060
* **Why**: The default SELinux label for containers (`container_t`) does not allow the creation of namespaces, which gVisor requires for additional isolation . The `container_engine_t` label allows this.
6161
* If you don't have SELinux enabled, this setting does nothing and may be omitted.
6262

63-
NOTE: Per bug reports (see issue #2 and #3), you may also need to set `--cgroupns=host` (see issue #2 for more details). **This is temporary and should stop being required soon.**
64-
6563
</details>
6664

6765
## Self-test mode
@@ -77,19 +75,25 @@ $ git clone https://github.com/EtiennePerot/open-webui-code-execution && \
7775
--security-opt=label=type:container_engine_t \
7876
--mount=type=bind,source="$(pwd)/open-webui-code-execution",target=/selftest \
7977
ghcr.io/open-webui/open-webui:main \
80-
python3 /selftest/open-webui/tools/run_code.py --use-sample-code
78+
python3 /selftest/open-webui/tools/run_code.py --self_test
8179
```
8280

8381
If all goes well, you should see:
8482

8583
```
86-
Event: {'type': 'status', 'data': {'status': 'in_progress', 'description': 'Checking if environment supports sandboxing...', 'done': False}}
87-
Event: {'type': 'status', 'data': {'status': 'in_progress', 'description': 'Auto-installing gVisor...', 'done': False}}
88-
Event: {'type': 'status', 'data': {'status': 'in_progress', 'description': 'Initializing sandbox configuration...', 'done': False}}
89-
Event: {'type': 'status', 'data': {'status': 'in_progress', 'description': 'Setting up sandbox environment...', 'done': False}}
90-
Event: {'type': 'status', 'data': {'status': 'in_progress', 'description': 'Running Python code in gVisor sandbox...', 'done': False}}
91-
Event: {'type': 'status', 'data': {'status': 'complete', 'description': 'Python code executed successfully.', 'done': True}}
92-
{"status": "OK", "output": "Hello from the sandbox!\nCurrent date and time: 2024-09-04 05:06:26.021759\n[ 0.000000] Starting gVisor... [...]"}
84+
⏳ Running self-test: simple_python
85+
✔ Self-test simple_python passed.
86+
⏳ Running self-test: simple_bash
87+
✔ Self-test simple_bash passed.
88+
⏳ Running self-test: bad_syntax_python
89+
✔ Self-test bad_syntax_python passed.
90+
⏳ Running self-test: bad_syntax_bash
91+
✔ Self-test bad_syntax_bash passed.
92+
⏳ Running self-test: long_running_code
93+
✔ Self-test long_running_code passed.
94+
⏳ Running self-test: ram_hog
95+
✔ Self-test ram_hog passed.
96+
✅ All self-tests passed, good go to!
9397
```
9498

9599
If you get an error, try to add the `--debug` flag at the very end of this command (i.e. as a `run_code.py` flag) for extra information, then file a bug.
@@ -107,6 +111,9 @@ The code execution tool and function have the following valves available:
107111
* **Auto Install**: Whether to automatically download and install gVisor if not present in the container.
108112
* If not installed, gVisor will be automatically installed in `/tmp`.
109113
* Useful for convenience, but should be disabled for production setups.
114+
* **Debug**: Whether to produce debug logs.
115+
* This should never be enabled in production setups as it produces a lot of information that isn't necessary for regular use.
116+
* **When filing a bug report**, please enable this valve, then reproduce the issue in a new chat session, then download the chat log (triple-dot menu → `Download``Export chat (.json)`) and attach it to the bug report.
110117

111118
## Optional: Pre-install gVisor
112119

0 commit comments

Comments
 (0)