Use the Sandbox.pip_install method to install Python packages from the PyPi registry:
predictor.py
Copy
from muna import compile, Sandbox# Install numpy and sklearnsandbox = (Sandbox() .pip_install("numpy", "scikit-learn"))# Compile your function with the sandbox@compile(..., sandbox=sandbox)def predict() -> np.ndarray: ...
We highly recommend pinning the specific versions of Python packages in use, so as to
prevent incompatibilities when creating the sandbox.
Use the Sandbox.apt_install method to install Debian system packages:
predictor.py
Copy
from muna import compile, Sandbox# Install git and wgetsandbox = (Sandbox() .apt_install("git", "wget"))# Compile your function with the sandbox@compile(..., sandbox=sandbox)def predict() -> BytesIO: ...
Use the Sandbox.upload_file method to upload a file to a path in the sandbox:
predictor.py
Copy
from muna import compile, Sandbox# Upload a model weight to the sandboxsandbox = (Sandbox() .upload_file("DeepSeek-R1.gguf", "/Deepseek-R1.gguf"))# Compile your function with the sandbox@compile(..., sandbox=sandbox)def predict(prompt: str) -> str: ...
Use the Sandbox.upload_directory method to upload a directory and all its contents to a path in the sandbox:
predictor.py
Copy
from muna import compile, Sandbox# Upload a directory to the sandboxsandbox = (Sandbox() .upload_file("resources/", "/resources"))# Compile your function with the sandbox@compile(..., sandbox=sandbox)def predict(prompt: str) -> str: ...
Use the Sandbox.env method to define plaintext environment variables:
predictor.py
Copy
from muna import compile, Sandbox# Define an environment variablesandbox = (Sandbox() .env({ "MUNA_WEBSITE": "https://muna.ai" }))# Compile your function with the sandbox@compile(..., sandbox=sandbox)def predict(prompt: str) -> str: ...
Muna does not yet support defining secrets. Do not provide secrets
using sandbox environment variables as they are not designed for storing secrets.