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

Slightly more robust MSONAtoms handling #3869

Merged
merged 1 commit into from
Jun 9, 2024
Merged

Conversation

Andrew-S-Rosen
Copy link
Member

@Andrew-S-Rosen Andrew-S-Rosen commented Jun 8, 2024

Broader context: This PR basically impacts nobody and is just a marginally safer way to index the MSONAtoms info key when parsing the dictionary representation.

Technical details: As noted by @samblau, if for some reason your MSONAtoms.as_dict() representation no longer has an atoms_info key, then doing MSONAtoms.from_dict() will crash. In virtually all cases, the user will have an atoms_info key, but it's pretty trivial to fix this by doing .get(dct["atoms_info"], {}) instead of dct["atoms_info"], so I've done that here.

Broader context: This PR basically impacts nobody and is just a marginally safer way to index the `MSONAtoms` info key in the output dictionary.

Technical details: As noted by @samblau, if for some reason your `MSONAtoms.as_dict()` representation no longer has an `atoms_info` key, then doing `MSONAtoms.from_dict()` will crash. In virtually all cases, the user will have an `atoms_info` key, but it's pretty trivial to fix this by doing `.get(dct["atoms_info"], {})` instead of `dct["atoms_info"]`, so I've done that here.

Signed-off-by: Andrew S. Rosen <asrosen93@gmail.com>
@Andrew-S-Rosen
Copy link
Member Author

Will re-open if needed.

@janosh
Copy link
Member

janosh commented Jun 8, 2024

how come it's no longer needed? seems like a sensible change

@janosh janosh added ase Atomic simulation environment invalid User error/mistake serialization Data/object serialization labels Jun 8, 2024
@Andrew-S-Rosen Andrew-S-Rosen reopened this Jun 9, 2024
@Andrew-S-Rosen
Copy link
Member Author

Feel free to merge. I was indifferent.

@janosh janosh merged commit 024fce1 into master Jun 9, 2024
65 checks passed
@janosh janosh deleted the Andrew-S-Rosen-patch-1 branch June 9, 2024 01:22
@janosh
Copy link
Member

janosh commented Jun 9, 2024

i guess i'm still missing something. if it avoids an error that occurred in practice for @samblau, it's a keeper, no?

@samblau
Copy link
Contributor

samblau commented Jun 9, 2024

I only encountered this error because I was dealing with task docs from an older version of QuAcc... this shouldn't be a common scenario. But it still seems better to have it than not.

@janosh janosh added fix Bug fix PRs and removed invalid User error/mistake labels Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ase Atomic simulation environment fix Bug fix PRs serialization Data/object serialization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants