-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
[RLlib] Adjust callback validation to account for MultiCallback
.
#50920
base: master
Are you sure you want to change the base?
[RLlib] Adjust callback validation to account for MultiCallback
.
#50920
Conversation
…nd added a test for callbacks. Signed-off-by: simonsays1980 <[email protected]>
@@ -0,0 +1,131 @@ | |||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Let's add this to BUILD ...
rllib/algorithms/algorithm_config.py
Outdated
"returns a subclass of DefaultCallbacks, got " | ||
f"{callbacks_class}!" | ||
) | ||
if isinstance(callbacks_class, list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we simplify a bit?
Something like:
from ray.rllib.utils import force_list
to_check = force_list(callbacks_class)
if not all(callable(cc) for cc in to_check):
raise ValueError ...
Avoids the many if blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just one nit and to add to BUILD. Thx @simonsays1980 !
MultiCallback
.MultiCallback
.
…d the test to the BUILD file and removed an if-clause. Signed-off-by: simonsays1980 <[email protected]>
Signed-off-by: simonsays1980 <[email protected]>
Why are these changes needed?
The validation of
Algorithm.callbacks
was expecting solely aCallable
fromcallback_class
. For aMultiCallback
users can, however, pass inList[RLlibCallback]
. The latter was running into a validation error. This PR fixes this bug and adds a test for callbacks to the CI suite.Related issue number
Closes #48089
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.