-
Notifications
You must be signed in to change notification settings - Fork 132
Update repository to be compatible with numpy 2.0, refactor non-core functionality into optional dependencies, update to PEP 621 and PEP 660 #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d75b8a7
Gate optional GPy dependencies; add pytest markers; make wrappers imp…
AlejandroGomezFrieiro ee58765
refactor: unify dependency gating and markers; promote matplotlib & D…
AlejandroGomezFrieiro f5bc001
docs: document pytest marker taxonomy and gating (Ticket 024)
AlejandroGomezFrieiro 82e5308
docs: clarify optional extras; add GPy to docs extra and switch RTD t…
AlejandroGomezFrieiro d01caa6
merge: bring docs extras clarification and RTD config update from opt…
AlejandroGomezFrieiro f4c3902
ci: split core and gpy test jobs; document optional extras in changelog
AlejandroGomezFrieiro 3c057c5
feat(extras): introduce optional dependency groups and docs updates\n…
AlejandroGomezFrieiro b7cc71f
chore: remove tracked .opencode timeline file
AlejandroGomezFrieiro 61aa33e
build: migrate packaging to PEP 621 in pyproject.toml with dynamic ve…
AlejandroGomezFrieiro 4fd20bd
build: migrate CI & docs to extras-based installation; add packaging …
AlejandroGomezFrieiro 4fe9a61
chore: Run black and isort
AlejandroGomezFrieiro 70f66a8
Answer comments with minor changes
AlejandroGomezFrieiro 7f27f2f
Adds random seed fixture for uniform sampling
AlejandroGomezFrieiro 0128fc2
Passes to , and updates the tests
AlejandroGomezFrieiro 39e5d33
Cleanup pyproject.toml dependencies
AlejandroGomezFrieiro 9a614ec
Fixes bad definition in pyproject toml
AlejandroGomezFrieiro a7e9de8
Add comments to all guarded imports
AlejandroGomezFrieiro 574b94d
Remove gpy from several tests and one notebook
apaleyes 4c72915
Notice, update rtd python version
apaleyes f1e24e1
Test for modern python versions
apaleyes 387f90b
Add nbformat
apaleyes df270b6
Add integ tests install, fix a warning, fix linting
apaleyes 6d8e7e0
improve test skipping
apaleyes 9d5b1ac
fix?
apaleyes e8685e3
Improve coverage reports, remove editable installs
apaleyes ff9f010
One job to monitor
apaleyes b24a4c4
fix?
apaleyes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,7 @@ Before submitting the pull request, please go through this checklist to make the | |
| ## Setting up a development environment | ||
|
|
||
| ### Building the code | ||
| See installing from source. | ||
| See installing from source (from version 0.5.0 using `pip install -e .[tests]` for core development, and `pip install -e .[dev]` for examples and docs as well). Note that, due to `numpy` version incompatibilities brought forwards by legacy dependencies (such as `GPy`), it is recommended to develop core features without installing any of the extras, using `tests` whenever possible. This will be improved whenever major dependencies, such as `GPy`, are updated. | ||
|
|
||
| ### Running tests | ||
| Run the full suite of unit tests or integration tests with these commands: | ||
|
|
@@ -91,10 +91,65 @@ from the top level directory. To check unit test coverage, run this: | |
| pytest --verbose --cov emukit --cov-report term-missing tests | ||
| ``` | ||
|
|
||
| Notice that unit tests and integration tests have their own set of additional dependencies. Those can be found in the `requirements` folder, and installed with: | ||
| Notice that unit tests and integration tests have their own set of additional dependencies. You can install them via extras defined in `pyproject.toml`: | ||
| ``` | ||
| pip install -r requirements/test_requirements.txt | ||
| pip install -r requirements/integration_test_requirements.txt | ||
| # Core + test tooling | ||
| pip install -e .[tests] | ||
|
|
||
| # Add optional dependency groups as needed (examples): | ||
| pip install -e .[gpy] | ||
| pip install -e .[bnn] | ||
| pip install -e .[sklearn] | ||
| # Or everything: | ||
| pip install -e .[examples] | ||
| ``` | ||
| Legacy requirement files in `requirements/` remain temporarily for reference but will be phased out; prefer extras going forward. | ||
|
|
||
| ### Test markers & optional dependencies | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section is dope! |
||
| Emukit uses pytest markers to group tests that rely on optional dependencies. Current markers (defined in `pyproject.toml` under `[tool.pytest.ini_options]`): | ||
|
|
||
| - gpy: tests requiring GPy optional dependency | ||
| - pybnn: tests requiring pybnn optional dependency | ||
| - sklearn: tests requiring scikit-learn optional dependency | ||
| - notebooks: tests executing Jupyter notebooks (requires nbformat, nbconvert) | ||
|
|
||
| Example of gating a test that needs GPy: | ||
| ```python | ||
| import pytest | ||
|
|
||
| pytest.importorskip("GPy") # skip if GPy not installed | ||
| pytestmark = pytest.mark.gpy # file-level marker (can also set per test) | ||
|
|
||
| def test_some_gpy_integration(): | ||
| import GPy | ||
| # ... assertions using GPy ... | ||
| ``` | ||
| Function-level alternative: | ||
| ```python | ||
| import pytest | ||
|
|
||
| def test_feature_x(): | ||
| GPy = pytest.importorskip("GPy") | ||
| # ... use GPy ... | ||
|
|
||
| test_feature_x = pytest.mark.gpy(test_feature_x) | ||
| ``` | ||
| Guidelines: | ||
| - Always protect optional imports with `pytest.importorskip("<module>")` to turn absence into a skip, not an error. | ||
| - Apply the corresponding marker (`pytestmark = pytest.mark.<marker>` or function-level) so contributors can include/exclude groups via `-m`. | ||
| - When introducing a new optional dependency group, add its marker entry in `setup.cfg` under `[tool:pytest]` and document it in this section. | ||
| - Avoid installing heavy optional dependencies in default dev loops; install only when working on that area (e.g. `pip install .[gpy]`). | ||
| - Notebook execution tests use the `notebooks` marker; exclude them during rapid iteration with `pytest -m 'not notebooks'`. | ||
| - Keep slow or heavyweight examples under an appropriate marker instead of core unit tests. | ||
|
|
||
| Filtering examples: | ||
| Run only core tests (skip all optional groups): | ||
| ``` | ||
| pytest -m 'not (gpy or pybnn or sklearn or notebooks)' | ||
| ``` | ||
| Run just the sklearn tests: | ||
| ``` | ||
| pytest -m sklearn | ||
| ``` | ||
|
|
||
| ### Formatting | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,67 @@ | ||
| Installation | ||
| ============ | ||
|
|
||
| Emukit requires Python 3.5 or above and NumPy for basic functionality. Some core features also need GPy. Some advanced elements may have their own dependencies, but their installation is optional. | ||
| Emukit requires Python 3.10 or above. The core installation provides the numerical stack and Emukit's pure numpy features. Gaussian process functionality based on GPy, multi-fidelity models, and quadrature models require the optional GPy extra. | ||
|
|
||
| To install emukit, just run | ||
| To install the core emukit package (without GPy), run | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pip install emukit | ||
|
|
||
| Installation from sources | ||
| Optional dependencies | ||
| ________ | ||
| The simplest way to install emukit from sources is to run | ||
| You can install optional dependency groups via setuptools extras. Each group enables additional functionality without inflating the core install: | ||
|
|
||
| - ``gpy``: Gaussian process wrappers, multi-fidelity models, Bayesian quadrature (adds ``GPy``). | ||
| - ``bnn``: Bayesian neural network (Bohamiann) and Profet meta-surrogate examples (adds ``pybnn``, ``torch``). | ||
| - ``sklearn``: scikit-learn model wrapper and related examples (adds ``scikit-learn``). | ||
| - ``docs``: Build documentation locally (Sphinx toolchain + GPy for rendering GP API docs). | ||
| - ``tests``: Test tooling only. | ||
| - ``examples``: Convenience bundle for most example scripts (installs ``GPy``, ``pybnn``, ``torch``, ``scikit-learn``). | ||
| - ``dev``: Convenience meta extra installing all of the above. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| # Gaussian processes / multi-fidelity / quadrature | ||
| pip install emukit[gpy] | ||
|
|
||
| # Bayesian neural network & Profet examples | ||
| pip install emukit[bnn] | ||
|
|
||
| # scikit-learn model wrapper | ||
| pip install emukit[sklearn] | ||
|
|
||
| # Build documentation locally (includes gpy) | ||
| pip install emukit[docs] | ||
|
|
||
| # Bundle of example dependencies | ||
| pip install emukit[examples] | ||
|
|
||
| # Everything (gpy + bnn + sklearn + examples + docs + tests) | ||
| pip install emukit[dev] | ||
|
|
||
| Installation from sources | ||
|
|
||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pip install git+https://github.com/emukit/emukit.git | ||
|
|
||
| If you would like a bit more control, you can do it step by step: clone the repo, install dependencies, install emukit. | ||
| If you would like a bit more control (e.g. for development), clone the repo, install dependencies, install emukit. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| git clone https://github.com/emukit/emukit.git | ||
| cd Emukit | ||
| pip install -r requirements/requirements.txt | ||
| python setup.py develop | ||
| git clone https://github.com/emukit/emukit.git | ||
| cd Emukit | ||
| # Editable install with desired extras (examples below) | ||
| pip install -e .[tests] # core + test tooling | ||
| pip install -e .[gpy] # add GPy-based functionality | ||
| # Or everything: | ||
| pip install -e .[dev] | ||
|
|
||
| `python setup.py develop` is no longer needed; PEP 621 metadata in `pyproject.toml` enables editable installs directly via pip (PEP 660). | ||
|
|
||
| NumPy 2 notice | ||
| ________ | ||
| Core Emukit functionality works with NumPy 2.0+. However, some parts of Emukit (e.g. most acquisition functions) need GPy, that for the time being is a bit behind. If using GPy is critical for you, consider installing earlier versions of Emukit. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.