Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed tune.report import for ray>=2 #1392

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
11 changes: 9 additions & 2 deletions flaml/tune/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,16 @@ def compute_with_config(config):
global _training_iteration
if _use_ray:
try:
from ray import tune
from ray import __version__ as ray_version

if ray_version.startswith("1."):
from ray import tune

return tune.report(_metric, **kwargs)
else: # ray>=2
from ray.air import session

return tune.report(_metric, **kwargs)
return session.report(metrics={"metric": _metric, **kwargs})
except ImportError:
# calling tune.report() outside tune.run()
return
Expand Down
Loading