Skip to content

[Question] Suport "native" environments #2106

@martinitus

Description

@martinitus

❓ Question

Hey SB3 team!

I was experimenting the last days with rewriting my working custom python environment in rust and exposing it to python via pyo3 and maturin.

Doing so I came about a couple of issues, most of them I could solve. However, I needed to disable one or two isintance(env,Env) checks within my local stable_baselines3 package, as inheritance from non built-ins seems not to be possible in pyo3 at the moment. I also could not find a solution to patch sb3 or "inject" the base type into my custom environment class imported from rust.

I therefore have two questions:

  1. Is there interest in this topic? Currently all i have is mixed into my own codebase, but i could produce a minimal standalone repository demonstrating how this would be feasible.
  2. Could you imagine a contribution that includes a mechanism to disables certain "safety checks" (such as the isintance(env,Env) checks into which advanced users could opt in - allowing them to use environments that come from native code like C++ or rust?

Curious about your thoughts!

Remarks:

  • I am aware, that I could just write a thin wrapper in python that capsules my rust environment, but it would just be nice if i wouldn't need that :-)
  • For complicated environments, the observation and step function may also cost some computation/performance, so implementing them in native code seems to make sense.
  • For applications where there already is a lot of rust code, defining the environment directly in rust would kinda feel natural to me.

Finally a random screenshot to hopefully ignite some curiosity ;-)

Image

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions