Skip to content

Add a nox session for regenerating pinned requirements files used in CI - #2664

Merged
namurphy merged 18 commits into
PlasmaPy:mainfrom
namurphy:nox-requirements
May 9, 2024
Merged

namurphy merged 18 commits into
PlasmaPy:mainfrom
namurphy:nox-requirements

Conversation

@namurphy

@namurphy namurphy commented May 3, 2024 •

Copy link
Copy Markdown
Member

This PR adds a nox environment that can be used to regenerate requirements files. It can be run with nox -s requirements. The intention of this nox environment is to eventually replace the current tox environment, but the removal of the tox environment will come after sessions for running tests get added to noxfile.py...hopefully soon.

This PR also standardizes the naming scheme for the requirements files, ideally making the names of the files better reflect what they are used for.

All of the files in ci_requirements/ are auto-generated, so they probably be mostly skipped during the review.

Only a couple pull requests into this, and I'm already hoping I never have to edit a tox.ini file ever again! 😹

Related issues

#1734, #1735, #2647, #2654, #2656

@github-actions github-actions Bot added the packaging Related to packaging or distribution label May 3, 2024
@codecov

codecov Bot commented May 3, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.88%. Comparing base (79b1c19) to head (f454ee0).

❗ Current head f454ee0 differs from pull request most recent head b3d6ce4. Consider uploading reports for the commit b3d6ce4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2664      +/-   ##
==========================================
- Coverage   95.21%   94.88%   -0.33%     
==========================================
  Files         103      103              
  Lines        9412     9412              
  Branches     2155     2155              
==========================================
- Hits         8962     8931      -31     
- Misses        273      299      +26     
- Partials      177      182       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions Bot added testing CI Related to continuous integration labels May 4, 2024
@namurphy

namurphy commented May 4, 2024 •

Copy link
Copy Markdown
Member Author

I ran into a problem when I was running nox -e requirements locally with Python 3.12, without Python 3.10 installed, and when trying to resolve requirements for Python 3.10. I ended up getting:

nox > python -m uv pip compile pyproject.toml --upgrade -p 3.10 --extra tests -o ci_requirements/tests-3.10-highest.txt
error: Querying Python at `/usr/bin/python3` failed with status exit status: 1 with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/.cache/uv/.tmppRkEoP/python/get_interpreter_info.py", line 536, in main
    "platform": get_operating_system_and_architecture(),
  File "/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/.cache/uv/.tmppRkEoP/python/get_interpreter_info.py", line 439, in get_operating_system_and_architecture
    from .packaging._manylinux import _get_glibc_version
  File "/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/.cache/uv/.tmppRkEoP/python/packaging/_manylinux.py", line 1
    from __future__ import annotations
    ^
SyntaxError: future feature annotations is not defined
---
nox > Command python -m uv pip compile pyproject.toml --upgrade -p 3.10 --extra tests -o ci_requirements/tests-3.10-highest.txt failed with exit code 2
nox > Session requirements failed.

Will have to look into this later...

@namurphy namurphy changed the title 🚧 Add a nox environment for regenerating pinned requirements files used in CI 🚧 Add a nox session for regenerating pinned requirements files used in CI May 4, 2024
@namurphy

namurphy commented May 4, 2024

Copy link
Copy Markdown
Member Author

📝 Some differences between nox and tox

  • A tox environment corresponds to a nox session.
  • Similarly, the flag used to invoke a nox session should preferably be nox -s requirements (instead of -e, though -e also works, presumably for cross-compatibility with tox).

Comment thread noxfile.py Outdated
requirements_directory = "ci_requirements"


def get_requirements_file(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One of the benefits of switching to nox is that we can define functions to help create testing environments!

Comment thread noxfile.py Resolved
@namurphy

namurphy commented May 6, 2024

Copy link
Copy Markdown
Member Author

I ran into a problem when I was running nox -e requirements locally with Python 3.12, without Python 3.10 installed, and when trying to resolve requirements for Python 3.10.

It turns out that this problem occurred on my workstation at work (running RHEL) but did not occur on my home computer (running Ubuntu 22.04).

This PR is going to wait until after the 2024.5.0 release.

Comment thread noxfile.py Resolved
@github-actions github-actions Bot added the GitHub Actions A continuous integration platform for automating tests and other tasks (see .github/ directory) label May 9, 2024
Comment thread ci_requirements/all-3.12.txt Resolved
Comment on lines +29 to +30
# Temporarily use requirements files generated both by tox and nox
# during the switchover from tox to nox.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because the requirements filenames are changing, we'll need the files generated by tox for the remaining tox environments, as well as the files generated by nox for the current and forthcoming nox sessions. It'll be messier having duplicate requirements files under different names, but I want to switch things over completely soon.

namurphy added 2 commits May 8, 2024 22:37
Running `nox` will now make it print out a help message along with
the list of sessions.
@namurphy
namurphy marked this pull request as ready for review May 9, 2024 02:41
@namurphy
namurphy requested a review from a team as a code owner May 9, 2024 02:41
@namurphy
namurphy requested review from ejohnson-96 and removed request for a team May 9, 2024 02:41
@namurphy namurphy changed the title 🚧 Add a nox session for regenerating pinned requirements files used in CI Add a nox session for regenerating pinned requirements files used in CI May 9, 2024
@namurphy
namurphy requested a review from pheuer May 9, 2024 18:03

@ejohnson-96 ejohnson-96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@namurphy
namurphy removed the request for review from pheuer May 9, 2024 19:10
@namurphy
namurphy merged commit f35d5b3 into PlasmaPy:main May 9, 2024
@namurphy
namurphy deleted the nox-requirements branch May 9, 2024 19:23
@namurphy namurphy added the nox Related to the nox automation software label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Related to continuous integration GitHub Actions A continuous integration platform for automating tests and other tasks (see .github/ directory) nox Related to the nox automation software packaging Related to packaging or distribution testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants