Skip to content

Commit

Permalink
[RLlib] Remove all default config objects and rllib/agents (#33242)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
  • Loading branch information
ArturNiederfahrenhorst authored Mar 17, 2023
1 parent 5651256 commit 8a9a176
Show file tree
Hide file tree
Showing 79 changed files with 108 additions and 697 deletions.
4 changes: 2 additions & 2 deletions rllib/algorithms/a2c/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ray.rllib.algorithms.a2c.a2c import A2CConfig, A2C, A2C_DEFAULT_CONFIG
from ray.rllib.algorithms.a2c.a2c import A2CConfig, A2C

__all__ = ["A2CConfig", "A2C", "A2C_DEFAULT_CONFIG"]
__all__ = ["A2CConfig", "A2C"]
18 changes: 0 additions & 18 deletions rllib/algorithms/a2c/a2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
)
from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated
from ray.rllib.utils.metrics import (
APPLY_GRADS_TIMER,
COMPUTE_GRADS_TIMER,
Expand Down Expand Up @@ -241,20 +240,3 @@ def training_step(self) -> ResultDict:
train_results = {DEFAULT_POLICY_ID: info}

return train_results


# Deprecated: Use ray.rllib.algorithms.a2c.A2CConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(A2CConfig().to_dict())

@Deprecated(
old="ray.rllib.agents.a3c.a2c.A2C_DEFAULT_CONFIG",
new="ray.rllib.algorithms.a2c.a2c.A2CConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


A2C_DEFAULT_CONFIG = _deprecated_default_config()
4 changes: 2 additions & 2 deletions rllib/algorithms/a3c/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ray.rllib.algorithms.a3c.a3c import A3CConfig, A3C, DEFAULT_CONFIG
from ray.rllib.algorithms.a3c.a3c import A3CConfig, A3C

__all__ = ["A3CConfig", "A3C", "DEFAULT_CONFIG"]
__all__ = ["A3CConfig", "A3C"]
18 changes: 0 additions & 18 deletions rllib/algorithms/a3c/a3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ray.rllib.evaluation.rollout_worker import RolloutWorker
from ray.rllib.policy.policy import Policy
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated
from ray.rllib.utils.metrics import (
APPLY_GRADS_TIMER,
GRAD_WAIT_TIMER,
Expand Down Expand Up @@ -251,20 +250,3 @@ def sample_and_compute_grads(worker: RolloutWorker) -> Dict[str, Any]:
)

return learner_info_builder.finalize()


# Deprecated: Use ray.rllib.algorithms.a3c.A3CConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(A3CConfig().to_dict())

@Deprecated(
old="ray.rllib.agents.a3c.a3c.DEFAULT_CONFIG",
new="ray.rllib.algorithms.a3c.a3c.A3CConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
6 changes: 3 additions & 3 deletions rllib/algorithms/algorithm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def from_dict(cls, config_dict: dict) -> "AlgorithmConfig":
"""Creates an AlgorithmConfig from a legacy python config dict.
Examples:
>>> from ray.rllib.algorithms.ppo.ppo import DEFAULT_CONFIG, PPOConfig
>>> ppo_config = PPOConfig.from_dict(DEFAULT_CONFIG)
>>> ppo = ppo_config.build(env="Pendulum-v1")
>>> from ray.rllib.algorithms.ppo.ppo import PPOConfig # doctest: +SKIP
>>> ppo_config = PPOConfig.from_dict({...}) # doctest: +SKIP
>>> ppo = ppo_config.build(env="Pendulum-v1") # doctest: +SKIP
Args:
config_dict: The legacy formatted python config dict for some algorithm.
Expand Down
2 changes: 0 additions & 2 deletions rllib/algorithms/alpha_star/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from ray.rllib.algorithms.alpha_star.alpha_star import (
AlphaStar,
AlphaStarConfig,
DEFAULT_CONFIG,
)

__all__ = [
"AlphaStar",
"AlphaStarConfig",
"DEFAULT_CONFIG",
]
18 changes: 0 additions & 18 deletions rllib/algorithms/alpha_star/alpha_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ray.rllib.policy.sample_batch import MultiAgentBatch
from ray.rllib.utils import deep_update
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated
from ray.rllib.utils.from_config import from_config
from ray.rllib.utils.metrics import (
LAST_TARGET_UPDATE_TS,
Expand Down Expand Up @@ -635,20 +634,3 @@ def __setstate__(self, state: dict) -> None:
state_copy = state.copy()
self.league_builder.__setstate__(state.pop("league_builder", {}))
super().__setstate__(state_copy)


# Deprecated: Use ray.rllib.algorithms.alpha_star.AlphaStarConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(AlphaStarConfig().to_dict())

@Deprecated(
old="ray.rllib.algorithms.alpha_star.alpha_star.DEFAULT_CONFIG",
new="ray.rllib.algorithms.alpha_star.alpha_star.AlphaStarConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
2 changes: 0 additions & 2 deletions rllib/algorithms/alpha_zero/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from ray.rllib.algorithms.alpha_zero.alpha_zero import (
AlphaZero,
AlphaZeroConfig,
DEFAULT_CONFIG,
)
from ray.rllib.algorithms.alpha_zero.alpha_zero_policy import AlphaZeroPolicy

__all__ = [
"AlphaZero",
"AlphaZeroConfig",
"AlphaZeroPolicy",
"DEFAULT_CONFIG",
]
19 changes: 1 addition & 18 deletions rllib/algorithms/alpha_zero/alpha_zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ray.rllib.models.torch.torch_action_dist import TorchCategorical
from ray.rllib.policy.policy import Policy
from ray.rllib.policy.sample_batch import concat_samples
from ray.rllib.utils.annotations import Deprecated, override
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import DEPRECATED_VALUE
from ray.rllib.utils.framework import try_import_torch
from ray.rllib.utils.metrics import (
Expand Down Expand Up @@ -400,20 +400,3 @@ def training_step(self) -> ResultDict:

# Return all collected metrics for the iteration.
return train_results


# Deprecated: Use ray.rllib.algorithms.alpha_zero.AlphaZeroConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(AlphaZeroConfig().to_dict())

@Deprecated(
old="ray.rllib.algorithms.alpha_zero.alpha_zero.DEFAULT_CONFIG",
new="ray.rllib.algorithms.alpha_zero.alpha_zero.AlphaZeroConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
2 changes: 0 additions & 2 deletions rllib/algorithms/apex_ddpg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from ray.rllib.algorithms.apex_ddpg.apex_ddpg import (
ApexDDPG,
ApexDDPGConfig,
APEX_DDPG_DEFAULT_CONFIG,
)

__all__ = [
"ApexDDPG",
"ApexDDPGConfig",
"APEX_DDPG_DEFAULT_CONFIG",
]
19 changes: 1 addition & 18 deletions rllib/algorithms/apex_ddpg/apex_ddpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ray.rllib.algorithms.apex_dqn.apex_dqn import ApexDQN
from ray.rllib.algorithms.ddpg.ddpg import DDPG, DDPGConfig
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import DEPRECATED_VALUE, Deprecated
from ray.rllib.utils.deprecation import DEPRECATED_VALUE
from ray.rllib.utils.typing import (
ResultDict,
)
Expand Down Expand Up @@ -147,20 +147,3 @@ def setup(self, config: AlgorithmConfig):
def training_step(self) -> ResultDict:
"""Use APEX-DQN's training iteration function."""
return ApexDQN.training_step(self)


# Deprecated: Use ray.rllib.algorithms.apex_ddpg.ApexDDPGConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(ApexDDPGConfig().to_dict())

@Deprecated(
old="ray.rllib.algorithms.ddpg.apex.APEX_DDPG_DEFAULT_CONFIG",
new="ray.rllib.algorithms.apex_ddpg.apex_ddpg::ApexDDPGConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


APEX_DDPG_DEFAULT_CONFIG = _deprecated_default_config()
2 changes: 0 additions & 2 deletions rllib/algorithms/apex_dqn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from ray.rllib.algorithms.apex_dqn.apex_dqn import (
ApexDQN,
ApexDQNConfig,
APEX_DEFAULT_CONFIG,
)

__all__ = [
"ApexDQN",
"ApexDQNConfig",
"APEX_DEFAULT_CONFIG",
]
19 changes: 1 addition & 18 deletions rllib/algorithms/apex_dqn/apex_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ray.rllib.utils.actor_manager import FaultTolerantActorManager
from ray.rllib.utils.actors import create_colocated_actors
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import DEPRECATED_VALUE, Deprecated
from ray.rllib.utils.deprecation import DEPRECATED_VALUE
from ray.rllib.utils.metrics import (
LAST_TARGET_UPDATE_TS,
NUM_AGENT_STEPS_SAMPLED,
Expand Down Expand Up @@ -753,20 +753,3 @@ def default_resource_request(
),
strategy=cf.placement_strategy,
)


# Deprecated: Use ray.rllib.algorithms.apex_dqn.ApexDQNConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(ApexDQNConfig().to_dict())

@Deprecated(
old="ray.rllib.agents.dqn.apex.APEX_DEFAULT_CONFIG",
new="ray.rllib.algorithms.apex_dqn.apex_dqn.ApexDQNConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


APEX_DEFAULT_CONFIG = _deprecated_default_config()
3 changes: 1 addition & 2 deletions rllib/algorithms/appo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ray.rllib.algorithms.appo.appo import APPO, APPOConfig, DEFAULT_CONFIG
from ray.rllib.algorithms.appo.appo import APPO, APPOConfig
from ray.rllib.algorithms.appo.appo_tf_policy import APPOTF1Policy, APPOTF2Policy
from ray.rllib.algorithms.appo.appo_torch_policy import APPOTorchPolicy

Expand All @@ -8,5 +8,4 @@
"APPOTF1Policy",
"APPOTF2Policy",
"APPOTorchPolicy",
"DEFAULT_CONFIG",
]
18 changes: 0 additions & 18 deletions rllib/algorithms/appo/appo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ray.rllib.execution.common import _get_shared_metrics, STEPS_SAMPLED_COUNTER
from ray.rllib.policy.policy import Policy
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated
from ray.rllib.utils.metrics import (
LAST_TARGET_UPDATE_TS,
NUM_AGENT_STEPS_SAMPLED,
Expand Down Expand Up @@ -294,20 +293,3 @@ def get_default_policy_class(
from ray.rllib.algorithms.appo.appo_tf_policy import APPOTF2Policy

return APPOTF2Policy


# Deprecated: Use ray.rllib.algorithms.appo.APPOConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(APPOConfig().to_dict())

@Deprecated(
old="ray.rllib.agents.ppo.appo::DEFAULT_CONFIG",
new="ray.rllib.algorithms.appo.appo::APPOConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
3 changes: 1 addition & 2 deletions rllib/algorithms/ars/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ray.rllib.algorithms.ars.ars import ARS, ARSConfig, DEFAULT_CONFIG
from ray.rllib.algorithms.ars.ars import ARS, ARSConfig
from ray.rllib.algorithms.ars.ars_tf_policy import ARSTFPolicy
from ray.rllib.algorithms.ars.ars_torch_policy import ARSTorchPolicy

Expand All @@ -7,5 +7,4 @@
"ARSConfig",
"ARSTFPolicy",
"ARSTorchPolicy",
"DEFAULT_CONFIG",
]
18 changes: 0 additions & 18 deletions rllib/algorithms/ars/ars.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ray.rllib.utils import FilterManager
from ray.rllib.utils.actor_manager import FaultAwareApply
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated
from ray.rllib.utils.metrics import (
NUM_AGENT_STEPS_SAMPLED,
NUM_AGENT_STEPS_TRAINED,
Expand Down Expand Up @@ -605,20 +604,3 @@ def __setstate__(self, state):
FilterManager.synchronize(
{DEFAULT_POLICY_ID: self.policy.observation_filter}, self.workers
)


# Deprecated: Use ray.rllib.algorithms.ars.ARSConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(ARSConfig().to_dict())

@Deprecated(
old="ray.rllib.algorithms.ars.ars.DEFAULT_CONFIG",
new="ray.rllib.algorithms.ars.ars.ARSConfig(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
2 changes: 1 addition & 1 deletion rllib/algorithms/ars/ars_torch_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name="ARSTorchPolicy",
framework="torch",
loss_fn=None,
get_default_config=lambda: ray.rllib.algorithms.ars.ars.DEFAULT_CONFIG,
get_default_config=lambda: ray.rllib.algorithms.ars.ars.ARSConfig(),
before_init=before_init,
after_init=after_init,
make_model_and_action_dist=make_model_and_action_dist,
Expand Down
18 changes: 0 additions & 18 deletions rllib/algorithms/bandit/bandit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ray.rllib.algorithms.bandit.bandit_torch_policy import BanditTorchPolicy
from ray.rllib.policy.policy import Policy
from ray.rllib.utils.annotations import override
from ray.rllib.utils.deprecation import Deprecated

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -121,20 +120,3 @@ def get_default_policy_class(
return BanditTFPolicy
else:
raise NotImplementedError("Only `framework=[torch|tf2]` supported!")


# Deprecated: Use ray.rllib.algorithms.bandit.BanditLinUCBConfig instead!
class _deprecated_default_config(dict):
def __init__(self):
super().__init__(BanditLinUCBConfig().to_dict())

@Deprecated(
old="ray.rllib.algorithms.bandit.bandit.DEFAULT_CONFIG",
new="ray.rllib.algorithms.bandit.bandit.BanditLin[UCB|TS]Config(...)",
error=True,
)
def __getitem__(self, item):
return super().__getitem__(item)


DEFAULT_CONFIG = _deprecated_default_config()
2 changes: 1 addition & 1 deletion rllib/algorithms/bandit/bandit_tf_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def after_init(policy, *args):

BanditTFPolicy = build_tf_policy(
name="BanditTFPolicy",
get_default_config=lambda: ray.rllib.algorithms.bandit.bandit.DEFAULT_CONFIG,
get_default_config=lambda: ray.rllib.algorithms.bandit.bandit.BanditConfig(),
validate_spaces=validate_spaces,
make_model=make_model,
loss_fn=None,
Expand Down
4 changes: 1 addition & 3 deletions rllib/algorithms/bc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from ray.rllib.algorithms.bc.bc import BCConfig, BC, BC_DEFAULT_CONFIG
from ray.rllib.algorithms.bc.bc import BCConfig, BC

__all__ = [
"BCConfig",
"BC",
# Deprecated.
"BC_DEFAULT_CONFIG",
]
Loading

0 comments on commit 8a9a176

Please sign in to comment.