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

fix: DataCollector versioning deprecation #173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions minari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ def __getattr__(name):
if name == "DataCollectorV0":
from minari.data_collector import DataCollectorV0
return DataCollectorV0
else:
raise ImportError(f"cannot import name '{name}' from '{__name__}' ({__file__})")
2 changes: 2 additions & 0 deletions minari/data_collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ def __getattr__(name):
if name == "DataCollectorV0":
from minari.data_collector.data_collector import DataCollectorV0
return DataCollectorV0
else:
raise ImportError(f"cannot import name '{name}' from '{__name__}' ({__file__})")
15 changes: 10 additions & 5 deletions minari/data_collector/data_collector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import copy
import inspect
import os
import secrets
import shutil
Expand Down Expand Up @@ -29,11 +30,15 @@
EpisodeBuffer = Dict[str, Any] # TODO: narrow this down


class DataCollectorV0:
warnings.warn("DataCollectorV0 is deprecated and will be removed. Use DataCollector instead.", DeprecationWarning, stacklevel=5)

def __new__(cls, *args, **kwargs):
return DataCollector(*args, **kwargs)
def __getattr__(name):
if name == "DataCollectorV0":
stacklevel = len(inspect.stack(0))
warnings.warn("DataCollectorV0 is deprecated and will be removed. Use DataCollector instead.", DeprecationWarning, stacklevel=stacklevel)
return DataCollector
elif name == "__path__":
return False # see https://stackoverflow.com/a/60803436
else:
raise ImportError(f"cannot import name '{name}' from '{__name__}' ({__file__})")


class DataCollector(gym.Wrapper):
Expand Down