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
Deprecate create_dataset_from_collector_env #169
Deprecate create_dataset_from_collector_env #169
Conversation
create_dataset moved to env.create_dataset and env.save_to_disk to be made private
@younik Faced a circular import issue due to DataCollectorV0 being still used in the create_dataset_from_collector_env argument type, while env.create_data() uses functions from utils.py. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good thanks, I suggested some minor changes
docs/api/minari_functions.md
Outdated
@@ -10,7 +10,7 @@ minari_dataset/episode_data | |||
## Create Minari Dataset | |||
|
|||
```{eval-rst} | |||
.. autofunction:: minari.create_dataset_from_collector_env | |||
.. autofunction:: env.create_dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this generates the documentation properly
Can you check? You can build the doc locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't spot it since I had failures in building the docs. Now removed it since it is no longer required due to the deprecation.
docs/api/data_collector.md
Outdated
@@ -22,6 +22,7 @@ data_collector_callbacks/episode_metadata_callback | |||
.. autofunction:: minari.DataCollectorV0.step | |||
.. autofunction:: minari.DataCollectorV0.reset | |||
.. autofunction:: minari.DataCollectorV0.close | |||
.. autofunction:: minari.DataCollectorV0.create_dataset | |||
.. autofunction:: minari.DataCollectorV0.save_to_disk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove save_to_disk
from doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
docs/content/basic_usage.md
Outdated
@@ -52,7 +52,7 @@ In this example, the :class:`minari.DataCollectorV0` wraps the `'CartPole-v1'` e | |||
```{eval-rst} | |||
To create a Minari dataset first we need to step the environment with a given policy to allow the :class:`minari.DataCollectorV0` to record the data that will comprise the dataset. This is as simple as just looping through the Gymansium MDP API. For our example we will loop through ``100`` episodes of the ``'CartPole-v1'`` environment with a random policy. | |||
|
|||
Finally, we need to create the Minari dataset and give it a name id. This is done by calling the :func:`minari.create_dataset_from_collector_env` Minari function which will move the temporary data recorded in the :class:`minari.DataCollectorV0` environment to a permanent location in the `local Minari root path </content/dataset_standards>`_ with the Minari dataset standard structure. | |||
Finally, we need to create the Minari dataset and give it a name id. This is done by calling the :func:`env.create_dataset` Minari function which will move the temporary data recorded in the :class:`minari.DataCollectorV0` environment to a permanent location in the `local Minari root path </content/dataset_standards>`_ with the Minari dataset standard structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the doc, maybe you should write DataCollectorV0.create_dataset
? As env can be unclear what it means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[there are multiple places where this comment is valid]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified in all the instances in the docs.
@@ -396,8 +395,7 @@ def __call__( | |||
|
|||
obs, rew, terminated, truncated, info = collector_env.step(action) | |||
|
|||
dataset = minari.create_dataset_from_collector_env( | |||
collector_env=collector_env, | |||
dataset = env.create_dataset( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to fix tests, env
-> collector_env
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
minari/utils.py
Outdated
@@ -567,7 +566,7 @@ def create_dataset_from_buffers( | |||
|
|||
def create_dataset_from_collector_env( | |||
dataset_id: str, | |||
collector_env: DataCollectorV0, | |||
collector_env: Any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid circular import, in DataCollectorV0, you can import from minari.utils import _generate_dataset_metadata, _generate_dataset_path
inside the create_dataset
function (please also add a #TODO comment saying to move it on top with 0.5.0 release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is also done.
call DataCollectorV0.create_dataset from create_dataset_from_collector_env to avoid duplicate code shift imports for _generate_dataset_metadata and _generate_dataset_path down to create_dataset method to avoid circular imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Description
Both changes planned for release 0.5.0
Fixes # (issue), Depends on # (pull request)
Type of change
Screenshots
N/A
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)pytest -v
and no errors are present.pytest -v
has generated that are related to my code to the best of my knowledge.