From d4dd8ea841943a89d7879628d43e4a7919e9e01b Mon Sep 17 00:00:00 2001 From: Xavier Bouthillier Date: Fri, 3 Nov 2023 14:04:44 -0400 Subject: [PATCH 1/5] Pin pre-commit to py3.11 Some dependencies (namely autoflake) are not compatible with py3.12 yet. Pinning pre-commit to py3.11 until we can move to py3.12. There is no reason for having a pre-commit on a later version than what orion supports anyway. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4fe7d26d..6b1500d7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 + with: + python-version: 3.11 - run: pip install pre-commit - run: pre-commit --version - run: pre-commit install From 3480a97e3e67f9fa84541be2ef932f148ce46405 Mon Sep 17 00:00:00 2001 From: Xavier Bouthillier Date: Fri, 3 Nov 2023 14:52:49 -0400 Subject: [PATCH 2/5] Try switching from flake to ruff --- .pre-commit-config.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df56d8d66..489ee7813 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,14 +13,13 @@ repos: hooks: - id: codespell args: ["--skip", "*.html,*.ipynb,dashboard/src/.yarn/**,dashboard/src/yarn.lock,dashboard/build/**,dashboard/src/src/__tests__/**", "--ignore-words-list=hist,wont,ro"] - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.3 hooks: - - id: flake8 + - id: ruff args: - --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841,W503,E302,E704 - - --max-complexity=30 - - --max-line-length=456 + - --line-length=456 - --show-source - --statistics - repo: https://github.com/PyCQA/isort From 8cf31da50875114e4ae58db77e42555ab32a1a9d Mon Sep 17 00:00:00 2001 From: Xavier Bouthillier Date: Mon, 13 Nov 2023 16:21:12 -0500 Subject: [PATCH 3/5] Fix ruff --- .pre-commit-config.yaml | 5 ++--- tests/unittests/algo/test_space.py | 8 ++++---- tests/unittests/benchmark/task/test_tasks.py | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 489ee7813..06ed1f05b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,10 +18,9 @@ repos: hooks: - id: ruff args: - - --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841,W503,E302,E704 - - --line-length=456 + - --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841 + - --line-length=300 - --show-source - - --statistics - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/tests/unittests/algo/test_space.py b/tests/unittests/algo/test_space.py index f3961670e..ab55735fa 100644 --- a/tests/unittests/algo/test_space.py +++ b/tests/unittests/algo/test_space.py @@ -311,7 +311,7 @@ def test_init_with_default_value(self): """Make sure the default value is set""" dim = Real("yolo", "uniform", -3, 10, default_value=2.0) - assert type(dim.default_value) is float + assert isinstance(dim.default_value, float) def test_set_outside_bounds_default_value(self): """Make sure default value is inside the bounds""" @@ -440,7 +440,7 @@ def test_init_with_default_value(self): """Make sure the type of the default value is int""" dim = Integer("yolo", "uniform", -3, 10, default_value=2) - assert type(dim.default_value) is int + assert isinstance(dim.default_value, int) def test_set_outside_bounds_default_value(self): """Make sure the default value is inside the bounds of the dimensions""" @@ -588,14 +588,14 @@ def test_init_with_default_value_string(self): categories = {"asdfa": 0.1, 2: 0.2, 3: 0.3, "lalala": 0.4} dim = Categorical("yolo", categories, default_value="asdfa") - assert type(dim.default_value) is str + assert isinstance(dim.default_value, str) def test_init_with_default_value_int(self): """Make sure the default value is of the correct type""" categories = {"asdfa": 0.1, 2: 0.2, 3: 0.3, "lalala": 0.4} dim = Categorical("yolo", categories, default_value=2) - assert type(dim.default_value) is int + assert isinstance(dim.default_value, int) def test_init_with_wrong_default_value(self): """Make sure the default value exists""" diff --git a/tests/unittests/benchmark/task/test_tasks.py b/tests/unittests/benchmark/task/test_tasks.py index 88d16ce73..a047fa386 100644 --- a/tests/unittests/benchmark/task/test_tasks.py +++ b/tests/unittests/benchmark/task/test_tasks.py @@ -20,7 +20,7 @@ def test_call(self): assert callable(task) objectives = task([1, 2]) - assert type(objectives[0]) == dict + assert isinstance(objectives[0], dict) def test_search_space(self): """Test to get task search space""" @@ -45,7 +45,7 @@ def test_call(self): assert callable(task) objectives = task([1, 2]) - assert type(objectives[0]) == dict + assert isinstance(objectives[0], dict) def test_search_space(self): """Test to get task search space""" @@ -70,7 +70,7 @@ def test_call(self): assert callable(task) objectives = task([1, 2]) - assert type(objectives[0]) == dict + assert isinstance(objectives[0], dict) def test_search_space(self): """Test to get task search space""" @@ -95,7 +95,7 @@ def test_call(self): assert callable(task) objectives = task([1, 2]) - assert type(objectives[0]) == dict + assert isinstance(objectives[0], dict) def test_search_space(self): """Test to get task search space""" From 651866f3565203628249e8a6db47958d4cda492c Mon Sep 17 00:00:00 2001 From: Xavier Bouthillier Date: Fri, 17 Nov 2023 11:42:55 -0500 Subject: [PATCH 4/5] Remove FCMA from working algorithms in nevergrad :( --- src/orion/algo/nevergradoptimizer/nevergradoptimizer.py | 1 + tests/unittests/algo/long/nevergrad/integration_test.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/orion/algo/nevergradoptimizer/nevergradoptimizer.py b/src/orion/algo/nevergradoptimizer/nevergradoptimizer.py index 34bc7f0b3..8fcc06a55 100644 --- a/src/orion/algo/nevergradoptimizer/nevergradoptimizer.py +++ b/src/orion/algo/nevergradoptimizer/nevergradoptimizer.py @@ -141,6 +141,7 @@ def _(dim: Fidelity): "OptimisticNoisyOnePlusOne", "Powell", "CmaFmin2", + "FCMA", "RPowell", "RSQP", "PymooNSGA2", diff --git a/tests/unittests/algo/long/nevergrad/integration_test.py b/tests/unittests/algo/long/nevergrad/integration_test.py index a1cb52fb7..b72aa5bb1 100644 --- a/tests/unittests/algo/long/nevergrad/integration_test.py +++ b/tests/unittests/algo/long/nevergrad/integration_test.py @@ -90,7 +90,6 @@ def merge_dicts(*dicts: dict) -> dict: "DiscreteOnePlusOne": _deterministic_first_point, "EDA": _no_tell_without_ask, "ES": {}, - "FCMA": {}, "GeneticDE": {}, "HaltonSearch": _deterministic_points, "HaltonSearchPlusMiddlePoint": _deterministic_points, @@ -218,6 +217,7 @@ def merge_dicts(*dicts: dict) -> dict: "NGOpt14": {}, "NGOpt21": {}, "NGOpt38": {}, + "FCMA": _not_serializable, } From 9b47459e7a6e257f9b35ea4f873c47e908de06b4 Mon Sep 17 00:00:00 2001 From: Xavier Bouthillier Date: Fri, 17 Nov 2023 12:50:54 -0500 Subject: [PATCH 5/5] Run pypi/conda tests even if dashboard tests fail --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b1500d7a..3e42622ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -257,7 +257,7 @@ jobs: name: codecov-umbrella fail_ci_if_error: false pypi: - needs: [test, backward-compatibility, test-long-algos, mongodb, test_no_extras, test-dashboard-build] + needs: [test, backward-compatibility, test-long-algos, mongodb, test_no_extras] # , test-dashboard-build] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -351,7 +351,7 @@ jobs: user: __token__ password: ${{ secrets.pypi_password }} conda: - needs: [test, backward-compatibility, test-long-algos, test-dashboard-build] + needs: [test, backward-compatibility, test-long-algos] #, test-dashboard-build] runs-on: ubuntu-latest env: ANACONDA_TOKEN: ${{ secrets.anaconda_token }}