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

CLI: filter cutoffs from JSON file for family cutoffs set #132

Merged
merged 2 commits into from
Oct 10, 2022

Conversation

mbercx
Copy link
Member

@mbercx mbercx commented Oct 9, 2022

Fixes #93

Currently the family cutoffs set command requires that the JSON file that contains the cutoffs only has the cutoff keys specified for each element. This is because the cutoffs are validated by the RecommendedCutoffMixin.validate_cutoffs() method, which doesn't allow for extraneous keys.

However, the .json file could have been adapted by the user from e.g. the SSSP metadata.json or some other dictionary that also contains other keys. As long as the cutoff keys are defined, we shouldn't raise an error just because there are other keys present.

Here we first filter the data loaded from the JSON file for the cutoffs, before passing the dictionary to the set_cutoffs method.

@mbercx mbercx requested a review from sphuber October 9, 2022 13:11
@mbercx
Copy link
Member Author

mbercx commented Oct 9, 2022

@sphuber while working myself back into #94 I decided to separate the work into different PR's since not everything is related to the same topic and it'll be easier to rebase/adapt/review.

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @mbercx just some minor comments

src/aiida_pseudo/cli/family.py Outdated Show resolved Hide resolved
tests/cli/test_family.py Outdated Show resolved Hide resolved
src/aiida_pseudo/cli/family.py Show resolved Hide resolved
Currently the `family cutoffs set` command requires that the JSON file
that contains the cutoffs _only_ has the cutoff keys specified for each
element. This is because the cutoffs are validated by the
`RecommendedCutoffMixin.validate_cutoffs()` method, which doesn't allow
for extraneous keys.

However, the  `.json`  file could have been adapted by the user from e.g. the
SSSP `metadata.json` or some other dictionary that also contains other keys.
As long as the cutoff keys are defined, we shouldn't raise an error just because
there are other keys present.

Here we first filter the data loaded from the JSON file for the cutoffs,
before passing the dictionary to the `set_cutoffs` method.
@sphuber sphuber merged commit 5028c9a into aiidateam:master Oct 10, 2022
@sphuber
Copy link
Contributor

sphuber commented Oct 10, 2022

Thanks @mbercx

@mbercx mbercx deleted the fix/93/filter-cutoffs branch October 10, 2022 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: family cutoffs set does not accept SSSP metadata
2 participants