Skip to content

Commit 1e5c6b9

Browse files
authored
Merge pull request #14 from algorithmiaio/load-func-default
load function default improvement [urgent]
2 parents 6eca469 + 59c9a7b commit 1e5c6b9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adk/ADK.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def __init__(self, apply_func, load_func=None, client=None):
2929
if load_func:
3030
load_args, _, _, _, _, _, _ = inspect.getfullargspec(load_func)
3131
self.load_arity = len(load_args)
32-
if self.load_arity != 1:
33-
raise Exception("load function expects 1 parameter to be used to store algorithm state")
32+
if self.load_arity not in (0, 1):
33+
raise Exception("load function expects 0 parameters or 1 parameter to be used to store algorithm state")
3434
self.load_func = load_func
3535
else:
3636
self.load_func = None
@@ -48,8 +48,10 @@ def load(self):
4848
try:
4949
if self.model_data.available():
5050
self.model_data.initialize()
51-
if self.load_func:
51+
if self.load_func and self.load_arity == 1:
5252
self.load_result = self.load_func(self.model_data)
53+
elif self.load_func:
54+
self.load_result = self.load_func()
5355
except Exception as e:
5456
self.loading_exception = e
5557
finally:

0 commit comments

Comments
 (0)