forked from arogozhnikov/einops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
54 lines (43 loc) · 1.3 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Usage: python test.py
1. Installs part of dependencies (make sure `which pip` points to correct location)
2. Installs current version of einops in editable mode
3. Runs tests
"""
import os
from subprocess import Popen, PIPE
from pathlib import Path
__author__ = 'Alex Rogozhnikov'
def run(cmd, **env):
# keeps printing output when testing
cmd = cmd.split(' ') if isinstance(cmd, str) else cmd
p = Popen(cmd, cwd=str(Path(__file__).parent), env={**os.environ, **env})
p.communicate()
return p.returncode
# check we have nvidia-smi
output, _ = Popen('which nvidia-smi'.split(' '), stdout=PIPE).communicate()
have_cuda = b'nvidia' in output
# install cupy. It can't be installed without cuda available (with compilers).
if have_cuda:
return_code = run('pip install cupy --pre --progress-bar off')
assert return_code == 0
# install dependencies
dependencies = [
'numpy',
'mxnet==1.*',
'torch',
'tensorflow',
'chainer',
'jax',
'jaxlib',
'nbformat',
'nbconvert',
'jupyter',
'pillow',
'nose',
]
assert 0 == run('pip install {} --progress-bar off'.format(' '.join(dependencies)))
# install einops
assert 0 == run('pip install -e .')
return_code = run('python -m nose tests -vds', EINOPS_SKIP_CUPY='0' if have_cuda else '1')
assert return_code == 0