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: add the aiida-pseudo family cutoffs set command #55

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Mar 17, 2021

Fixes #50

This command allows to set recommended cutoffs for a given family. The
cutoffs are specified in a JSON file that is given as an argument and
the stringency is specified through the -s/--stringency option. If the
stringency already exists, it is simply overwritten.

@sphuber sphuber requested a review from mbercx March 17, 2021 13:02
@sphuber sphuber added the pr/blocked PR is blocked by another PR that should be merged first label Mar 17, 2021
@sphuber
Copy link
Contributor Author

sphuber commented Mar 17, 2021

Was wondering if we might need to emit a warning if a stringency is specified that already exists, with the --force option to prevent prompting. A lot more work and not sure if it is really necessary.

@sphuber
Copy link
Contributor Author

sphuber commented Mar 17, 2021

At some point will probably also need a family cutoffs default and family cutoffs list

@sphuber sphuber force-pushed the fix/050/cli-set-recommended-cutoffs branch 2 times, most recently from 6ece23c to eb7c884 Compare March 18, 2021 11:00
@mbercx
Copy link
Member

mbercx commented Apr 8, 2021

Was wondering if we might need to emit a warning if a stringency is specified that already exists, with the --force option to prevent prompting. A lot more work and not sure if it is really necessary.

I'd think someone that goes through the effort of preparing the json file and then specifically writes an already existing stringency knows what they are doing?

Copy link
Member

@mbercx mbercx left a comment

Choose a reason for hiding this comment

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

Thanks @sphuber! Just added a small fix for the command docstring and a question.

One use case I'm still considering is when someone wants to change the cutoffs only for a specific element. This is currently not possible because all the elements need to provided to the set_cutoffs method. However, I can imagine I'm working on a specific class of materials and just want to increase the cutoff for oxygen for example. Would it make sense to allow this in case the stringency specified is already defined, and then just load the cutoffs and override those provided in the JSON by the user?

@options.STRINGENCY(required=True)
@decorators.with_dbenv()
def cmd_family_cutoffs_set(family, cutoffs, stringency):
r"""Set the recommended cutoffs for a pseudo potential family.
Copy link
Member

Choose a reason for hiding this comment

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

The raw format messes up your beautiful formatting 😭

Suggested change
r"""Set the recommended cutoffs for a pseudo potential family.
"""Set the recommended cutoffs for a pseudo potential family.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird, I could have sworn that I added this because without it the \b marker didn't seem to be respected. But indeed, removing it keeps the formatting as intended

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see why, it is pydocstyle that complains about the \b marker saying I should use r when using backslashes. Will try to add an exception


@cmd_family_cutoffs.command('set')
@arguments.PSEUDO_POTENTIAL_FAMILY()
@click.argument('cutoffs', type=click.File(mode='rb'))
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for making the cutoffs an argument and the stringency a required option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, in the current conception. I think originally I intended to allow to specify multiple stringencies at once and then let one define the default. But indeed, now that only on stringency is defined at a time, maybe it makes more sense to specify it as an argument. On the other hand, leaving it like this does make it possible in the future to make the command more flexible and also allow a file with multiple stringencies defined, where the keys are the stringency name. Then it makes more sense to make the default stringency parameter an option and use the first one defined in the file as the default such that the flag becomes optional. Think that is the best option actually thinking about it now

@sphuber sphuber force-pushed the fix/050/cli-set-recommended-cutoffs branch from eb7c884 to beb1ee6 Compare April 9, 2021 06:55
This command allows to set recommended cutoffs for a given family. The
cutoffs are specified in a JSON file that is given as an argument and
the stringency is specified through the `-s/--stringency` option. If the
stringency already exists, it is simply overwritten.
@sphuber sphuber force-pushed the fix/050/cli-set-recommended-cutoffs branch from beb1ee6 to c47c3b2 Compare April 9, 2021 06:56
@sphuber sphuber merged commit c644a94 into master Apr 9, 2021
@sphuber sphuber deleted the fix/050/cli-set-recommended-cutoffs branch April 9, 2021 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/blocked PR is blocked by another PR that should be merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting of recommended cutoff parameters through the CLI
2 participants