Skip to content

Commit

Permalink
[RLlib] Always create connectors if it's enabled. Otherwise the polic…
Browse files Browse the repository at this point in the history
…y won't run (#31444)

Signed-off-by: Jun Gong <jungong@anyscale.com>
  • Loading branch information
Jun Gong authored Jan 4, 2023
1 parent 19e54bf commit 1abbbd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rllib/connectors/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_connectors_for_policy(policy: "Policy", config: TrainerConfigDict):
ctx: ConnectorContext = ConnectorContext.from_policy(policy)

assert (
policy.agent_connectors is None and policy.agent_connectors is None
policy.agent_connectors is None and policy.action_connectors is None
), "Can not create connectors for a policy that already has connectors."

policy.agent_connectors = get_agent_connectors_from_config(ctx, config)
Expand Down
5 changes: 4 additions & 1 deletion rllib/evaluation/rollout_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,10 @@ def _build_policy_map(
# Also note that we cannot just check the existence of connectors
# to decide whether we should create connectors because we may be
# restoring a policy that has 0 connectors configured.
if not policy and not restore_states:
if (
new_policy.agent_connectors is None
or new_policy.action_connectors is None
):
# TODO(jungong) : revisit this. It will be nicer to create
# connectors as the last step of Policy.__init__().
create_connectors_for_policy(new_policy, merged_conf)
Expand Down

0 comments on commit 1abbbd7

Please sign in to comment.