Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lithops/job/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from types import CodeType, FunctionType, ModuleType

from lithops.libs import imp
from lithops.libs import inspect as linspect
from lithops.utils import bytes_to_b64str
from lithops.libs.multyvac.module_dependency import ModuleDependencyAnalyzer

Expand Down Expand Up @@ -132,7 +133,7 @@ def _module_inspect(self, obj):
worklist.append(obj)

elif type(obj).__name__ == 'cython_function_or_method':
for k, v in inspect.getmembers(obj):
for k, v in linspect.getmembers_static(obj):
if k == '__globals__':
mods.add(v['__file__'])

Expand All @@ -146,13 +147,13 @@ def _module_inspect(self, obj):
worklist.append(param)
else:
# it is a user defined class
for k, v in inspect.getmembers(param):
for k, v in linspect.getmembers_static(param):
if inspect.isfunction(v) or (inspect.ismethod(v) and inspect.isfunction(v.__func__)):
worklist.append(v)
else:
# The obj is the user's function but in form of a class
found_methods = []
for k, v in inspect.getmembers(obj):
for k, v in linspect.getmembers_static(obj):
if inspect.isfunction(v) or (inspect.ismethod(v) and inspect.isfunction(v.__func__)):
found_methods.append(k)
worklist.append(v)
Expand Down
15 changes: 15 additions & 0 deletions lithops/tests/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,18 @@ def my_map_function_storage(key_i, bucket_name, storage):
else:
counter[word] += 1
return counter


class SideEffect:
def __init__(self):
pass

@property
def foo(self):
raise RuntimeError("Side effect triggered")

result = 5


def passthrough_function(x):
return x.result
13 changes: 12 additions & 1 deletion lithops/tests/test_call_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import pytest
import lithops
import logging
from lithops.tests.functions import simple_map_function
from lithops.tests.functions import (
SideEffect,
passthrough_function,
simple_map_function
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -50,3 +54,10 @@ def test_dict_iterdata(self):
fexec.call_async(simple_map_function, {'x': 2, 'y': 8})
result = fexec.get_result()
assert result == 10

def test_object_with_side_effects(self):
se = SideEffect()
fexec = lithops.FunctionExecutor(config=pytest.lithops_config)
fexec.call_async(passthrough_function, se)
result = fexec.get_result()
assert result == 5
1 change: 0 additions & 1 deletion lithops/tests/test_map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def setup_class(cls):
@classmethod
def teardown_class(cls):
for key in cls.storage.list_keys(bucket=cls.bucket, prefix=DATASET_PREFIX):
logger.debug(key)
cls.storage.delete_object(bucket=cls.bucket, key=key)

def test_simple_map_reduce(self):
Expand Down
1 change: 0 additions & 1 deletion lithops/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def setup_class(cls):
@classmethod
def teardown_class(cls):
for key in cls.storage.list_keys(bucket=cls.bucket, prefix=STORAGE_PREFIX):
logger.debug(key)
cls.storage.delete_object(bucket=cls.bucket, key=key)

def test_storage_handler(self):
Expand Down