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; Offline RL] Added stop method to OfflineEnvRunner. #47155

Conversation

simonsays1980
Copy link
Collaborator

@simonsays1980 simonsays1980 commented Aug 15, 2024

Why are these changes needed?

The max_rows_per_file gives a user control over the number of writing processes during a run when recording the experiences. It does so by buffering episodes or row data until max_rows_per_file is reached.

If the run stops, this buffer could be still non-empty. This PR proposes to override the EnvRunner.stop method to write remaining episodes or step data onto disk.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

…ces in the buffer to disk.

Signed-off-by: simonsays1980 <simon.zehnder@gmail.com>
Signed-off-by: simonsays1980 <simon.zehnder@gmail.com>
…'max_rows_per_file' is defining now the maximum number of episodes to store into a file/folder. Furthermore, unified buffer for episodes and column data.

Signed-off-by: simonsays1980 <simon.zehnder@gmail.com>
@simonsays1980 simonsays1980 marked this pull request as ready for review August 15, 2024 15:40
number of rows for the remaining samples could be
less than the defined maximum row number by the user.
"""
# If there are samples left over we have to write htem to disk. them
Copy link
Contributor

Choose a reason for hiding this comment

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

The parent method doesn't do anything, but I think we should still call it, what do you think?

super().stop()

@@ -229,7 +239,7 @@ def _map_episodes_to_data(self, samples: List[EpisodeType]) -> None:
Columns.ACTIONS: pack_if_needed(
to_jsonable_if_needed(sample.get_actions(i), action_space)
)
if Columns.OBS in self.output_compress_columns
if Columns.ACTIONS in self.output_compress_columns
Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch! :)

self._samples = []
else:
self._samples_data = []
# Define the buffer for experiences stored until written to disk.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!

Copy link
Contributor

Choose a reason for hiding this comment

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

That was a little confusing :)

Copy link
Contributor

@sven1977 sven1977 left a comment

Choose a reason for hiding this comment

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

Love it. So much more elegant to put this in stop.

Just the nit about the parent stop method call.

Thanks @simonsays1980 !!

@simonsays1980 simonsays1980 changed the title [RLlib; Offline RL] - Added 'stop' method to 'OfflineEnvRunner' [RLlib; Offline RL] - Added stop method to 'OfflineEnvRunner' Aug 16, 2024
@simonsays1980 simonsays1980 changed the title [RLlib; Offline RL] - Added stop method to 'OfflineEnvRunner' [RLlib; Offline RL] - Added stop method to OfflineEnvRunner. Aug 16, 2024
@sven1977 sven1977 changed the title [RLlib; Offline RL] - Added stop method to OfflineEnvRunner. [RLlib; Offline RL] Added stop method to OfflineEnvRunner. Aug 16, 2024
@sven1977 sven1977 enabled auto-merge (squash) August 16, 2024 09:45
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Aug 16, 2024
@sven1977 sven1977 merged commit 4f0924a into ray-project:master Aug 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants