mirror of
https://github.com/wassname/ray.git
synced 2026-07-18 12:40:56 +08:00
[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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user