[Bug] Cloudpickle losing parents of types defined in __main__ if an ancestor used a type annotation #22552
Closed
2 tasks done
Labels
Milestone
Search before asking
Ray Component
Ray Core
What happened + What you expected to happen
When Ray cannot import a specific type, it creates a "skeleton class" remotely instead. This skeleton class is meant to be identical to the original, however, if an ancestor of the class used type annotations, the skeleton class will subclass the most recent type annotations rather than the parents. In rare cases this can cause the remote class to differ from the local one.
This is particularly problematic, because
MultiAgentEnv
fromrllib
subclassesgym.Env
, and with gym version 22,gym.Env
now subclassesGeneric[ObsType, ActType]
. This means that if you define an env subclassing fromMultiAgentEnv
in__main__
, on the workers, your environement will be a subclass ofGeneric[ObsType, ActType]
-- notMultiAgentEnv
.Versions / Dependencies
Tested on Python 3.7 and 3.9 with Ray 1.10.0.
The specific problem with
MultiAgentEnv
requires gym version 22Reproduction script
Just using
ray.remote
:Rllib MultiAgent:
Anything else
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: