This document describes how to use Singularity containers as runtimes for your Lithops functions.
The runtime provides a pre-configured environment to execute your Lithops functions within Singularity containers. It includes the necessary and dependencies to execute your lithops code.
Note: This backend requires a RabbitMQ server for communication.
Use the lithops runtime build command to create a .sif image containing the necessary Lithops environment.
-
Building a basic runtime
$ lithops runtime build -b singularity singularity-runtime-name --fakeroot --forceThis command creates the a new
singularity-runtime-name.siffile with the necessary libraries. -
Building a custom runtime from a definition file
For greater control and flexibility with custom packages, use a Singularity definition file (.def):
$ lithops runtime build -b singularity my-custom-runtime -f my-runtime.def --fakeroot --forceThis command generates
my-custom-runtime.sifbased onmy-runtime.def.
Building flags:
--fakeroot: Often required for building Singularity images without root privileges.--force: Overwrites any existing images with the same name.
You can find more information about the Singularity flags in the Singularity documentation.
We need to perform a manual deployment because we do not have direct access to the cluster nodes. In this case, manually transferring the built .sif image to each cluster node is necessary. This ensures that the required runtime environment is available on each node for running Lithops functions.
-
Image Transfer: Manually transfer the built
.sifimage to each cluster node that will run Lithops functions. -
Starting the Singularity Instance: On each node, start a Singularity instance with your runtime image:
$ singularity instance start --fakeroot /tmp/singularity-runtime-name.sif lithops-workerThis creates a Singularity instance called
lithops-worker. -
Running Functions: Execute Lithops functions within this instance:
$ singularity run --env AMQP_URL=amqp://<username>:<password>@<rabbitmq_host>:<rabbitmq_port>/<vhost> instance://lithops-workerReplace the placeholders (e.g.,
<username>) with your RabbitMQ credentials to enable communication between your Lithops client and the function runtime.
By default, the Singularity runtime uses the /tmp directory to store the .sif images. You can customize this path in your Lithops configuration file:
singularity:
sif_path: /your/custom/path
runtime: singularity-runtime-nameAlso, to execute the Singularity backend, you need to set the RabbitMQ AMPQ URL in your configuration file:
rabbitmq:
amqp_url: amqp://<username>:<password>@<rabbitmq_host>:<rabbitmq_port>/<vhost>