Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RLlib; Docs overhaul] Docstring cleanup: Environments. #19784

Merged
merged 12 commits into from
Oct 29, 2021

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Oct 27, 2021

Docstring cleanup: rllib/env folder.

  • Cleanup docstrings.
  • Remove type hints in Args list (already in the signature).
  • Remve type hint from "Returns" (already in signature).
  • Add docstrings where missing.
  • Re-sort some class methods (by their importance, private/public, deprecated, etc..).

Why are these changes needed?

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also a few minor comments.


Args:
env: The environment type to convert/wrap.
make_env: A callable taking an int as input (number of sub-envs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reads a bit weird, return a list of sub-envs of type env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yeah, I'll try to clarify a bit better.

env = _ExternalEnvToBaseEnv(env)
elif isinstance(env, VectorEnv):
env = _VectorEnvToBaseEnv(env)
# `env` is already a BaseEnv -> Return as is.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR does have some logic changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I just cleaned up the if block with a "early-out" -> Less indentation.

vector_index: When there are multiple envs per worker, this
uniquely identifies the env index within the worker.
Starts from 0.
remote: Whether single sub-environments (in a vectorized env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe individual sub-environments (...) sounds a bit better?

Copy link
Contributor Author

@sven1977 sven1977 Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I should probably explain better, what a sub-env is :)
Aka "underlying" envs -> The n single (cloned) envs within a vectorized one.

I'll fix this. We should use the same terminology throughout (I like sub-envs as it hints that there are many sub-envs within the actual env, rather than "unwrapped" which could be interpreted as a single env that's just wrapped and there is no vectorization).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using "sub environments" now across the board, sometimes: "underlying sub environments". Also I added explanations as to what that means and made sure it's changes everywhere we used to have "underlying" or "wrapped". I also changed the method: get_underlying into get_sub_environment using soft-deprecation.

"""Initializes a RemoteVectorEnv instance.

Args:
make_env: Callable that produces a single (non-vectorized) env,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is interesting. so here we only want make_env to return a single non-vectoriezed env? not like above.

@sven1977
Copy link
Contributor Author

Hey @gjoliver , could you take another look? I addressed all your questions and change requests.
Thanks!

Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. looks good. thanks a ton.

@sven1977 sven1977 merged commit 902e854 into ray-project:master Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants