Skip to content

Commit

Permalink
Docs: Add links about "entry point" and "plugin" to tutorial (#6095)
Browse files Browse the repository at this point in the history
The tutorial was missing an explanation of where the entry point for the workflow came from, and how users can write their own plugins and make them available via an entry point.

---------

Co-authored-by: Leopold Talirz <leopold.talirz@gmail.com>
Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
  • Loading branch information
3 people authored Aug 19, 2023
1 parent 2a2353d commit 517ffcb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/source/intro/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,22 +501,26 @@ class MultiplyAddWorkChain(WorkChain):
```

:::{note}
Besides WorkChain's, workflows can also be implemented as *work functions*.
Besides WorkChain's, workflows can also be implemented as {ref}`work functions <topics:workflows:concepts:workfunctions>`.
These are ideal for workflows that are not very computationally intensive and can be easily implemented in a Python function.
:::

Let's run the `WorkChain` above!

Start up the `verdi shell` and load the `MultiplyAddWorkChain` using the `WorkflowFactory`:

```{code-cell} ipython3
from aiida import plugins
MultiplyAddWorkChain = plugins.WorkflowFactory('core.arithmetic.multiply_add')
```

The `WorkflowFactory` is a useful and robust tool for loading workflows based on their *entry point*, e.g. `'core.arithmetic.multiply_add'` in this case.
The `WorkflowFactory` loads workflows based on their {ref}`entry point <topics:plugins:entrypoints>`, e.g. `'core.arithmetic.multiply_add'` in this case.
The entry point mechanism allows AiiDA to automatically discover workflows provided by `aiida-core` and {ref}`AiiDA plugins <how-to:plugins-install>`, and display them to the user, e.g. via `verdi plugin list aiida.workflows`. Pass the entry point as an argument to display detailed information, e.g. via `verdi plugin list aiida.workflows core.arithmetic.multiply_add`.

Similar to a `CalcJob`, the `WorkChain` input can be set up using a builder:

```{code-cell} ipython3
from aiida import orm
builder = MultiplyAddWorkChain.get_builder()
builder.code = orm.load_code(label='add')
builder.x = orm.Int(2)
Expand All @@ -528,6 +532,7 @@ builder
Once the `WorkChain` input has been set up, we run it with the AiiDA engine:

```{code-cell} ipython3
from aiida import engine
engine.run(builder)
```

Expand Down

0 comments on commit 517ffcb

Please sign in to comment.