hybrid.core.Runnable.run#

Runnable.run(state, **kwargs)[source]#

Execute the next step/iteration of an instantiated Runnable.

Accepts a state in a Future-like object and returns a new state in a Future-like object.

Parameters:
  • state (State) – Computation state future-like object passed between connected components.

  • executor (Executor, optional, default=None) – The Executor to which the execution of this block is scheduled. By default hybrid.concurrency.thread_executor is used.

Examples

These two code snippets run one iteration of a sampler to produce a new state. The first is an asynchronous call and the second a blocking call.

>>> sampler.run(State.from_sample(min_sample(bqm), bqm))   
<Future at 0x20cbe22ea20 state=running>
>>> sampler.run(State.from_sample(min_sample(bqm), bqm),
...             executor=hybrid.immediate_executor)   
<Present at 0x20ca68cd2b0 state=finished returned State>