Dependencies
Python and System dependencies of functions can be packaged into images.
Custom Docker Images
Specify the commands to install dependencies in a custom Docker image. You can choose any base image, and install any system or python dependencies.
An image can be used to run multiple functions. You can specify the image name in the function decorator.
Step 1: Define the Image
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:3.11.10-slim-bookworm
.
Step 2: Use the Image in a Function
In the function decorator, we pass the image
object. This tells Tensorlake to run the function in the specified image.
Step 3: Build the Image
You can build the Docker image using the tensorlake prepare
command.
Assuming the function is in a file named pdf_parser.py
, you can run:
This will build the Docker image, named my-pdf-parser-image
.
Step 4: Deploying Functions
When you deploy a graph, images are automatically build as part of the deploy process.
Tensorlake will ensure that all invocations of a specific function is done within the image defined on the tensorlake_function
decorator.
Was this page helpful?