-
Notifications
You must be signed in to change notification settings - Fork 876
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
build against NPY2 #3894
build against NPY2 #3894
Conversation
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Unluckily, there are still several errors. Some are related to the upstream chgnet and scipy and cannot be fixed here. |
Signed-off-by: Jinzhe Zeng <[email protected]>
e3fbc67
to
41e6d99
Compare
@njzjz sorry for the lack of reply here! looks like this is almost finished. thanks for the effort! feel free to skip the failing chgnet tests for now. re |
I really appreciate the pioneering work @njzjz! Meanwhile in case anyone missed this,
|
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
For cross reference, I've submitted the SciPy issue to scipy/scipy#21052 |
I do not know how to fix the rest of the errors and need help. |
@njzjz feel free to skip the two failing @pytest.mark.skipif(sys.platform == "win32" and np.__version__ > "2.0.0", reason="Fails on Windows with numpy > 2.0.0, awaiting https://github.com/scipy/scipy/issues/21052 resolution")
def test_delta_func():
x = np.array([0, 1, 2, 3, 4, 5]) not sure about |
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.
thanks a lot @njzjz for this work and esp. for reporting multiple upstream issues! 🥇 and thanks @DanielYang59 for supporting! good team effort to get the many failing tests here sorted out.
The failing tests for |
@@ -50,7 +50,8 @@ class LinearAssignment: | |||
""" | |||
|
|||
def __init__(self, costs, epsilon=1e-13): | |||
self.orig_c = np.array(costs, dtype=np.float_, copy=False, order="C") | |||
# https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword |
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.
@janosh This doesn't look like something we should keep inside the code (it's pretty easy to find)? What do you think?
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.
i'm generally in favor of linking relevant docs. even if easy to find, people might not think to look for them. but no strong opinion in this case
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.
This one looks more like a "disposable" migration guide which we would only do once :)
probably something to report to https://github.com/Unidata/netcdf4-python, even if just to say the error message is self-contradictory...
|
Agreed, just for my own record, it failed in another PR randomly https://github.com/materialsproject/pymatgen/actions/runs/10268736299/job/28412461926?pr=3892 |
This part of the code is generated by delvewheel here. I think I can report there. According to the Windows documentation, this error message means no error. So it may be incorrect to throw an error (while it is also strange that
See also https://stackoverflow.com/questions/7524142/what-does-windows-error-0-error-success-mean |
Submitted to adang1345/delvewheel#51 |
@njzjz can you pin pyproject to the fixed |
temp install delvewheel>=1.7.4 in CI
Signed-off-by: Jinzhe Zeng <[email protected]>
Head branch was pushed to by a user without write access
This may not work, as delvewheel is a build-time dependency, not a runtime dependency. |
ah, didn't realize that. so the place to pin that would be here Lines 1 to 4 in 1dfc9e4
but looks like we're in the green anyway so would be good to remove the temp install command in |
thanks again @njzjz! 👍 |
Just recorded another failure in https://github.com/materialsproject/pymatgen/actions/runs/10319015504/job/28566565139:
|
@@ -88,7 +90,7 @@ ase = ["ase>=3.23.0"] | |||
# don't depend on tblite above 3.11 since unsupported https://github.com/tblite/tblite/issues/175 | |||
tblite = ["tblite[ase]>=0.3.0; python_version<'3.12'"] | |||
vis = ["vtk>=6.0.0"] | |||
abinit = ["netcdf4>=1.6.5"] | |||
abinit = ["netcdf4>=1.7.1"] |
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.
@janosh Janosh can I have a quick comment on this bump of netcdf4
version here from commit 1dfc9e4?
It seems to cause CI failure (more details on #4128 (comment)) in Ubuntu CI runner for netcdf4>=1.7.1.post1
(1.7.1 is yanked), 1.6.5
seems to work though
I also tried to install delvewheel
but doesn't seem to help
There seem to be a lot of discussion around this error but didn't see a solid solution yet. And the issue for me is that I cannot recreate this with my local Ubuntu machine (with exactly the same dependency versions).
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.
netcdf
needed to be bumped in #3894 to fix the following CI errors:
_____________ ERROR collecting tests/io/abinit/test_abiobjects.py _____________
tests\io\abinit\test_abiobjects.py:10: in <module>
from pymatgen.io.abinit.abiobjects import (
src\pymatgen\io\abinit\__init__.py:5: in <module>
from .netcdf import (
src\pymatgen\io\abinit\netcdf.py:25: in <module>
import netCDF4
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\netCDF4\__init__.py:28: in <module>
_delvewheel_patch_1_7_0()
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\netCDF4\__init__.py:25: in _delvewheel_patch_1_7_0
raise OSError('Error loading {}; {}'.format(lib, ctypes.FormatError(ctypes.get_last_error())))
E OSError: Error loading charset-[23](https://github.com/materialsproject/pymatgen/actions/runs/10265440264/job/28401647005#step:8:24)3f44715e5aacaf3a688c2faff5ddf7.dll; The operation completed successfully.
if it's causing problems again and this time downgrading helps, by all means let's do 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.
Current pymatgen
dependency declare has duplicate (would be fixed #4128), you must have been mislead too :)
The netcdf4
bumped is not really the one installed in CI (the one in optional
section is the one actually installed in CI, surely you know):
pymatgen/.github/workflows/test.yml
Lines 41 to 44 in 3ee17e2
- os: ubuntu-latest | |
python: "3.12" | |
resolution: lowest-direct | |
extras: ci,optional |
Line 95 in 3ee17e2
abinit = ["netcdf4>=1.7.1"] |
Lines 100 to 113 in 3ee17e2
optional = [ | |
"ase>=3.23.0", | |
"beautifulsoup4", | |
# BoltzTraP2 build fails on Windows GitHub runners | |
"BoltzTraP2>=24.9.4 ; platform_system != 'Windows'", | |
"chemview>=0.6", | |
"chgnet>=0.3.8", | |
"f90nml>=1.1.2", | |
"galore>=0.6.1", | |
"h5py>=3.11.0", | |
"jarvis-tools>=2020.7.14", | |
"matgl>=1.1.3", | |
"matplotlib>=3.8", | |
"netCDF4>=1.6.5", |
So it still installed: + netcdf4==1.6.5
I looked into the error log again, and turns out it's + netcdf4==1.7.1.post1
causing the following error:
______________ ERROR collecting tests/io/abinit/test_pseudos.py _______________
tests\io\abinit\test_pseudos.py:11: in <module>
from pymatgen.io.abinit.pseudos import Pseudo, PseudoTable
src\pymatgen\io\abinit\__init__.py:5: in <module>
from .netcdf import (
src\pymatgen\io\abinit\netcdf.py:25: in <module>
import netCDF4
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\netCDF4\__init__.py:28: in <module>
_delvewheel_patch_1_7_0()
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\netCDF4\__init__.py:25: in _delvewheel_patch_1_7_0
raise OSError('Error loading {}; {}'.format(lib, ctypes.FormatError(ctypes.get_last_error())))
E OSError: Error loading charset-233f44715e5aacaf3a688c2faff5ddf7.dll; The operation completed successfully.
So I might revert that pin to <1.7.1.post1
and (1.7.1.post2 also triggers error), same for latest 1.7.2
It's a huge headache because I cannot recreate these errors locally, which make things very hard.
Summary
Major changes:
np.int_t
(missing in NPY2) withnp.int64_t
andnp.float_
withnp.float64
.long
withnp.int64_t
, as "The default integer type on Windows is now int64 rather thanint32, matching the behavior on other platforms" per the change log of NPY2.
Todos
If this is work in progress, what else needs to be done?
Checklist
ruff
.mypy
.duecredit
@due.dcite
decorators to reference relevant papers by DOI (example)Tip: Install
pre-commit
hooks to auto-check types and linting before every commit: