From d8ac11940b2dc09305811918d762ec35a5fa6dfb Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Sat, 12 Jul 2025 16:12:33 -0400 Subject: [PATCH 1/9] Update pyproject.toml to use PEP-621 dependency specification --- pyproject.toml | 51 +++++++-------- requirements-dev.txt | 144 +++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 6 ++ 3 files changed, 171 insertions(+), 30 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 requirements.txt diff --git a/pyproject.toml b/pyproject.toml index 94c65973..0851dc2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,39 +25,30 @@ dependencies = [ "colorama>=0.4.6,<1.0.0", ] -[tool.poetry] -requires-poetry = ">=2.0" -packages = [{ include = "bayes_opt" }] - - -[tool.poetry.group.dev] # for testing/developing -optional = true -[tool.poetry.group.dev.dependencies] -pytest = "^8.0.0" -pytest-cov = "^4.1.0" -coverage = "^7.4.1" -ruff = "0.6.6" -pre-commit = "^3.7.1" - - -[tool.poetry.group.nbtools] # for running/converting notebooks -optional = true -[tool.poetry.group.nbtools.dependencies] -nbformat = "^5.9.2" -nbconvert = "^7.14.2" -jupyter = "^1.0.0" -matplotlib = "^3.0" -nbsphinx = "^0.9.4" -sphinx-immaterial = "^0.12.0" -sphinx = [ - { version = "^7.0.0", python = "<3.10" }, - { version = "^8.0.0", python = ">=3.10" }, +[project.optional-dependencies] +dev = [ + "pytest>=8.0.0,<9.0", + "pytest-cov>=4.1.0,<5.0", + "coverage>=7.4.1,<8.0", + "ruff==0.6.6", + "pre-commit>=3.7.1,<4.0", ] -sphinx-autodoc-typehints = [ - { version = "^2.3.0", python = "<3.10" }, - { version = "^2.4.0", python = ">=3.10" }, +nbtools = [ + "nbformat>=5.9.2,<6.0", + "nbconvert>=7.14.2,<8.0", + "jupyter>=1.0.0,<2.0", + "matplotlib>=3.0,<4.0", + "nbsphinx>=0.9.4,<1.0", + "sphinx-immaterial>=0.12.0,<1.0", + "sphinx>=7.0.0,<8.0; python_version<'3.10'", + "sphinx>=8.0.0,<9.0; python_version>='3.10'", + "sphinx-autodoc-typehints>=2.3.0,<3.0; python_version<'3.10'", + "sphinx-autodoc-typehints>=2.4.0,<3.0; python_version>='3.10'", ] +[tool.poetry] +requires-poetry = ">=2.0" +packages = [{ include = "bayes_opt" }] [build-system] requires = ["poetry-core>=2.0"] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..6c89bf16 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,144 @@ +alabaster==1.0.0 +annotated-types==0.7.0 +anyio==4.9.0 +appdirs==1.4.4 +appnope==0.1.4 +argon2-cffi==25.1.0 +argon2-cffi-bindings==21.2.0 +arrow==1.3.0 +asttokens==3.0.0 +async-lru==2.0.5 +attrs==25.3.0 +babel==2.17.0 +beautifulsoup4==4.13.4 +bleach==6.2.0 +certifi==2025.7.9 +cffi==1.17.1 +cfgv==3.4.0 +charset-normalizer==3.4.2 +colorama==0.4.6 +comm==0.2.2 +contourpy==1.3.2 +coverage==7.9.2 +cycler==0.12.1 +debugpy==1.8.14 +decorator==5.2.1 +defusedxml==0.7.1 +distlib==0.3.9 +docutils==0.21.2 +executing==2.2.0 +fastjsonschema==2.21.1 +filelock==3.18.0 +fonttools==4.58.5 +fqdn==1.5.1 +h11==0.16.0 +httpcore==1.0.9 +httpx==0.28.1 +identify==2.6.12 +idna==3.10 +imagesize==1.4.1 +iniconfig==2.1.0 +ipykernel==6.29.5 +ipython==9.4.0 +ipython_pygments_lexers==1.1.1 +ipywidgets==8.1.7 +isoduration==20.11.0 +jedi==0.19.2 +Jinja2==3.1.6 +joblib==1.5.1 +json5==0.12.0 +jsonpointer==3.0.0 +jsonschema==4.24.0 +jsonschema-specifications==2025.4.1 +jupyter==1.1.1 +jupyter-console==6.6.3 +jupyter-events==0.12.0 +jupyter-lsp==2.2.5 +jupyter_client==8.6.3 +jupyter_core==5.8.1 +jupyter_server==2.16.0 +jupyter_server_terminals==0.5.3 +jupyterlab==4.4.4 +jupyterlab_pygments==0.3.0 +jupyterlab_server==2.27.3 +jupyterlab_widgets==3.0.15 +kiwisolver==1.4.8 +MarkupSafe==3.0.2 +matplotlib==3.10.3 +matplotlib-inline==0.1.7 +mistune==3.1.3 +nbclient==0.10.2 +nbconvert==7.16.6 +nbformat==5.10.4 +nbsphinx==0.9.7 +nest-asyncio==1.6.0 +nodeenv==1.9.1 +notebook==7.4.4 +notebook_shim==0.2.4 +numpy==2.3.1 +overrides==7.7.0 +packaging==25.0 +pandocfilters==1.5.1 +parso==0.8.4 +pexpect==4.9.0 +pillow==11.3.0 +platformdirs==4.3.8 +pluggy==1.6.0 +pre-commit==3.8.0 +prometheus_client==0.22.1 +prompt_toolkit==3.0.51 +psutil==7.0.0 +ptyprocess==0.7.0 +pure_eval==0.2.3 +pycparser==2.22 +pydantic==2.11.7 +pydantic-extra-types==2.10.5 +pydantic_core==2.33.2 +Pygments==2.19.2 +pyparsing==3.2.3 +pytest==8.4.1 +pytest-cov==4.1.0 +python-dateutil==2.9.0.post0 +python-json-logger==3.3.0 +PyYAML==6.0.2 +pyzmq==27.0.0 +referencing==0.36.2 +requests==2.32.4 +rfc3339-validator==0.1.4 +rfc3986-validator==0.1.1 +rpds-py==0.26.0 +ruff==0.6.6 +scikit-learn==1.7.0 +scipy==1.16.0 +Send2Trash==1.8.3 +setuptools==80.9.0 +six==1.17.0 +sniffio==1.3.1 +snowballstemmer==3.0.1 +soupsieve==2.7 +Sphinx==8.1.3 +sphinx-autodoc-typehints==2.5.0 +sphinx_immaterial==0.13.5 +sphinxcontrib-applehelp==2.0.0 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 +sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +stack-data==0.6.3 +terminado==0.18.1 +threadpoolctl==3.6.0 +tinycss2==1.4.0 +tornado==6.5.1 +traitlets==5.14.3 +types-python-dateutil==2.9.0.20250708 +typing-inspection==0.4.1 +typing_extensions==4.14.1 +uri-template==1.3.0 +urllib3==2.5.0 +virtualenv==20.31.2 +wcwidth==0.2.13 +webcolors==24.11.1 +webencodings==0.5.1 +websocket-client==1.8.0 +widgetsnbextension==4.0.14 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..9cd29cee --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +colorama==0.4.6 +joblib==1.5.1 +numpy==2.3.1 +scikit-learn==1.7.0 +scipy==1.16.0 +threadpoolctl==3.6.0 From 742ffe4777f93f29d06c5e4373ba92f461c37c35 Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 00:06:38 -0400 Subject: [PATCH 2/9] Remove requirements files --- requirements-dev.txt | 144 ------------------------------------------- requirements.txt | 6 -- 2 files changed, 150 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 6c89bf16..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,144 +0,0 @@ -alabaster==1.0.0 -annotated-types==0.7.0 -anyio==4.9.0 -appdirs==1.4.4 -appnope==0.1.4 -argon2-cffi==25.1.0 -argon2-cffi-bindings==21.2.0 -arrow==1.3.0 -asttokens==3.0.0 -async-lru==2.0.5 -attrs==25.3.0 -babel==2.17.0 -beautifulsoup4==4.13.4 -bleach==6.2.0 -certifi==2025.7.9 -cffi==1.17.1 -cfgv==3.4.0 -charset-normalizer==3.4.2 -colorama==0.4.6 -comm==0.2.2 -contourpy==1.3.2 -coverage==7.9.2 -cycler==0.12.1 -debugpy==1.8.14 -decorator==5.2.1 -defusedxml==0.7.1 -distlib==0.3.9 -docutils==0.21.2 -executing==2.2.0 -fastjsonschema==2.21.1 -filelock==3.18.0 -fonttools==4.58.5 -fqdn==1.5.1 -h11==0.16.0 -httpcore==1.0.9 -httpx==0.28.1 -identify==2.6.12 -idna==3.10 -imagesize==1.4.1 -iniconfig==2.1.0 -ipykernel==6.29.5 -ipython==9.4.0 -ipython_pygments_lexers==1.1.1 -ipywidgets==8.1.7 -isoduration==20.11.0 -jedi==0.19.2 -Jinja2==3.1.6 -joblib==1.5.1 -json5==0.12.0 -jsonpointer==3.0.0 -jsonschema==4.24.0 -jsonschema-specifications==2025.4.1 -jupyter==1.1.1 -jupyter-console==6.6.3 -jupyter-events==0.12.0 -jupyter-lsp==2.2.5 -jupyter_client==8.6.3 -jupyter_core==5.8.1 -jupyter_server==2.16.0 -jupyter_server_terminals==0.5.3 -jupyterlab==4.4.4 -jupyterlab_pygments==0.3.0 -jupyterlab_server==2.27.3 -jupyterlab_widgets==3.0.15 -kiwisolver==1.4.8 -MarkupSafe==3.0.2 -matplotlib==3.10.3 -matplotlib-inline==0.1.7 -mistune==3.1.3 -nbclient==0.10.2 -nbconvert==7.16.6 -nbformat==5.10.4 -nbsphinx==0.9.7 -nest-asyncio==1.6.0 -nodeenv==1.9.1 -notebook==7.4.4 -notebook_shim==0.2.4 -numpy==2.3.1 -overrides==7.7.0 -packaging==25.0 -pandocfilters==1.5.1 -parso==0.8.4 -pexpect==4.9.0 -pillow==11.3.0 -platformdirs==4.3.8 -pluggy==1.6.0 -pre-commit==3.8.0 -prometheus_client==0.22.1 -prompt_toolkit==3.0.51 -psutil==7.0.0 -ptyprocess==0.7.0 -pure_eval==0.2.3 -pycparser==2.22 -pydantic==2.11.7 -pydantic-extra-types==2.10.5 -pydantic_core==2.33.2 -Pygments==2.19.2 -pyparsing==3.2.3 -pytest==8.4.1 -pytest-cov==4.1.0 -python-dateutil==2.9.0.post0 -python-json-logger==3.3.0 -PyYAML==6.0.2 -pyzmq==27.0.0 -referencing==0.36.2 -requests==2.32.4 -rfc3339-validator==0.1.4 -rfc3986-validator==0.1.1 -rpds-py==0.26.0 -ruff==0.6.6 -scikit-learn==1.7.0 -scipy==1.16.0 -Send2Trash==1.8.3 -setuptools==80.9.0 -six==1.17.0 -sniffio==1.3.1 -snowballstemmer==3.0.1 -soupsieve==2.7 -Sphinx==8.1.3 -sphinx-autodoc-typehints==2.5.0 -sphinx_immaterial==0.13.5 -sphinxcontrib-applehelp==2.0.0 -sphinxcontrib-devhelp==2.0.0 -sphinxcontrib-htmlhelp==2.1.0 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==2.0.0 -sphinxcontrib-serializinghtml==2.0.0 -stack-data==0.6.3 -terminado==0.18.1 -threadpoolctl==3.6.0 -tinycss2==1.4.0 -tornado==6.5.1 -traitlets==5.14.3 -types-python-dateutil==2.9.0.20250708 -typing-inspection==0.4.1 -typing_extensions==4.14.1 -uri-template==1.3.0 -urllib3==2.5.0 -virtualenv==20.31.2 -wcwidth==0.2.13 -webcolors==24.11.1 -webencodings==0.5.1 -websocket-client==1.8.0 -widgetsnbextension==4.0.14 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9cd29cee..00000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -colorama==0.4.6 -joblib==1.5.1 -numpy==2.3.1 -scikit-learn==1.7.0 -scipy==1.16.0 -threadpoolctl==3.6.0 From 1e950c6d4da1f157778e6fa02b6c6ba707747a66 Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 00:07:02 -0400 Subject: [PATCH 3/9] Merge dependency groups, sort dependencies within groups --- pyproject.toml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0851dc2b..4e3814b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,28 +17,26 @@ classifiers = [ "Programming Language :: Python :: 3.13", ] dependencies = [ - "scikit-learn>=1.0.0,<2.0.0", + "colorama>=0.4.6,<1.0.0", "numpy>=1.25; python_version<'3.13'", "numpy>=2.1.3; python_version>='3.13'", + "scikit-learn>=1.0.0,<2.0.0", "scipy>=1.0.0,<2.0.0; python_version<'3.13'", "scipy>=1.14.1,<2.0.0; python_version>='3.13'", - "colorama>=0.4.6,<1.0.0", ] [project.optional-dependencies] dev = [ - "pytest>=8.0.0,<9.0", - "pytest-cov>=4.1.0,<5.0", "coverage>=7.4.1,<8.0", - "ruff==0.6.6", - "pre-commit>=3.7.1,<4.0", -] -nbtools = [ - "nbformat>=5.9.2,<6.0", - "nbconvert>=7.14.2,<8.0", "jupyter>=1.0.0,<2.0", "matplotlib>=3.0,<4.0", + "nbconvert>=7.14.2,<8.0", + "nbformat>=5.9.2,<6.0", "nbsphinx>=0.9.4,<1.0", + "pre-commit>=3.7.1,<4.0", + "pytest>=8.0.0,<9.0", + "pytest-cov>=4.1.0,<5.0", + "ruff==0.6.6", "sphinx-immaterial>=0.12.0,<1.0", "sphinx>=7.0.0,<8.0; python_version<'3.10'", "sphinx>=8.0.0,<9.0; python_version>='3.10'", From 8593e7d9921090354908092ed486c1b9fedc17c7 Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 08:32:44 -0400 Subject: [PATCH 4/9] Remove upper bound constraints, update workflow --- .github/workflows/run_tests.yml | 2 +- pyproject.toml | 40 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 6ae4602c..deb2fd4a 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -40,7 +40,7 @@ jobs: - name: Install test dependencies run: | poetry self add poetry-plugin-export - poetry export -f requirements.txt --with dev,nbtools --without-hashes --output requirements-dev.txt + poetry export -f requirements.txt --with dev --without-hashes --output requirements-dev.txt echo "numpy${{ matrix.numpy-version }}" >> constraints.txt uv pip compile requirements-dev.txt --output-file requirements.txt \ --python-version ${{ matrix.python-version }} \ diff --git a/pyproject.toml b/pyproject.toml index 4e3814b3..da764d01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "Bayesian Optimization package" authors = [{ name = "Fernando Nogueira", email = "fmfnogueira@gmail.com" }] license = { file = "LICENSE" } readme = "README.md" -requires-python = ">=3.9,<4.0" +requires-python = ">=3.9" classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", @@ -17,31 +17,31 @@ classifiers = [ "Programming Language :: Python :: 3.13", ] dependencies = [ - "colorama>=0.4.6,<1.0.0", + "colorama>=0.4.6", "numpy>=1.25; python_version<'3.13'", "numpy>=2.1.3; python_version>='3.13'", - "scikit-learn>=1.0.0,<2.0.0", - "scipy>=1.0.0,<2.0.0; python_version<'3.13'", - "scipy>=1.14.1,<2.0.0; python_version>='3.13'", + "scikit-learn>=1.0.0", + "scipy>=1.0.0; python_version<'3.13'", + "scipy>=1.14.1; python_version>='3.13'", ] [project.optional-dependencies] dev = [ - "coverage>=7.4.1,<8.0", - "jupyter>=1.0.0,<2.0", - "matplotlib>=3.0,<4.0", - "nbconvert>=7.14.2,<8.0", - "nbformat>=5.9.2,<6.0", - "nbsphinx>=0.9.4,<1.0", - "pre-commit>=3.7.1,<4.0", - "pytest>=8.0.0,<9.0", - "pytest-cov>=4.1.0,<5.0", - "ruff==0.6.6", - "sphinx-immaterial>=0.12.0,<1.0", - "sphinx>=7.0.0,<8.0; python_version<'3.10'", - "sphinx>=8.0.0,<9.0; python_version>='3.10'", - "sphinx-autodoc-typehints>=2.3.0,<3.0; python_version<'3.10'", - "sphinx-autodoc-typehints>=2.4.0,<3.0; python_version>='3.10'", + "coverage>=7.4.1", + "jupyter>=1.0.0", + "matplotlib>=3.0", + "nbconvert>=7.14.2", + "nbformat>=5.9.2", + "nbsphinx>=0.9.4", + "pre-commit>=3.7.1", + "pytest>=8.0.0", + "pytest-cov>=4.1.0", + "ruff>=0.12.3", + "sphinx-immaterial>=0.12.0", + "sphinx>=7.0.0; python_version<'3.10'", + "sphinx>=8.0.0; python_version>='3.10'", + "sphinx-autodoc-typehints>=2.3.0; python_version<'3.10'", + "sphinx-autodoc-typehints>=2.4.0; python_version>='3.10'", ] [tool.poetry] From 3e48bed98d7f75c1c481f8e14c0252590d87346c Mon Sep 17 00:00:00 2001 From: jameskrach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 08:57:19 -0400 Subject: [PATCH 5/9] Update run_tests.yml --- .github/workflows/run_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index deb2fd4a..0c2e49c3 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -40,7 +40,7 @@ jobs: - name: Install test dependencies run: | poetry self add poetry-plugin-export - poetry export -f requirements.txt --with dev --without-hashes --output requirements-dev.txt + poetry export -f requirements.txt --extras dev --without-hashes --output requirements-dev.txt echo "numpy${{ matrix.numpy-version }}" >> constraints.txt uv pip compile requirements-dev.txt --output-file requirements.txt \ --python-version ${{ matrix.python-version }} \ From 41c98e5b111030822ccbf166260adba4c8b0dedb Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 19:47:31 -0400 Subject: [PATCH 6/9] Use just uv instead of uv and poetry --- .github/workflows/build_docs.yml | 15 +++++--------- .github/workflows/format_and_lint.yml | 13 ++++-------- .github/workflows/python-publish.yml | 16 +++++++-------- .github/workflows/run_tests.yml | 29 +++++++-------------------- .gitignore | 1 + .pre-commit-config.yaml | 2 +- pyproject.toml | 12 +++++------ scripts/check.sh | 4 ++-- scripts/check_precommit.sh | 4 ++-- scripts/format.sh | 5 ++--- 10 files changed, 38 insertions(+), 63 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index a4abfa8b..335ed9c1 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -18,25 +18,20 @@ jobs: contents: write steps: - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v3 + - name: Install uv + uses: astral-sh/setup-uv@v6 with: - python-version: '3.10' + python-version: "3.10" - name: Get tag uses: olegtarasov/get-tag@v2.1 - name: Install pandoc run: sudo apt-get install -y pandoc - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 'latest' - name: Install package and test dependencies - run: | - poetry install --with dev,nbtools + run: uv sync --extra dev - name: build sphinx docs run: | cd docsrc - poetry run make github + uv run make github - name: Determine directory to publish docs to id: docs-publish-dir uses: jannekem/run-python-script-action@v1 diff --git a/.github/workflows/format_and_lint.yml b/.github/workflows/format_and_lint.yml index a7fffe02..a8a3eab6 100644 --- a/.github/workflows/format_and_lint.yml +++ b/.github/workflows/format_and_lint.yml @@ -13,16 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v3 + - name: Install uv + uses: astral-sh/setup-uv@v6 with: python-version: "3.9" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 'latest' - name: Install dependencies - run: | - poetry install --with dev + run: uv sync --extra dev - name: Run pre-commit - run : poetry run pre-commit run --all-files --show-diff-on-failure --color=always + run : uv run pre-commit run --all-files --show-diff-on-failure --color=always diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 5395e754..13ae75d4 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,4 +1,4 @@ -# This workflow will upload a Python Package using poetry when a release is created +# This workflow will upload a Python Package using uv when a release is created # Note that you must manually update the version number in pyproject.toml before attempting this. name: Upload Python Package @@ -14,10 +14,10 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Build and publish to pypi - uses: JRubics/poetry-publish@v2.0 - with: - pypi_token: ${{ secrets.PYPI_API_TOKEN }} - # python_version: "3.10" - # poetry_version: "==1.8" # can lock versions if we want + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + - run: uv build + - name: Publish to pypi + env: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + run: uv publish --token $PYPI_API_TOKEN diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 0c2e49c3..6873be5d 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python +# This workflow will install Python dependencies and run tests in multiple versions of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: tests @@ -25,31 +25,16 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 + - name: Install uv and set the python version + uses: astral-sh/setup-uv@v6 with: python-version: ${{ matrix.python-version }} - - name: Install the latest version of uv - uses: astral-sh/setup-uv@v5 - with: - version: "latest" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 'latest' - name: Install test dependencies run: | - poetry self add poetry-plugin-export - poetry export -f requirements.txt --extras dev --without-hashes --output requirements-dev.txt - echo "numpy${{ matrix.numpy-version }}" >> constraints.txt - uv pip compile requirements-dev.txt --output-file requirements.txt \ - --python-version ${{ matrix.python-version }} \ - --override constraints.txt - poetry run pip install -r requirements.txt - poetry install --only-root - - name: Test with pytest - run: | - poetry run pytest --cov-report xml --cov=bayes_opt/ + uv sync --extra dev + uv add "numpy${{ matrix.numpy-version}}" + - name: Run pytest + run: uv run pytest --cov-report xml --cov=bayes_opt/ - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.gitignore b/.gitignore index 4b159c12..672b76dd 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ docsrc/static/* docsrc/README.md poetry.lock +uv.lock # Add log files and optimizer state files to gitignore examples/logs.log diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 99908079..d86185de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,4 +6,4 @@ repos: name: ruff-format args: [--check] repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.6 \ No newline at end of file + rev: v0.12.3 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index da764d01..99c2bfd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,13 +44,13 @@ dev = [ "sphinx-autodoc-typehints>=2.4.0; python_version>='3.10'", ] -[tool.poetry] -requires-poetry = ">=2.0" -packages = [{ include = "bayes_opt" }] - [build-system] -requires = ["poetry-core>=2.0"] -build-backend = "poetry.core.masonry.api" +requires = ["uv_build>=0.7.21,<0.8.0"] +build-backend = "uv_build" + +[tool.uv.build-backend] +module-name = "bayes_opt" +module-root = "" [tool.coverage.report] exclude_lines = [ diff --git a/scripts/check.sh b/scripts/check.sh index 180d03d9..19c15f5f 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh set -ex -poetry run ruff format --check bayes_opt tests -poetry run ruff check bayes_opt tests +uv run ruff format --check bayes_opt tests +uv run ruff check bayes_opt tests diff --git a/scripts/check_precommit.sh b/scripts/check_precommit.sh index c58fd7ad..26956718 100755 --- a/scripts/check_precommit.sh +++ b/scripts/check_precommit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh set -ex -poetry run pre-commit install -poetry run pre-commit run --all-files --show-diff-on-failure \ No newline at end of file +uv run pre-commit install +uv run pre-commit run --all-files --show-diff-on-failure diff --git a/scripts/format.sh b/scripts/format.sh index bff192c0..ea3844b6 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,6 +1,5 @@ #!/usr/bin/env sh set -ex -poetry run ruff format bayes_opt tests -poetry run ruff check bayes_opt --fix - +uv run ruff format bayes_opt tests +uv run ruff check bayes_opt --fix From 73ba3aea12ad4472a5e8146995dafe281d40495d Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:05:54 -0400 Subject: [PATCH 7/9] Appease the new version of ruff --- bayes_opt/__init__.py | 4 ++-- bayes_opt/constraint.py | 2 +- bayes_opt/exception.py | 2 +- tests/test_seq_domain_red.py | 4 ++-- tests/test_target_space.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bayes_opt/__init__.py b/bayes_opt/__init__.py index 7bdc88ea..8fa19ad6 100644 --- a/bayes_opt/__init__.py +++ b/bayes_opt/__init__.py @@ -15,10 +15,10 @@ __all__ = [ - "acquisition", "BayesianOptimization", - "TargetSpace", "ConstraintModel", "ScreenLogger", "SequentialDomainReductionTransformer", + "TargetSpace", + "acquisition", ] diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index b823c909..8042cc9f 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -240,7 +240,7 @@ def approx(self, X: NDArray[Float]) -> NDArray[Float]: return self._model[0].predict(X).reshape(X_shape[:-1]) result = np.column_stack([gp.predict(X) for gp in self._model]) - return result.reshape(X_shape[:-1] + (len(self._lb),)) + return result.reshape(*X_shape[:-1], len(self._lb)) def allowed(self, constraint_values: NDArray[Float]) -> NDArray[np.bool_]: """Check whether `constraint_values` fulfills the specified limits. diff --git a/bayes_opt/exception.py b/bayes_opt/exception.py index 628e20d7..642b0909 100644 --- a/bayes_opt/exception.py +++ b/bayes_opt/exception.py @@ -4,9 +4,9 @@ __all__ = [ "BayesianOptimizationError", - "NotUniqueError", "ConstraintNotSupportedError", "NoValidPointRegisteredError", + "NotUniqueError", "TargetSpaceEmptyError", ] diff --git a/tests/test_seq_domain_red.py b/tests/test_seq_domain_red.py index c22dd0d1..5865d877 100644 --- a/tests/test_seq_domain_red.py +++ b/tests/test_seq_domain_red.py @@ -156,14 +156,14 @@ def verify_bounds_in_range(new_bounds, global_bounds): # test if both (upper/lower) bounds for a parameter exceed the global bounds new_bounds = np.array([[-50, -20], [20, 50]]) - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match="A parameter's lower bound is greater than the global upper bound"): trimmed_bounds = bounds_transformer._trim(new_bounds, global_bounds) assert verify_bounds_in_range(trimmed_bounds, global_bounds) # test if both (upper/lower) bounds for a parameter exceed the global bounds # while they are out of order new_bounds = np.array([[-20, -50], [-10, 10]]) - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match="A parameter's lower bound is greater than the global upper bound"): trimmed_bounds = bounds_transformer._trim(new_bounds, global_bounds) assert verify_bounds_in_range(trimmed_bounds, global_bounds) diff --git a/tests/test_target_space.py b/tests/test_target_space.py index dad89986..45729cd2 100644 --- a/tests/test_target_space.py +++ b/tests/test_target_space.py @@ -125,7 +125,7 @@ def test_register_point_beyond_bounds(): PBOUNDS = {"p1": (0, 1), "p2": (1, 10)} space = TargetSpace(target_func, PBOUNDS) - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match="is outside the bounds of the parameter"): space.register(params={"p1": 0.5, "p2": 20}, target=2.5) @@ -209,7 +209,7 @@ def test_y_max_within_pbounds(): assert space._target_max() is None space.probe(params={"p1": 1, "p2": 2}) space.probe(params={"p1": 0, "p2": 1}) - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match="is outside the bounds of the parameter"): space.probe(params={"p1": 5, "p2": 1}) assert space._target_max() == 3 From 44ba539086f692bac6265e55ef5efc461eb531b4 Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:32:24 -0400 Subject: [PATCH 8/9] Fix workflow bugs --- .github/workflows/format_and_lint.yml | 2 +- .github/workflows/python-publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format_and_lint.yml b/.github/workflows/format_and_lint.yml index a8a3eab6..2f7665f1 100644 --- a/.github/workflows/format_and_lint.yml +++ b/.github/workflows/format_and_lint.yml @@ -20,4 +20,4 @@ jobs: - name: Install dependencies run: uv sync --extra dev - name: Run pre-commit - run : uv run pre-commit run --all-files --show-diff-on-failure --color=always + run: uv run pre-commit run --all-files --show-diff-on-failure --color=always diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 13ae75d4..30c16176 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -20,4 +20,4 @@ jobs: - name: Publish to pypi env: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} - run: uv publish --token $PYPI_API_TOKEN + run: uv publish --token "$PYPI_API_TOKEN" From 9d28aed8fb6be8a399ad32449e162a1ab470b0b0 Mon Sep 17 00:00:00 2001 From: James Krach <69264125+jameskrach@users.noreply.github.com> Date: Tue, 15 Jul 2025 23:44:34 -0400 Subject: [PATCH 9/9] Fix numpy version issue on build --- .github/workflows/run_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 6873be5d..61bf7e92 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -32,9 +32,9 @@ jobs: - name: Install test dependencies run: | uv sync --extra dev - uv add "numpy${{ matrix.numpy-version}}" + uv pip install "numpy${{ matrix.numpy-version}}" - name: Run pytest - run: uv run pytest --cov-report xml --cov=bayes_opt/ + run: uv run --no-sync pytest --cov-report xml --cov=bayes_opt/ - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: