From 2b702c748bd1d739fc842fb285ce7adb2c0fb80e Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Wed, 11 Oct 2023 13:11:28 +0900 Subject: [PATCH 1/4] Add Python 3.12 in tests.yml --- .github/workflows/tests.yml | 20 +++++++++++++++++--- pyproject.toml | 2 +- tests/integration_tests/test_botorch.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b3bc880935b..ec21a440266 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] services: redis: @@ -77,13 +77,27 @@ jobs: - name: Scheduled tests if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} run: | - pytest tests -m "not integration" + if [ ${{ matrix.python-version }} == 3.12 ]; then + # TODO(not522): Remove ignores when BoTorch supports Python 3.12 + pytest tests -m "not integration" \ + --ignore tests/terminator_tests/ \ + --ignore tests/visualization_tests/test_terminator_improvement.py + else + pytest tests -m "not integration" + fi env: SQLALCHEMY_WARN_20: 1 - name: Tests if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }} run: | - pytest tests -m "not integration and not slow" + if [ ${{ matrix.python-version }} == 3.12 ]; then + # TODO(not522): Remove ignores when BoTorch supports Python 3.12 + pytest tests -m "not integration and not slow" \ + --ignore tests/terminator_tests/ \ + --ignore tests/visualization_tests/test_terminator_improvement.py + else + pytest tests -m "not integration and not slow" + fi env: SQLALCHEMY_WARN_20: 1 diff --git a/pyproject.toml b/pyproject.toml index 447cd7b3cd5..5957793e4b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,7 @@ integration = [ ] optional = [ "boto3", # optuna/artifacts/_boto3.py. - "botorch", # optuna/terminator/gp/botorch. + "botorch; python_version<='3.11'", # optuna/terminator/gp/botorch. "cmaes>=0.10.0", # optuna/samplers/_cmaes.py. "google-cloud-storage", # optuna/artifacts/_gcs.py. "matplotlib!=3.6.0", # optuna/visualization/matplotlib. diff --git a/tests/integration_tests/test_botorch.py b/tests/integration_tests/test_botorch.py index 85347d857ce..48a0a9a1fdd 100644 --- a/tests/integration_tests/test_botorch.py +++ b/tests/integration_tests/test_botorch.py @@ -5,7 +5,6 @@ from unittest.mock import patch import warnings -import botorch from packaging import version import pytest @@ -22,6 +21,7 @@ with try_import() as _imports: + import botorch import torch if not _imports.is_successful(): From 0d40e800d132261c700bf4ebfff71764647c9fa6 Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Wed, 11 Oct 2023 13:11:41 +0900 Subject: [PATCH 2/4] Add badge in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 24f199bc6da..d08dc433013 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Optuna: A hyperparameter optimization framework -[![Python](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://www.python.org) +[![Python](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org) [![pypi](https://img.shields.io/pypi/v/optuna.svg)](https://pypi.python.org/pypi/optuna) [![conda](https://img.shields.io/conda/vn/conda-forge/optuna.svg)](https://anaconda.org/conda-forge/optuna) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/optuna/optuna) From a6cc09f4c727a5eae6ece9ba79ef7be2836e8969 Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Wed, 11 Oct 2023 13:12:00 +0900 Subject: [PATCH 3/4] Update classifiers in pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 5957793e4b4..aba36bfeef5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3 :: Only", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Mathematics", From 94ccb3bc3fcdc3f0149f14dfe881412f5a76ddb3 Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Tue, 31 Oct 2023 10:36:24 +0900 Subject: [PATCH 4/4] Put together in options --- .github/workflows/tests.yml | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c81534aac71..436924b6892 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,30 +74,23 @@ jobs: pip install pipdeptree pipdeptree - - name: Scheduled tests - if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + - name: Tests run: | - if [ ${{ matrix.python-version }} == 3.12 ]; then - # TODO(not522): Remove ignores when BoTorch supports Python 3.12 - pytest tests -m "not integration" \ - --ignore tests/terminator_tests/ \ - --ignore tests/visualization_tests/test_terminator_improvement.py + if [ "${{ github.event_name }}" = "schedule" ] || \ + [ "${{ github.event_name }}" = "workflow_dispatch" ] ; then + target="not integration" else - pytest tests -m "not integration" + target="not integration and not slow" fi - env: - SQLALCHEMY_WARN_20: 1 - - name: Tests - if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }} - run: | - if [ ${{ matrix.python-version }} == 3.12 ]; then + if [ "${{ matrix.python-version }}" = "3.12" ] ; then # TODO(not522): Remove ignores when BoTorch supports Python 3.12 - pytest tests -m "not integration and not slow" \ - --ignore tests/terminator_tests/ \ - --ignore tests/visualization_tests/test_terminator_improvement.py + ignore_option="--ignore tests/terminator_tests/ \ + --ignore tests/visualization_tests/test_terminator_improvement.py" else - pytest tests -m "not integration and not slow" + ignore_option="" fi + + pytest tests -m "$target" $ignore_option env: SQLALCHEMY_WARN_20: 1