-
Notifications
You must be signed in to change notification settings - Fork 192
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
Ignore pytest deprecation warning for monty dependency of pymatgen #6680
Ignore pytest deprecation warning for monty dependency of pymatgen #6680
Conversation
a799eb8
to
a1c8dd4
Compare
a1c8dd4
to
c358ee9
Compare
This is how they raise deprecation warnings to fail tests run in downstream libraries' CI, it is ridiculous! Took me quite long to figure out why the failed "warning" was only happened on CI but not locally. They literally RAISE the warning, very confuse. if (
_deadline is not None
and os.getenv("CI") is not None
and datetime.now() > _deadline
and _is_in_owner_repo()
):
raise DeprecationWarning(
f"This function should have been removed on {_deadline:%Y-%m-%d}."
) |
c358ee9
to
8e0581b
Compare
@mikibonacci do you think we can move it to |
8e0581b
to
6050b5a
Compare
Hi @unkcpz, are you saying we should move all the pymatgen-related tests (and pymatgne dependency) in Thanks a lot for catching this, BTW! |
Also: I was fixing the |
Just passing since i saw tests failing on aiida-quantumespresso. Please, do not remove the core StructureData as I have put tons of work on HubbardStructureData and associated plugin (also, now people started using it for XPS, XAS), and we use a lot pymatgen since they implement very useful routines, which we would otherwise need to reimplement. I also don't know how much it will take to transition to the newer StructureData of aiida-atomistic, since i won't have time and i don't know who will have it |
PS: since this is blocking any aiida related plugin, do you think we can quickly fix and merge this PR? |
Make sense. But we have to struggle when pymatgen did bad things fail downstream libs like this one. I was thinking to move all pymatgen related tests to run in a separate CI and make it the test not mandatory to pass if it is the problem from upstream pymatgen. What do you think?? @bastonero
No quick fix from our side, because pymatgen raise the warning where it should be just using warning.warn to print to the pytest summary. Either we wait them to fix or we as I mentioned above we move it to separate CI test bundle. Not sure if they fix the issue, would you mind to open an issue there (the source of the issue is from monty library)? |
Now that I am thinking better, I guess this will affect as well aiida-quantumespresso, since we import pymatgen functions, AFAIR. I honestely still didn't understand well what is the problem, but the fact they raise the warning instead of using the right function. Maybe it's better if you give it go, so you know better how to state the problem? |
Sure, I'll open the issue. Here it is materialsvirtuallab/monty#738 |
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.
There is a newer version of monty
released this year that has changed the dev.py
. Maybe we can try to use this one. But in any case I am fine to exclude these tests temporary. Would just be more specific in the skip function (see my comment)
@@ -113,8 +113,14 @@ def test_obj(): | |||
assert left == right | |||
|
|||
|
|||
skip_pymatgen_anyhow = pytest.mark.skipif(not has_pymatgen(), reason='Unable to import pymatgen') |
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.
Since this a temporary fix that should be removed after it has been fixed upstream. Could we use not has_pymatgen
but a custom function
def is_pymatgen_upstream_issue738() -> bool:
"""Checks if we encounter the upstream bug in pymatgen referenced in materialsvirtuallab/monty issue #738.
We cannot fix the bug for now and have to skip the tests that encounter this bug.
"""
try:
from pymatgen.core.structure import Molecule
except DeprecationWarning as exc:
exc.args[0] == "This function should have been removed on 2025-01-01."
return True
return False
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.
and then maybe
skip_pymatgen_anyhow = pytest.mark.skipif(not has_pymatgen(), reason='Unable to import pymatgen') | |
skip_pymatgen_issue738 = pytest.mark.skipif(is_pymatgen_upstream_issue738(), reason='upstream issue | |
#738 in materialsvirtuallab/monty ') |
Incidentally, I am updating the uv lockfile in #6676. In that PR, only Python 3.9 tests are now failing. |
NOTE: A good discussion about the issue is happening in the pymatgen repo here: |
I'd rather not change this even though it seems safe for the moment. The env variable is global from github and we don't know if github will use this for something else of not. |
@unkcpz I agree it's not an ideal solution. But this workaround is quite targeted, only in two specific job steps, and only for Python 3.9. Since will be dropping Python 3.9 support sometimes this year anyway I believe this is acceptable, and is much simpler then mucking around with the test suite. Please see #6676 |
Recreate the uv lockfile (`uv.lock`) with a newer uv version that uses an updated resolution strategy. Previously, it tried to find a version of the package that would be compatible with all supported Python versions, which in turn meant that if a package dropped support for 3.9 for example, we'd be stuck on an old version. In the new uv version, this is not the case, and uv will try to find the newest version of a package for a given python version. Incidentally, this also help partly resolve the pymatgen issue, see #6680. The issue has been fixed in a new version of monty package, which however does not support Python 3.9. So in the updated lockfile, the issue is fixed for Python >=3.10. For Python 3.9, a workaround suggested in materialsproject/pymatgen#4243, and unset the CI environmental variable. Since this workaround is quite targeted (only in two specific job steps, and only for Python 3.9), I believe this is acceptable, and we will be dropping Python 3.9 support sometimes this year anyway.
superseded by #6676 |
It is just annoy to have pymatgen as the dependency we REALLLY need to move it out.