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

ruff fixes #184

Merged
merged 42 commits into from
Sep 12, 2024
Merged

ruff fixes #184

merged 42 commits into from
Sep 12, 2024

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Aug 5, 2024

Summary

  • test_wandb_log_frequency use temporary path to avoid creating files locally

Relocate to another PR

@DanielYang59
Copy link
Contributor Author

@janosh Can you please approve the workflow? Thanks!

@janosh janosh added pkg Package compatibility Compatibility with different OS, Python, PyTorch, numpy, etc. labels Aug 5, 2024
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Aug 5, 2024

Thanks! I believe the test failure is owing to the lack of support of NumPy 2.0 from pymatgen's side materialsproject/pymatgen#3953. Not sure what's the best practice at this moment as pymatgen is waiting for chgnet to support NumPy 2.0 too materialsproject/pymatgen#3894 (comment) (perhaps use np2 for build system and np1 for runtime dependency?)

@janosh
Copy link
Collaborator

janosh commented Aug 5, 2024

Pymatgen should go first and ignore failing chgnet tests

@DanielYang59
Copy link
Contributor Author

Yes I just realized the same, pymatgen should build against np2 first :) And it would be compatible with np1 at runtime

@DanielYang59 DanielYang59 marked this pull request as ready for review August 9, 2024 02:58
@DanielYang59
Copy link
Contributor Author

@janosh It looks like you have to approve the workflow again for some reason?

@janosh
Copy link
Collaborator

janosh commented Aug 9, 2024

until your first PR to a repo is merged, workflows need to be re-approved on every commit. it's quite annoying

@DanielYang59 DanielYang59 marked this pull request as draft August 13, 2024 02:37
@janosh janosh marked this pull request as ready for review September 10, 2024 12:40
@DanielYang59
Copy link
Contributor Author

Hi @janosh if i remember correctly, this cannot be merged until a new release of pymatgen is issued.

@janosh
Copy link
Collaborator

janosh commented Sep 10, 2024

@DanielYang59 thanks for the reminder. pymatgen v2024.9.10 should be on PyPI in a few minutes

@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Sep 11, 2024

@janosh Have to ping you to approve the workflow (again), hopefully no test fails this time

@DanielYang59
Copy link
Contributor Author

@janosh Should be good this time :)

@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Sep 12, 2024

perhaps this signals that one of the dtype changes in make_graph is still platform dependent or needs to be reverted?

Concur, we should focus on inferred (implicit) types, i.e. np.array([0, 1]) whose type would still be platform dependent.

Instead of just changing the type in tests, we should also update the code where int is expected and automatically cast the type to int64. Otherwise users might still experience issues if they don't explicitly declare types.

However, I'm not familiar with the code base so if @BowenD-UCB could give a hand that would very helpful.

Sorry about the delay on the PR, been a bit busy lately.

It has not been delayed at all :) pymatgen just unblocked this.

@DanielYang59 DanielYang59 changed the title Build against NumPy 2.0 ruff fixes Sep 12, 2024
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Sep 12, 2024

@janosh I reverted all (I believe) numpy related change from this PR, and relocate NumPy v2 migration to another PR as it turns out there's more debugging needed than I expected.

Might need to replace the labels for this PR

@DanielYang59 DanielYang59 mentioned this pull request Sep 12, 2024
chgnet/trainer/trainer.py Show resolved Hide resolved
chgnet/model/dynamics.py Outdated Show resolved Hide resolved
structure_perturbed.perturb(distance=0.1)
fixed_rng = np.random.default_rng(0)
with patch("numpy.random.default_rng", return_value=fixed_rng):
structure_perturbed.perturb(distance=0.1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should probably add a seed kwarg to Structure.perturb that's simply passed into np.random.default_rng(seed=seed) over in pymatgen

Copy link
Contributor Author

@DanielYang59 DanielYang59 Sep 12, 2024

Choose a reason for hiding this comment

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

That's a good point, especially with the generator implementation.

I didn't realize this downside before but it turns out with the new generator implementation every rng is a isolated instance, making it impossible to set a global seed and control all random states (or it's just me unaware of that).

chgnet/graph/graph.py Show resolved Hide resolved
…y:297: DeprecationWarning: Use FrechetCellFilter for better convergence w.r.t. cell variables."

This reverts commit b60f5e4.
@janosh janosh added linting Cleaning up and refactoring code and removed pkg Package compatibility Compatibility with different OS, Python, PyTorch, numpy, etc. labels Sep 12, 2024
@janosh janosh merged commit 9281cf4 into CederGroupHub:main Sep 12, 2024
8 of 10 checks passed
Copy link
Collaborator

@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 @DanielYang59! 👍

@DanielYang59 DanielYang59 deleted the numpy2 branch September 12, 2024 14:17
@DanielYang59
Copy link
Contributor Author

No problem, thanks for merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linting Cleaning up and refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants