- class adaptive.runner.AsyncRunner(learner, goal=None, *, executor=None, ntasks=None, log=False, shutdown_executor=False, ioloop=None, retries=0, raise_if_retries_exceeded=True)#
Run a learner asynchronously in an executor using
goal (callable, optional) – The end condition for the calculation. This function must take the learner as its sole argument, and return True when we should stop requesting more points. If not provided, the runner will run forever, or until
concurrent.futures.Executor, distributed.Client,) –
- mpi4py.futures.MPIPoolExecutor, ipyparallel.Client or
ntasks (int, optional) – The number of concurrent function evaluations. Defaults to the number of cores available in executor.
log (bool, default: False) – If True, record the method calls made to the learner by this runner.
shutdown_executor (bool, default: False) – If True, shutdown the executor when the runner has completed. If executor is not provided then the executor created internally by the runner is shut down, regardless of this parameter.
asyncio.AbstractEventLoop, optional) – The ioloop in which to run the learning algorithm. If not provided, the default event loop is used.
retries (int, default: 0) – Maximum amount of retries of a certain point
learner.function(x). After retries is reached for
xthe point is present in
raise_if_retries_exceeded (bool, default: True) – Raise the error after a point
The underlying learner. May be queried for its state.
Record of the method calls made to the learner, in the format
(point, n_fails). When a point has failed
runner.retriestimes it is removed but will be present in
list of tuples
List of of
(point, tb)for points that failed.
list of tuples
A list of tuples with
list of tuples
- elapsed_time : callable
A method that returns the time elapsed since the runner was started.
- overhead : callable
The overhead in percent of using Adaptive. This includes the overhead of the executor. Essentially, this is
100 * (1 - total_elapsed_function_time / self.elapsed_time()).
This runner can be used when an async function (defined with
async def) has to be learned. In this case the function will be run directly on the event loop (and not in the executor).
Cancel the runner.
This is equivalent to calling
Return the total time elapsed since the runner was started.
- live_info(*, update_interval=0.1)#
Display live information about the runner.
Returns an interactive ipywidget that can be visualized in a Jupyter notebook.
- live_plot(*, plotter=None, update_interval=2, name=None, normalize=True)#
Live plotting of the learner’s data.
plotter (function) – A function that takes the learner as a argument and returns a holoviews object. By default
learner.plot()will be called.
update_interval (int) – Number of second between the updates of the plot.
normalize (bool) – Normalize (scale to fit) the frame upon each update.
dm – The plot that automatically updates every update_interval.
- Return type
- start_periodic_saving(save_kwargs: dict[str, Any] | None = None, interval: int = 30, method: Callable[[BaseLearner], None] | None = None)#
Periodically save the learner’s data.
save_kwargs (dict) – Key-word arguments for
learner.save(**save_kwargs). Only used if
interval (int) – Number of seconds between saving the learner.
method (callable) – The method to use for saving the learner. If None, the default saves the learner using “pickle” which calls
learner.save(**save_kwargs). Otherwise provide a callable that takes the learner and saves the learner.
>>> runner = Runner(learner) >>> runner.start_periodic_saving( ... save_kwargs=dict(fname='data/test.pickle'), ... interval=600)
Return the runner status as a string.
The possible statuses are: running, cancelled, failed, and finished.