Skip to content
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] Convert PolicySpec to a readable format when converting to_dict() #31146

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion rllib/algorithms/algorithm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,22 @@ def to_dict(self) -> AlgorithmConfigDict:
# Setup legacy multi-agent sub-dict:
config["multiagent"] = {}
for k in self.multiagent.keys():
config["multiagent"][k] = config.pop(k)
# convert policies dict to something human-readable
if k == "policies" and isinstance(self.multiagent[k], dict):
policies_dict = {}
for policy_id, policy_spec in self.multiagent[k].items():
if isinstance(policy_spec, PolicySpec):
policies_dict[policy_id] = (
policy_spec.policy_class,
policy_spec.observation_space,
policy_spec.action_space,
policy_spec.config,
)
else:
policies_dict[policy_id] = policy_spec
config["multiagent"][k] = policies_dict
else:
config["multiagent"][k] = config.pop(k)

# Switch out deprecated vs new config keys.
config["callbacks"] = config.pop("callbacks_class", DefaultCallbacks)
Expand Down