Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ruamel.yaml #287

Merged
merged 4 commits into from Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -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
17 changes: 9 additions & 8 deletions Jenkinsfile
Expand Up @@ -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'
}
}
}
3 changes: 3 additions & 0 deletions ci-install.sh
Expand Up @@ -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
33 changes: 29 additions & 4 deletions 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
Expand Down
4 changes: 2 additions & 2 deletions requirements-cpu.conda
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements-gpu.conda
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
@@ -1,3 +1,5 @@
asttokens
codecov
prettyprinter
ruamel.yaml
ruamel.yaml.clib>=0.2
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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'],
Expand Down