Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Can't use processor without args #575

Open
aguschin opened this issue Jan 18, 2023 · 0 comments
Open

Can't use processor without args #575

aguschin opened this issue Jan 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@aguschin
Copy link
Contributor

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: 
@aguschin aguschin added the bug Something isn't working label Jan 18, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant