op.Image describes that container’s operating system, Python runtime and dependencies, and local files. Images are:
- Lazy: OuterProduct prepares them when they are first used by a Call.
- Immutable: methods such as
with_uv_pip_install()return a new Image instead of modifying the existing one.
Start from a container image
Create an Image from any compatible container registry reference. The base image supplies the operating system and Python interpreter.Install Python packages
Usewith_uv_pip_install() to add packages to the environment:
Add local files and directories
An Image can include files from your local project. Useadd_local_file() for an individual file and add_local_dir() for a directory:
Run with an Image
Pass the Image toclient.run():
If a nested Call uses an Image with local files, assign that Image to a variable outside any function, in the same file as the function you pass to
client.run(). OuterProduct uploads the local files of those Images from your machine when the Run starts; Images created inside a function can’t find their local files once they’re running remotely.