[tune] Support yield and return statements (#10857)

* Support `yield` and `return` statements in Tune trainable functions

* Support anonymous metric with ``tune.report(value)``

* Raise on invalid return/yield value

* Fix end to end reporter test
This commit is contained in:
Kai Fricke
2020-09-17 20:18:35 -07:00
committed by GitHub
parent 5cbc411e38
commit 508cfa3540
5 changed files with 172 additions and 45 deletions
+3 -2
View File
@@ -55,7 +55,7 @@ def shutdown():
_session = None
def report(**kwargs):
def report(_metric=None, **kwargs):
"""Logs all keyword arguments.
.. code-block:: python
@@ -71,12 +71,13 @@ def report(**kwargs):
analysis = tune.run(run_me)
Args:
_metric: Optional default anonymous metric for ``tune.report(value)``
**kwargs: Any key value pair to be logged by Tune. Any of these
metrics can be used for early stopping or optimization.
"""
_session = get_session()
if _session:
return _session(**kwargs)
return _session(_metric, **kwargs)
def make_checkpoint_dir(step=None):