mlem
mlem copied to clipboard
Can't use processor without args
You can have a model without args:
from mlem.api import save, load_meta
import random
def f():
random.seed(0)
return random.random()
save(f, "bug", sample_data=None)
print(f(), f())
model = load_meta("bug", load_value=True)
print(model())
output:
0.8444218515250481 0.8444218515250481
0.8444218515250481
But if you add the same processor manually, using it fails:
from mlem.core.objects import MlemModel, ModelAnalyzer
model = MlemModel()
model.add_processor("random", ModelAnalyzer.analyze(f))
model.call_orders["random"] = [("random", "__call__")]
model.random()
output:
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
Cell In[5], line 1
----> 1 model.random()
File ~/Git/iterative/mlem/mlem/core/objects.py:880, in _ModelMethodCall.__call__(self, *args, **kwargs)
876 if self.model.is_single_model:
877 return self.model.model_type.call_method(
878 self.name, *args, **kwargs
879 )
--> 880 data = next(itertools.chain(args, kwargs.values()))
881 for proc_name, method in self.order:
882 data = self.model.get_processor(proc_name).call_method(
883 method, data
884 )
StopIteration: