checking success before splitting result in step_wait #178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There is a minor bug in
AsyncVectorEnv.step_wait
. Here's what happens:(None, False)
back through the pipe to theAsyncVectorEnv
.AsyncVectorEnv.step_wait
receives the message from the pipe and unpacks it asresult, success = pipe.recv()
. At this pointresult = None
andsuccess = False
.result
further usingobs, rew, terminated, truncated, info = result
result
isNone
, this immediately throws aTypeError
and bypasses the normal error handling using_raise_if_errors
._raise_if_errors
.My change first checks the value of
success
before attempting to unpack the contents ofresult
. The values are only unpacked and appended to the intermediate lists (observations_list
,rewards
,terminateds
,truncateds
andinfos
) ifsuccess
.Note that this may result in temporarily strange but benign behavior. If there are 8 workers and two of them fail inside
step
, then the intermediate lists will only have 6 elements, and you would have to look at the list of successes to figure out which corresponded to which worker. However, this is irrelevant because as soon as the loop exits,_raise_if_errors
is called, which will handle exceptions, raise further exceptions and nothing will be done with those arrays anyway. The alternative would be to generate dummy variables (obs, rew, terminated, truncated, info = None, 0, False, False, {}
) to place in those lists temporarily in the case whensuccess == False
but this seems unnecessary.It looks like you guys are currently revamping the VectorEnv stuff, so hopefully this is still relevant. Feel free to ignore this if this chunk of code is already on the chopping block.
Fixes #177
Type of change
Please delete options that are not relevant.
Checklist:
I have not done these things, sorry! Excuses:
I can't run pre-commit because of a node dependency that won't run on my system
I haven't added comments because the
step_wait
method had no comments to begin with, and this is a very minor change.I haven't done anything to do the documentation because this is a small bugfix.
I don't think these changes generate any new warnings, but again, I can't run pre-commit on my system.
I haven't added any tests for this. Again, small bugfix.
I can't run the unit-tests locally.
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)Anyway, hopefully this is useful! Sorry for not being able to run the checks!