lithops-cloud / lithops

A multi-cloud framework for big data analytics and embarrassingly parallel jobs, that provides an universal API for building parallel applications in the cloud ☁️🚀
http://lithops.cloud
Apache License 2.0
315 stars 103 forks source link

Issue when updating runtime_cpus #1371

Closed abourramouss closed 1 month ago

abourramouss commented 3 months ago

The lithops FunctionExecutor allows runtime_memory as well as runtime_cpu. We can also specify the runtime_memory in a map call, but not runtime_cpus, which is decided by the FaaS backend.

The issue is when trying to update the runtime_memory or runtime_cpu once the FunctionExecutor object has been created, it doesn't get updated.

Given this code:

def my_map_function(id, x):
    print(f"I'm activation number {id}")
    time.sleep(5)
    return x + 7

if __name__ == "__main__":
    iterdata = [1, 2, 3, 4]
    fexec = FunctionExecutor(runtime_memory=800)

    fexec.config["k8s"]["runtime_memory"] = 1024
    print(fexec.config)
    fexec.map(my_map_function, range(2))
    print(fexec.get_result())

The output of this execution is:


2024-06-07 10:02:00,414 [INFO] config.py:139 -- Lithops v3.4.1.dev0 - Python3.10
2024-06-07 10:02:00,969 [INFO] minio.py:62 -- MinIO client created - Endpoint: http://192.168.5.24:9000
2024-06-07 10:02:01,002 [INFO] k8s.py:111 -- Kubernetes client created - Namespace: default
{'lithops': {'backend': 'k8s', 'storage': 'minio', 'log_level': 'INFO', 'execution_timeout': 1800, 'monitoring_interval': 2, 'mode': 'serverless', 'chunksize': 1, 'monitoring': 'storage'}, 'k8s': {'docker_server': 'docker.io', 'docker_user': 'ayman321', 'docker_password': 'some_password', 'runtime_timeout': 1800, 'runtime_memory': 1024, 'runtime_cpu': 1, 'max_workers': 100, 'worker_processes': 1, 'user_agent': 'lithops/3.4.1.dev0', 'namespace': 'default', 'cluster': 'kubernetes', 'user': '2304d41a58', 'master_name': 'lithops-master-2304d41a58', 'runtime': 'docker.io/ayman321/lithops-kubernetes-default-v310:3.4.1.dev0'}, 'minio': {'storage_bucket': 'ayman-extract', 'endpoint': 'some_endpoint', 'access_key_id': 'some_access_key', 'secret_access_key': 'some_secret_access_key', 'user_agent': 'lithops/3.4.1.dev0'}}
2024-06-07 10:02:01,002 [INFO] invokers.py:107 -- ExecutorID e3ec0c-0 | JobID M000 - Selected Runtime: docker.io/ayman321/lithops-kubernetes-default-v310:3.4.1.dev0 - 800MB
2024-06-07 10:02:01,217 [INFO] invokers.py:174 -- ExecutorID e3ec0c-0 | JobID M000 - Starting function invocation: my_map_function() - Total: 2 activations
2024-06-07 10:02:01,318 [INFO] invokers.py:213 -- ExecutorID e3ec0c-0 | JobID M000 - View execution logs at /tmp/lithops-ayman/logs/e3ec0c-0-M000.log
2024-06-07 10:02:01,318 [INFO] executors.py:491 -- ExecutorID e3ec0c-0 - Getting results from 2 function activations
2024-06-07 10:02:01,319 [INFO] wait.py:101 -- ExecutorID e3ec0c-0 - Waiting for 2 function activations to complete

In the output logs we can see that the config has been updated, but the runtime_memory that the invocation has is 800mb.

I would like to be able to update the runtime_memory or runtime_cpu without creating a new FunctionExecutor, would that be possible?

What's interesting is that when the runtime_memory is passed into the map, then it updates the runtime memory of the workers