Skip to content

Commit 18bb7d4

Browse files
committed
Changed tune.report import for ray>=2
1 parent 6d53929 commit 18bb7d4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

flaml/tune/tune.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,16 @@ def compute_with_config(config):
197197
global _training_iteration
198198
if _use_ray:
199199
try:
200-
from ray import tune
200+
from ray import __version__ as ray_version
201+
202+
if ray_version.startswith("1."):
203+
from ray import tune
204+
205+
return tune.report(_metric, **kwargs)
206+
else: # ray>=2
207+
from ray.air import session
201208

202-
return tune.report(_metric, **kwargs)
209+
return session.report(metrics={"metric": _metric, **kwargs})
203210
except ImportError:
204211
# calling tune.report() outside tune.run()
205212
return

0 commit comments

Comments
 (0)