dwave-hybrid icon indicating copy to clipboard operation
dwave-hybrid copied to clipboard

Make `Lambda` stateless by default

Open randomir opened this issue 5 years ago • 0 comments

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(...))

randomir avatar Oct 22 '19 10:10 randomir