Unverified 提交 e6a676a7 authored 作者: Dan Foreman-Mackey's avatar Dan Foreman-Mackey 提交者: GitHub

Update Travis infrastructure to Python 3.6/3.7 and current numpy (#7)

* Fix subtensor numpy warning * Fix simple typo: varible->size -> variable->size Closes #6734 * Counteract hypot redefinition for old Python versions * fix doc warning * Update extending_theano.txt * OrderedDict cannot be imported from collections.abc, it is not abstract See https://github.com/Theano/Theano/pull/6664#issuecomment-581845517 * Move more collections.abc imports to theano.compat * Use math.gcd instead of fractions.gcd when possible fractions.gcd() function has been removed from Python 3.9, it was deprecated since Python 3.5. https://docs.python.org/3.9/whatsnew/3.9.html#removed * DOC: Allow building with Sphinx >= 2.0 * MAINT: Avoid SyntaxWarnings on import in Python 3.8 * flake8 code style fixes * DOC: Retain compatibility with older Sphinx * MAINT: Be compatible with numpy 1.17 and scipy 1.3 Fixes #6715. Includes and supersedes #6721. * flake8 code style fixes * Remove doctest in python 3.4 * Do not install sphinx_rtd_theme for python 3.4 as the installation doesn't work anymore. * fixing typo in GammaIncC Op * re-add min > max clip test with fixed reference * DOC: min > max clip may not match numpy * updating travis build for Python 3 * order of stages * conda activate * installing conda properly * conda install on travis * conda activate issues on travis * conda activate issues on travis * doctest needs older version of numpy * doctest * reverting setup.cfg * conda version conflicts * need old sphinx version * sphinx version * don't bother building docs * moved nosetester import * also moving known failures plugin Co-authored-by: 's avatarAdrian Seyboldt <adrian.seyboldt@gmail.com> Co-authored-by: 's avatarFrédéric Bastien <frederic.bastien@gmail.com> Co-authored-by: 's avatarTim Gates <tim.gates@iress.com> Co-authored-by: 's avatarMarcel Bargull <marcel.bargull@udo.edu> Co-authored-by: 's avatarArnaud Bergeron <abergeron@gmail.com> Co-authored-by: 's avatarMiro Hrončok <miro@hroncok.cz> Co-authored-by: 's avatarRebecca N. Palmer <rebecca_palmer@zoho.com> Co-authored-by: 's avatarFrederic Bastien <fbastien@nvidia.com>
上级 fad7aacb
# After changing this file, check it on: # After changing this file, check it on:
# http://lint.travis-ci.org/ # http://lint.travis-ci.org/
sudo: false os: linux
dist: xenial
cache: cache:
directories: directories:
- $HOME/.cache/pip - $HOME/.cache/pip
- $HOME/.theano - $HOME/.theano
- $HOME/download # Sufficient to add miniconda.sh to TRAVIS cache. - $HOME/download
- $HOME/miniconda2 # Add the installation to TRAVIS cache. - $HOME/miniconda
language: python language: python
# For now, Python versions have to be listed in the "jobs" matrix
# NB: python:
# In before_install and install sections below, - "3.7"
# some codes have been moved to separate files - "3.6"
# to better handle if-else shell syntax
# for multiple lines. New files are in
# new folder ".travis".
# command to install dependencies stages:
before_install: - doc
- ./.travis/travis_before_install.sh - test
- export PATH=/home/travis/miniconda2/bin:$PATH
env:
global:
- NUMPY_VERSION=1.18.1
jobs:
# - DOC=1 PART="theano/tests/test_flake8.py"
- PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests -e test_flake8.py theano/typed_list"
- PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
- PART="theano/tensor/tests/test_basic.py"
- PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
- PART="theano/tensor/nnet -e test_abstract_conv.py"
- PART="theano/tensor/nnet/tests/test_abstract_conv.py"
addons: addons:
apt_packages: apt_packages:
...@@ -31,109 +38,53 @@ addons: ...@@ -31,109 +38,53 @@ addons:
- texlive-fonts-recommended - texlive-fonts-recommended
- dvipng - dvipng
before_install:
- source .travis/travis_before_install.sh
install: install:
- ./.travis/travis_install.sh - source .travis/travis_install.sh
- source activate pyenv
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install pydot; else pip install pydot-ng; fi
- pip install . --no-deps --upgrade
- pip install flake8-future-import parameterized
- if [[ $TRAVIS_PYTHON_VERSION != '3.4' ]]; then pip install sphinx_rtd_theme; fi
# nose-exclude plugin allow us to tell nosetests to exclude folder with --exclude-dir=path/to/directory.
- pip install nose-exclude nose-timer
- if [[ $NUMPY_VERSION == '1.13.1' ]]; then conda install --yes -q scipy=0.19.1; else conda install --yes -q scipy=0.14; fi # Try to reinstall it to fix the problem
jobs: jobs:
include: include:
# define prototype for doctest
- &doctest - &doctest
stage: doc stage: doc
python: "2.7" env: DOC=1 PART="theano/tests/test_flake8.py"
env: NUMPY_VERSION=1.9.1 DOC=1 PART="theano/tests/test_flake8.py"
# re-use prototype, changing the Python version
- <<: *doctest
python: "2.7"
env: NUMPY_VERSION=1.13.1 DOC=1 PART="theano/tests/test_flake8.py"
# - <<: *doctest
# python: "3.4"
# env: NUMPY_VERSION=1.9.1 DOC=1 PART="theano/tests/test_flake8.py"
- <<: *doctest
python: "3.6"
env: NUMPY_VERSION=1.13.1 DOC=1 PART="theano/tests/test_flake8.py"
- &normaltest - &normaltest
stage: test stage: test
python: "2.7" env: FAST_COMPILE=1 FLOAT32=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
env: NUMPY_VERSION=1.9.1 PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests -e test_flake8.py theano/typed_list"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests -e test_flake8.py theano/typed_list"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
- <<: *normaltest
env: NUMPY_VERSION=1.13.1 PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
- <<: *normaltest
python: "3.6"
env: NUMPY_VERSION=1.13.1 PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/tests/test_basic.py"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/tests/test_basic.py"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/nnet -e test_abstract_conv.py"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/nnet -e test_abstract_conv.py"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/nnet/tests/test_abstract_conv.py"
- <<: *normaltest
python: "3.4"
env: NUMPY_VERSION=1.9.1 PART="theano/tensor/nnet/tests/test_abstract_conv.py"
- <<: *normaltest
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 FLOAT32=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
- <<: *normaltest - <<: *normaltest
python: "3.4" env: FAST_COMPILE=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
- <<: *normaltest - <<: *normaltest
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/nnet" env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/nnet"
- <<: *normaltest - <<: *normaltest
python: "3.4" env: FAST_COMPILE=1 PART="theano/tensor/nnet"
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 PART="theano/tensor/nnet"
- <<: *normaltest - <<: *normaltest
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/signal" env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/signal"
- <<: *normaltest - <<: *normaltest
python: "3.4" env: FAST_COMPILE=1 PART="theano/tensor/signal"
env: NUMPY_VERSION=1.9.1 FAST_COMPILE=1 PART="theano/tensor/signal"
script: script:
- conda activate pyenv
- if [[ $FAST_COMPILE == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,mode=FAST_COMPILE; fi - if [[ $FAST_COMPILE == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,mode=FAST_COMPILE; fi
- if [[ $FLOAT32 == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,floatX=float32; fi - if [[ $FLOAT32 == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,floatX=float32; fi
- export THEANO_FLAGS=$THEANO_FLAGS,warn.ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc.cxxflags=-pipe - export THEANO_FLAGS=$THEANO_FLAGS,warn.ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc.cxxflags=-pipe
- export MKL_THREADING_LAYER=GNU - export MKL_THREADING_LAYER=GNU
- export MKL_NUM_THREADS=1 - export MKL_NUM_THREADS=1
- export OMP_NUM_THREADS=1 - export OMP_NUM_THREADS=1
- which python
- python --version - python --version
- uname -a - uname -a
- free -m - free -m
- df -h - df -h
- ulimit -a - ulimit -a
- echo "$PART" - echo "$PART"
# Print information to help debug problems # Print information to help debug problems
- python -c 'import numpy; print(numpy.__version__)' - python -c 'import numpy; print(numpy.__version__)'
- python -c 'import theano; print(theano.__version__)' - python -c 'import theano; print(theano.__version__)'
- python -c 'import theano; print(theano.config.__str__(print_doc=False))' - python -c 'import theano; print(theano.config.__str__(print_doc=False))'
- python -c 'import theano; assert(theano.config.blas.ldflags != "")' - python -c 'import theano; assert(theano.config.blas.ldflags != "")'
# Run tests for the given part # Run tests for the given part
- theano-nose -v --with-timer --timer-top-n 10 $PART - theano-nose -v --with-timer --timer-top-n 10 $PART
- if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --nopdf --check; fi
- if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --test --check; fi
after_failure: after_failure:
- cat /home/travis/.pip/pip.log - cat $HOME/.pip/pip.log
#!/usr/bin/env bash #!/usr/bin/env bash
set -e
# Install miniconda to avoid compiling scipy # Install miniconda to avoid compiling scipy
if test -e $HOME/miniconda2/bin ; then if test -e $HOME/miniconda/bin ; then
echo "miniconda already installed." echo "miniconda already installed."
else else
echo "Installing miniconda." echo "Installing miniconda."
rm -rf $HOME/miniconda2 rm -rf $HOME/miniconda
mkdir -p $HOME/download mkdir -p $HOME/download
if [[ -d $HOME/download/miniconda.sh ]] ; then rm -rf $HOME/download/miniconda.sh ; fi if [[ -d $HOME/download/miniconda.sh ]] ; then rm -rf $HOME/download/miniconda.sh ; fi
wget -c https://repo.continuum.io/miniconda/Miniconda2-4.5.11-Linux-x86_64.sh -O $HOME/download/miniconda.sh wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $HOME/download/miniconda.sh
chmod +x $HOME/download/miniconda.sh
$HOME/download/miniconda.sh -b mkdir $HOME/.conda
bash $HOME/download/miniconda.sh -b -p $HOME/miniconda
fi fi
$HOME/miniconda/bin/conda init bash
source ~/.bash_profile
conda activate base
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
#!/usr/bin/env bash #!/usr/bin/env bash
# In Python 3.4, we test the min version of NumPy and SciPy. In Python 2.7, we test more recent version.
if test -e $HOME/miniconda2/envs/pyenv; then set -e
echo "pyenv already exists."
if [[ $DOC == "1" ]]; then
# this is a hack to deal with the fact that the docs and flake8 config are all set up
# for old versions
conda create --yes -q -n pyenv python=3.6 numpy=1.13.1
conda activate pyenv
conda install --yes -q mkl numpy=1.13.1 scipy=0.19.1 nose=1.3.7 pip flake8=3.5 six=1.11.0 pep8=1.7.1 pyflakes=1.6.0 mkl-service graphviz
python -m pip install pydot-ng flake8-future-import parameterized nose-exclude nose-timer
else else
echo "Creating pyenv." conda create --yes -q -n pyenv python=$TRAVIS_PYTHON_VERSION
if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then conda create --yes -q -n pyenv python=2.7 ; fi conda activate pyenv
if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then conda create --yes -q -n pyenv python=3.4 ; fi conda install --yes -q mkl numpy scipy nose pip flake8 six pep8 pyflakes sphinx mkl-service graphviz # libgfortran
if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then conda create --yes -q -n pyenv python=3.6 ; fi python -m pip install -q pydot-ng flake8-future-import parameterized sphinx_rtd_theme nose-exclude nose-timer
fi fi
source activate pyenv python -m pip install --no-deps --upgrade -e .
if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $NUMPY_VERSION == '1.9.1' ]]; then conda install --yes -q mkl numpy=1.9.1 scipy=0.14.0 nose=1.3.0 pip flake8=2.3 six=1.9.0 pep8=1.6.2 pyflakes=0.8.1 sphinx=1.5.1 mkl-service libgfortran=1 graphviz; fi
if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $NUMPY_VERSION == '1.13.1' ]]; then conda install --yes -q mkl numpy=1.13.1 scipy=0.19.1 nose=1.3.0 pip flake8=2.3 six=1.9.0 pep8=1.6.2 pyflakes=0.8.1 sphinx=1.5.1 mkl-service libgfortran=3 graphviz; fi
if [[ $TRAVIS_PYTHON_VERSION == '3.4' && $NUMPY_VERSION == '1.9.1' ]]; then conda install --yes -q mkl numpy=1.9.1 scipy=0.14.0 nose=1.3.4 pip flake8=2.3 six=1.9.0 pep8=1.6.2 pyflakes=0.8.1 sphinx=1.5.1 mkl-service libgfortran=1 graphviz pygments=2.1.3; fi
if [[ $TRAVIS_PYTHON_VERSION == '3.6' && $NUMPY_VERSION == '1.13.1' ]]; then conda install --yes -q mkl numpy=1.13.1 scipy=0.19.1 nose=1.3.7 pip flake8=3.5 six=1.11.0 pep8=1.7.1 pyflakes=1.6.0 sphinx=1.5.1 mkl-service libgfortran=3 graphviz; fi
source deactivate
...@@ -101,11 +101,17 @@ def main_function(): ...@@ -101,11 +101,17 @@ def main_function():
if '--without-knownfailure' not in sys.argv: if '--without-knownfailure' not in sys.argv:
try: try:
from numpy.testing.noseclasses import KnownFailure from numpy.testing.noseclasses import KnownFailure
except ImportError:
try:
from numpy.testing._private.noseclasses import KnownFailure
addplugins.append(KnownFailure()) addplugins.append(KnownFailure())
except ImportError: except ImportError:
_logger.warn( _logger.warn(
'KnownFailure plugin from NumPy could not be imported. ' 'KnownFailure plugin from NumPy could not be imported. '
'Use --without-knownfailure to disable this warning.') 'Use --without-knownfailure to disable this warning.')
else:
addplugins.append(KnownFailure())
else: else:
sys.argv.remove('--without-knownfailure') sys.argv.remove('--without-knownfailure')
......
...@@ -3,7 +3,11 @@ import os ...@@ -3,7 +3,11 @@ import os
import unittest import unittest
import sys import sys
from numpy.testing.nosetester import NoseTester try:
from numpy.testing.nosetester import NoseTester
except ImportError:
# The tester has been moved in recent versions of numpy
from numpy.testing._private.nosetester import NoseTester
# This class contains code adapted from NumPy, # This class contains code adapted from NumPy,
...@@ -31,51 +35,70 @@ class TheanoNoseTester(NoseTester): ...@@ -31,51 +35,70 @@ class TheanoNoseTester(NoseTester):
""" """
# self.package_path = os.path.abspath(self.package_path) # self.package_path = os.path.abspath(self.package_path)
argv = [__file__, self.package_path] argv = [__file__, self.package_path]
argv += ['--verbosity', str(verbose)] argv += ["--verbosity", str(verbose)]
if extra_argv: if extra_argv:
argv += extra_argv argv += extra_argv
return argv return argv
def _show_system_info(self): def _show_system_info(self):
import theano import theano
print("Theano version %s" % theano.__version__) print("Theano version %s" % theano.__version__)
theano_dir = os.path.dirname(theano.__file__) theano_dir = os.path.dirname(theano.__file__)
print("theano is installed in %s" % theano_dir) print("theano is installed in %s" % theano_dir)
super(TheanoNoseTester, self)._show_system_info() super(TheanoNoseTester, self)._show_system_info()
def prepare_test_args(self, verbose=1, extra_argv=None, coverage=False, def prepare_test_args(
capture=True, knownfailure=True): self,
verbose=1,
extra_argv=None,
coverage=False,
capture=True,
knownfailure=True,
):
""" """
Prepare arguments for the `test` method. Prepare arguments for the `test` method.
Takes the same arguments as `test`. Takes the same arguments as `test`.
""" """
import nose.plugins.builtin import nose.plugins.builtin
# compile argv # compile argv
argv = self._test_argv(verbose, extra_argv) argv = self._test_argv(verbose, extra_argv)
# numpy way of doing coverage # numpy way of doing coverage
if coverage: if coverage:
argv += ['--cover-package=%s' % self.package_name, argv += [
'--with-coverage', '--cover-tests', "--cover-package=%s" % self.package_name,
'--cover-inclusive', '--cover-erase'] "--with-coverage",
"--cover-tests",
"--cover-inclusive",
"--cover-erase",
]
# Capture output only if needed # Capture output only if needed
if not capture: if not capture:
argv += ['-s'] argv += ["-s"]
# construct list of plugins # construct list of plugins
plugins = [] plugins = []
if knownfailure: if knownfailure:
from numpy.testing.noseclasses import KnownFailure from numpy.testing.noseclasses import KnownFailure
plugins.append(KnownFailure()) plugins.append(KnownFailure())
plugins += [p() for p in nose.plugins.builtin.plugins] plugins += [p() for p in nose.plugins.builtin.plugins]
return argv, plugins return argv, plugins
def test(self, verbose=1, extra_argv=None, coverage=False, capture=True, def test(
knownfailure=True): self,
verbose=1,
extra_argv=None,
coverage=False,
capture=True,
knownfailure=True,
):
""" """
Run tests for module using nose. Run tests for module using nose.
...@@ -107,17 +130,21 @@ class TheanoNoseTester(NoseTester): ...@@ -107,17 +130,21 @@ class TheanoNoseTester(NoseTester):
from nose.config import Config from nose.config import Config
from nose.plugins.manager import PluginManager from nose.plugins.manager import PluginManager
from numpy.testing.noseclasses import NumpyTestProgram from numpy.testing.noseclasses import NumpyTestProgram
# Many Theano tests suppose device=cpu, so we need to raise an # Many Theano tests suppose device=cpu, so we need to raise an
# error if device==gpu. # error if device==gpu.
if not os.path.exists('theano/__init__.py'): if not os.path.exists("theano/__init__.py"):
try: try:
from theano import config from theano import config
if config.device != "cpu": if config.device != "cpu":
raise ValueError("Theano tests must be run with device=cpu." raise ValueError(
"Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.\n" " This will also run GPU tests when possible.\n"
" If you want GPU-related tests to run on a" " If you want GPU-related tests to run on a"
" specific GPU device, and not the default one," " specific GPU device, and not the default one,"
" you should use the init_gpu_device theano flag.") " you should use the init_gpu_device theano flag."
)
except ImportError: except ImportError:
pass pass
...@@ -129,15 +156,19 @@ class TheanoNoseTester(NoseTester): ...@@ -129,15 +156,19 @@ class TheanoNoseTester(NoseTester):
if self.package_path in os.listdir(cwd): if self.package_path in os.listdir(cwd):
# The tests give weird errors if the package to test is # The tests give weird errors if the package to test is
# in current directory. # in current directory.
raise RuntimeError(( raise RuntimeError(
(
"This function does not run correctly when, at the time " "This function does not run correctly when, at the time "
"theano was imported, the working directory was theano's " "theano was imported, the working directory was theano's "
"parent directory. You should exit your Python prompt, change " "parent directory. You should exit your Python prompt, change "
"directory, then launch Python again, import theano, then " "directory, then launch Python again, import theano, then "
"launch theano.test().")) "launch theano.test()."
)
)
argv, plugins = self.prepare_test_args(verbose, extra_argv, coverage, argv, plugins = self.prepare_test_args(
capture, knownfailure) verbose, extra_argv, coverage, capture, knownfailure
)
# The "plugins" keyword of NumpyTestProgram gets ignored if config is # The "plugins" keyword of NumpyTestProgram gets ignored if config is
# specified. Moreover, using "addplugins" instead can lead to strange # specified. Moreover, using "addplugins" instead can lead to strange
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论