By default function containers use a basic Debian based container image python:{LOCAL_PYTHON_VERSION}-slim-bookworm with LOCAL_PYTHON_VERSION being Python version from the current Python environment. Functions can depend on any Python or system packages installed into their container images. We provide declarative APIs to define function container images with the dependencies. When you deploy a graph, the function container images are automatically built as part of the deploy process.

Images

Specify the commands to install dependencies in the image used to run functions. You can choose any base image, and install any system or python dependencies. An image can be used to run multiple functions.

Step 1: Define the Image

from tensorlake import Image

image = (
    Image()
    .name("my-pdf-parser-image")
    .base_image("ubuntu:22.04")
    .run("apt update")
    .run("pip install torch")
    .run("pip install langchain")
)
This defines an Image object and specify the name of the image. We then run commands to install the dependencies. You can use any base image, the default being python:{LOCAL_PYTHON_VERSION}-slim-bookworm.

Step 2: Use the Image in a Function

from tensorlake import tensorlake_function

@tensorlake_function(image=image)
def parse_pdf(pdf_path: str) -> str:
    ...
In the function decorator, we pass the image object. This tells Tensorlake to run the function in the specified image.