forked from lithops-cloud/lithops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.py
34 lines (23 loc) · 793 Bytes
/
storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Simple Lithops example using the 'Storage' interface
"""
from lithops import FunctionExecutor, Storage
BUCKET_NAME = 'lithops-sample-data' # change-me
def my_function(obj_id, storage):
print(obj_id)
data = storage.get_cloudobject(obj_id)
return data.decode()
if __name__ == '__main__':
obj_key = 'cloudobject1.txt'
storage = Storage()
obj_id = storage.put_cloudobject('Hello World!', BUCKET_NAME, obj_key)
print(obj_id)
fexec = FunctionExecutor()
fexec.call_async(my_function, obj_id)
print(fexec.get_result())
obj_key = 'cloudobject2.txt'
storage = fexec.storage
obj_id = storage.put_cloudobject('Hello World!', BUCKET_NAME, obj_key)
print(obj_id)
fexec.call_async(my_function, obj_id)
print(fexec.get_result())