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

Docs: Create a new tutorial for first-time users #3981

Closed
mbercx opened this issue Apr 30, 2020 · 1 comment · Fixed by #4070
Closed

Docs: Create a new tutorial for first-time users #3981

mbercx opened this issue Apr 30, 2020 · 1 comment · Fixed by #4070
Assignees
Labels
priority/critical-blocking must be resolved before next release topic/documentation

Comments

@mbercx
Copy link
Member

mbercx commented Apr 30, 2020

Create a short (~30 min) tutorial to give beginning users a first introduction on how to use AiiDA.

@mbercx mbercx self-assigned this Apr 30, 2020
@giovannipizzi
Copy link
Member

Here a possible short code that can be used as CalcJob, avoiding to have to create a custom plugin.

  1. Make sure they start with a localhost computer (probably with direct scheduler and local transport)

  2. Ask them to setup a bash@localhost code (good excuse to explain what a code is), with the following one-liner:

    verdi code setup -L bash -P templatereplacer --on-computer --computer=localhost --remote-abs-path=/bin/bash --non-interactive

    Optionally, you can explain them verdi code list here.

  3. Ask them to run a calculation with the following script:

    from aiida.orm import Dict, load_code
    from aiida.engine import run_get_node
    
    code = load_code('bash@localhost')
    
    builder = code.get_builder()
    builder.parameters = Dict(dict={'x': 3, 'y': 4})
    builder.template = Dict(
        dict={
            'input_file_name': 'script.sh',
            'input_file_template': "echo $(({x} * {y}))",
            'cmdline_params': ['script.sh'],
            'output_file_name': 'stdout.txt'
        }
    )
    builder.metadata.options = {
        'resources': {'num_machines': 1},
        'parser_name': 'templatereplacer.doubler',
    }
    
    results, calcjobnode = run_get_node(builder)
    
    print(calcjobnode.res.value)

Possible things to adapt:

  • define a better parser (e.g. generic.integer_parser, generic.cvs_parser, generic.json_parser) that could become part of AiiDA
  • use print(results['output_parameters'].get_dict()['value']) instead of calcjobnode.res.value (a bit more explicit, but maybe they understand what is going on.
  • should we extend the template_replacer so that if an input_file_template is provided, the input_file_name is set by default (maybe using the metadata option that now AiiDA has), and also the cmdline_params becomes by default just the filename? This would remove two lines from above

We should then think if instead of multiplying two numbers we want to do something more fancy, but the snippet above should be enough to extend the example.

Note also that the advantage of the input parameters dict is that the values can then be queried.
And, even if slightly more complex than the add calculation, this makes it obvious how this can be extended to any code without the need to write any new calculation plugin.

@mbercx mbercx changed the title Create a new tutorial for the revamped documentation Docs: Create a new tutorial for first-time users May 1, 2020
@csadorf csadorf added this to the Publish revised documentation milestone May 6, 2020
@csadorf csadorf added the priority/critical-blocking must be resolved before next release label May 15, 2020
@csadorf csadorf linked a pull request May 20, 2020 that will close this issue
@csadorf csadorf closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/critical-blocking must be resolved before next release topic/documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants