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

support tfrecord for datastore #15

Merged
merged 10 commits into from
Dec 29, 2023
Merged

support tfrecord for datastore #15

merged 10 commits into from
Dec 29, 2023

Conversation

youliangtan
Copy link
Owner

@youliangtan youliangtan commented Dec 8, 2023

Summary

This PR introduces rlds loader and reader for all existing datastore. It supports both TrajectoryBuffer and ReplayBuffer Datastore. how it is being used is

This requires installation of

from oxe_envlogger.rlds_logger import RLDSLogger
from edgeml.data.jaxrl_data_store import ReplayBufferDataStore

rlds_logger =  RLDSLogger(
        observation_space=env.observation_space,
        action_space=env.action_space,
        dataset_name="test_rlds_env",
        directory=log_dir,
        max_episodes_per_file=5,  # TODO: arbitrary number
)
store = ReplayBufferDataStore(obs_space, action_space, cap, rlds_logger)

# insert
store.insert(DATA)   # every insert it will automatically get logged

...OTHER PROCESSES...

# exit
rlds_logger.close()   # explicityly flush and close the logger
  • For more info, refer to the test case: edgeml/tests/test_tfds.py.
  • an example is also shown in async_learner_actor.py by adding flag of --rlds_log_dir.

Gotchas

Some things might need further considerations, and even changes.

  • the default traj buffer only supports array as input (no dict)
  • we logged next_observations instead of observations, as it seems that next obs is the obs at the current timestep.
  • ReplayBufferDataStore doesnt support truncation, which is sad.
  • The TrajectoryBuffer method should require more cleanup.

Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
Signed-off-by: youliang <tan_you_liang@hotmail.com>
@youliangtan youliangtan merged commit 52929ba into main Dec 29, 2023
1 check passed
@youliangtan youliangtan deleted the tfds-logger-for-datastore branch December 29, 2023 23:34
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.

1 participant