-
Notifications
You must be signed in to change notification settings - Fork 200
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
CI: fix problems in the code, pre-commit and docs-build workflows #5301
CI: fix problems in the code, pre-commit and docs-build workflows #5301
Conversation
According to AEP 003, which states that we follow NEP 029, support for NumPy 1.18 can be dropped as of December 22 2021.
The link used to provide more background information on the concept of exit codes has been experiencing downtime often recently, causing the builds to fail in the `docs-build` workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, all looks good to me. I feel like I was not on the wrong track updating mypy
and trying to solve the new problems, it is incredibly frustrating that my local mypy
is misbehaving. Not being able to set a reliable work environment is hell 😞.
Anyways, thanks for the fix! Just had a couple of questions but probably ok to go ahead and merge this.
BTW also pinging @csadorf for informing on the dependency updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well err there is a 2 line fix for the pre-commit issue: #5302. (although I guess we could update the mypy/sqlalchemy at some point anyway)
Whatever you do, I would suggest pinning the install of requirements, which will lead to less unexpected failures when a package releases a new version
the pymatgen fix is good though 👍 |
f933893
to
cbfbf26
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5301 +/- ##
===========================================
+ Coverage 81.51% 81.51% +0.01%
===========================================
Files 530 530
Lines 37103 37105 +2
===========================================
+ Hits 30242 30244 +2
Misses 6861 6861
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@chrisjsewell I updated the last commit to include your changes. Figured that even though that is the better fix, it is maybe still worth it to keep the update to |
setup.json
Outdated
"sqlalchemy[mypy]~=1.4.29", | ||
"sqlalchemy2-stubs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqlalchemy[mypy] is the same as sqlalchemy2-stubs: https://docs.sqlalchemy.org/en/14/orm/extensions/mypy.html#installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we remove the sqlalchemy2-stubs
one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the stubs one. I have to leave now and can't respond again until later tonight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeh heres he exact axtra: https://github.com/sqlalchemy/sqlalchemy/blob/a869dc8fe3cd579ed9bab665d215a6c3e3d8a4ca/setup.cfg#L45-L47,
well I feel the version of sqlalchemy itself should come from the main requirements lock file, so I would remove sqlalchemy[mypy]~=1.4.29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we won't be automatically updated if sqlachemy
adds another requirement to the mypy
extra. And only upping the version in our pre-commit
extra makes sense since that more recent version is only required to make the typing work. It is not necessary for the normal install so would be a bit restrictive to unnecessarily up the minimum requirement there as well, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its just obviously possible for the sqlalchemy version to then get out of sync, and for you to end up "further away" from the requirements in the requirements.txt file. But honestly it's not a big thing either way, I'll leave it up to you
yeh it can't hurt 👍 |
cbfbf26
to
c3decf4
Compare
.github/workflows/test-install.yml
Outdated
- name: Build pymatgen with compatible numpy | ||
run: | | ||
# This step is necessary because certain versions of `pymatgen` will not specify an explicit version of | ||
# `numpy` in its build requirements, and so the latest version will be used. This causes problems, | ||
# however, because this means that the compiled version of `pymatgen` can only be used with that version | ||
# of `numpy` or higher, since `numpy` only guarantees forward compatibility of the ABI. If we want to | ||
# run with an older version of `numpy`, we need to ensure that `pymatgen` is built with that same | ||
# version. This we can accomplish by installing the desired version of `numpy` manually and then calling | ||
# the install command for `pymatgen` with the `--no-build-isolation` flag. This flag will ensure that | ||
# build dependencies are ignored and won't be installed (preventing the most recent version of `numpy` | ||
# to be installed) and the build relies on those requirements already being present in the environment. | ||
# We also need to install `wheel` because otherwise the `pymatgen` build will fail because `bdist_wheel` | ||
# will not be available. | ||
pip install numpy==1.21.4 wheel | ||
pip install pymatgen==2022.0.16 --no-cache-dir --no-build-isolation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we also change our installation documentation, we cannot add this step here. The steps carried out as part of this workflow are particular designed to check that the steps documented as part of the user documentation for installing this package are working as expected. It seems like we will have to make that more obvious as part of the action's documentation.
Furthermore, afaik, the test-install flow has not failed due to the pymatgen issue, so there should be no need to "fix" it in this way either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, will revert this. That being said, the existing workflow explicitly updates pip
and setuptools
adding a comment that the latter is critical for an install of pymatgen
. This is not reflected in the documentation. But maybe this is no longer applicable and should also be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, maybe we add a comment to the docs that we test against the latest version of setuptools and pip and if there are any issues, users should try to update them? We could also explicitly test against the minimal version supported according to our build settings and the latest version?
My inclination would be to not make this more complicated until we run into problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. But I would suggest we leave this for another PR as it seems beyond the scope of getting the CI back up and running.
setup.json
Outdated
@@ -86,7 +86,7 @@ | |||
"PyCifRW~=4.4", | |||
"ase~=3.18", | |||
"matplotlib~=3.3,>=3.3.4", | |||
"pymatgen>=2019.7.2,<=2022.02.03,!=2019.9.7", | |||
"pymatgen>=2019.7.2,!=2019.9.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pymatgen does not follow semantic versioning, not sure whether it is a good idea to leave this unbounded. Any future release could break our package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added <=2022.1.9
which is the latest version and for which our tests pass.
With the release of `numpy==1.22.0` on December 31 2022, our CI builds started failing. The reason being that `pymatgen` would get built with a version of `numpy` that is incompatible with the version of `numpy` that would be installed in the environment in which the tests are run. The reason for this is that `pymatgen` does not specify an explicit version of `numpy` in its build requirements and so will pick the latest version. But `numpy` only guarantees foreward compatibility with its ABI and so if compiled with a certain version, the resulting binary won't be compatible with older `numpy` versions. In this case explicitly, `pymatgen` was getting built with `numpy==1.22` but then the tests were run with `1.21.4` which would cause the exception. The solution is to ensure `pymatgen` is compiled with a version of `numpy` that is ABI-compatible with the version that will be used in the actual test run. The way to do this is to first explicitly install a version of `numpy` that we need and then install `pymatgen` using the `--no-build-isolation` flag to force `pip` to not install build requirements but take them from the existing environment. This is also why we need to install the `wheel` package explicitly, because this is also a build requirement of `pymatgen` that no longer will be installed automatically by `pip` due to `--no-build-isolation`. Finally, there was a necessary change for the dependencies of Python 3.10 where we update the version of `pymatgen` because older versions could not be built since the building used CPython code that has been removed in Python 3.10.
The pre-commit step was failing due to an exception in `mypy`. This was caused by a bug in the typing of `sqlalchemy`. Upping the requirement in the `pre-commit` extra to `sqlalchemy[mypy]~=1.4.29` makes sure that we install a version that fixes the problem. The `mypy` extra will install the `sqlalchemy2-stubs` package, so that explicit requirement is removed. Note that these new versions require `mypy==0.930` so we update that version. The update in `mypy` comes with some improvements that allow us to remove some previous ignore statements and others have to be added or updated. In addition, we ensure that we install pinned versions in the workflow by installing from the requirements file, and then just adding the additional dependencies from the `pre-commit` extra.
c3decf4
to
ae592f1
Compare
In the end we might not need to fix this ourselves anymore! Or at least we will be able to revert it as soon as a new (we should still go ahead and merge this to fix the tests now, just saying for the near future) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ta
Indeed, I asked them to fix this, but even if they release this, if we want to rely on this, we would have to up our minimum requirement to that latest release, which is maybe not something we want. But maybe we do, not sure to be honest. |
I would recommend to update this and maybe a few other major requirements with version 2.0. |
Fixes #5293
Fixes #5299
First commit is not 100% necessary but related to the fix of
pymatgen
and it is time for the change anyway following AEP 003.The other three commits solve the problem of each failing workflow.