Skip to content

Commit 1f96a7b

Browse files
committed
Switch to tox
1 parent a53d8bd commit 1f96a7b

6 files changed

+89
-79
lines changed

azure-pipelines-steps.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
55

66
parameters:
7-
body: []
8-
package: '-e .'
7+
post: []
8+
env: 'py38'
99

1010
steps:
1111
- task: UsePythonVersion@0
@@ -18,13 +18,8 @@ steps:
1818
displayName: 'Enable long paths on Windows'
1919
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
2020

21-
# Install graphviz programmatically on Linux
22-
- script: 'sudo apt-get -yq install graphviz'
23-
displayName: 'Install graphviz on Linux'
24-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
21+
# Run tox
22+
- script: 'python -m pip install --upgrade pip && pip install --upgrade tox && tox -e ${{ parameters.env }}'
23+
displayName: 'Install and run tox'
2524

26-
# Install the package
27-
- script: 'python -m pip install --upgrade pip && pip install --upgrade setuptools wheel Cython && pip install ${{ parameters.package }}'
28-
displayName: 'Install dependencies'
29-
30-
- ${{ parameters.body }}
25+
- ${{ parameters.post }}

azure-pipelines.yml

+28-40
Original file line numberDiff line numberDiff line change
@@ -55,53 +55,34 @@ jobs:
5555
pool:
5656
vmImage: 'ubuntu-18.04'
5757
variables:
58-
python.version: '3.6'
58+
python.version: '3.8'
5959
steps:
6060
- template: azure-pipelines-steps.yml
6161
parameters:
62-
body:
63-
- script: 'sudo apt-get -yq install graphviz'
64-
displayName: 'Install graphviz'
65-
66-
- script: 'pip install sklearn-contrib-lightning'
67-
displayName: 'Install lightning'
68-
69-
- script: 'pip install git+https://github.com/slundberg/shap.git@d1d2700acc0259f211934373826d5ff71ad514de'
70-
displayName: 'Install specific version of shap'
71-
72-
- script: 'python setup.py build_sphinx -W'
73-
displayName: 'Build documentation'
74-
62+
post:
7563
- publish: 'build/sphinx/html'
7664
artifact: 'Documentation'
7765
displayName: 'Publish documentation as artifact'
78-
79-
- script: 'python setup.py build_sphinx -b doctest'
80-
displayName: 'Run doctests'
81-
package: '-e .[automl]'
66+
env: 'doctest'
8267

8368
- job: 'Notebooks'
8469
dependsOn: 'EvalChanges'
8570
condition: eq(dependencies.EvalChanges.outputs['output.buildNbs'], 'True')
86-
variables:
87-
python.version: '3.8'
8871
pool:
8972
vmImage: 'ubuntu-18.04'
73+
variables:
74+
python.version: '3.8'
9075
steps:
9176
- template: azure-pipelines-steps.yml
9277
parameters:
93-
body:
94-
- script: 'python setup.py pytest'
95-
displayName: 'Unit tests'
96-
env:
97-
PYTEST_ADDOPTS: '-m "notebook"'
98-
78+
post:
9979
- task: PublishTestResults@2
10080
displayName: 'Publish Test Results **/test-results.xml'
10181
inputs:
10282
testResultsFiles: '**/test-results.xml'
10383
testRunTitle: 'Notebooks'
10484
condition: succeededOrFailed()
85+
env: 'notebooks'
10586

10687
# - job: 'AutoML'
10788
# dependsOn: 'EvalChanges'
@@ -141,17 +122,19 @@ jobs:
141122
- job: 'Linting'
142123
dependsOn: 'EvalChanges'
143124
condition: eq(dependencies.EvalChanges.outputs['output.testCode'], 'True')
144-
variables:
145-
python.version: '3.8'
146125
pool:
147126
vmImage: 'macOS-10.15'
148127
steps:
149-
- template: azure-pipelines-steps.yml
150-
parameters:
151-
body:
152-
- script: 'pip install pycodestyle && pycodestyle econml'
153-
failOnStderr: true
154-
displayName: Linting
128+
- task: UsePythonVersion@0
129+
displayName: 'Use Python 3.8'
130+
inputs:
131+
versionSpec: '3.8'
132+
# note: don't need to install the package itself to lint it
133+
- script: 'python -m pip install --upgrade pip && pip install pycodestyle'
134+
displayName: 'Install pycodestyle'
135+
- script: 'pycodestyle econml'
136+
failOnStderr: true
137+
displayName: Linting
155138

156139
- job: 'Tests'
157140
dependsOn: 'EvalChanges'
@@ -160,30 +143,39 @@ jobs:
160143
matrix:
161144
Linux, Python 3.6:
162145
imageName: 'ubuntu-18.04'
146+
env: 'py36'
163147
python.version: '3.6'
164148
macOS, Python 3.6:
165149
imageName: 'macOS-10.15'
150+
env: 'py36'
166151
python.version: '3.6'
167152
Windows, Python 3.6:
168153
imageName: 'windows-2019'
154+
env: 'py36'
169155
python.version: '3.6'
170156
Linux, Python 3.7:
171157
imageName: 'ubuntu-18.04'
158+
env: 'py37'
172159
python.version: '3.7'
173160
macOS, Python 3.7:
174161
imageName: 'macOS-10.15'
162+
env: 'py37'
175163
python.version: '3.7'
176164
Windows, Python 3.7:
177165
imageName: 'windows-2019'
166+
env: 'py37'
178167
python.version: '3.7'
179168
Linux, Python 3.8:
180169
imageName: 'ubuntu-18.04'
170+
env: 'py38'
181171
python.version: '3.8'
182172
macOS, Python 3.8:
183173
imageName: 'macOS-10.15'
174+
env: 'py38'
184175
python.version: '3.8'
185176
Windows, Python 3.8:
186177
imageName: 'windows-2019'
178+
env: 'py38'
187179
python.version: '3.8'
188180

189181
pool:
@@ -194,12 +186,7 @@ jobs:
194186
steps:
195187
- template: azure-pipelines-steps.yml
196188
parameters:
197-
body:
198-
- script: 'python setup.py pytest'
199-
displayName: 'Unit tests'
200-
env:
201-
PYTEST_ADDOPTS: '-m "not (notebook or automl)"'
202-
COVERAGE_PROCESS_START: 'setup.cfg'
189+
post:
203190
- task: PublishTestResults@2
204191
displayName: 'Publish Test Results **/test-results.xml'
205192
inputs:
@@ -212,3 +199,4 @@ jobs:
212199
inputs:
213200
codeCoverageTool: Cobertura
214201
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
202+
env: $(env)

pyproject.toml

+9
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ markers = [
1414
"slow",
1515
"notebook",
1616
"automl"
17+
]
18+
19+
[tool.coverage.run]
20+
omit = "econml/tests/*"
21+
branch = "True"
22+
# need to explicitly add support for multiprocessing for OrthoForest
23+
concurrency = [
24+
"thread",
25+
"multiprocessing"
1726
]

setup.cfg

-26
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ classifiers =
3232

3333
[options]
3434
packages = find_namespace:
35-
setup_requires =
36-
pytest-runner
37-
sphinx < 3.2
38-
sphinx_rtd_theme
39-
Cython
4035
install_requires =
4136
numpy
4237
scipy > 1.4.0
@@ -51,18 +46,6 @@ install_requires =
5146
matplotlib
5247
pandas < 1.1
5348
shap ~= 0.38.1
54-
test_suite = econml.tests
55-
tests_require =
56-
pytest
57-
pytest-xdist < 2.0.0
58-
pytest-cov
59-
jupyter
60-
nbconvert < 6
61-
nbformat
62-
seaborn
63-
lightgbm
64-
dowhy
65-
xgboost
6649

6750
[options.extras_require]
6851
automl =
@@ -79,12 +62,3 @@ include =
7962
[options.package_data]
8063
; include all CSV files as data
8164
* = *.csv
82-
83-
; coverage configuration
84-
[coverage:run]
85-
omit = econml/tests/*
86-
branch = True
87-
; need to explicitly add support for multiprocessing for OrthoForest
88-
concurrency =
89-
thread
90-
multiprocessing

setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from Cython.Build import cythonize
44
import numpy as np
55

6-
76
# configuration is all pulled from setup.cfg
8-
setup(ext_modules=cythonize([Extension("*", ["**/*.pyx"],
7+
setup(ext_modules=cythonize([Extension("econml.tree.*", ["econml/tree/*.pyx"],
8+
include_dirs=[np.get_include()]),
9+
Extension("econml.grf.*", ["econml/grf/*.pyx"],
910
include_dirs=[np.get_include()])],
1011
language_level="3"),
1112
zip_safe=False)

tox.ini

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[tox]
2+
envlist = py{36,37,38}, notebooks, doctest
3+
4+
isolated_build = true
5+
6+
[testenv]
7+
# install additional testing requirements
8+
deps =
9+
pytest
10+
pytest-xdist
11+
pytest-cov
12+
coverage[toml]
13+
nbconvert < 6
14+
15+
# run the tests
16+
commands =
17+
pytest -m "not (notebook or automl)"
18+
19+
[testenv:notebooks]
20+
deps =
21+
{[testenv]deps}
22+
jupyter
23+
nbconvert < 6
24+
shap
25+
lightgbm
26+
seaborn
27+
xgboost
28+
dowhy
29+
30+
commands =
31+
pytest -m "notebook"
32+
33+
[testenv:doctest]
34+
deps =
35+
sklearn-contrib-lightning
36+
sphinx
37+
extras =
38+
automl
39+
commands =
40+
sudo apt-get -yq install graphviz
41+
sphinx-build -b html ./doc ./build/sphinx -W
42+
sphinx-build -b doctest ./doc ./build/sphinx
43+

0 commit comments

Comments
 (0)