2024-06-05 15:53:02 +00:00
{
lib ,
buildPythonPackage ,
pythonOlder ,
fetchFromGitHub ,
ninja ,
setuptools ,
wheel ,
which ,
cloudpickle ,
numpy ,
torch ,
ale-py ,
gym ,
pygame ,
torchsnapshot ,
gymnasium ,
mujoco ,
h5py ,
huggingface-hub ,
minari ,
pandas ,
pillow ,
requests ,
scikit-learn ,
torchvision ,
tqdm ,
moviepy ,
git ,
hydra-core ,
tensorboard ,
wandb ,
packaging ,
tensordict ,
imageio ,
pytest-rerunfailures ,
pytestCheckHook ,
pyyaml ,
scipy ,
stdenv ,
2024-01-25 14:12:00 +00:00
} :
buildPythonPackage rec {
pname = " t o r c h r l " ;
2024-05-15 15:35:15 +00:00
version = " 0 . 4 . 0 " ;
2024-01-25 14:12:00 +00:00
pyproject = true ;
disabled = pythonOlder " 3 . 8 " ;
src = fetchFromGitHub {
owner = " p y t o r c h " ;
repo = " r l " ;
rev = " r e f s / t a g s / v ${ version } " ;
2024-05-15 15:35:15 +00:00
hash = " s h a 2 5 6 - 8 w S y y E r q v e P 9 z Z S / U G v W V B Y y y l u 9 B u A 4 4 7 G E j X I z B I k = " ;
2024-01-25 14:12:00 +00:00
} ;
2024-05-15 15:35:15 +00:00
build-system = [
2024-01-25 14:12:00 +00:00
ninja
setuptools
wheel
which
] ;
2024-05-15 15:35:15 +00:00
dependencies = [
2024-01-25 14:12:00 +00:00
cloudpickle
numpy
packaging
tensordict
torch
] ;
passthru . optional-dependencies = {
atari = [
ale-py
gym
pygame
] ;
2024-06-05 15:53:02 +00:00
checkpointing = [ torchsnapshot ] ;
2024-01-25 14:12:00 +00:00
gym-continuous = [
gymnasium
mujoco
] ;
2024-05-15 15:35:15 +00:00
offline-data = [
h5py
huggingface-hub
minari
pandas
pillow
requests
scikit-learn
torchvision
tqdm
] ;
2024-06-05 15:53:02 +00:00
rendering = [ moviepy ] ;
2024-01-25 14:12:00 +00:00
utils = [
git
hydra-core
tensorboard
tqdm
wandb
] ;
} ;
# torchrl needs to create a folder to store datasets
preBuild = ''
export D4RL_DATASET_DIR = $ ( mktemp - d )
'' ;
2024-06-05 15:53:02 +00:00
pythonImportsCheck = [ " t o r c h r l " ] ;
2024-01-25 14:12:00 +00:00
# We have to delete the source because otherwise it is used instead of the installed package.
preCheck = ''
rm - rf torchrl
export XDG_RUNTIME_DIR = $ ( mktemp - d )
'' ;
2024-06-05 15:53:02 +00:00
nativeCheckInputs =
[
gymnasium
imageio
pytest-rerunfailures
pytestCheckHook
pyyaml
scipy
torchvision
]
++ passthru . optional-dependencies . atari
++ passthru . optional-dependencies . gym-continuous
++ passthru . optional-dependencies . rendering ;
2024-01-25 14:12:00 +00:00
disabledTests = [
# mujoco.FatalError: an OpenGL platform library has not been loaded into this process, this most likely means that a valid OpenGL context has not been created before mjr_makeContext was called
" t e s t _ v e c e n v s _ e n v "
# ValueError: Can't write images with one color channel.
" t e s t _ l o g _ v i d e o "
# Those tests require the ALE environments (provided by unpackaged shimmy)
" t e s t _ c o l l e c t o r _ e n v _ r e s e t "
" t e s t _ g y m "
" t e s t _ g y m _ f a k e _ t d "
" t e s t _ r e c o r d e r "
" t e s t _ r e c o r d e r _ l o a d "
" t e s t _ r o l l o u t "
" t e s t _ p a r a l l e l _ t r a n s _ e n v _ c h e c k "
" t e s t _ s e r i a l _ t r a n s _ e n v _ c h e c k "
" t e s t _ s i n g l e _ t r a n s _ e n v _ c h e c k "
" t e s t _ t d _ c r e a t i o n _ f r o m _ s p e c "
" t e s t _ t r a n s _ p a r a l l e l _ e n v _ c h e c k "
" t e s t _ t r a n s _ s e r i a l _ e n v _ c h e c k "
" t e s t _ t r a n s f o r m _ e n v "
2024-06-20 14:57:18 +00:00
# undeterministic
" t e s t _ d i s t r i b u t e d _ c o l l e c t o r _ u p d a t e p o l i c y "
" t e s t _ t i m e i t "
2024-01-25 14:12:00 +00:00
] ;
meta = with lib ; {
2024-06-20 14:57:18 +00:00
description = " M o d u l a r , p r i m i t i v e - f i r s t , p y t h o n - f i r s t P y T o r c h l i b r a r y f o r R e i n f o r c e m e n t L e a r n i n g " ;
2024-01-25 14:12:00 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / p y t o r c h / r l " ;
2024-04-21 15:54:59 +00:00
changelog = " h t t p s : / / g i t h u b . c o m / p y t o r c h / r l / r e l e a s e s / t a g / v ${ version } " ;
2024-01-25 14:12:00 +00:00
license = licenses . mit ;
maintainers = with maintainers ; [ GaetanLepage ] ;
2024-05-15 15:35:15 +00:00
# ~3k tests fail with: RuntimeError: internal error
broken = stdenv . isLinux && stdenv . isAarch64 ;
2024-01-25 14:12:00 +00:00
} ;
}