Skip to main content
Tensorlake functions run in function containers. To install dependencies in the containers, we use container images that are built when you deploy an application. Functions can use any Python or system packages installed into their container images. Tensorlake provides a declarative API to define function container images with their dependencies.

Defining Images

1

Define your image

An image is defined using an Image object. You can modify the base image, run commands to install dependencies at build time, and modify other image attributes, like its name.
from tensorlake.applications import Image

image = (
    Image(
        name="my-pdf-parser-image",
        base_image="ubuntu:24.04",
    )
    .run("apt update")
    .run("pip install langchain")
)
2

Associate the image with the function

from tensorlake.applications import function

@function(image=image)
def parse_pdf(pdf_path: str) -> str:
    import langchain
    # All the packages installed in the image are available inside the function.
    # They need to be imported here because they might not be available
    # in the Python environment used to deploy the application.
    ...

Default Base Image

We use a Debian based image python:{LOCAL_PYTHON_VERSION}-slim-bookworm as the default. LOCAL_PYTHON_VERSION represents the Python version in your current Python environment.