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

[CI] Fix Minari tests #2419

Merged
merged 5 commits into from
Sep 17, 2024
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: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_minari/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dependencies:
- pyyaml
- scipy
- hydra-core
- minari[gcs]
- minari[gcs,hdf5]
35 changes: 4 additions & 31 deletions test/test_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2823,34 +2823,11 @@ def _minari_selected_datasets():

torch.manual_seed(0)

# We rely on sorting the keys as v0 < v1 but if the version is greater than 9 this won't work
total_keys = sorted(minari.list_remote_datasets())
assert not any(
key[-2:] == "10" for key in total_keys
), "You should adapt the Minari test scripts as some dataset have a version >= 10 and sorting will fail."
total_keys_splits = [key.split("-") for key in total_keys]
total_keys = sorted(
minari.list_remote_datasets(latest_version=True, compatible_minari_version=True)
)
indices = torch.randperm(len(total_keys))[:20]
keys = [total_keys[idx] for idx in indices]
keys = [
key
for key in keys
if "=0.4" in minari.list_remote_datasets()[key]["minari_version"]
]

def _replace_with_max(key):
key_split = key.split("-")
same_entries = (
torch.tensor(
[total_key[:-1] == key_split[:-1] for total_key in total_keys_splits]
)
.nonzero()
.squeeze()
.tolist()
)
last_same_entry = same_entries[-1]
return total_keys[last_same_entry]

keys = [_replace_with_max(key) for key in keys]
Comment on lines -2826 to -2853
Copy link
Contributor Author

@younik younik Sep 12, 2024

Choose a reason for hiding this comment

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

I believed what changed is the order of _MINARI_DATASETS given the above modification.
The test work with kitchen or antmaze datasets as the observation space is a dictionary, while it doesn't work for pen datasets.
I can change the code to test only a kitchen dataset or to work with the pen one.


assert len(keys) > 5, keys
_MINARI_DATASETS += keys
Expand Down Expand Up @@ -2880,12 +2857,8 @@ def test_load(self, selected_dataset, split):
break

def test_minari_preproc(self, tmpdir):
global _MINARI_DATASETS
if not _MINARI_DATASETS:
_minari_selected_datasets()
selected_dataset = _MINARI_DATASETS[0]
dataset = MinariExperienceReplay(
selected_dataset,
"D4RL/pointmaze/large-v2",
batch_size=32,
split_trajs=False,
download="force",
Expand Down
Loading