dwave-hybrid
dwave-hybrid copied to clipboard
Make `Lambda` stateless by default
Initially, hybrid.Lambda
was made to bind hybrid.Lambda
instance as self
in next
/error
/init
calls. That allowed runnable implementations via hybrid.Lambda
to have access to a persistent state (like any other runnable does).
However, the most common hybrid.Lambda
usage pattern these days is actually a stateless runnable.
So, to simplify the common use case, we're making hybrid.Lambda
stateless (no reference to self
), and we're introducing hybrid.StatefulLambda
that'll behave like hybrid.Lambda
did so far.
Going forward, the expected usage is:
import hybrid
stateless_workflow = hybrid.Lambda(lambda state: state.updated(...))
stateful_workflow = hybrid.StatefulLambda(lambda self, state: state.updated(...))