diff --git a/.travis.yml b/.travis.yml index 93e9fab10..e3aafa685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: - TEST_SUITE=static - TEST_SUITE=unit script: - - if [[ $TEST_SUITE == "static" ]]; then flake8 && pydocstyle myia && isort -c -df; fi - - if [[ $TEST_SUITE == "unit" ]]; then pytest tests --cov=./ --cov-report term-missing; fi + - if [[ $TEST_SUITE == "static" ]]; then source activate test && flake8 && pydocstyle myia && isort -c -df; fi + - if [[ $TEST_SUITE == "unit" ]]; then source activate test && pytest tests --cov=./ --cov-report term-missing; fi after_success: - if [[ $TEST_SUITE == "unit" ]]; then codecov; fi diff --git a/Jenkinsfile b/Jenkinsfile index cc040055d..077350b60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,19 +7,20 @@ node ('gpu') { } try { stage ('Test') { - sh script: '$HOME/miniconda/bin/pytest --cov=./ --cov-report= --gpu --junit-xml test-report.xml' + sh script: '. $HOME/miniconda/bin/activate test && pytest --cov=./ --cov-report= --gpu --junit-xml test-report.xml' } } finally { junit 'test-report.xml' } stage ('Coverage') { - withEnv(['PATH+CONDA=/home/jenkins/miniconda/bin']) { - sh script: './cov.sh' - sh script: 'coverage xml' - sh script: 'pip install codecov' - withCredentials([string(credentialsId: 'myia_codecov', variable: 'CODECOV_TOKEN')]) { - sh script: 'codecov' - } + sh script: """ +. $HOME/miniconda/bin/activate test && +./cov.sh && +coverage xml +""" + sh script: '$HOME/miniconda/bin/pip install codecov' + withCredentials([string(credentialsId: 'myia_codecov', variable: 'CODECOV_TOKEN')]) { + sh script: '$HOME/miniconda/bin/codecov' } } } diff --git a/ci-install.sh b/ci-install.sh index 737ff04fa..c9da0b736 100755 --- a/ci-install.sh +++ b/ci-install.sh @@ -23,6 +23,9 @@ export PATH="$HOME/miniconda/bin:$PATH" hash -r conda config --set always_yes yes --set changeps1 no conda update -q conda +conda create -y -n test python=3.7 +conda init +source activate test conda install --file=requirements-$DEV.conda pip install -r requirements.txt pip install -e . --no-deps diff --git a/myia/utils/serialize.py b/myia/utils/serialize.py index 32a3bbef0..076ad1343 100644 --- a/myia/utils/serialize.py +++ b/myia/utils/serialize.py @@ -1,9 +1,34 @@ """Serialization utilities for graphs and their properties.""" -try: - from yaml import CSafeLoader as SafeLoader, CSafeDumper as SafeDumper -except ImportError: # pragma: no cover - from yaml import SafeLoader, SafeDumper +# This is a mess of imports + +# 1) We prefer ruamel.yaml since it has merged the large files fix. +# 2) Conda has a different name for it since it doesn't like namespaces. +# 3) We attempt to use pyyaml as a fallback +try: # pragma: no cover + try: + from ruamel.yaml import ( + CSafeLoader as SafeLoader, + CSafeDumper as SafeDumper + ) + except ImportError: + try: + from ruamel_yaml import ( + CSafeLoader as SafeLoader, + CSafeDumper as SafeDumper + ) + except ImportError: + from yaml import ( + CSafeLoader as SafeLoader, + CSafeDumper as SafeDumper + ) +except ImportError as e: # pragma: no cover + raise RuntimeError(""" +Couldn't find a C-backed version of yaml. + +Please install either ruamel.yaml or PyYAML with the C extension. The python + versions are just too slow to work properly. +""") from e import codecs import os diff --git a/requirements-cpu.conda b/requirements-cpu.conda index f92c871b0..af468236b 100644 --- a/requirements-cpu.conda +++ b/requirements-cpu.conda @@ -4,9 +4,9 @@ numpy abergeron::tvm==0.6dev+3.* pytest pytest-cov -pyyaml +yaml flake8==3.7.7 -pytorch::pytorch==1.1.0 +pytorch::pytorch-cpu==1.1.0 pydocstyle==2.1.1 isort==4.3.21 docopt==0.6.2 diff --git a/requirements-gpu.conda b/requirements-gpu.conda index e93ffb2a2..209fc50aa 100644 --- a/requirements-gpu.conda +++ b/requirements-gpu.conda @@ -5,7 +5,7 @@ abergeron/label/cuda::tvm-libs abergeron::tvm==0.6dev+3.* pytest pytest-cov -pyyaml +yaml flake8==3.7.7 pytorch::pytorch==1.1.0 pydocstyle==2.1.1 diff --git a/requirements.txt b/requirements.txt index 5467c8d86..acbdb5351 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ asttokens codecov prettyprinter +ruamel.yaml +ruamel.yaml.clib>=0.2 diff --git a/setup.py b/setup.py index 7feedee90..f38ff008d 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ ], packages=find_packages(exclude=['docs', 'tests']), install_requires=['asttokens', 'colorama', 'prettyprinter', - 'numpy', 'pyyaml'], + 'numpy', 'ruamel.yaml'], extras_require={ 'test': ['flake8', 'pytest', 'codecov', 'isort', 'pytest-cov', 'pydocstyle', 'docopt'],