Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 3.21 KB

File metadata and controls

74 lines (51 loc) · 3.21 KB

Virtual Machine

Lithops can run functions using a remote host or a virtual machine (VM). In this backend, Lithops uses all the available VM CPUs to parallelize the tasks of a job. For testing purposes, it is preferable to have an Ubuntu > 22.04 host.

Configuration

  1. Edit your Lithops config and add the following keys:
lithops:
    backend: vm
    
vm:
    ip_address: <ip>
    ssh_username: <username>
    ssh_password: <password>

Execution Environments

The virtual machine backend can run functions either using the default python3 interpreter of the VM, or by using a Docker container within the VM. The environment is automatically chosen depending on whether or not you provided a Docker image as a runtime.

Default Environment

The default environment runs the functions in the same python3 interpreter that you ran the Lithops script. It does not require any extra configuration. You must ensure that your VM contains the same python3 interpreter, and all the dependencies required by your Lithops app. So, once the backend is configured in the config file, you only need to create a FunctionExecutor to work with it:

fexec = lithops.FunctionExecutor()

Docker Environment

The Docker environment runs the functions within a Docker container. In this case you must install the Docker CE version in your VM. Note that in this case the container image must contain all the dependencies required by your Lithops app. This environment is automatically activated when you provide a Docker image as a runtime. For example, by adding the following keys in the config:

vm:
    runtime: lithopscloud/ibmcf-python-v312

or by using the runtime param in a function executor:

fexec = lithops.FunctionExecutor(runtime='lithopscloud/ibmcf-python-v312')

In this backend, you can use any Docker image that contains all the required dependencies. For example, the IBM Cloud Functions and Knative runtimes are compatible with it.

Summary of configuration keys for a single Virtual Machine:

Group Key Default Mandatory Additional info
vm ip_address yes IP Address of the VM
vm ssh_username yes SSH username for accessing the VM
vm ssh_password no SSH password for accessing the VM
vm ssh_key_filename no Path to SSH key
vm runtime python3 no python3 or a Docker image name
vm worker_processes 1 no Number of Lithops processes within the VM. This can be used to parallelize function activations within the VM. It is recommended to set it to the same number of CPUs as the VM
vm extra_apt_packages [] no Extra Debian/Ubuntu packages during Lithops setup on the VM (YAML list or space-separated string)
vm extra_python_packages [] no Extra pip packages after Lithops on the VM (YAML list or space-separated string)

Test Lithops

Once you have your compute and storage backends configured, you can run a Hello World function with:

lithops hello -b vm -s aws_s3

Viewing the execution logs

You can view the function executions logs in your local machine using the lithops client:

lithops logs poll