Skip to content
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

Fix Incar check_params for Union type #3958

Merged
merged 13 commits into from
Aug 2, 2024

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Jul 31, 2024

Summary

@wladerer
Copy link
Contributor

wladerer commented Jul 31, 2024

This might be a silly question, but is changing the "type" parameter in the json file possible? The following evaluates to typing.Union

type(eval('bool | str'))

Example:

>>> isinstance(True, eval('bool | str'))
True
>>> isinstance("string thing", eval('bool | str'))
True
>>> isinstance(55, eval('bool | str'))
False

@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Jul 31, 2024

That's actually an ingenious solution IMO, now that using of eval is not risky in this scenario.

However the only pitfall being that the alias of Union[x, y] as x | y is introduced in Python 3.10, and as the min supported version for pymatgen is 3.9 at this moment, we still cannot implement that change. But still I think it's a cleaner solution than mine, perhaps we could import Union for now until we move to Python 3.10+.

@DanielYang59 DanielYang59 changed the title Fix Incar check_params for composite types Fix Incar check_params for Union type Jul 31, 2024
@DanielYang59

This comment was marked as resolved.

@DanielYang59 DanielYang59 marked this pull request as ready for review July 31, 2024 10:04
@DanielYang59
Copy link
Contributor Author

@janosh Can you please review this? Thanks. I believe the CI failing is unrelated to this PR.

@janosh
Copy link
Member

janosh commented Aug 2, 2024

I believe the CI failing is unrelated to this PR.

i think the issue is due to installing the latest torch in test.yml while matGL requires torch=2.2.1 or older

pip install torch --upgrade

can you try pinning to torch 2.2.1 in CI with a TODO to remove pin later?

@DanielYang59
Copy link
Contributor Author

Yes sure. Let me have a try.

@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Aug 2, 2024

Looks like matgl has removed the torch version limitation, but still we need to wait for a new release. materialsvirtuallab/matgl@d0bf202

@janosh
Copy link
Member

janosh commented Aug 2, 2024

afaik dgl isn't compatible with torch==2.3 yet, let alone 2.4 so don't think the matgl up pin should have been removed. i was advocating for a down pin in another thread. either way, let's revert the temp torch==2.2.1 pin here and just skip the matGL tests for now to keep things moving

@DanielYang59
Copy link
Contributor Author

Sure! Thanks for the input, and I know nothing about matgl :)

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks a lot @DanielYang59! 👍

@janosh janosh merged commit 940eb60 into materialsproject:master Aug 2, 2024
31 of 32 checks passed
@DanielYang59 DanielYang59 deleted the fix-incar-check-param branch August 3, 2024 01:30
@DanielYang59
Copy link
Contributor Author

Thanks for reviewing!

@janosh janosh changed the title Fix Incar check_params for Union type Fix Incar check_params for Union type Aug 9, 2024
@janosh janosh added io Input/output functionality vasp Vienna Ab initio Simulation Package refactor Refactorings labels Aug 9, 2024
@DanielYang59 DanielYang59 mentioned this pull request Aug 21, 2024
1 task
DanielYang59 added a commit to DanielYang59/pymatgen that referenced this pull request Aug 21, 2024
shyuep pushed a commit that referenced this pull request Aug 21, 2024
* drop python 3.9 and add python 3.13

* remove yanked matplotlib pin

* remove clarified TODO tag

* bump python version in CI

* try to explicitly declare python 313 in mamba

* use 3.13 pre-release rc1

* remove Python 3.13

* remove TODO for Python 2

* remove docstring TODO for unit test

* enable this seemingly passing test

* tweak and fix typo in get_dos_fp_similarity ValueError msg

* ruff auto-fixes

* manual fix: type unions use pipe op

* replace union with | operator

* add TypeAlias to honor type-alias-without-annotation (PYI026)

* replace pariwise iteration using zip with itertools

* fix error message

* not sure why it failed, try to separate available index

* sure I forgot about double quote and single quote

* use | in INCAR tag check from #3958

* fix RUF017

* Revert "fix RUF017" as I haven't got time to verify

This reverts commit b6dbf20.

* fix DeprecationWarning: dict interface (SpglibDataset['international']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Input/output functionality refactor Refactorings vasp Vienna Ab initio Simulation Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vasp Incar check_params() can't handle Union types
3 participants