[BugFix] Check agent presence before updating action mask in PettingZoo#3703
[BugFix] Check agent presence before updating action mask in PettingZoo#3703nshoman wants to merge 1 commit intopytorch:mainfrom
Conversation
check to see if the agent is present in the observation and info dicts before accessing the keys
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3703
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New FailuresAs of commit b4f3e2e with merge base 8038188 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @nshoman! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
@nshoman thanks for contributing. Can you sign the CLA, I can't merge without it |
Sorry for the delay! I'll ping you once I've done so; my employer has to sign off on it, so it might take a few days. |
Description
This PR fixes a case an error in the PettingZoo adapter where, in cases of a
ParallelEnv, with action masking anddone_on_any=False, aKeyErrorcan occur. This happens because there is no check on active agents before values are pulled from the observation dictionary. PettingZoo expects that the observation dictionary only contains entries for active agents.Motivation and Context
PettingZoo expects that agents are removed from observations if inactive, so the
torchrlshould handle that situation. It's worth noting that I implemented a simple check before trying to index the dictionary, but another viable fix would be repositioning the existing checkif agent in agents_acting:to an earlier location in the execution path as well.This is a PR to address #3702.
Types of changes
What types of changes does your code introduce? Remove all that do not apply:
Checklist
Go over all the following points, and put an
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!