Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8162567
Execute the first two sets of unit tests in parallel.
Oct 15, 2019
1ac5033
Wrap test estimator checks in a python unit test.
Oct 15, 2019
04ea00f
Combine the non-extended test runs together to make them more paralle…
Oct 15, 2019
f25bb32
Reverse the tests path args order to try and have test_estimator_chec…
Oct 15, 2019
eeb4e30
Group the unit tests by filename to make their execution more stable.
Oct 15, 2019
a591122
Add the build script changes to build.sh
Oct 15, 2019
7e2a160
Set the minimum number of concurrent unit tests to 4 for the windows …
Oct 15, 2019
c741c9a
Merge branch 'master' into parallel-unit-tests
Oct 15, 2019
e9557ad
Split test_estimator_checks into two separate tests.
Oct 15, 2019
9e6968c
Hard code num concurrent unit tests to 4 for linux and mac. Disable f…
Oct 15, 2019
69dca80
Merge branch 'master' into parallel-unit-tests
Oct 15, 2019
265e04f
Run the two extended tests in parallel.
Oct 16, 2019
5df9ad3
Support running test_estimator_checks as the main file.
Oct 16, 2019
3f8168c
Merge branch 'master' into parallel-unit-tests
Oct 16, 2019
010856d
Merge branch 'master' into parallel-unit-tests
Oct 17, 2019
51cc916
Dynamically generate the test_estimator_checks unit tests.
Oct 17, 2019
9e4efff
Test intentional failure on build servers.
Oct 17, 2019
4afbf71
Merge branch 'master' into parallel-unit-tests
Oct 21, 2019
c33fcc8
Create the test_docs_example unit tests dynamically so they can be pa…
Oct 21, 2019
0e785bc
Update the number of concurrent extended tests.
Oct 21, 2019
1c7de9d
Merge branch 'master' into parallel-unit-tests
Oct 22, 2019
cd81f83
Remove intentional error from test_csr_matrix_output.
Oct 22, 2019
643b39f
Test intentional error in test_estimator_checks.
Oct 22, 2019
dbec373
Remove the intentional error which was used for testing.
Oct 22, 2019
fda4887
Add whitespace change to restart CI run.
Oct 22, 2019
9138a0d
Add whitespace change to start a new CI run.
Oct 22, 2019
95de280
Load balance by sending test grouped by file to any available environ…
Oct 23, 2019
0495136
Add whitespace change to start a new CI run.
Oct 23, 2019
2f6aeb6
Fix KMeansPlusPlus does not work with a cluster size of 1 when using …
Oct 24, 2019
472ad3f
Fix OLS divide by 0 when given a particular set of inputs to fit. Thi…
Oct 24, 2019
b1ccc3a
Fix issue when ranking where the output of TextToKeyConverter was
Oct 24, 2019
be8835f
Remove a test_estimator_check for OrdinaryLeastSquaresRegressor
Oct 24, 2019
3de74fe
Update test_permutation_feature_importance tests to support parallel …
Oct 24, 2019
75df293
Remove --dist=loadfile from the windows unit test run.
Oct 24, 2019
7122e19
Update test_load_save to support parallel execution.
Oct 24, 2019
dbf6c47
Test turning off pytest assert rewriting.
Oct 24, 2019
366b1b0
Test turning off forcing at least 4 concurrent unit tests
Oct 24, 2019
c345a0f
Whitespace change to start a new CI run.
Oct 24, 2019
e6804ea
Test tests run without coverage.
Oct 24, 2019
4cf17cd
Try and capture the test order during the CI run.
Oct 25, 2019
3988ac4
Remove the pydist replay request.
Oct 25, 2019
ed10974
Rerun unit tests one extra time if any failed to check for intermitte…
Oct 25, 2019
8161d24
Turn back on assert rewriting and coverage reporting. Run extended te…
Oct 28, 2019
9822643
Merge branch 'master' into parallel-unit-tests
Oct 28, 2019
c3c4dbd
Remove whitespace at the end of the comment in build.cmd.
Oct 28, 2019
c7bb353
Test errors in tests show up correctly in CI build output.
Oct 28, 2019
8aeab82
Revert the intentional test failures from the previous commit.
Oct 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ if "%InstallPythonPackages%" == "True" (
echo "Installing python packages ... "
echo "#################################"
call "%PythonExe%" -m pip install --upgrade pip
call "%PythonExe%" -m pip install --upgrade nose pytest graphviz imageio pytest-cov "jupyter_client>=4.4.0" "nbconvert>=4.2.0"
call "%PythonExe%" -m pip install --upgrade nose pytest pytest-xdist graphviz imageio pytest-cov "jupyter_client>=4.4.0" "nbconvert>=4.2.0"

if %PythonVersion% == 2.7 (
call "%PythonExe%" -m pip install --upgrade pyzmq
Expand All @@ -414,19 +414,27 @@ set TestsPath1=%PackagePath%\tests
set TestsPath2=%__currentScriptDir%src\python\tests
set TestsPath3=%__currentScriptDir%src\python\tests_extended
set ReportPath=%__currentScriptDir%build\TestCoverageReport
call "%PythonExe%" -m pytest --verbose --maxfail=1000 --capture=sys "%TestsPath1%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
if errorlevel 1 (
goto :Exit_Error
)
call "%PythonExe%" -m pytest --verbose --maxfail=1000 --capture=sys "%TestsPath2%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
set NumConcurrentTests=%NUMBER_OF_PROCESSORS%

call "%PythonExe%" -m pytest -n %NumConcurrentTests% --verbose --maxfail=1000 --capture=sys "%TestsPath2%" "%TestsPath1%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
if errorlevel 1 (
goto :Exit_Error
:: Rerun any failed tests to give them one more
:: chance in case the errors were intermittent.
call "%PythonExe%" -m pytest -n %NumConcurrentTests% --last-failed --verbose --maxfail=1000 --capture=sys "%TestsPath2%" "%TestsPath1%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
if errorlevel 1 (
goto :Exit_Error
)
)

if "%RunExtendedTests%" == "True" (
call "%PythonExe%" -m pytest --verbose --maxfail=1000 --capture=sys "%TestsPath3%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
call "%PythonExe%" -m pytest -n %NumConcurrentTests% --verbose --maxfail=1000 --capture=sys "%TestsPath3%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
if errorlevel 1 (
goto :Exit_Error
:: Rerun any failed tests to give them one more
:: chance in case the errors were intermittent.
call "%PythonExe%" -m pytest -n %NumConcurrentTests% --last-failed --verbose --maxfail=1000 --capture=sys "%TestsPath3%" --cov="%PackagePath%" --cov-report term-missing --cov-report html:"%ReportPath%"
if errorlevel 1 (
goto :Exit_Error
)
)
)

Expand Down
7 changes: 3 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ then
exit 1
fi
# Review: Adding "--upgrade" to pip install will cause problems when using Anaconda as the python distro because of Anaconda's quirks with pytest.
"${PythonExe}" -m pip install nose "pytest>=4.4.0" graphviz "pytest-cov>=2.6.1" "jupyter_client>=4.4.0" "nbconvert>=4.2.0"
"${PythonExe}" -m pip install nose "pytest>=4.4.0" pytest-xdist graphviz "pytest-cov>=2.6.1" "jupyter_client>=4.4.0" "nbconvert>=4.2.0"
if [ ${PythonVersion} = 2.7 ]
then
"${PythonExe}" -m pip install --upgrade pyzmq
Expand All @@ -307,8 +307,7 @@ then
TestsPath2=${__currentScriptDir}/src/python/tests
TestsPath3=${__currentScriptDir}/src/python/tests_extended
ReportPath=${__currentScriptDir}/build/TestCoverageReport
"${PythonExe}" -m pytest --verbose --maxfail=1000 --capture=sys "${TestsPath1}"
"${PythonExe}" -m pytest --verbose --maxfail=1000 --capture=sys "${TestsPath2}"
"${PythonExe}" -m pytest -n 4 --verbose --maxfail=1000 --capture=sys "${TestsPath2}" "${TestsPath1}"

if [ ${__runExtendedTests} = true ]
then
Expand All @@ -325,7 +324,7 @@ then
yum install glibc-devel -y
}
fi
"${PythonExe}" -m pytest --verbose --maxfail=1000 --capture=sys "${TestsPath3}"
"${PythonExe}" -m pytest -n 4 --verbose --maxfail=1000 --capture=sys "${TestsPath3}"
fi
fi

Expand Down
8 changes: 6 additions & 2 deletions src/python/nimbusml/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,10 +1529,14 @@ def _evaluation_infer(self, evaltype, label_column, group_id,
models_anomalydetectionevaluator(**params)])

elif type_ == 'ranking':
svd = "$scoredVectorData"
column = [OrderedDict(Source=group_id, Name=group_id)]
algo_args = dict(data=svd, output_data=svd, column=column)
algo_args = dict(
data="$scoredVectorData",
output_data="$scoredVectorData2",
column=column)
key_node = transforms_texttokeyconverter(**algo_args)

params['data'] = "$scoredVectorData2"
evaluate_node = models_rankingevaluator(
group_id_column=group_id, **params)
all_nodes.extend([
Expand Down
10 changes: 5 additions & 5 deletions src/python/nimbusml/tests/model_summary/test_model_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
GamBinaryClassifier(),
PcaAnomalyDetector(),
FactorizationMachineBinaryClassifier(),
KMeansPlusPlus(),
KMeansPlusPlus(n_clusters=2),
NaiveBayesClassifier(),
FastForestBinaryClassifier(number_of_trees=2),
FastForestRegressor(number_of_trees=2),
Expand Down Expand Up @@ -119,24 +119,24 @@ def test_summary_called_back_to_back_on_predictor(self):
ols.summary()

def test_pipeline_summary_is_refreshed_after_refitting(self):
predictor = OrdinaryLeastSquaresRegressor(normalize='No', l2_regularization=0)
predictor = OrdinaryLeastSquaresRegressor()
pipeline = Pipeline([predictor])

pipeline.fit([0,1,2,3], [1,2,3,4])
summary1 = pipeline.summary()

pipeline.fit([0,1,2,3], [2,5,8,11])
pipeline.fit([0,1,2.5,3], [2,5,8,11])
summary2 = pipeline.summary()

self.assertFalse(summary1.equals(summary2))

def test_predictor_summary_is_refreshed_after_refitting(self):
predictor = OrdinaryLeastSquaresRegressor(normalize='No', l2_regularization=0)
predictor = OrdinaryLeastSquaresRegressor()

predictor.fit([0,1,2,3], [1,2,3,4])
summary1 = predictor.summary()

predictor.fit([0,1,2,3], [2,5,8,11])
predictor.fit([0,1,2.5,3], [2,5,8,11])
summary2 = predictor.summary()

self.assertFalse(summary1.equals(summary2))
Expand Down
39 changes: 24 additions & 15 deletions src/python/nimbusml/tests/pipeline/test_load_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
import pickle
import tempfile
import unittest

import numpy as np
Expand Down Expand Up @@ -32,6 +33,12 @@
(train, label) = get_X_y(train_file, label_column, sep=',')
(test, test_label) = get_X_y(test_file, label_column, sep=',')

def get_temp_file(suffix=None):
fd, file_name = tempfile.mkstemp(suffix=suffix)
fl = os.fdopen(fd, 'w')
fl.close()
return file_name


class TestLoadSave(unittest.TestCase):

Expand All @@ -48,7 +55,7 @@ def test_model_dataframe(self):
model_nimbusml.fit(train, label)

# Save with pickle
pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')
with open(pickle_filename, 'wb') as f:
pickle.dump(model_nimbusml, f)

Expand All @@ -65,9 +72,10 @@ def test_model_dataframe(self):
test, test_label, output_scores=True)

# Save load with pipeline methods
model_nimbusml.save_model('model.nimbusml.m')
model_filename = get_temp_file(suffix='.m')
model_nimbusml.save_model(model_filename)
model_nimbusml_load = Pipeline()
model_nimbusml_load.load_model('model.nimbusml.m')
model_nimbusml_load.load_model(model_filename)

score1 = model_nimbusml.predict(test).head(5)
score2 = model_nimbusml_load.predict(test).head(5)
Expand All @@ -82,7 +90,7 @@ def test_model_dataframe(self):
model_nimbusml_load.sum().sum(),
decimal=2)

os.remove('model.nimbusml.m')
os.remove(model_filename)

def test_model_datastream(self):
model_nimbusml = Pipeline(
Expand All @@ -97,7 +105,7 @@ def test_model_datastream(self):
model_nimbusml.fit(train, label)

# Save with pickle
pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')
with open(pickle_filename, 'wb') as f:
pickle.dump(model_nimbusml, f)

Expand All @@ -120,9 +128,10 @@ def test_model_datastream(self):
decimal=2)

# Save load with pipeline methods
model_nimbusml.save_model('model.nimbusml.m')
model_filename = get_temp_file(suffix='.m')
model_nimbusml.save_model(model_filename)
model_nimbusml_load = Pipeline()
model_nimbusml_load.load_model('model.nimbusml.m')
model_nimbusml_load.load_model(model_filename)

score1 = model_nimbusml.predict(test).head(5)
score2 = model_nimbusml_load.predict(test).head(5)
Expand All @@ -137,7 +146,7 @@ def test_model_datastream(self):
model_nimbusml_load.sum().sum(),
decimal=2)

os.remove('model.nimbusml.m')
os.remove(model_filename)

def test_pipeline_saves_complete_model_file_when_pickled(self):
model_nimbusml = Pipeline(
Expand All @@ -152,7 +161,7 @@ def test_pipeline_saves_complete_model_file_when_pickled(self):
model_nimbusml.fit(train, label)
metrics, score = model_nimbusml.test(test, test_label, output_scores=True)

pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')

# Save with pickle
with open(pickle_filename, 'wb') as f:
Expand Down Expand Up @@ -202,7 +211,7 @@ def test_unfitted_pickled_pipeline_can_be_fit(self):
shuffle=False,
number_of_threads=1))])

pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')

# Save with pickle
with open(pickle_filename, 'wb') as f:
Expand Down Expand Up @@ -234,7 +243,7 @@ def test_unpickled_pipeline_has_feature_contributions(self):
fc = model_nimbusml.get_feature_contributions(test)

# Save with pickle
pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')
with open(pickle_filename, 'wb') as f:
pickle.dump(model_nimbusml, f)
# Unpickle model
Expand All @@ -260,7 +269,7 @@ def test_unpickled_predictor_has_feature_contributions(self):
fc = model_nimbusml.get_feature_contributions(test)

# Save with pickle
pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')
with open(pickle_filename, 'wb') as f:
pickle.dump(model_nimbusml, f)
# Unpickle model
Expand All @@ -287,7 +296,7 @@ def test_pipeline_loaded_from_zip_has_feature_contributions(self):
fc = model_nimbusml.get_feature_contributions(test)

# Save the model to zip
model_filename = 'nimbusml_model.zip'
model_filename = get_temp_file(suffix='.zip')
model_nimbusml.save_model(model_filename)
# Load the model from zip
model_nimbusml_zip = Pipeline()
Expand All @@ -312,7 +321,7 @@ def test_predictor_loaded_from_zip_has_feature_contributions(self):
fc = model_nimbusml.get_feature_contributions(test)

# Save the model to zip
model_filename = 'nimbusml_model.zip'
model_filename = get_temp_file(suffix='.zip')
model_nimbusml.save_model(model_filename)
# Load the model from zip
model_nimbusml_zip = Pipeline()
Expand Down Expand Up @@ -347,7 +356,7 @@ def test_pickled_pipeline_with_predictor_model(self):
self.assertTrue(pipeline.predictor_model)
self.assertNotEqual(pipeline.model, pipeline.predictor_model)

pickle_filename = 'nimbusml_model.p'
pickle_filename = get_temp_file(suffix='.p')
with open(pickle_filename, 'wb') as f:
pickle.dump(pipeline, f)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License.
# --------------------------------------------------------------------------------------------
import os
import tempfile
import unittest

from nimbusml import FileDataStream
Expand All @@ -16,6 +17,14 @@
from numpy.testing import assert_almost_equal
from pandas.testing import assert_frame_equal


def get_temp_model_file():
fd, file_name = tempfile.mkstemp(suffix='.zip')
fl = os.fdopen(fd, 'w')
fl.close()
return file_name


class TestPermutationFeatureImportance(unittest.TestCase):

@classmethod
Expand Down Expand Up @@ -65,7 +74,7 @@ def test_binary_classifier(self):
assert_almost_equal(self.binary_pfi['AreaUnderPrecisionRecallCurve'].sum(), -0.19365, 5)

def test_binary_classifier_from_loaded_model(self):
model_path = "model.zip"
model_path = get_temp_model_file()
self.binary_model.save_model(model_path)
loaded_model = Pipeline()
loaded_model.load_model(model_path)
Expand All @@ -81,7 +90,7 @@ def test_clasifier(self):
assert_almost_equal(self.classifier_pfi['PerClassLogLoss.1'].sum(), 0.419826, 6)

def test_classifier_from_loaded_model(self):
model_path = "model.zip"
model_path = get_temp_model_file()
self.classifier_model.save_model(model_path)
loaded_model = Pipeline()
loaded_model.load_model(model_path)
Expand All @@ -96,7 +105,7 @@ def test_regressor(self):
assert_almost_equal(self.regressor_pfi['RSquared'].sum(), -0.203612, 6)

def test_regressor_from_loaded_model(self):
model_path = "model.zip"
model_path = get_temp_model_file()
self.regressor_model.save_model(model_path)
loaded_model = Pipeline()
loaded_model.load_model(model_path)
Expand All @@ -113,7 +122,7 @@ def test_ranker(self):
assert_almost_equal(self.ranker_pfi['NDCG@3'].sum(), -0.236544, 6)

def test_ranker_from_loaded_model(self):
model_path = "model.zip"
model_path = get_temp_model_file()
self.ranker_model.save_model(model_path)
loaded_model = Pipeline()
loaded_model.load_model(model_path)
Expand Down
Loading