Skip to content

Commit 3aba9d4

Browse files
committed
add the use of 'runner.traceback' and 'runner.elapsed_time()' to the docs
1 parent a6dae43 commit 3aba9d4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

adaptive/runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def _run(self):
338338
self._cleanup()
339339

340340
def elapsed_time(self):
341+
"""Return the total time elapsed since the runner
342+
was started."""
341343
if self.end_time is None:
342344
# This shouldn't happen if the BlockingRunner
343345
# correctly finished.
@@ -532,6 +534,8 @@ async def _run(self):
532534
self._cleanup()
533535

534536
def elapsed_time(self):
537+
"""Return the total time elapsed since the runner
538+
was started."""
535539
if self.task.done():
536540
end_time = self.end_time
537541
if end_time is None:

docs/source/tutorial/tutorial.advanced-topics.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ raise the exception with the stack trace:
298298

299299
runner.task.result()
300300

301+
302+
You can also check ``runner.tracebacks`` which is a mapping from
303+
point → traceback.
304+
305+
.. jupyter-execute::
306+
307+
for point, tb in runner.tracebacks.items():
308+
print(f'point: {point}:\n {tb}')
309+
301310
Logging runners
302311
~~~~~~~~~~~~~~~
303312

@@ -337,10 +346,16 @@ set of operations on another runner:
337346

338347
learner.plot().Scatter.I.opts(style=dict(size=6)) * reconstructed_learner.plot()
339348

340-
Timing functions
341-
~~~~~~~~~~~~~~~~
349+
Adding coroutines
350+
-----------------
351+
352+
In the following example we'll add a `~asyncio.Task` that times the runner.
353+
This is *only* for demonstration purposes because one can simply
354+
check ``runner.elapsed_time()`` or use the ``runner.live_info()``
355+
widget to see the time since the runner has started.
342356

343-
To time the runner you **cannot** simply use
357+
So let's get on with the example. To time the runner
358+
you **cannot** simply use
344359

345360
.. code:: python
346361

0 commit comments

Comments
 (0)