code-interpreter
code-interpreter copied to clipboard
run_code as a user instead of root
- Jupyter Server and Code Interpreter are started as a non-privileged user
- Adds ability to change user by creating a new context
- BREAKING: Default user root > user to match the Sandbox commands.run behavior
- POSSIBLY BREAKING: when cwd is not set and user is root, it will set cwd to /root
Sample code
const ctx = await sbx.createCodeContext({ language: "python", user: "user" })
const code = await sbx.runCode(`import getpass; print(getpass.getuser())`, { context })
console.log(code.logs);
{
stdout: [ "user\n" ],
stderr: [],
}
This won't be probably backwards compatible right?
Can I specify if I want run something as root?
Not backwards-compatible. You cannot specify the user, the kernels start as same user as Jupyter. There is a possible some workaround suggested by ChatGPT but it's a bit inconvenient:
I created a new template, code-interpreter-v1beta1