Skip to content

Commit

Permalink
Poetry packaging (#458)
Browse files Browse the repository at this point in the history
* switched to poetry packaging
* fix my mistakes in viz notebook
* Update run_tests.yml
* add install poetry step to CI
* remove support for 3.8 as well
* fix accidental comment of numpy dependency
* hard code package name into __init__
* update docstring tests
* fix docstring job for poetry packaging

---------

Co-authored-by: till-m <36440677+till-m@users.noreply.github.com>
  • Loading branch information
bwheelz36 and till-m committed Mar 6, 2024
1 parent 383cb29 commit cec177f
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 101 deletions.
24 changes: 0 additions & 24 deletions .coveragerc

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/check_docstrings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pydocstyle
poetry install --with dev
- name: Check docstyle
run : pydocstyle --convention=numpy --add-select D417 bayes_opt/*
run : poetry run pydocstyle --convention=numpy --add-select D417 bayes_opt/*
#- name: Run linting
# run : pylint bayes_opt/* --disable=C0103 # ignore no snake_case conformity of arguments
22 changes: 6 additions & 16 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-cov
pip install coverage
- name: Install notebook dependencies
run: |
pip install nbformat
pip install nbconvert
pip install jupyter
pip install matplotlib
- name: Install package
run: |
pip install -e .
poetry install --with dev,nbtools
- name: Test with pytest
run: |
pytest --cov-report xml --cov=bayes_opt/
poetry run pytest --cov-report xml --cov=bayes_opt/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ docsrc/.ipynb_checkpoints/*
docsrc/*.ipynb
docsrc/static/*
docsrc/README.md

poetry.lock
5 changes: 5 additions & 0 deletions bayes_opt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from .constraint import ConstraintModel
from .util import UtilityFunction

import importlib.metadata
__version__ = importlib.metadata.version('bayesian-optimization')



__all__ = [
"BayesianOptimization",
"ConstraintModel",
Expand Down
47 changes: 19 additions & 28 deletions examples/visualization.ipynb

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[tool.poetry]
name = "bayesian-optimization"
version = "1.4.3"
description = "Bayesian Optimization package"
authors = ["Fernando Nogueira"]
license = "MIT"
readme = "README.md"
packages = [{include = "bayes_opt"}]

[tool.poetry.dependencies]
python = "^3.9"
scikit-learn = ">=1.0.0"
numpy = ">=1.9.0"
scipy = ">=1.0.0"
colorama = "^0.4.6"



[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"
pydocstyle = "^6.3.0"


[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"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 0 additions & 5 deletions pytest.ini

This file was deleted.

23 changes: 0 additions & 23 deletions setup.py

This file was deleted.

3 changes: 1 addition & 2 deletions tests/test_notebooks_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def check_notebook_runs(notebook_loc):
ep = ExecutePreprocessor(timeout=600, kernel_name='python3')
ep.preprocess(nb, {'metadata': {'path': Path(notebook_loc).parent}})
except Exception as e:
print(f'failed to run notebook {notebook_loc}: rethrowing exception:')
raise e
raise Exception(f'failed to run notebook {notebook_loc}')
print(f'success!')

def test_all_notebooks_run():
Expand Down

0 comments on commit cec177f

Please sign in to comment.