diff --git a/lithops/job/serialize.py b/lithops/job/serialize.py index 7c8cbcc29..e140f7003 100644 --- a/lithops/job/serialize.py +++ b/lithops/job/serialize.py @@ -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 @@ -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__']) @@ -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) diff --git a/lithops/tests/functions.py b/lithops/tests/functions.py index 93208b6bf..6af1c844e 100644 --- a/lithops/tests/functions.py +++ b/lithops/tests/functions.py @@ -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 diff --git a/lithops/tests/test_call_async.py b/lithops/tests/test_call_async.py index f0b75cd60..b74d8fac4 100644 --- a/lithops/tests/test_call_async.py +++ b/lithops/tests/test_call_async.py @@ -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__) @@ -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 diff --git a/lithops/tests/test_map_reduce.py b/lithops/tests/test_map_reduce.py index 8425ef13a..6bc39c1c6 100644 --- a/lithops/tests/test_map_reduce.py +++ b/lithops/tests/test_map_reduce.py @@ -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): diff --git a/lithops/tests/test_storage.py b/lithops/tests/test_storage.py index d7dcb5ae8..04c7eac34 100644 --- a/lithops/tests/test_storage.py +++ b/lithops/tests/test_storage.py @@ -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):