From 6d11fb8bc6a7eaed92e9e3247ed244c6a9b218f3 Mon Sep 17 00:00:00 2001 From: Kai Fricke Date: Wed, 21 Oct 2020 00:03:24 +0100 Subject: [PATCH] [tune] validate function callable in `tune.with_parameters()` (#11504) --- python/ray/tune/function_runner.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/ray/tune/function_runner.py b/python/ray/tune/function_runner.py index 5b0c59abf..9fa19e6d2 100644 --- a/python/ray/tune/function_runner.py +++ b/python/ray/tune/function_runner.py @@ -616,6 +616,12 @@ def with_parameters(fn, **kwargs): ) """ + if not callable(fn): + raise ValueError( + "`tune.with_parameters()` only works with the function API. " + "If you want to pass parameters to Trainable _classes_, consider " + "passing them via the `config` parameter.") + prefix = f"{str(fn)}_" for k, v in kwargs.items(): parameter_registry.put(prefix + k, v)