You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some models require additional functionality, particularly in the configuration step (step 2), where many MVC components come together to form the
99
+
UI for specifying both the workflow and its input.
100
+
Each of these is defined as a ``SettingsPanel`` with a corresponding ``SettingsModel``.
101
+
Some of these are defined in the app, such as the basic and advanced settings panels.
102
+
For dedicated calculations (e.g. bands, pdos, xps), they are defined externally as :ref:`plugins <develop:plugins>`.
103
+
104
+
Below are snippets of the ``AdvancedModel`` and ``AdvancedSettings`` classes:
105
+
106
+
.. code:: python
107
+
108
+
classAdvancedModel(
109
+
SettingsModel,
110
+
HasModels[AdvancedSubModel],
111
+
HasInputStructure,
112
+
):
113
+
dependencies = [
114
+
"input_structure",
115
+
"workchain.protocol",
116
+
...
117
+
]
118
+
119
+
protocol = tl.Unicode()
120
+
121
+
kpoints_distance = tl.Float(0.0)
122
+
...
123
+
124
+
self.include =True# includes this model in the configuration step
125
+
126
+
# Optional attributes can be defined here
127
+
self.dftd3_version = {
128
+
...
129
+
}
130
+
131
+
defupdate(self, specific=""):
132
+
# Update the model, optionally limited to a specific scope
133
+
...
134
+
135
+
defget_model_state(self) -> dict:
136
+
# Return the model state as a dictionary
137
+
...
138
+
139
+
defset_model_state(self, parameters: dict):
140
+
# Set the model state from a parameters dictionary
141
+
# Used when loading a previous calculation
142
+
...
143
+
144
+
defreset(self):
145
+
# Reset the model to its defaults
146
+
...
147
+
148
+
Model updates recompute trait defaults w.r.t dependent traits (e.g. input structure, protocol) and update the model's traits to these defaults.
149
+
The defaults are stored in a ``_defaults`` dictionary that is used in ``reset`` to return the model to its *current* defaults.
150
+
The dependencies of a model are defined in the ``dependencies`` list, which is used by in configuration step during plugin discovery to connect the model network.
151
+
The inter-connection of dependency traits forms an **Observer** pattern across the app, with each dependent model receiving notifications of state changes in dependencies.
152
+
When a calculation is submitted, the configuration step will collect the parameters from all *included* models (``include == True``) and pass them to the submit step.
153
+
154
+
.. note:: The basic and advanced models are included by default. Inclusion of installed plugin models is controlled by the user in step 2.1.
155
+
156
+
.. warning:: The ``default_value`` of ``List`` or ``Dict`` traits is not stored by ``traitlets``.
157
+
Instead, explicitly define the defaults to at least ``[]`` or ``{}``, respectively.
.. note:: The generic type ``AdvancedModel`` in ``SettingsPanel[AdvancedModel]`` is used to specify the model type, which is used to infer the type of the model in the class and provide type hinting in modern IDEs.
198
+
199
+
Mixins
200
+
------
201
+
202
+
The ``HasModels`` mixin class inherited by the ``AdvancedModel`` is used to manage sub-models.
203
+
It provides functionality to add, register, and get a sub-model.
204
+
It is presently used by the configuration step to register basic, advanced, and plugin models.
205
+
It is also used by the advanced panel to register the sub-sections of the advanced settings (e.g. magnetization, hubbard, etc.).
206
+
207
+
Other mixins, such as ``HasInputStructure``, provide are trait oriented, providing both the trait and methods to work with it.
208
+
The ``Confirmable`` mixin, for example, provides a ``confirmed`` trait, a ``confirm`` method, and an means of un-confirming on any state change in the inheriting model.
209
+
210
+
.. code:: python
211
+
212
+
classConfirmable(tl.HasTraits):
213
+
confirmed = tl.Bool(False)
214
+
215
+
defconfirm(self):
216
+
self.confirmed =True
217
+
218
+
@tl.observe(tl.All)
219
+
def_on_any_change(self, change):
220
+
if change and change["name"] !="confirmed":
221
+
self._unconfirm()
222
+
223
+
def_unconfirm(self):
224
+
self.confirmed =False
225
+
226
+
App status
227
+
==========
228
+
229
+
To keep track of the status of the app at any given step, a ``state`` trait of a step is linked with the ``previous_step_state`` trait of its following step. A ``SUCCESS`` state is used to auto-proceed to a following step.
Data is passed to the next step by use of ``App``-level controller observations of step (un)confirmation following the **Mediator** pattern, as follows:
243
+
244
+
- Step 1 confirmed -> triggers setting of ``input_structure`` in step 2
245
+
- Step 2 confirmed -> triggers setting of ``input_structure`` and ``input_parameters`` in step 3
246
+
- Step 3 submitted -> triggers setting of ``process.uuid`` in step 4
27
247
28
-
Each step widget can contains several panels. In the configuration step, the parameters from the panels are generated and stored as a dictionary, which is linked to the ``input_parameters`` trait of the next submit step.
29
-
The dictionary has the following structure:
248
+
.. note:: In the observers of step 1 and 2, ``_update_blockers()`` is also triggered to identify any current blockers to submission.
249
+
These blockers are linked with the submission model, which is used to show any submission warnings in step 3.
250
+
251
+
In confirming step 2, the configuration step collects the parameters from all included models and returns them as a dictionary of the following format:
30
252
31
253
.. code:: python
32
254
@@ -55,17 +277,23 @@ The dictionary has the following structure:
55
277
"plugin_2": {...},
56
278
}
57
279
58
-
Plugin
59
-
=========
60
-
QuantumESPRESSO app supports running multiple properties (bands, pdos, etc.) calculations in one app.
61
-
The individual properties to be developed and seamlessly integrated into the QuantumESPRESSO app as plugins. This integration is made possible due to several key aspects:
280
+
.. _develop:plugins:
281
+
282
+
Plugins
283
+
=======
62
284
63
-
- the configuration for a property calculation has its settings unrelated to other properties.
64
-
- the sub-workchain of the properties can be run independently.
65
-
- the analysis of the results of the properties is independent.
0 commit comments