Add a set of click based cli utilities to simplify writing launch scripts#1194
Merged
Merged
Conversation
giovannipizzi
previously approved these changes
Feb 27, 2018
Member
giovannipizzi
left a comment
There was a problem hiding this comment.
Awesome! Could you add some documentation for developers (form the PR message) and convert at least one command to this format, so we have an example of how it works?
Contributor
Author
|
I explicitly did not add documentation here, because I wasn't sure whether this would stay in in this form for a long time, given that Rico would be porting the |
b1fad5f to
69fde3b
Compare
…ipts These utilities simplify the writing of command line interface scripts that are very useful for plugin developers to write launch scripts with minimal effort. It provides a decorator `@command` that will turn a function into a click command that automatically loads the database environment. It also provides various other `@option` like decorators which predefine commonly used input arguments and their validators for AiiDA types such as `Code`, `StructureData` and `Calculation`. For example a minimal script that will take a structure data id and print its cell would look like: # -*- coding: utf-8 -*- import click from aiida.utils.cli import command from aiida.utils.cli import options @options.structure() def launch(structure): click.echo(structure.cell)
69fde3b to
139848f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1193
Note: I know Rico has been working on porting
verditoclickat which point part of this may be tackled, but until that time I really need this functionality in different plugins that is currently included inaiida-quantumespresso.These utilities simplify the writing of command line interface scripts
that are very useful for plugin developers to write launch scripts with
minimal effort. It provides a decorator
@commandthat will turn afunction into a click command that automatically loads the database
environment. It also provides various other
@optionlike decoratorswhich predefine commonly used input arguments and their validators for
AiiDA types such as
Code,StructureDataandCalculation. Forexample a minimal script that will take a structure data id and print
its cell would look like: