Skip to content

Commit 0627e85

Browse files
Ibinarriaga8vmoens
andauthored
[Feature] Add support for loading datasets from local Minari cache (#3068)
Co-authored-by: vmoens <vincentmoens@gmail.com>
1 parent 8ac73aa commit 0627e85

File tree

13 files changed

+566
-188
lines changed

13 files changed

+566
-188
lines changed

.github/unittest/linux_libs/scripts_minari/environment.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@ dependencies:
2020
- scipy
2121
- hydra-core
2222
- minari[gcs,hdf5,hf]
23-
- gymnasium<1.0.0
23+
- gymnasium>=1.2.0
24+
- ale-py
25+
- gymnasium-robotics
26+
- minari[create]
27+
- jax
28+
- mujoco
29+
- mujoco-py<2.2,>=2.1
30+
- minigrid

.github/unittest/linux_libs/scripts_minari/install.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ unset PYTORCH_VERSION
77

88
set -e
99

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

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

25-
2624
# submodules
2725
git submodule sync && git submodule update --init --recursive
2826

2927
printf "Installing PyTorch with cu128"
3028
if [[ "$TORCH_VERSION" == "nightly" ]]; then
3129
if [ "${CU_VERSION:-}" == cpu ] ; then
32-
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
30+
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
3331
else
34-
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 -U
32+
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 -U
3533
fi
3634
elif [[ "$TORCH_VERSION" == "stable" ]]; then
3735
if [ "${CU_VERSION:-}" == cpu ] ; then
38-
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
36+
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
3937
else
40-
pip3 install torch --index-url https://download.pytorch.org/whl/cu128
38+
uv pip install torch --index-url https://download.pytorch.org/whl/cu128
4139
fi
4240
else
4341
printf "Failed to install pytorch"
@@ -46,9 +44,9 @@ fi
4644

4745
# install tensordict
4846
if [[ "$RELEASE" == 0 ]]; then
49-
pip3 install git+https://github.com/pytorch/tensordict.git
47+
uv pip install git+https://github.com/pytorch/tensordict.git
5048
else
51-
pip3 install tensordict
49+
uv pip install tensordict
5250
fi
5351

5452
# smoke test

.github/unittest/linux_libs/scripts_minari/post_process.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
set -e
44

5-
eval "$(./conda/bin/conda shell.bash hook)"
6-
conda activate ./env
5+
# Note: This script is sourced by run_all.sh, so the environment is already active
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
hypothesis
2+
future
3+
cloudpickle
4+
pytest
5+
pytest-cov
6+
pytest-mock
7+
pytest-instafail
8+
pytest-rerunfailures
9+
pytest-error-for-skips
10+
pytest-asyncio
11+
expecttest
12+
pybind11[global]
13+
pyyaml
14+
scipy
15+
hydra-core
16+
minari[gcs,hdf5,hf,create]
17+
gymnasium>=1.2.0
18+
ale-py
19+
gymnasium-robotics
20+
mujoco
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
# Run all minari test scripts in sequence, sourcing each one to maintain environment state
6+
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
7+
8+
echo "Running minari tests with uv-based setup..."
9+
10+
# Source each script in sequence to maintain environment state
11+
source "${this_dir}/setup_env.sh"
12+
source "${this_dir}/install.sh"
13+
source "${this_dir}/run_test.sh"
14+
source "${this_dir}/post_process.sh"
15+
16+
echo "Minari tests completed successfully!"

.github/unittest/linux_libs/scripts_minari/run_test.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
set -e
44

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

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

21-
conda deactivate && conda activate ./env
22-
2320
# this workflow only tests the libs
2421
python -c "import minari"
2522

.github/unittest/linux_libs/scripts_minari/setup_env.sh

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,40 @@ apt-get upgrade -y libstdc++6
3333

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

3938
cd "${root_dir}"
4039

41-
case "$(uname -s)" in
42-
Darwin*) os=MacOSX;;
43-
*) os=Linux
44-
esac
45-
46-
# 1. Install conda at ./conda
47-
if [ ! -d "${conda_dir}" ]; then
48-
printf "* Installing conda\n"
49-
wget -O miniconda.sh "http://repo.continuum.io/miniconda/Miniconda3-latest-${os}-x86_64.sh"
50-
bash ./miniconda.sh -b -f -p "${conda_dir}"
40+
# Install uv if not already installed
41+
if ! command -v uv &> /dev/null; then
42+
printf "* Installing uv\n"
43+
# Try different Python commands
44+
if command -v python3 &> /dev/null; then
45+
python3 -m pip install uv
46+
elif command -v python &> /dev/null; then
47+
python -m pip install uv
48+
else
49+
# Fallback to curl installation
50+
curl -LsSf https://astral.sh/uv/install.sh | sh
51+
export PATH="$HOME/.local/bin:$PATH"
52+
fi
5153
fi
52-
eval "$(${conda_dir}/bin/conda shell.bash hook)"
5354

54-
# 2. Create test environment at ./env
55+
# Create virtual environment using uv
5556
printf "python: ${PYTHON_VERSION}\n"
5657
if [ ! -d "${env_dir}" ]; then
57-
printf "* Creating a test environment\n"
58-
conda create --prefix "${env_dir}" -y python="$PYTHON_VERSION"
58+
printf "* Creating a test environment with uv\n"
59+
uv venv "${env_dir}" --python "${PYTHON_VERSION}"
5960
fi
60-
conda activate "${env_dir}"
6161

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

67-
pip3 install pip --upgrade
65+
# Upgrade pip
66+
uv pip install --upgrade pip
6867

69-
conda env update --file "${this_dir}/environment.yml" --prune
68+
# Install dependencies from requirements.txt (we'll create this)
69+
printf "* Installing dependencies (except PyTorch)\n"
70+
if [ -f "${this_dir}/requirements.txt" ]; then
71+
uv pip install -r "${this_dir}/requirements.txt"
72+
fi

.github/workflows/test-linux-libs.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,7 @@ jobs:
466466
export BATCHED_PIPE_TIMEOUT=60
467467
export TD_GET_DEFAULTS_TO_NONE=1
468468
469-
bash .github/unittest/linux_libs/scripts_minari/setup_env.sh
470-
bash .github/unittest/linux_libs/scripts_minari/install.sh
471-
bash .github/unittest/linux_libs/scripts_minari/run_test.sh
472-
bash .github/unittest/linux_libs/scripts_minari/post_process.sh
469+
bash .github/unittest/linux_libs/scripts_minari/run_all.sh
473470
474471
unittests-openx:
475472
strategy:

packaging/build_wheels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
77
export BUILD_TYPE=wheel
88
setup_env
99
setup_wheel_python
10-
pip_install numpy pyyaml future ninja
10+
pip_install numpy pyyaml future ninja "pybind11[global]"
1111
pip_install --upgrade setuptools
1212
setup_pip_pytorch_version
1313
python setup.py clean

test/_utils_internal.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import unittest
1414
import warnings
1515
from functools import wraps
16+
from typing import Callable
1617

1718
import pytest
1819
import torch
@@ -214,7 +215,12 @@ def generate_seeds(seed, repeat):
214215

215216

216217
# Decorator to retry upon certain Exceptions.
217-
def retry(ExceptionToCheck, tries=3, delay=3, skip_after_retries=False):
218+
def retry(
219+
ExceptionToCheck: type[Exception],
220+
tries: int = 3,
221+
delay: int = 3,
222+
skip_after_retries: bool = False,
223+
) -> Callable[[Callable], Callable]:
218224
def deco_retry(f):
219225
@wraps(f)
220226
def f_retry(*args, **kwargs):

0 commit comments

Comments
 (0)