Skip to content
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

Test latest dependencies #344

Merged
merged 32 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b7daa56
add latest_dependencies.py and workflow
AdamOrmondroyd Sep 24, 2023
0b549bd
version bump
AdamOrmondroyd Sep 24, 2023
5d53524
actually run correct test (should fail)
AdamOrmondroyd Sep 24, 2023
16f0ff0
use latest stable python
AdamOrmondroyd Sep 24, 2023
8edb717
put 3.x in the right place this time
AdamOrmondroyd Sep 24, 2023
8a60ee8
use --no-deps to avoid anesthetic overriding the latest versions
AdamOrmondroyd Sep 24, 2023
e5ec305
remove cov
AdamOrmondroyd Sep 24, 2023
e5032f3
Merge branch 'master' into latesttest
lukashergt Sep 30, 2023
b3434b1
increase python version in readme
AdamOrmondroyd Oct 1, 2023
5b25b87
3.9 duh
AdamOrmondroyd Oct 1, 2023
8c1e854
break up min/latest dependencies tests for output readability
AdamOrmondroyd Oct 1, 2023
f4bdb46
Merge remote-tracking branch 'handley-lab/master' into latesttest
AdamOrmondroyd Oct 1, 2023
5db5ae9
version bump
AdamOrmondroyd Oct 1, 2023
80289c9
first pass at checking anesthetic is up to date (plus merge messed up…
AdamOrmondroyd Oct 1, 2023
9306b31
lets try a different number of brackets
AdamOrmondroyd Oct 1, 2023
636bcbf
separate into two tests + double quotes
AdamOrmondroyd Oct 1, 2023
c59b5c1
deliberately reduce pandas version
AdamOrmondroyd Oct 1, 2023
1aae3dc
Revert "deliberately reduce pandas version"
AdamOrmondroyd Oct 1, 2023
0eef161
tidy condition
AdamOrmondroyd Oct 1, 2023
8cf9914
Revert "tidy condition"
AdamOrmondroyd Oct 1, 2023
77c3de9
create bin/check_up_to_date.py which compares package version to pypi
AdamOrmondroyd Oct 2, 2023
f245a9a
remember to add new file
AdamOrmondroyd Oct 2, 2023
f1aefb3
remember to install requests
AdamOrmondroyd Oct 2, 2023
00c67dd
artificially restrict matplotlib
AdamOrmondroyd Oct 2, 2023
f1d796f
Revert "artificially restrict matplotlib"
AdamOrmondroyd Oct 2, 2023
c11fbc1
use latest_dependencies to get list of packages (some gymnastics invo…
AdamOrmondroyd Oct 2, 2023
83e00dd
I guess I need tomli again
AdamOrmondroyd Oct 2, 2023
516683e
artificially restrict numpy
AdamOrmondroyd Oct 2, 2023
2c52c6e
Revert "artificially restrict numpy"
AdamOrmondroyd Oct 2, 2023
bec343f
remove codecov
AdamOrmondroyd Oct 4, 2023
4cefb0d
remove cov from minimum-dependencies
AdamOrmondroyd Oct 4, 2023
33ceb6a
specify that tests are in
AdamOrmondroyd Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,66 @@ jobs:
with:
python-version: 3.9

- name: Install dependencies
- name: Upgrade pip and install tomli
run: |
python -m pip install --upgrade pip
python -m pip install tomli
eval "python -m pip install $(./bin/min_dependencies.py)"
python -m pip install -e ".[test]"
- name: Install minimum dependencies
run: eval "python -m pip install $(./bin/min_dependencies.py)"
- name: Install anesthetic
run: python -m pip install -e ".[test]"

- name: Test with pytest
run: python -m pytest --cov=anesthetic tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the codecov upload for minimum-dependencies, too? Not really what this job is about either, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, since it is necessary that anesthetic works with the lowest versions we allow, and a PR should not be merged unless this is true

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But codecov has nothing to do with whether anesthetic works or not, that is what pytest is for. Codecov should definitely be in the pip and conda jobs (or at least in one of them), but the coverage does not really depend on versions (unless we specifically add version related conditional statements to the code, which we don't). Besides, the minimum-dependencies job does not even include extra dependencies, so it doesn't do a full code coverage anyhow...

Copy link
Collaborator

@lukashergt lukashergt Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the minimum-dependencies code coverage were to fail, while the pip job code coverage passes, then we wouldn't even know about it, because as long as the pip jobs cover every line at least once, codecov will mark 100% coverage. But I don't even think it is possible for code coverage to be different for the pip jobs and the minimum job...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the tests are now different for matplotlib≥3.8, and at one point in beta some of the anesthetic plotting code was different for pandas 1 vs 2. cov would tell us when these lines are no longer needed right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try it, but I think there will be missing coverage without minimum-dependencies

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the tests are now different for matplotlib≥3.8,

Code in tests/ doesn't matter for code coverage, only code in anesthetic/ matters.

and at one point in beta some of the anesthetic plotting code was different for pandas 1 vs 2. cov would tell us when these lines are no longer needed right?

In a situation like that we would indeed need the code coverage in minimum-dependencies for as long as we wanted to be backwards compatible. However, we already have pandas>=2.0.0, so this shouldn't be an issue, here.

In fact, I think this might be an argument in favour of not having code coverage in minimum-dependencies, to flag up once parts of code are no longer needed for newer versions. Currently we wouldn't know if parts of code were no longer needed by newer versions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and at one point in beta some of the anesthetic plotting code was different for pandas 1 vs 2. cov would tell us when these lines are no longer needed right?

In a situation like that we would indeed need the code coverage in minimum-dependencies for as long as we wanted to be backwards compatible. However, we already have pandas>=2.0.0, so this shouldn't be an issue, here.

In fact, I think this might be an argument in favour of not having code coverage in minimum-dependencies, to flag up once parts of code are no longer needed for newer versions. Currently we wouldn't know if parts of code were no longer needed by newer versions.

I guess it depends how cut-throat we want to be with older packages. I suppose the pandas2 difference was because pandas2 hadn't actually released yet, and once it did, we dropped support for pandas1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the tests are now different for matplotlib≥3.8,

Code in tests/ doesn't matter for code coverage, only code in anesthetic/ matters.

Ah - I'd thought pytest --cov anesthetic tests meant that coverage was looking at anesthetic AND tests, but tests is just to tell pytest where the tests are. I don't think I specified this in the new pytest calls

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there might be a point where we'll want to re-introduce this for backwards compatibility, but I'd rather be aware when that happens.


latest-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up latest stable Python 3
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Upgrade pip and install tomli
run: |
python -m pip install --upgrade pip
python -m pip install tomli
- name: Install latest dependencies
run: eval "python -m pip install $(./bin/latest_dependencies.py)"
- name: Install pytest and anesthetic
run: |
python -m pip install pytest
python -m pip install --no-deps -e .

- name: Test with pytest
run: python -m pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to upload to codecov for this job? If we don't then I'd prefer to leave this out. Faster and easier to review.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have flagged this earlier as I wasn't sure myself. @williamjameshandley what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the github settings will also need adjusting to control which tests are required to pass in order for a PR to be merged. I don't think I have access to these settings, @lukashergt can you check them? Maybe these tests will need to be put in a different file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only branch protection rules for the master branch, so until this PR gets merged there is nothing to be done. Once this is merged we can individually remove jobs from the master branch protection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the jobs under CI separate or one in the settings?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate. Each job can be added/removed individually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgim then

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgim

???

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"let's get it merged", which I think is what @williamjameshandley thought I meant by "lgtm" (looks good to me, which I learned from pandas)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, we had this before... I don't retain this stuff...^^


check-for-new-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up latest stable Python 3
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Upgrade pip and install tomli and requests
run: |
python -m pip install --upgrade pip
python -m pip install tomli requests

- name: Install anesthetic
run: python -m pip install -e ".[test]"

- name: Check anesthetic dependencies are up to date
run: python -m pytest ./bin/check_up_to_date.py

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
lukashergt marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
anesthetic: nested sampling post-processing
===========================================
:Authors: Will Handley and Lukas Hergt
:Version: 2.4.1
:Version: 2.4.2
:Homepage: https://github.com/handley-lab/anesthetic
:Documentation: http://anesthetic.readthedocs.io/

Expand Down Expand Up @@ -96,7 +96,7 @@ Dependencies

Basic requirements:

- Python 3.6+
- Python 3.9+
- `matplotlib <https://pypi.org/project/matplotlib/>`__
- `numpy <https://pypi.org/project/numpy/>`__
- `scipy <https://pypi.org/project/scipy/>`__
Expand Down
2 changes: 1 addition & 1 deletion anesthetic/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.4.1'
__version__ = '2.4.2'
19 changes: 19 additions & 0 deletions bin/check_up_to_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
import requests
from packaging import version
import importlib
from latest_dependencies import deps


packages = [importlib.import_module(package) for package in deps]


@pytest.mark.parametrize('package', packages)
def test_packages(package):
response = requests.get(f"https://pypi.org/pypi/{package.__name__}/json")
latest_version = response.json()['info']['version']

if version.parse(latest_version) > version.parse(package.__version__):
print(f"You should upgrade the {package.__name__} requirement "
f"from {package.__version__} to {latest_version}")
assert version.parse(latest_version) <= version.parse(package.__version__)
18 changes: 18 additions & 0 deletions bin/latest_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
import tomli

with open("pyproject.toml", 'rb') as f:
pyproject = tomli.load(f)

deps = pyproject["project"]["dependencies"]
deps = [dep.partition("==")[0] for dep in deps]
deps = [dep.partition(">=")[0] for dep in deps]
deps = [dep.partition("<=")[0] for dep in deps]
deps = [dep.partition(">")[0] for dep in deps]
deps = [dep.partition("<")[0] for dep in deps]
deps = [dep.partition("~=")[0] for dep in deps]
deps = [dep.partition("^=")[0] for dep in deps]

if __name__ == "__main__":
deps = [f'"{dep}"' for dep in deps]
print(' '.join(deps))
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ requires-python = ">=3.8"
dependencies = [
"scipy",
"numpy",
"pandas>=2.0.0",
"matplotlib>=3.6.1",
"pandas>=2.0.0,<2.2.0",
"matplotlib>=3.6.1,<3.9.0",
]
classifiers = [
"Programming Language :: Python :: 3",
Expand Down
Loading