def _register_all(): from ray.rllib.agents.trainer import Trainer, with_common_config from ray.rllib.agents.registry import ALGORITHMS, get_agent_class from ray.rllib.contrib.registry import CONTRIBUTED_ALGORITHMS for key in list(ALGORITHMS.keys()) + list(CONTRIBUTED_ALGORITHMS.keys( )) + ["__fake", "__sigmoid_fake_data", "__parameter_tuning"]: register_trainable(key, get_agent_class(key)) def _see_contrib(name): """Returns dummy agent class warning algo is in contrib/.""" class _SeeContrib(Trainer): _name = "SeeContrib" _default_config = with_common_config({}) def setup(self, config): raise NameError( "Please run `contrib/{}` instead.".format(name)) return _SeeContrib # also register the aliases minus contrib/ to give a good error message for key in list(CONTRIBUTED_ALGORITHMS.keys()): assert key.startswith("contrib/") alias = key.split("/", 1)[1] register_trainable(alias, _see_contrib(alias))
def _register_all(): from ray.rllib.agents.registry import ALGORITHMS from ray.rllib.contrib.registry import CONTRIBUTED_ALGORITHMS for key in list(ALGORITHMS.keys()) + list(CONTRIBUTED_ALGORITHMS.keys( )) + ["__fake", "__sigmoid_fake_data", "__parameter_tuning"]: from ray.rllib.agents.registry import get_agent_class register_trainable(key, get_agent_class(key))
def _register_all(): from ray.rllib.algorithms.algorithm import Algorithm from ray.rllib.algorithms.registry import ALGORITHMS, get_algorithm_class from ray.rllib.contrib.registry import CONTRIBUTED_ALGORITHMS for key in (list(ALGORITHMS.keys()) + list(CONTRIBUTED_ALGORITHMS.keys()) + ["__fake", "__sigmoid_fake_data", "__parameter_tuning"]): register_trainable(key, get_algorithm_class(key)) def _see_contrib(name): """Returns dummy agent class warning algo is in contrib/.""" class _SeeContrib(Algorithm): def setup(self, config): raise NameError( "Please run `contrib/{}` instead.".format(name)) return _SeeContrib # Also register the aliases minus contrib/ to give a good error message. for key in list(CONTRIBUTED_ALGORITHMS.keys()): assert key.startswith("contrib/") alias = key.split("/", 1)[1] if alias not in ALGORITHMS: register_trainable(alias, _see_contrib(alias))
def test_register_all(self): """Tests the old (1.10) way of registering all Trainers. Uses the old 1.10 registry.py file and thus makes sure all Trainers can still be imported using their old paths (albeit this will create a warning). """ # Try importing old Trainer class (this is just an Alias now to the `Algorithm` # class). from ray.rllib.agents.trainer import Trainer # noqa # Old registry code. from ray.rllib.tests.backward_compat.old_registry import ( ALGORITHMS, _get_trainer_class, ) from ray.rllib.contrib.registry import CONTRIBUTED_ALGORITHMS # Test the old `_get_trainer_class()` utility that was used to pull Trainer # class and default config. for key in (list(ALGORITHMS.keys()) + list(CONTRIBUTED_ALGORITHMS.keys()) + ["__fake", "__sigmoid_fake_data", "__parameter_tuning"]): _get_trainer_class(key)