Getting Started with Lithops
Installation
pip install lithops Lithops is available as a Python package that can be installed with pip. It requires Python 3.6 or higher.
Configuration
Lithops needs access to your cloud provider credentials. You can configure Lithops in several ways:
- Using a configuration file (
~/.lithops_config) - Using environment variables
- Programmatically when creating the executor
Example Configuration File
lithops:
backend: aws_lambda
aws:
access_key_id: your_access_key
secret_access_key: your_secret_key
region: us-east-1 Your First Lithops Function
Here's a simple example to get you started with Lithops:
from lithops import FunctionExecutor
def hello_world(name):
return f'Hello, {name}!'
# Create a FunctionExecutor
with FunctionExecutor() as executor:
# Execute the function
future = executor.call_async(hello_world, 'World')
# Get the result
result = future.result()
print(result) # Prints: Hello, World! Parallel Execution
Lithops makes it easy to execute functions in parallel:
from lithops import FunctionExecutor
def process_data(data):
# Some computation with the data
return data * 2
data_list = list(range(10))
with FunctionExecutor() as executor:
# Map the function to the data
futures = executor.map(process_data, data_list)
# Get all results
results = executor.get_result()
print(results) # Prints: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] Next Steps
Now that you've got the basics, you can:
- Explore the full documentation
- Learn about green computing with Lithops
- Check out the example repository
- Join the Lithops community on Slack