@@ -0,0 +1,98 @@
1+{ stdenv
2+, lib
3+, buildPythonPackage
4+, pythonOlder
5+, fetchPypi
6+, tensorflow
7+, annoy
8+, pillow
9+, matplotlib
10+, numpy
11+, pandas
12+, pygame
13+, pyopengl
14+, scipy
15+, scikitimage
16+, gym
17+, bokeh
18+, kubernetes
19+, redis
20+, minio
21+, pytest
22+, psutil
23+}:
24+
25+buildPythonPackage rec {
26+ version = "0.12.0";
27+ pname = "rl-coach";
28+
29+ src = fetchPypi {
30+ inherit pname version;
31+ sha256 = "0kfm699rsy63726hpz3fyppl7zbl0fzf0vk2kkfgg718mcjxmdnh";
32+ };
33+
34+ propagatedBuildInputs = [
35+ tensorflow
36+ annoy
37+ pillow
38+ matplotlib
39+ numpy
40+ pandas
41+ pygame
42+ pyopengl
43+ scipy
44+ scikitimage
45+ gym
46+ bokeh
47+ kubernetes
48+ redis
49+ minio
50+ psutil
51+ ];
52+
53+ checkInputs = [
54+ pytest
55+ ];
56+
57+ # run only some tests that do not need any optional dependencies
58+ # available tests: https://github.com/NervanaSystems/coach/tree/master/rl_coach/tests
59+ testsToRun = [
60+ # test only the tensorflow backend (not mxnet)
61+ "architectures/tensorflow_components"
62+ "agents"
63+ "exploration_policies"
64+ "filters"
65+ "memories"
66+ "utils"
67+ ];
68+ checkPhase = let
69+ fullTestPaths = map (testfile: "rl_coach/tests/${testfile}") testsToRun;
70+ escapedPaths = map lib.escapeShellArg fullTestPaths;
71+ pytestArgs = builtins.concatStringsSep " " escapedPaths;
72+ in
73+ ''
74+ pytest ${pytestArgs}
75+ '';
76+
77+ postPatch = ''
78+ # pinned to 8.0.1 for unknown reason, at least basic functionallity seems to work without it
79+ # https://github.com/NervanaSystems/coach/pull/149#issuecomment-495915804
80+ sed -i '/kubernetes/d' requirements.txt
81+
82+ # this is just an "intel-optimized" version of tensorflow, e.g. an implementation detail
83+ sed -i 's/intel-tensorflow/tensorflow/g' setup.py
84+
85+ # backports of python3 features not needed
86+ # https://github.com/NervanaSystems/coach/issues/324
87+ sed -i '/futures/d' requirements.txt
88+ '';
89+
90+ disabled = pythonOlder "3.5"; # minimum required version
91+
92+ meta = with stdenv.lib; {
93+ description = "Enables easy experimentation with state of the art Reinforcement Learning algorithms";
94+ homepage = "https://nervanasystems.github.io/coach/";
95+ license = licenses.asl20;
96+ maintainers = with maintainers; [ timokau ];
97+ };
98+}