MNT, CI: Update pyproject.toml to include [dependency-groups] - #127
MNT, CI: Update pyproject.toml to include [dependency-groups]#127aganguly-lab wants to merge 4 commits into
Conversation
… simplify the process of restoring this version of the code. * Introduces two new dependency-groups in the pyproject.toml file: testing and linting * Removed [project.optional-dependencies] from pyproject.toml: none are needed * Removed the .github/constraints/deps.txt file * Updated .yml files with new install instructions
I forgot to install the project and its dependencies.
tylerjereddy
left a comment
There was a problem hiding this comment.
Thanks, I added some quick review comments, but I'll let Seth do the main review here.
| python -m pip install ruff==0.15.0 | ||
| python -m pip install -r .github/constraints/deps.txt | ||
| python -m pip install -v --group testing . | ||
| python -m pip install -v --group linting . |
There was a problem hiding this comment.
Here and elsewhere, what's the motivation behind install the project (the dot .) twice?
There was a problem hiding this comment.
Good catch. I was running these separately while testing, so it was useful to have both but there is no reason for it. I made the relevant adjustments.
| "numpydoc", | ||
| "sphinx_copybutton", | ||
| "sphinx_design", | ||
| "pydata_sphinx_theme", |
There was a problem hiding this comment.
Some of these are docs deps rather than linting, right?
Perhaps it would make sense to have a doc group or similar, to form a clear separation from linting, and then be able to install all development deps with a dev group or something like that (I believe the upstream example does something similar).
There was a problem hiding this comment.
I did this. The scipy package also had a build dependency-group, but I couldn't see the point of it in our case. The build project wouldn't install the gfdl module which would be necessary no matter what. And by installing it, we would automatically get any packages in the build dependency-group.
Our dev dependency group simply combines testing, linting and doc.
…nse to #127 (comment) and updated the .yml files accordingly. Changes are untested, but I included this commit for easy retreval during testing.
…ant. Not sure why SciPy has it. I also removed some packages in the linting group that belonged purely in the doc group.
sdtemple
left a comment
There was a problem hiding this comment.
I verified that your commands run Mac OS and on selene (different but same OS from your darwin run).
It would be nice to confirm that the CI failures are from #117. The CI is set by default to fail-fast, whereas with in the .yml file I think we can keep it running for a bit:
strategy:
fail-fast: false # <--- This is the key line
This might not be the desired long term '.yml' file strategy, though. I forked the branch and added this fail-fast: false to the ci.yml file. I also changed on pushes to be "*". I confirmed via this that the base CI failure is from the partial fit test.
Note: this happens for both Windows OS and Ubuntu OS. We might only have been noticing it for Linux because that's what the cluster uses and it is the first crash (temporally) in the CI run.
| python -m pip install -v ".[test]" | ||
| python -m pip install -r .github/constraints/deps.txt | ||
| python -m pip install -v . | ||
| python -m pip install -v --group doc |
There was a problem hiding this comment.
Do you need the -v verbose options in the CI?
There was a problem hiding this comment.
I think it is better to leave the -v options here. It should make it easier to debug the issue if the pipeline fails as due to a broken build. I imagine that is why the -v option was used in the previous commit as well.
| gfdl = ["testdata/**/*"] | ||
|
|
||
|
|
||
| [project.optional-dependencies] |
There was a problem hiding this comment.
The scipy PR you're following as an example mentions that you can keep project.optional-dependencies if there were packages you wanted the user to maybe install.
https://github.com/scipy/scipy/blob/8f7565df3e164e35bbde58e0db735bcf1598715b/pyproject.toml#L78
I'm not saying there is a particular package we want to install. I'm just noting this functionality should we circle back.
| python -m pip install -v -e ".[test]" | ||
| python -m pip install -r .github/constraints/deps.txt | ||
| python -m pip install -v . | ||
| python -m pip install -v --group doc |
There was a problem hiding this comment.
Do you need the -v option in the CI?
| python -m pip install -r .github/constraints/deps.txt | ||
| python -m pip install -v . | ||
| python -m pip install -v --group testing | ||
| python -m pip install -v --group linting |
There was a problem hiding this comment.
Do you need the -v option in the CI?
| python -m pip install -v --group doc | ||
| - name: lint and build docs | ||
| run: | | ||
| numpydoc lint src/gfdl/model.py src/gfdl/activations.py src/gfdl/weights.py |
There was a problem hiding this comment.
Is this line necessary?
AI suggestion:
Create a conf.py with the following:
# docs/conf.py
extensions = [
"sphinx.ext.autodoc",
"numpydoc", # Crucial: This must be present
]
# This is what replaces your "numpydoc lint" command!
numpydoc_validation_checks = {
"all", # Instructs numpydoc to lint everything during the build
}Then, you don't have to manually add files like src/gfdl/model.py whenever you add a new file to the package.
There was a problem hiding this comment.
Such a file belongs under docs/
| [project.optional-dependencies] | ||
| test = [ | ||
| [dependency-groups] | ||
| testing = [ |
| "pytest", | ||
| "pytest-cov", | ||
| ] | ||
| linting = [ |
There was a problem hiding this comment.
lint not linting. I think the convention is that test, lint, and doc are active verbs.
| python -m pip install -r .github/constraints/deps.txt | ||
| python -m pip install -v . | ||
| python -m pip install -v --group doc | ||
| - name: lint and build docs |
There was a problem hiding this comment.
This is really supposed to be build docs and not linting, if you remove the numpydoc line
| testing = [ | ||
| "ucimlrepo", | ||
| "pytest", | ||
| "pytest-cov", |
There was a problem hiding this comment.
Given that you like to use pytest-xdist, it might be worthwhile to add that to the test dependency.
| [dependency-groups] | ||
| testing = [ | ||
| "ucimlrepo", | ||
| "pytest", |
There was a problem hiding this comment.
It might be worth specifying a minimum version for pytest.
|
Just a suggestion--usually best to only review things that changed in the diff vs. stuff that was already there before re: #127 (comment) for example. |
Fixes #123.
[project.optional-dependencies]list is removed frompyproject.toml[dependency-groups]list is added topyproject.toml.ymlfiles (exceptwheel.ymlanddependabot.yml) to account for the updated workflow.With this update, there are three commands that can be used to build the project from source:
The first command installs the project as normal. The second installs the dependencies needed to run the test suite. The last installs all dependencies needed to lint (
ruff checkandnumpydoc lint).When running, make sure pip is up to date. Installation of the testing or linting group will fail if the version of pip is 25.0 or lower. In particular, I found that the default version of pip on darwin and chicoma was too low for this to work, but everything does work when I update pip using
pip install --upgrade pipfirst. I am not sure if this will cause the CI pipeline to fail. If it does, I will add another commit adding the above incantation to the relevant.ymlfiles.I did not modify
wheel.yml. To my understanding,wheel.ymlis intended to test the build as seen by users of the code. Users should not be able to directly install the testing/linting versions of the package.AI Statement: I did not use AI to write any of the code on this branch. I did consult AI extensively with questions about pip installations and builds. I also used AI for debugging purposes.
Testing the update
I have little experience working with installation, so I figured I would include an outline of how I tested my changes to help reviewers. I ran the code below on my laptop and on darwin (I could not secure a chicoma node). For the unit tests, I first ran the code as described below, but then once I confirmed all tests were collected and a few tests had run, I stopped the testing. I then used
python -m pytest -n 8to verify the tests separately (remember topip install pytest-xdistfirst).Return to the root directory.