Skip to content

[Feature] Add support for loading datasets from local Minari cache #3068

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

Merged
merged 27 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
26aa0ff
[Feature] Add support for loading datasets from local Minari cache
Ibinarriaga8 Jul 14, 2025
a56c508
[Refactor] Fixed linting errors
Ibinarriaga8 Jul 14, 2025
e90f4d0
[Refactor] moved minari import to local scope
Ibinarriaga8 Jul 14, 2025
cc43f9a
[Refactor] Refactor Minari testing to use custom datasets
Ibinarriaga8 Jul 15, 2025
23aecec
[Fix] eliminate global imports for test_libs
Ibinarriaga8 Jul 18, 2025
9321adb
[Refactor] Reduce dataset index range in Minari tests
Ibinarriaga8 Jul 18, 2025
a4993c3
Merge branch 'pytorch:main' into main
Ibinarriaga8 Jul 18, 2025
08779c2
Merge branch 'pytorch:main' into main
Ibinarriaga8 Jul 21, 2025
0ab8f81
[Enhancement] Update minari environment.yml and refactored minari test
Ibinarriaga8 Jul 21, 2025
01965f4
[Refactor] Reduced datasets for minari tests
Ibinarriaga8 Jul 21, 2025
dcd06b2
[Enhancement] Update environment.yml minari dependencies
Ibinarriaga8 Jul 22, 2025
88b3dbe
[Enhancement] Added minari environment.yml dependencies
Ibinarriaga8 Jul 22, 2025
5983008
[Enhancement] Update dataset fetching to retrieve 2 random datasets a…
Ibinarriaga8 Jul 22, 2025
c532070
[Fix] Resolved mujoco-py version
Ibinarriaga8 Jul 23, 2025
c5b12b9
[Feature] Add support for loading datasets from local Minari cache
Ibinarriaga8 Jul 14, 2025
5e0fca8
[Refactor] Fixed linting errors
Ibinarriaga8 Jul 14, 2025
d7c9aae
[Refactor] moved minari import to local scope
Ibinarriaga8 Jul 14, 2025
52f94bd
[Refactor] Refactor Minari testing to use custom datasets
Ibinarriaga8 Jul 15, 2025
4965ba3
[Fix] eliminate global imports for test_libs
Ibinarriaga8 Jul 18, 2025
a78f660
[Refactor] Reduce dataset index range in Minari tests
Ibinarriaga8 Jul 18, 2025
eb99021
[Enhancement] Update minari environment.yml and refactored minari test
Ibinarriaga8 Jul 21, 2025
40d54df
[Refactor] Reduced datasets for minari tests
Ibinarriaga8 Jul 21, 2025
d81b32f
conda -> uv
vmoens Jul 24, 2025
4b4c524
Merge remote-tracking branch 'origin/main'
Ibinarriaga8 Jul 24, 2025
2ddce39
Updated gym version
Ibinarriaga8 Jul 24, 2025
51c0167
Updated requirements
Ibinarriaga8 Jul 24, 2025
be40b1c
Fixes
vmoens Jul 24, 2025
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
9 changes: 8 additions & 1 deletion .github/unittest/linux_libs/scripts_minari/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ dependencies:
- scipy
- hydra-core
- minari[gcs,hdf5,hf]
- gymnasium<1.0.0
- gymnasium>=1.2.0
- ale-py
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new dependencies

- gymnasium-robotics
- minari[create]
- jax
- mujoco
- mujoco-py<2.2,>=2.1
- minigrid
16 changes: 7 additions & 9 deletions .github/unittest/linux_libs/scripts_minari/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ unset PYTORCH_VERSION

set -e

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env
# Note: This script is sourced by run_all.sh, so the environment is already active

if [ "${CU_VERSION:-}" == cpu ] ; then
version="cpu"
Expand All @@ -22,22 +21,21 @@ else
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
fi


# submodules
git submodule sync && git submodule update --init --recursive

printf "Installing PyTorch with cu128"
if [[ "$TORCH_VERSION" == "nightly" ]]; then
if [ "${CU_VERSION:-}" == cpu ] ; then
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
else
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 -U
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 -U
fi
elif [[ "$TORCH_VERSION" == "stable" ]]; then
if [ "${CU_VERSION:-}" == cpu ] ; then
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
else
pip3 install torch --index-url https://download.pytorch.org/whl/cu128
uv pip install torch --index-url https://download.pytorch.org/whl/cu128
fi
else
printf "Failed to install pytorch"
Expand All @@ -46,9 +44,9 @@ fi

# install tensordict
if [[ "$RELEASE" == 0 ]]; then
pip3 install git+https://github.com/pytorch/tensordict.git
uv pip install git+https://github.com/pytorch/tensordict.git
else
pip3 install tensordict
uv pip install tensordict
fi

# smoke test
Expand Down
3 changes: 1 addition & 2 deletions .github/unittest/linux_libs/scripts_minari/post_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

set -e

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env
# Note: This script is sourced by run_all.sh, so the environment is already active
20 changes: 20 additions & 0 deletions .github/unittest/linux_libs/scripts_minari/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
hypothesis
future
cloudpickle
pytest
pytest-cov
pytest-mock
pytest-instafail
pytest-rerunfailures
pytest-error-for-skips
pytest-asyncio
expecttest
pybind11[global]
pyyaml
scipy
hydra-core
minari[gcs,hdf5,hf,create]
gymnasium>=1.2.0
ale-py
gymnasium-robotics
mujoco
16 changes: 16 additions & 0 deletions .github/unittest/linux_libs/scripts_minari/run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euxo pipefail

# Run all minari test scripts in sequence, sourcing each one to maintain environment state
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

echo "Running minari tests with uv-based setup..."

# Source each script in sequence to maintain environment state
source "${this_dir}/setup_env.sh"
source "${this_dir}/install.sh"
source "${this_dir}/run_test.sh"
source "${this_dir}/post_process.sh"

echo "Minari tests completed successfully!"
5 changes: 1 addition & 4 deletions .github/unittest/linux_libs/scripts_minari/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

set -e

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env
# Note: This script is sourced by run_all.sh, so the environment is already active

apt-get update && apt-get remove swig -y && apt-get install -y git gcc patchelf libosmesa6-dev libgl1-mesa-glx libglfw3 swig3.0 cmake
ln -s /usr/bin/swig3.0 /usr/bin/swig
Expand All @@ -18,8 +17,6 @@ root_dir="$(git rev-parse --show-toplevel)"
env_dir="${root_dir}/env"
lib_dir="${env_dir}/lib"

conda deactivate && conda activate ./env

# this workflow only tests the libs
python -c "import minari"

Expand Down
47 changes: 25 additions & 22 deletions .github/unittest/linux_libs/scripts_minari/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,40 @@ apt-get upgrade -y libstdc++6

this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
root_dir="$(git rev-parse --show-toplevel)"
conda_dir="${root_dir}/conda"
env_dir="${root_dir}/env"

cd "${root_dir}"

case "$(uname -s)" in
Darwin*) os=MacOSX;;
*) os=Linux
esac

# 1. Install conda at ./conda
if [ ! -d "${conda_dir}" ]; then
printf "* Installing conda\n"
wget -O miniconda.sh "http://repo.continuum.io/miniconda/Miniconda3-latest-${os}-x86_64.sh"
bash ./miniconda.sh -b -f -p "${conda_dir}"
# Install uv if not already installed
if ! command -v uv &> /dev/null; then
printf "* Installing uv\n"
# Try different Python commands
if command -v python3 &> /dev/null; then
python3 -m pip install uv
elif command -v python &> /dev/null; then
python -m pip install uv
else
# Fallback to curl installation
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
fi
eval "$(${conda_dir}/bin/conda shell.bash hook)"

# 2. Create test environment at ./env
# Create virtual environment using uv
printf "python: ${PYTHON_VERSION}\n"
if [ ! -d "${env_dir}" ]; then
printf "* Creating a test environment\n"
conda create --prefix "${env_dir}" -y python="$PYTHON_VERSION"
printf "* Creating a test environment with uv\n"
uv venv "${env_dir}" --python "${PYTHON_VERSION}"
fi
conda activate "${env_dir}"

# 3. Install Conda dependencies
printf "* Installing dependencies (except PyTorch)\n"
echo " - python=${PYTHON_VERSION}" >> "${this_dir}/environment.yml"
cat "${this_dir}/environment.yml"
# Activate the virtual environment
source "${env_dir}/bin/activate"

pip3 install pip --upgrade
# Upgrade pip
uv pip install --upgrade pip

conda env update --file "${this_dir}/environment.yml" --prune
# Install dependencies from requirements.txt (we'll create this)
printf "* Installing dependencies (except PyTorch)\n"
if [ -f "${this_dir}/requirements.txt" ]; then
uv pip install -r "${this_dir}/requirements.txt"
fi
5 changes: 1 addition & 4 deletions .github/workflows/test-linux-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,7 @@ jobs:
export BATCHED_PIPE_TIMEOUT=60
export TD_GET_DEFAULTS_TO_NONE=1

bash .github/unittest/linux_libs/scripts_minari/setup_env.sh
bash .github/unittest/linux_libs/scripts_minari/install.sh
bash .github/unittest/linux_libs/scripts_minari/run_test.sh
bash .github/unittest/linux_libs/scripts_minari/post_process.sh
bash .github/unittest/linux_libs/scripts_minari/run_all.sh

unittests-openx:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion packaging/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export BUILD_TYPE=wheel
setup_env
setup_wheel_python
pip_install numpy pyyaml future ninja
pip_install numpy pyyaml future ninja "pybind11[global]"
pip_install --upgrade setuptools
setup_pip_pytorch_version
python setup.py clean
Expand Down
8 changes: 7 additions & 1 deletion test/_utils_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import unittest
import warnings
from functools import wraps
from typing import Callable

import pytest
import torch
Expand Down Expand Up @@ -214,7 +215,12 @@ def generate_seeds(seed, repeat):


# Decorator to retry upon certain Exceptions.
def retry(ExceptionToCheck, tries=3, delay=3, skip_after_retries=False):
def retry(
ExceptionToCheck: type[Exception],
tries: int = 3,
delay: int = 3,
skip_after_retries: bool = False,
) -> Callable[[Callable], Callable]:
def deco_retry(f):
@wraps(f)
def f_retry(*args, **kwargs):
Expand Down
Loading
Loading