From 1f96a7b0f268c7da2eb0cfed6037b9a515ede255 Mon Sep 17 00:00:00 2001 From: Keith Battocchi Date: Tue, 22 Dec 2020 13:43:53 -0500 Subject: [PATCH] Switch to tox --- azure-pipelines-steps.yml | 17 ++++------ azure-pipelines.yml | 68 ++++++++++++++++----------------------- pyproject.toml | 9 ++++++ setup.cfg | 26 --------------- setup.py | 5 +-- tox.ini | 43 +++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 79 deletions(-) create mode 100644 tox.ini diff --git a/azure-pipelines-steps.yml b/azure-pipelines-steps.yml index ac9325c98..bb8492908 100644 --- a/azure-pipelines-steps.yml +++ b/azure-pipelines-steps.yml @@ -4,8 +4,8 @@ # https://docs.microsoft.com/azure/devops/pipelines/languages/python parameters: - body: [] - package: '-e .' + post: [] + env: 'py38' steps: - task: UsePythonVersion@0 @@ -18,13 +18,8 @@ steps: displayName: 'Enable long paths on Windows' condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) -# Install graphviz programmatically on Linux -- script: 'sudo apt-get -yq install graphviz' - displayName: 'Install graphviz on Linux' - condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) +# Run tox +- script: 'python -m pip install --upgrade pip && pip install --upgrade tox && tox -e ${{ parameters.env }}' + displayName: 'Install and run tox' -# Install the package -- script: 'python -m pip install --upgrade pip && pip install --upgrade setuptools wheel Cython && pip install ${{ parameters.package }}' - displayName: 'Install dependencies' - -- ${{ parameters.body }} +- ${{ parameters.post }} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0e2163be5..afa9a1f2c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -55,53 +55,34 @@ jobs: pool: vmImage: 'ubuntu-18.04' variables: - python.version: '3.6' + python.version: '3.8' steps: - template: azure-pipelines-steps.yml parameters: - body: - - script: 'sudo apt-get -yq install graphviz' - displayName: 'Install graphviz' - - - script: 'pip install sklearn-contrib-lightning' - displayName: 'Install lightning' - - - script: 'pip install git+https://github.com/slundberg/shap.git@d1d2700acc0259f211934373826d5ff71ad514de' - displayName: 'Install specific version of shap' - - - script: 'python setup.py build_sphinx -W' - displayName: 'Build documentation' - + post: - publish: 'build/sphinx/html' artifact: 'Documentation' displayName: 'Publish documentation as artifact' - - - script: 'python setup.py build_sphinx -b doctest' - displayName: 'Run doctests' - package: '-e .[automl]' + env: 'doctest' - job: 'Notebooks' dependsOn: 'EvalChanges' condition: eq(dependencies.EvalChanges.outputs['output.buildNbs'], 'True') - variables: - python.version: '3.8' pool: vmImage: 'ubuntu-18.04' + variables: + python.version: '3.8' steps: - template: azure-pipelines-steps.yml parameters: - body: - - script: 'python setup.py pytest' - displayName: 'Unit tests' - env: - PYTEST_ADDOPTS: '-m "notebook"' - + post: - task: PublishTestResults@2 displayName: 'Publish Test Results **/test-results.xml' inputs: testResultsFiles: '**/test-results.xml' testRunTitle: 'Notebooks' condition: succeededOrFailed() + env: 'notebooks' # - job: 'AutoML' # dependsOn: 'EvalChanges' @@ -141,17 +122,19 @@ jobs: - job: 'Linting' dependsOn: 'EvalChanges' condition: eq(dependencies.EvalChanges.outputs['output.testCode'], 'True') - variables: - python.version: '3.8' pool: vmImage: 'macOS-10.15' steps: - - template: azure-pipelines-steps.yml - parameters: - body: - - script: 'pip install pycodestyle && pycodestyle econml' - failOnStderr: true - displayName: Linting + - task: UsePythonVersion@0 + displayName: 'Use Python 3.8' + inputs: + versionSpec: '3.8' + # note: don't need to install the package itself to lint it + - script: 'python -m pip install --upgrade pip && pip install pycodestyle' + displayName: 'Install pycodestyle' + - script: 'pycodestyle econml' + failOnStderr: true + displayName: Linting - job: 'Tests' dependsOn: 'EvalChanges' @@ -160,30 +143,39 @@ jobs: matrix: Linux, Python 3.6: imageName: 'ubuntu-18.04' + env: 'py36' python.version: '3.6' macOS, Python 3.6: imageName: 'macOS-10.15' + env: 'py36' python.version: '3.6' Windows, Python 3.6: imageName: 'windows-2019' + env: 'py36' python.version: '3.6' Linux, Python 3.7: imageName: 'ubuntu-18.04' + env: 'py37' python.version: '3.7' macOS, Python 3.7: imageName: 'macOS-10.15' + env: 'py37' python.version: '3.7' Windows, Python 3.7: imageName: 'windows-2019' + env: 'py37' python.version: '3.7' Linux, Python 3.8: imageName: 'ubuntu-18.04' + env: 'py38' python.version: '3.8' macOS, Python 3.8: imageName: 'macOS-10.15' + env: 'py38' python.version: '3.8' Windows, Python 3.8: imageName: 'windows-2019' + env: 'py38' python.version: '3.8' pool: @@ -194,12 +186,7 @@ jobs: steps: - template: azure-pipelines-steps.yml parameters: - body: - - script: 'python setup.py pytest' - displayName: 'Unit tests' - env: - PYTEST_ADDOPTS: '-m "not (notebook or automl)"' - COVERAGE_PROCESS_START: 'setup.cfg' + post: - task: PublishTestResults@2 displayName: 'Publish Test Results **/test-results.xml' inputs: @@ -212,3 +199,4 @@ jobs: inputs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + env: $(env) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ade500a2f..41df4972d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,4 +14,13 @@ markers = [ "slow", "notebook", "automl" +] + +[tool.coverage.run] +omit = "econml/tests/*" +branch = "True" +# need to explicitly add support for multiprocessing for OrthoForest +concurrency = [ + "thread", + "multiprocessing" ] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 6dc1fe85f..e779776d7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,11 +32,6 @@ classifiers = [options] packages = find_namespace: -setup_requires = - pytest-runner - sphinx < 3.2 - sphinx_rtd_theme - Cython install_requires = numpy scipy > 1.4.0 @@ -51,18 +46,6 @@ install_requires = matplotlib pandas < 1.1 shap ~= 0.38.1 -test_suite = econml.tests -tests_require = - pytest - pytest-xdist < 2.0.0 - pytest-cov - jupyter - nbconvert < 6 - nbformat - seaborn - lightgbm - dowhy - xgboost [options.extras_require] automl = @@ -79,12 +62,3 @@ include = [options.package_data] ; include all CSV files as data * = *.csv - -; coverage configuration -[coverage:run] -omit = econml/tests/* -branch = True -; need to explicitly add support for multiprocessing for OrthoForest -concurrency = - thread - multiprocessing diff --git a/setup.py b/setup.py index 0c1629ce4..31215c70a 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,10 @@ from Cython.Build import cythonize import numpy as np - # configuration is all pulled from setup.cfg -setup(ext_modules=cythonize([Extension("*", ["**/*.pyx"], +setup(ext_modules=cythonize([Extension("econml.tree.*", ["econml/tree/*.pyx"], + include_dirs=[np.get_include()]), + Extension("econml.grf.*", ["econml/grf/*.pyx"], include_dirs=[np.get_include()])], language_level="3"), zip_safe=False) diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..402e72f9d --- /dev/null +++ b/tox.ini @@ -0,0 +1,43 @@ +[tox] +envlist = py{36,37,38}, notebooks, doctest + +isolated_build = true + +[testenv] +# install additional testing requirements +deps = + pytest + pytest-xdist + pytest-cov + coverage[toml] + nbconvert < 6 + +# run the tests +commands = + pytest -m "not (notebook or automl)" + +[testenv:notebooks] +deps = + {[testenv]deps} + jupyter + nbconvert < 6 + shap + lightgbm + seaborn + xgboost + dowhy + +commands = + pytest -m "notebook" + +[testenv:doctest] +deps = + sklearn-contrib-lightning + sphinx +extras = + automl +commands = + sudo apt-get -yq install graphviz + sphinx-build -b html ./doc ./build/sphinx -W + sphinx-build -b doctest ./doc ./build/sphinx +