Skip to content

Commit 5329025

Browse files
committed
Changed my mind, changing structure entirely lol
1 parent dec8103 commit 5329025

File tree

17 files changed

+2045
-154
lines changed

17 files changed

+2045
-154
lines changed

docs/conf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@
4646
"sphinx_copybutton",
4747
"sphinx_panels",
4848
]
49+
50+
myst_enable_extensions = [
51+
# "amsmath",
52+
"colon_fence", # Allow ::: to define directives
53+
# "deflist",
54+
# "dollarmath",
55+
# "html_admonition",
56+
# "html_image",
57+
# "linkify",
58+
# "replacements",
59+
# "smartquotes",
60+
# "substitution",
61+
# "tasklist",
62+
]
63+
4964
ipython_mplbackend = ""
5065

5166
copybutton_selector = "div:not(.no-copy)>div.highlight pre"

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ links inside the respective sections.
6161
sections/setup/index
6262
sections/fundamentals/index
6363
sections/calculations/index
64+
sections/data/index
6465
sections/matsci/index

docs/sections/calculations/calcjobs.md

Lines changed: 509 additions & 138 deletions
Large diffs are not rendered by default.
258 KB
Loading

docs/sections/data/groups.md

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
(virtual-intro-data)=
2+
3+
# Working with data and querying your results
4+
5+
In this section of the tutorial we will focus on how to organise and explore the data in an AiiDA database.
6+
As in (**TODO FIX LINK**), we will be using the previously created database entries for this tutorial.
7+
To follow the tutorial then, you can use the profile in to which you have previously imported this data, or you may wish to create a fresh profile and import the archive into that:
8+
9+
```{code-block} console
10+
11+
$ verdi quicksetup --profile data
12+
$ verdi profile setdefault data
13+
$ verdi import https://object.cscs.ch/v1/AUTH_b1d80408b3d340db9f03d373bbde5c1e/marvel-vms/tutorials/aiida_tutorial_2020_07_perovskites_v0.9.aiida
14+
15+
```
16+
17+
## How to group nodes
18+
19+
AiiDA's database is great for automatically storing all your data, but sometimes it can be tricky to navigate this flat data store.
20+
To create some order in this mass of data, you can *group* sets of nodes together, just as you would with files in folders on your filesystem.
21+
Each group instance can hold any amount of nodes and any node can be contained in any number of groups.
22+
A typical use case is to store all nodes that share a common property in a single group.
23+
24+
### Listing existing groups
25+
26+
Lets explore the groups already present in the imported archive:
27+
28+
```{code-block} console
29+
30+
$ verdi group list -a -A
31+
PK Label Type string User
32+
---- --------------- ------------- ---------------
33+
1 tutorial_pbesol core aiida@localhost
34+
2 tutorial_lda core aiida@localhost
35+
3 tutorial_pbe core aiida@localhost
36+
4 GBRV_pbe core.upf aiida@localhost
37+
5 GBRV_pbesol core.upf aiida@localhost
38+
6 GBRV_lda core.upf aiida@localhost
39+
7 20200705-071658 core.import aiida@localhost
40+
41+
```
42+
43+
The default table shows us four pieces of information:
44+
45+
PK
46+
47+
: The Primary Key of the group
48+
49+
Label
50+
51+
: The label by which the group has been named
52+
53+
Type string
54+
55+
: This tells us what "sub-class" of group this is.
56+
Type strings can be used to class certain types of data, for example here we have general groups (`core`), groups containing pseudopotentials (`core.upf`), and an auto-generated group containing the nodes we imported from the archive (`core.import`).
57+
For advanced use, you can create your own group subclass plugins, with specialised methods.
58+
59+
User
60+
61+
: The email of the user that created this group.
62+
63+
:::{tip}
64+
65+
The `-a` and `-A` flags we used above ensure that groups for all type strings and users are shown respectively.
66+
67+
:::
68+
69+
We can then inspect the content of a group by its label (if it is unique) or the PK:
70+
71+
```{code-block} console
72+
73+
$ verdi group show tutorial_pbesol
74+
----------------- ----------------
75+
Group label tutorial_pbesol
76+
Group type_string core
77+
Group description <no description>
78+
----------------- ----------------
79+
# Nodes:
80+
PK Type Created
81+
---- ----------- -----------------
82+
380 CalcJobNode 2078D:17h:46m ago
83+
1273 CalcJobNode 2078D:18h:03m ago
84+
...
85+
86+
```
87+
88+
Conversely, if you want to see all the groups a node belongs to, you can run:
89+
90+
```{code-block} console
91+
92+
$ verdi group list -a -A --node 380
93+
PK Label Type string User
94+
---- --------------- ------------- ---------------
95+
1 tutorial_pbesol core aiida@localhost
96+
7 20200705-071658 core.import aiida@localhost
97+
98+
```
99+
100+
### Creating and manipulating groups
101+
102+
Lets make a new group:
103+
104+
```{code-block} console
105+
106+
$ verdi group create a_group
107+
Success: Group created with PK = 8 and name 'a_group'
108+
109+
```
110+
111+
If we want to change the name of the group at any time:
112+
113+
```{code-block} console
114+
115+
$ verdi group relabel a_group my_group
116+
Success: Label changed to my_group
117+
118+
```
119+
120+
Now we can add one or more nodes to it:
121+
122+
```{code-block} console
123+
124+
$ verdi group add-nodes -G my_group 380 1273
125+
Do you really want to add 2 nodes to Group<my_group>? [y/N]: y
126+
127+
```
128+
129+
We can also copy the nodes from an existing group to another group:
130+
131+
```{code-block} console
132+
133+
$ verdi group copy tutorial_pbesol my_group
134+
Warning: Destination group<my_group> already exists and is not empty.
135+
Do you wish to continue anyway? [y/N]: y
136+
Success: Nodes copied from group<tutorial_pbesol> to group<my_group>
137+
$ verdi group show my_group
138+
----------------- ----------------
139+
Group label my_group
140+
Group type_string core
141+
Group description <no description>
142+
----------------- ----------------
143+
# Nodes:
144+
PK Type Created
145+
---- ----------- -----------------
146+
74 CalcJobNode 2078D:17h:51m ago
147+
76 CalcJobNode 2078D:17h:57m ago
148+
...
149+
150+
```
151+
152+
To remove nodes from the group run:
153+
154+
```{code-block} console
155+
156+
$ verdi group remove-nodes -G my_group 74
157+
Do you really want to remove 1 nodes from Group<my_group>? [y/N]: y
158+
159+
```
160+
161+
and finally to remove the group entirely:
162+
163+
```{code-block} console
164+
165+
$ verdi group delete --clear my_group
166+
Are you sure to delete Group<my_group>? [y/N]: y
167+
Success: Group<my_group> deleted.
168+
169+
```
170+
171+
:::{important}
172+
173+
Any deletion operation related to groups won't affect the nodes themselves.
174+
For example if you delete a group, the nodes that belonged to the group will remain in the database.
175+
The same happens if you remove nodes from the group -- they will remain in the database but won't belong to the group any more.
176+
177+
:::
178+
179+
## Organising groups in hierarchies
180+
181+
Earlier we mentioned that groups are like files in folders on your filesystem.
182+
As with folders and sub-folders then, as the amount of groups we have grows, we may also wish to structure our groups in a hierarchy.
183+
Groups in AiiDA are inherently "flat", in that groups may only contain nodes and not other groups.
184+
However it is possible to construct *virtual* group hierarchies based on delimited group labels, using the `grouppath` utility.
185+
186+
Like folder paths grouppath requires delimitation by `/` (forward slash) characters.
187+
Lets copy and rename the three tutorial groups:
188+
189+
```{code-block} console
190+
191+
$ verdi group copy tutorial_lda tutorial/lda/basic
192+
$ verdi group copy tutorial_pbe tutorial/gga/pbe
193+
$ verdi group copy tutorial_pbesol tutorial/gga/pbesol
194+
195+
```
196+
197+
We can now list the groups in a new way:
198+
199+
```{code-block} console
200+
201+
$ verdi group path ls -l
202+
Path Sub-Groups
203+
--------------- ------------
204+
tutorial 3
205+
tutorial_lda 0
206+
tutorial_pbe 0
207+
tutorial_pbesol 0
208+
209+
```
210+
211+
:::{note}
212+
213+
In the terminal, paths that contain nodes are listed in bold
214+
215+
:::
216+
217+
You can see that the actual groups that we create do not show, only the initial part of the "path", and how many sub-groups that path contains.
218+
We can then step into a path:
219+
220+
```{code-block} console
221+
222+
$ verdi group path ls -l tutorial
223+
Path Sub-Groups
224+
------------ ------------
225+
tutorial/gga 2
226+
tutorial/lda 1
227+
228+
```
229+
230+
This feature is also particularly useful in the verdi shell:
231+
232+
```{code-block} ipython
233+
234+
In [1]: from aiida.tools.groups import GroupPath
235+
In [2]: for subpath in GroupPath("tutorial/gga").walk(return_virtual=False):
236+
...: print(subpath.get_group())
237+
...:
238+
"tutorial/gga/pbesol" [type core], of user aiida@localhost
239+
"tutorial/gga/pbe" [type core], of user aiida@localhost
240+
241+
```
242+
243+
:::{seealso}
244+
245+
Please see the {ref}`corresponding section in the documentation <aiida:how-to:data:organize>` for more details on groups and how to use them.
246+
247+
:::

docs/sections/data/index.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Data
2+
====
3+
4+
.. rst-class:: header-text
5+
6+
In this section you can find modules that explain how to work with data in AiiDA.
7+
This includes how to organise data, look for data and back up your data.
8+
9+
.. panels::
10+
:header: header-text
11+
:body: bg-light
12+
:footer: bg-light border-0
13+
14+
------
15+
:column: col-lg-6
16+
17+
.. link-button:: groups
18+
:type: ref
19+
:text: Groups
20+
:classes: btn-light text-left stretched-link font-weight-bold
21+
^^^^^^^^
22+
23+
This module teaches you how to organise your data in Groups.
24+
25+
+++
26+
.. list-table::
27+
:widths: 50 50
28+
:class: footer-table
29+
:header-rows: 0
30+
31+
* - |time| 15 min
32+
- Basic
33+
34+
---
35+
:column: col-lg-6
36+
37+
.. link-button:: querying
38+
:type: ref
39+
:text: Querying for data
40+
:classes: btn-light text-left stretched-link font-weight-bold
41+
^^^^^^^^^^^^
42+
43+
Here you can learn all about how to look - or query - for your data using the `QueryBuilder`.
44+
45+
+++++++++++++
46+
.. list-table::
47+
:widths: 50 50
48+
:class: footer-table
49+
:header-rows: 0
50+
51+
* - |time| 20 min
52+
- Intermediate
53+
54+
.. toctree::
55+
:hidden:
56+
57+
groups
58+
querying

0 commit comments

Comments
 (0)