docstr: Tests, whether we can build Algorithm objects with old config dicts.
docstr_tok: ["Tests",",","whether","we","can","build","Algorithm","objects","with","old","config","dicts","."]
code: def test_old_algorithm_config_dicts(self):
      """Tests, whether we can build Algorithm objects with old config dicts."""
  
      config_dict = {
          "evaluation_config": {
              "lr": 0.1,
          },
          "lr": 0.2,
          # Old-style multi-agent dict.
          "multiagent": {
              "policies": {"pol1", "pol2"},
              "policies_to_train": ["pol1"],
              "policy_mapping_fn": lambda aid, episode, worker, **kwargs: "pol1",
          },
      }
      config = AlgorithmConfig.from_dict(config_dict)
      self.assertFalse(config.in_evaluation)
      self.assertTrue(config.lr == 0.2)
      self.assertTrue(config.policies == {"pol1", "pol2"})
      self.assertTrue(config.policy_mapping_fn(1, 2, 3) == "pol1")
      eval_config = config.get_evaluation_config_object()
      self.assertTrue(eval_config.in_evaluation)
      self.assertTrue(eval_config.lr == 0.1)
  
      register_env(
          "test",
          lambda ctx: MultiAgentCartPole(
              config={"num_agents": ctx["num_agents"]}
          ),
      )
  
      config = {
          "env": "test",
          "env_config": {
              "num_agents": 1,
          },
          "lr": 0.001,
          "evaluation_config": {
              "num_envs_per_worker": 4,
              "explore": False,
          },
          "evaluation_num_workers": 1,
          "multiagent": {
              "policies": {
                  "policy1": PolicySpec(),
              },
              "policy_mapping_fn": lambda aid, episode, worker, **kw: "policy1",
              "policies_to_train": ["policy1"],
          },
      }
      algo = DQN(config=config)
      self.assertTrue(algo.config.lr == 0.001)
      self.assertTrue(algo.config.evaluation_num_workers == 1)
      self.assertTrue(list(algo.config.policies.keys()) == ["policy1"])
      self.assertTrue(algo.config.explore is True)
      self.assertTrue(algo.evaluation_config.explore is False)
      print(algo.train())
      algo.stop()
  
imports: import os
  from pathlib import Path
  from packaging import version
  import sys
  import unittest
  import ray
  import ray.cloudpickle
  from ray.rllib.algorithms.algorithm import Algorithm
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.dqn import DQN
  from ray.rllib.algorithms.ppo import PPO
  from ray.rllib.examples.env.multi_agent import MultiAgentCartPole
  from ray.rllib.policy.policy import Policy, PolicySpec
  from ray.rllib.utils.checkpoints import get_checkpoint_info
  from ray.rllib.utils.test_utils import framework_iterator
  from ray.tune.registry import register_env
label_desc: Use image node_id 4 for calling the TestBackwardCompatibility obj's underlying member method code with example usage: obj.test_old_algorithm_config_dicts() without return types