Skip to main content
Tensorlake functions run in completely isolated environments. To install dependencies in those environments, we use containers images that are built when you deploy an application. By default function images use a generic Debian based image python:{LOCAL_PYTHON_VERSION}-slim-bookworm. LOCAL_PYTHON_VERSION represents the Python version in your current Python environment. Functions can depend on any Python or system packages installed into their container images. Tensorlake provides a declarative API to define function container images with their dependencies. When you deploy an application, the function container images are automatically built as part of the deployment process.

How to define images

Tensorlake gives you a library to define your own custom images when you need to customize the environment in which your functions run.
1

Define your image

An image is defined using the Image class from the tensorlake module. You can modify the base image, run commands to install dependencies at build time, and modify some image’s attributes, like its name.
from tensorlake.applications import Image

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

Associate your function to the image defined

In the function decorator, we pass the image object. This tells Tensorlake to run the function in the specified image.
from tensorlake.applications import function

@function(image=image)
def parse_pdf(pdf_path: str) -> str:
    ...
I