Skip to content

Commit

Permalink
Switch to tox
Browse files Browse the repository at this point in the history
  • Loading branch information
kbattocchi committed Dec 22, 2020
1 parent 9741ace commit 43182d0
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 79 deletions.
17 changes: 6 additions & 11 deletions azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

parameters:
body: []
package: '-e .'
post: []
env: 'py38'

steps:
- task: UsePythonVersion@0
Expand All @@ -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 }}
68 changes: 28 additions & 40 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '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: 'pip install shap'
displayName: 'Install shap'

- 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'
Expand Down Expand Up @@ -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'
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -212,3 +199,4 @@ jobs:
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
env: $(env)
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
26 changes: 0 additions & 26 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,18 +45,6 @@ install_requires =
graphviz
matplotlib
pandas < 1.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 =
Expand All @@ -78,12 +61,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
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
43 changes: 43 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 43182d0

Please sign in to comment.