From f27f98c6d716b4b4133346e2782d6df1b2b8a7fd Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Tue, 6 Aug 2024 13:50:44 +0800 Subject: [PATCH] Fix test mac os python 3.11 (#1328) * add test * Skip test_autohf_classificationhead.py for MacOS py311 * Skip test/nlp/test_default.py for MacOS py311 * Check test_tune * Check test_lexiflow * Check test_tune * Remove checks * Skip test_nested_run for macos py311) * Skip test_nested_space for macos py311 * Test tune on MacOS Python 3.11 w/o pytest * Split tests by folder * Skip test lexiflow for MacOS py311 * Enable test_tune for MacOS py311 * Clean up --- test/nlp/test_autohf_classificationhead.py | 3 +++ test/nlp/test_default.py | 3 +++ test/tune/test_lexiflow.py | 5 +++++ test/tune/test_tune.py | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/test/nlp/test_autohf_classificationhead.py b/test/nlp/test_autohf_classificationhead.py index 39d0b89b9f..9ce023f966 100644 --- a/test/nlp/test_autohf_classificationhead.py +++ b/test/nlp/test_autohf_classificationhead.py @@ -21,6 +21,9 @@ "textattack/bert-base-uncased-MNLI", ] +if sys.platform.startswith("darwin") and sys.version_info[0] == 3 and sys.version_info[1] == 11: + pytest.skip("skipping Python 3.11 on MacOS", allow_module_level=True) + def test_switch_1_1(): data_idx, model_path_idx = 0, 0 diff --git a/test/nlp/test_default.py b/test/nlp/test_default.py index 7b8b252e25..b3c9016486 100644 --- a/test/nlp/test_default.py +++ b/test/nlp/test_default.py @@ -7,6 +7,9 @@ from flaml.default import portfolio +if sys.platform.startswith("darwin") and sys.version_info[0] == 3 and sys.version_info[1] == 11: + pytest.skip("skipping Python 3.11 on MacOS", allow_module_level=True) + def pop_args(fit_kwargs): fit_kwargs.pop("max_iter", None) diff --git a/test/tune/test_lexiflow.py b/test/tune/test_lexiflow.py index dda6b924cb..9ee46dc48b 100644 --- a/test/tune/test_lexiflow.py +++ b/test/tune/test_lexiflow.py @@ -1,7 +1,9 @@ import math +import sys from collections import defaultdict import numpy as np +import pytest import thop import torch import torch.nn as nn @@ -19,6 +21,9 @@ N_TRAIN_EXAMPLES = BATCHSIZE * 30 N_VALID_EXAMPLES = BATCHSIZE * 10 +if sys.platform.startswith("darwin") and sys.version_info[0] == 3 and sys.version_info[1] == 11: + pytest.skip("skipping Python 3.11 on MacOS", allow_module_level=True) + def _BraninCurrin(config): # Rescale brain diff --git a/test/tune/test_tune.py b/test/tune/test_tune.py index 658c5a387c..5f17272dc5 100644 --- a/test/tune/test_tune.py +++ b/test/tune/test_tune.py @@ -3,8 +3,10 @@ import logging import math import os +import sys import time +import pytest import sklearn.datasets import sklearn.metrics import xgboost as xgb @@ -17,6 +19,7 @@ except ImportError: print("skip test_xgboost because ray tune cannot be imported.") + logger = logging.getLogger(__name__) os.makedirs("logs", exist_ok=True) logger.addHandler(logging.FileHandler("logs/tune.log")) @@ -496,4 +499,8 @@ def _test_xgboost_bohb(): if __name__ == "__main__": + test_nested_run() + test_nested_space() + test_run_training_function_return_value() + test_passing_search_alg() test_xgboost_bs()