|
10 | 10 | import unittest.mock |
11 | 11 |
|
12 | 12 | import numpy as np |
13 | | -import pytest |
14 | 13 |
|
15 | 14 | import openml |
16 | 15 | import openml.exceptions |
@@ -335,7 +334,7 @@ def _check_sample_evaluations( |
335 | 334 | for sample in range(num_sample_entrees): |
336 | 335 | evaluation = sample_evaluations[measure][rep][fold][sample] |
337 | 336 | self.assertIsInstance(evaluation, float) |
338 | | - if not os.environ.get("CI_WINDOWS"): |
| 337 | + if not (os.environ.get("CI_WINDOWS") or os.name == "nt"): |
339 | 338 | # Either Appveyor is much faster than Travis |
340 | 339 | # and/or measurements are not as accurate. |
341 | 340 | # Either way, windows seems to get an eval-time |
@@ -682,6 +681,8 @@ def test_run_and_upload_randomsearch(self): |
682 | 681 | flow_expected_rsv="12172", |
683 | 682 | ) |
684 | 683 | self.assertEqual(len(run.trace.trace_iterations), 5) |
| 684 | + trace = openml.runs.get_run_trace(run.run_id) |
| 685 | + self.assertEqual(len(trace.trace_iterations), 5) |
685 | 686 |
|
686 | 687 | def test_run_and_upload_maskedarrays(self): |
687 | 688 | # This testcase is important for 2 reasons: |
@@ -828,31 +829,12 @@ def _test_local_evaluations(self, run): |
828 | 829 | self.assertGreaterEqual(alt_scores[idx], 0) |
829 | 830 | self.assertLessEqual(alt_scores[idx], 1) |
830 | 831 |
|
831 | | - @unittest.skipIf( |
832 | | - LooseVersion(sklearn.__version__) < "0.20", |
833 | | - reason="SimpleImputer doesn't handle mixed type DataFrame as input", |
834 | | - ) |
835 | 832 | def test_local_run_swapped_parameter_order_model(self): |
| 833 | + clf = DecisionTreeClassifier() |
| 834 | + australian_task = 595 |
| 835 | + task = openml.tasks.get_task(australian_task) |
836 | 836 |
|
837 | | - # construct sci-kit learn classifier |
838 | | - clf = Pipeline( |
839 | | - steps=[ |
840 | | - ( |
841 | | - "imputer", |
842 | | - make_pipeline( |
843 | | - SimpleImputer(strategy="most_frequent"), |
844 | | - OneHotEncoder(handle_unknown="ignore"), |
845 | | - ), |
846 | | - ), |
847 | | - # random forest doesn't take categoricals |
848 | | - ("estimator", RandomForestClassifier()), |
849 | | - ] |
850 | | - ) |
851 | | - |
852 | | - # download task |
853 | | - task = openml.tasks.get_task(7) |
854 | | - |
855 | | - # invoke OpenML run |
| 837 | + # task and clf are purposely in the old order |
856 | 838 | run = openml.runs.run_model_on_task( |
857 | 839 | task, clf, avoid_duplicate_runs=False, upload_flow=False, |
858 | 840 | ) |
@@ -950,55 +932,6 @@ def test_initialize_model_from_run(self): |
950 | 932 | self.assertEqual(flowS.components["Imputer"].parameters["strategy"], '"most_frequent"') |
951 | 933 | self.assertEqual(flowS.components["VarianceThreshold"].parameters["threshold"], "0.05") |
952 | 934 |
|
953 | | - @pytest.mark.flaky() |
954 | | - def test_get_run_trace(self): |
955 | | - # get_run_trace is already tested implicitly in test_run_and_publish |
956 | | - # this test is a bit additional. |
957 | | - num_iterations = 10 |
958 | | - num_folds = 1 |
959 | | - task_id = 119 |
960 | | - |
961 | | - task = openml.tasks.get_task(task_id) |
962 | | - |
963 | | - # IMPORTANT! Do not sentinel this flow. is faster if we don't wait |
964 | | - # on openml server |
965 | | - clf = RandomizedSearchCV( |
966 | | - RandomForestClassifier(random_state=42, n_estimators=5), |
967 | | - { |
968 | | - "max_depth": [3, None], |
969 | | - "max_features": [1, 2, 3, 4], |
970 | | - "bootstrap": [True, False], |
971 | | - "criterion": ["gini", "entropy"], |
972 | | - }, |
973 | | - num_iterations, |
974 | | - random_state=42, |
975 | | - cv=3, |
976 | | - ) |
977 | | - |
978 | | - # [SPEED] make unit test faster by exploiting run information |
979 | | - # from the past |
980 | | - try: |
981 | | - # in case the run did not exists yet |
982 | | - run = openml.runs.run_model_on_task(model=clf, task=task, avoid_duplicate_runs=True,) |
983 | | - |
984 | | - self.assertEqual( |
985 | | - len(run.trace.trace_iterations), num_iterations * num_folds, |
986 | | - ) |
987 | | - run = run.publish() |
988 | | - TestBase._mark_entity_for_removal("run", run.run_id) |
989 | | - TestBase.logger.info("collected from test_run_functions: {}".format(run.run_id)) |
990 | | - self._wait_for_processed_run(run.run_id, 400) |
991 | | - run_id = run.run_id |
992 | | - except openml.exceptions.OpenMLRunsExistError as e: |
993 | | - # The only error we expect, should fail otherwise. |
994 | | - run_ids = [int(run_id) for run_id in e.run_ids] |
995 | | - self.assertGreater(len(run_ids), 0) |
996 | | - run_id = random.choice(list(run_ids)) |
997 | | - |
998 | | - # now the actual unit test ... |
999 | | - run_trace = openml.runs.get_run_trace(run_id) |
1000 | | - self.assertEqual(len(run_trace.trace_iterations), num_iterations * num_folds) |
1001 | | - |
1002 | 935 | @unittest.skipIf( |
1003 | 936 | LooseVersion(sklearn.__version__) < "0.20", |
1004 | 937 | reason="SimpleImputer doesn't handle mixed type DataFrame as input", |
|
0 commit comments