From 7d6822aa40883550e72c4ee24adb765c6e937ce7 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Fri, 24 Jun 2022 14:25:26 +0000 Subject: [PATCH 1/2] cath URLError --- test/automl/test_constraints.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/test/automl/test_constraints.py b/test/automl/test_constraints.py index a47be3078..7555100d3 100644 --- a/test/automl/test_constraints.py +++ b/test/automl/test_constraints.py @@ -1,11 +1,11 @@ -import unittest - +from urllib.error import URLError from sklearn.datasets import fetch_openml from sklearn.model_selection import train_test_split -from flaml.automl import AutoML +from sklearn.externals._arff import ArffException +from functools import partial +from flaml.automl import AutoML, size from flaml import tune - dataset = "credit-g" @@ -24,11 +24,10 @@ def test_metric_constraints(): "time_budget": 2, "pred_time_limit": 5.1e-05, } - from sklearn.externals._arff import ArffException try: X, y = fetch_openml(name=dataset, return_X_y=True) - except (ArffException, ValueError): + except (ArffException, ValueError, URLError): from sklearn.datasets import load_wine X, y = load_wine(return_X_y=True) @@ -42,10 +41,6 @@ def test_metric_constraints(): config = automl.best_config.copy() config["learner"] = automl.best_estimator automl.trainable(config) - - from flaml.automl import size - from functools import partial - print("metric constraints used in automl", automl.metric_constraints) analysis = tune.run( @@ -117,7 +112,6 @@ def test_metric_constraints_custom(): ("val_train_loss_gap", "<=", 0.05), ], } - from sklearn.externals._arff import ArffException try: X, y = fetch_openml(name=dataset, return_X_y=True) @@ -151,11 +145,8 @@ def test_metric_constraints_custom(): config = automl.best_config.copy() config["learner"] = automl.best_estimator automl.trainable(config) - - from flaml.automl import size - from functools import partial - print("metric constraints in automl", automl.metric_constraints) + analysis = tune.run( automl.trainable, automl.search_space, @@ -176,4 +167,5 @@ def test_metric_constraints_custom(): if __name__ == "__main__": - unittest.main() + test_metric_constraints() + test_metric_constraints_custom() From 8e3fccf592a6165b06f684e0644da54b1ea2f973 Mon Sep 17 00:00:00 2001 From: Zvi Baratz Date: Sat, 25 Jun 2022 20:46:28 +0300 Subject: [PATCH 2/2] Updated hooks (#609) Updated the flake8 hook and black's version, closes #608. Co-authored-by: Chi Wang --- .pre-commit-config.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd5922ab2..116a70261 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,17 @@ repos: - repo: https://github.com/psf/black - rev: stable + rev: 22.3.0 hooks: - id: black language_version: python3 + - repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.2.3 + rev: v4.3.0 hooks: - - id: flake8 - id: check-added-large-files - id: check-ast - id: check-byte-order-marker