Add wrapper checker utility for validating wrapper implementations#1556
Add wrapper checker utility for validating wrapper implementations#1556Jatin-Shihora wants to merge 3 commits intoFarama-Foundation:mainfrom
Conversation
pseudo-rnd-thoughts
left a comment
There was a problem hiding this comment.
Thanks for the PR, this overall looks good.
Could you add a test to check every wrapper that we implement to check that they all work as expected
Hi @pseudo-rnd-thoughts thanks for reviewing the PR. I just added tests that run check_wrapper() against 27 of built-in wrappers to verify they all pass the checker. I split the wrappers into three groups based on the environment they need:
The remaining wrappers I couldn't find a clean way to test:
If there's a preferred way to handle these (maybe pytest.importorskip for the ones that just need optional deps?), happy to add those too. total tests: 41 tests (14 original + 27 new ones) |
Description
Add a
check_wrapper()utility function for validating that wrapper implementations follow Gymnasium's Wrapper API correctly, similar to the existingcheck_env()for environments.The checker verifies:
gymnasium.Wrapperinstance with an inner environmentunwrappedreturns the base environmentreset()returns(obs, info)with correct types and obs in spacestep()returns(obs, reward, terminated, truncated, info)with correct typesrender()andclose()don't crashFixes #6
Type of change
Checklist:
pre-commitchecks withpre-commit run --all-files(seeCONTRIBUTING.mdinstructions to set it up)