forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RLlib] Better PolicyServer example (w/ or w/o tune) and add printing…
… out actual listen port address in log-level=INFO. (ray-project#18254)
- Loading branch information
Showing
7 changed files
with
176 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from ray.rllib.policy.policy import PolicySpec | ||
from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID | ||
from ray.rllib.utils.typing import PartialTrainerConfigDict | ||
|
||
|
||
def check_multi_agent(config: PartialTrainerConfigDict): | ||
"""Checks, whether a (partial) config defines a multi-agent setup. | ||
Args: | ||
config (PartialTrainerConfigDict): The user/Trainer/Policy config | ||
to check for multi-agent. | ||
Returns: | ||
Tuple[MultiAgentPolicyConfigDict, bool]: The resulting (all | ||
fixed) multi-agent policy dict and whether we have a | ||
multi-agent setup or not. | ||
""" | ||
multiagent_config = config["multiagent"] | ||
policies = multiagent_config.get("policies") | ||
if not policies: | ||
policies = {DEFAULT_POLICY_ID} | ||
if isinstance(policies, set): | ||
policies = multiagent_config["policies"] = { | ||
pid: PolicySpec() | ||
for pid in policies | ||
} | ||
is_multiagent = len(policies) > 1 or DEFAULT_POLICY_ID not in policies | ||
return policies, is_multiagent |