Skip to content

Commit cec177f

Browse files
bwheelz36till-m
andauthored
Poetry packaging (#458)
* 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 <[email protected]>
1 parent 383cb29 commit cec177f

File tree

10 files changed

+76
-101
lines changed

10 files changed

+76
-101
lines changed

.coveragerc

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/check_docstrings.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ jobs:
2020
uses: actions/setup-python@v3
2121
with:
2222
python-version: "3.10"
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
2325
- name: Install dependencies
2426
run: |
25-
python -m pip install --upgrade pip
26-
pip install pydocstyle
27+
poetry install --with dev
2728
- name: Check docstyle
28-
run : pydocstyle --convention=numpy --add-select D417 bayes_opt/*
29+
run : poetry run pydocstyle --convention=numpy --add-select D417 bayes_opt/*
2930
#- name: Run linting
3031
# run : pylint bayes_opt/* --disable=C0103 # ignore no snake_case conformity of arguments

.github/workflows/run_tests.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,21 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
python-version: ["3.7", "3.8", "3.9", "3.10"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2121

2222
steps:
2323
- uses: actions/checkout@v3
24-
- name: Set up Python 3.10
24+
- name: Set up Python
2525
uses: actions/setup-python@v3
2626
with:
2727
python-version: ${{ matrix.python-version }}
28+
- name: Install Poetry
29+
uses: snok/install-poetry@v1
2830
- name: Install test dependencies
2931
run: |
30-
python -m pip install --upgrade pip
31-
pip install pytest
32-
pip install pytest-cov
33-
pip install coverage
34-
- name: Install notebook dependencies
35-
run: |
36-
pip install nbformat
37-
pip install nbconvert
38-
pip install jupyter
39-
pip install matplotlib
40-
- name: Install package
41-
run: |
42-
pip install -e .
32+
poetry install --with dev,nbtools
4333
- name: Test with pytest
4434
run: |
45-
pytest --cov-report xml --cov=bayes_opt/
35+
poetry run pytest --cov-report xml --cov=bayes_opt/
4636
- name: Upload coverage to Codecov
4737
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ docsrc/.ipynb_checkpoints/*
3535
docsrc/*.ipynb
3636
docsrc/static/*
3737
docsrc/README.md
38+
39+
poetry.lock

bayes_opt/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
from .constraint import ConstraintModel
77
from .util import UtilityFunction
88

9+
import importlib.metadata
10+
__version__ = importlib.metadata.version('bayesian-optimization')
11+
12+
13+
914
__all__ = [
1015
"BayesianOptimization",
1116
"ConstraintModel",

examples/visualization.ipynb

Lines changed: 19 additions & 28 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[tool.poetry]
2+
name = "bayesian-optimization"
3+
version = "1.4.3"
4+
description = "Bayesian Optimization package"
5+
authors = ["Fernando Nogueira"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [{include = "bayes_opt"}]
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.9"
12+
scikit-learn = ">=1.0.0"
13+
numpy = ">=1.9.0"
14+
scipy = ">=1.0.0"
15+
colorama = "^0.4.6"
16+
17+
18+
19+
[tool.poetry.group.dev] # for testing/developing
20+
optional = true
21+
[tool.poetry.group.dev.dependencies]
22+
pytest = "^8.0.0"
23+
pytest-cov = "^4.1.0"
24+
coverage = "^7.4.1"
25+
pydocstyle = "^6.3.0"
26+
27+
28+
[tool.poetry.group.nbtools] # for running/converting notebooks
29+
optional = true
30+
[tool.poetry.group.nbtools.dependencies]
31+
nbformat = "^5.9.2"
32+
nbconvert = "^7.14.2"
33+
jupyter = "^1.0.0"
34+
matplotlib = "^3.0"
35+
36+
37+
[build-system]
38+
requires = ["poetry-core"]
39+
build-backend = "poetry.core.masonry.api"

pytest.ini

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/test_notebooks_run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def check_notebook_runs(notebook_loc):
1818
ep = ExecutePreprocessor(timeout=600, kernel_name='python3')
1919
ep.preprocess(nb, {'metadata': {'path': Path(notebook_loc).parent}})
2020
except Exception as e:
21-
print(f'failed to run notebook {notebook_loc}: rethrowing exception:')
22-
raise e
21+
raise Exception(f'failed to run notebook {notebook_loc}')
2322
print(f'success!')
2423

2524
def test_all_notebooks_run():

0 commit comments

Comments
 (0)