Skip to content

Commit 0499d0a

Browse files
committed
update docs
1 parent 6e2ea3f commit 0499d0a

File tree

3 files changed

+58
-9
lines changed

3 files changed

+58
-9
lines changed

Diff for: docs/source/development/plugin.rst

+29-1
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,42 @@ feed the `metadata` of each Calcjob which is submitted in the workchain. For exa
255255
set_component_resources(builder.pw, codes.get("pw"))
256256
257257
This function can and should be adapted for each plugin specific case.
258-
Then add the workchain and builder into the `workchain_and_builder` dict, so that the QuantumESPRESSO app can load them.
258+
259+
260+
The `update_inputs` function is used to update the inputs of the builder using the context.
261+
In most of the cases, you will need to update the structure of the builder to used the relaxed structure from the previous calculation.
262+
263+
.. code-block:: python
264+
265+
def update_inputs(inputs, ctx):
266+
"""Update the inputs using context."""
267+
inputs.structure = ctx.current_structure
268+
269+
Additionaly, you could provide a ``get_workchain_metadata`` function to tell the app how many calcjobs (estimation) will be submitted in the workchain.
270+
This is useful to show the progress in the workflow.
271+
272+
273+
.. code-block:: python
274+
275+
def get_workchain_metadata(codes: dict | None = None,
276+
structure: orm.StructureData | None = None,
277+
parameters: dict | None = None,
278+
**kwargs):
279+
"""Return the metadata for the workchain."""
280+
return {"dynamic": False,
281+
"number_of_calcjob": 4,
282+
}
283+
284+
Then add the above function into the `workchain_and_builder` dict, so that the QuantumESPRESSO app can load them.
259285

260286
.. code-block:: python
261287
262288
# register the workchain and builder
263289
workchain_and_builder = {
264290
"workchain": EOSWorkChain,
265291
"get_builder": get_builder,
292+
"update_inputs": update_inputs,
293+
"get_workchain_metadata": get_workchain_metadata,
266294
}
267295
268296
Entry point

Diff for: src/aiidalab_qe/plugins/bands/workchain.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
from aiida import orm
14
from aiida.plugins import WorkflowFactory
25
from aiida_quantumespresso.common.types import ElectronicType, SpinType
36
from aiidalab_qe.utils import (
@@ -98,11 +101,19 @@ def update_inputs(inputs, ctx):
98101
"""Update the inputs using context."""
99102
inputs.structure = ctx.current_structure
100103

101-
def get_workchain_metadata(parameters: dict):
104+
105+
def get_workchain_metadata(
106+
codes: dict | None = None,
107+
structure: orm.StructureData | None = None,
108+
parameters: dict | None = None,
109+
**kwargs,
110+
):
102111
"""Return the metadata for the workchain."""
103-
return {"dynamic": False,
104-
"number_of_calcjob": 2,
105-
}
112+
return {
113+
"dynamic": False,
114+
"number_of_calcjob": 2,
115+
}
116+
106117

107118
workchain_and_builder = {
108119
"workchain": BandsWorkChain,

Diff for: src/aiidalab_qe/plugins/pdos/workchain.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from aiida import orm
24
from aiida.plugins import WorkflowFactory
35
from aiida_quantumespresso.common.types import ElectronicType, SpinType
@@ -137,11 +139,19 @@ def update_inputs(inputs, ctx):
137139
"""Update the inputs using context."""
138140
inputs.structure = ctx.current_structure
139141

140-
def get_workchain_metadata(parameters: dict):
142+
143+
def get_workchain_metadata(
144+
codes: dict | None = None,
145+
structure: orm.StructureData | None = None,
146+
parameters: dict | None = None,
147+
**kwargs,
148+
):
141149
"""Return the metadata for the workchain."""
142-
return {"dynamic": False,
143-
"number_of_calcjob": 4,
144-
}
150+
return {
151+
"dynamic": False,
152+
"number_of_calcjob": 4,
153+
}
154+
145155

146156
workchain_and_builder = {
147157
"workchain": PdosWorkChain,

0 commit comments

Comments
 (0)