Using Compiler Sandboxes
Using Python packages, uploading files, and more.
Function supports defining custom sandboxes that can be used to reconstruct your Python environment before compiling your function.
Sandboxes are very much experimental, and will likely see major changes, additions, and revisions in the near future.
Defining a Sandbox
To compile in a sandbox, create one and provide it to the @compile
decorator:
Installing Packages
Sandboxes support installing both Python and Debian packages in the compiler sandbox:
Installing Python Packages
Use the Sandbox.pip_install
method to install Python packages from the PyPi registry:
Installing Debian Packages
Use the Sandbox.apt_install
method to install Debian system packages:
Uploading Files
You can upload files and directories to your sandbox, useful for prediction functions that require resources like model weights.
Uploading a File
Use the Sandbox.upload_file
method to upload a file to a path in the sandbox:
Uploading a Directory
Use the Sandbox.upload_directory
method to upload a directory and all its contents to a path in the sandbox:
Defining Environment Variables
Use the Sandbox.env
method to define plaintext environment variables:
Function does not yet support defining secrets. Do not provide secrets using sandbox environment variables as they are not designed for storing secrets.