forked from lithops-cloud/lithops
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstorage_arg.py
More file actions
29 lines (22 loc) · 756 Bytes
/
storage_arg.py
File metadata and controls
29 lines (22 loc) · 756 Bytes
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
"""
Simple Lithops example using the 'storage' parameter, which is
a ready-to-use Storage instance.
"""
import lithops
def my_function(bucket_name, obj_key, storage):
print(f'I am processing the object //{bucket_name}/{obj_key}')
counter = {}
data = storage.get_object(bucket_name, obj_key)
for line in data.splitlines():
for word in line.decode('utf-8').split():
if word not in counter:
counter[word] = 1
else:
counter[word] += 1
return counter
if __name__ == '__main__':
bucket_name = 'lithops-sample-data'
obj_key = 'obj1.txt'
fexec = lithops.FunctionExecutor()
fexec.call_async(my_function, (bucket_name, obj_key))
print(fexec.get_result())