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
Copy file name to clipboardExpand all lines: docs/core.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ This example data has been pre-uploaded and published on NOMAD. Go to the [examp
101
101
102
102
Create a workspace folder for this tutorial, e.g., `workspace_nomad_tutorial_workflows/`, and then move the downloaded zip to this folder. We suggest also creating sub-folders `Part-1`-`Part-4` for organizational purposes.
103
103
104
-
Now go to the [Test NOMAD Deployment](https://nomad-lab.eu/prod/v1/test/gui/search/entries){:target="\_blank"}.
104
+
**Now go to the [Test NOMAD Deployment](https://nomad-lab.eu/prod/v1/test/gui/search/entries){:target="\_blank"}.**
105
105
106
106
!!! warning "Attention"
107
107
@@ -147,6 +147,10 @@ We will need both the `upload_id` and the `entry_id` for this entry later. Copy
Copy file name to clipboardExpand all lines: docs/custom.md
+28-66Lines changed: 28 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@
3
3
## 🎯 What You Will Learn
4
4
5
5
- How to store data that is **not supported by existing NOMAD parsers**
6
-
- How to define a custom **YAML schema**
7
6
- How to use the **NOMAD ELN (Electronic Lab Notebook)** interface
8
-
- How to connect these custom entries into a workflow graph
7
+
- How to annotate and reference files as part of a workflow
8
+
- How to connect entries into a workflow graph
9
9
10
10
---
11
11
@@ -79,87 +79,36 @@ Uploading this yaml to the test deployment results in an entry with the overview
79
79
</label>
80
80
</div>
81
81
82
-
## Customizing the schema
83
-
84
-
To document our simulation setup workflow, we need to reference files within our ELN entry. For standardization and search capabilities, it is best practice to use existing classes in the MetaInfo. However, NOMAD also allows users to customize the schema to their own specific needs. Let's create our own schema to store annotated files within an ELN.
85
-
86
-
!!! warning "Attention"
87
-
Understanding the details of the customized schema below is beyond the scope of this tutorial, and is not necessarily the adviced route for the most robust customization. The important take away is that you can in principal create you own schema. In this case we have done so to enable storage of annotated files.
88
-
89
-
Create a file `ELNFiles.archive.yaml` with the following contents:
90
-
91
-
<h4><code>ELNFiles.archive.yaml</code></h4>
92
-
```yaml
93
-
definitions: # Use the defintions section to create your schema
94
-
name: 'ELN-Annotated-File-List'
95
-
sections:
96
-
AnnotatedFile: # A subsection for storing an annotated file
97
-
m_annotations:
98
-
eln:
99
-
overview: True # Displays this quantity in the overview page of the entry
100
-
quantities:
101
-
file: # a quantity for storing the actualy file reference
102
-
type: str
103
-
description: single workflow files
104
-
m_annotations:
105
-
browser:
106
-
adaptor: RawFileAdaptor # Allows to navigate to files in the data browser
107
-
eln:
108
-
component: FileEditQuantity # Allows editing with the GUI
109
-
description: # a quantity for storing the annotation
110
-
type: str
111
-
description: describe the file
112
-
m_annotations:
113
-
eln:
114
-
component: StringEditQuantity # Allows editing within the GUI
115
-
ELNAnnotatedFiles: # Define a subsection for storing files
116
-
base_sections:
117
-
- 'nomad.datamodel.metainfo.eln.ElnBaseSection' # inherits from the basic ELN class
118
-
- 'nomad.datamodel.data.EntryData' # necessary when a class will be the root of our archive
119
-
m_annotations:
120
-
eln:
121
-
hide: ['lab_id'] # hides the lab_id quantity that we will not use
122
-
sub_sections:
123
-
Files:
124
-
repeats: True # makes the subsection repeating (i.e., a list)
125
-
section: '#/AnnotatedFile' # this subsection will include the quantities defined within the `AnnotedFile` class defined above
126
-
```
127
-
128
-
The section `AnnotationFile` contains 2 quantities `file` and `description` for storing a file reference and annotation, respectively. The section `ELNAnnotatedFiles` extends the most basic ELN implementation (`ElnBaseSection`) with a repeating subsection of type `AnnotatedFile`. In this way, our ELN will be able to store a list of annotated files.
129
-
130
-
??? tip "More on custom schemas"
131
-
132
-
The YAML approach is a quick and dirty way to customize your NOMAD entries.
133
-
To disincentivise the proliferation of _ad-hoc_ schemas and remain FAIR, YAML sections or quantities only have partial support.
134
-
Seamless integration of new quantities happens when schemas are organized in **plugins** (python packages) and installed in NOMAD during deployment.
135
-
See [NOMAD Docs > How to write a YAML schema package](https://nomad-lab.eu/prod/v1/test/docs/howto/customization/basics.html){:target="_blank"} for more details about defining custom schemas in this way.
82
+
## The `ELNFileManager`
136
83
137
-
The more robust and powerful approach for creating custom schemas is to create a *schema plugin* (see [NOMAD Docs > How to get started with plugins](https://nomad-lab.eu/prod/v1/test/docs/howto/plugins/plugins.html){:target="_blank"}).
84
+
`ELNFileManager`is a built-in schema for referencing and annotating files within an ELN entry. You can create an `ELNFileManager` either from the GUI or via the YAML approach, in the same ways as described above.
138
85
139
-
Useful resources for plugin developers are the [Plugin Template](https://github.com/FAIRmat-NFDI/nomad-plugin-template) and the [NOMAD Distro Template](https://github.com/FAIRmat-NFDI/nomad-distro-template).
140
-
141
-
We can now use these definitions to create an entry file for the step of creating the force field file (as illustrated in the image above):
86
+
We can now use these definitions to create an entry file for the step of creating the force field, and link to the output force field file from this step in the workflow:
description: 'The force field is defined for input to the MD simulation engine.'
149
94
Files:
150
95
- file: 'Custom_ELN_Entries/water.top'
151
96
description: 'The force field file for simulation input.'
152
97
```
153
98
154
-
Here we define the data section using our `ELNFiles.archive.yaml` schema. The given path is a relative path assuming that we will upload these 2 files (i.e., `ELNFiles.archive.yaml` and `create_force_field.archive.yaml`) within the same upload with a root folder called `Custom_ELN_Entries`.
99
+
Uploading to NOMAD should result in the following entry display:
You can now create analogous files `create_box.archive.yaml`, `insert_water.archive.yaml`, `workflow_parameters.archive.yaml`, `workflow_scripts.archive.yaml`:
description: 'All the scripts run during setup of the MD simulation.'
198
147
Files:
@@ -202,9 +151,22 @@ You can now create analogous files `create_box.archive.yaml`, `insert_water.arch
202
151
description: 'Creates the appropriate force field files for the simulation engine.'
203
152
```
204
153
154
+
## Customizing the schema
155
+
156
+
For standardization and search capabilities, it is best practice to use existing classes in the MetaInfo. However, NOMAD also allows users to customize the schema to their own specific needs. For example, you can customize one of the existing ELN schemas by adding specific sections and quantities relevant for your use case.
157
+
158
+
Customization of schemas is beyond the scope of the present tutorial, however, the tip box below will direct you to further resources if you are interested in learning more.
159
+
160
+
??? tip "Customizing the schema"
161
+
Schema customization can be achieved via 2 approaches:
162
+
163
+
1. By including a `YAML`-based schema alongside your `YAML` entry file: This is a quick and dirty way to customize your NOMAD entries, and only provides partial support in terms of, e.g., search capabilities. See [NOMAD Docs > How to write a YAML schema package](https://nomad-lab.eu/prod/v1/test/docs/howto/customization/basics.html){:target="_blank"}.
164
+
165
+
2. By creating a *schema plugin*: This more robust and powerful approach integrates your new schema into NOMAD via python class definitions See [NOMAD Docs > How to get started with plugins](https://nomad-lab.eu/prod/v1/test/docs/howto/plugins/plugins.html){:target="_blank"}. The following tools are available to assist in plugin creation and development: [Plugin Template](https://github.com/FAIRmat-NFDI/nomad-plugin-template); [NOMAD Distro Template](https://github.com/FAIRmat-NFDI/nomad-distro-template).
166
+
205
167
## Creating a custom workflow in NOMAD
206
168
207
-
NOMAD allows users to connect entries into a workflow, i.e., a directed graph structure. This is achieved using the same parsing functionality as demonstrated with the custom schemas above. In this case, we simply populate the `workflow2` section instead of the `data` section. When uploaded to NOMAD, a new _workflow_ entry will be created, with references to each of the workflow tasks, and also an interactive workflow graph for easy navigation of the entire workflow. Learn more about the [archive file structure](https://nomad-lab.eu/prod/v1/test/docs/explanation/data.html#archive-files-a-shared-entry-structure) in the official NOMAD documentation.
169
+
NOMAD allows users to connect entries into a workflow, i.e., a directed graph structure. This is achieved using the same parsing functionality as demonstrated with the custom schemas above. In this case, we simply populate the `workflow2` section instead of the `data` section. When uploaded to NOMAD, a new _workflow_ entry will be created, with references to each of the workflow tasks, and also an interactive workflow graph for easy navigation of the entire workflow.
208
170
209
171
Let's construct this workflow yaml piece by piece, starting with the section definition and global inputs/outputs:
Copy file name to clipboardExpand all lines: docs/workflows.md
+21-22Lines changed: 21 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,7 +186,7 @@ import networkx as nx
186
186
from nomad_utility_workflows.utils.workflows import (
187
187
NodeAttributes,
188
188
NodeAttributesUniverse,
189
-
build_nomad_workflow,
189
+
NomadWorkflow
190
190
nodes_to_graph,
191
191
)
192
192
```
@@ -316,34 +316,21 @@ gv.d3(
316
316
</label>
317
317
</div>
318
318
319
-
## Generate the workflow yaml
319
+
## Filling the workflow graph with default connections
320
320
321
-
First designate the full path and filename for your YAML and a name for your workflow:
321
+
Before creating the workflow YAML, `nomad-utility-workflows` will fill the workflow graph generated in the previous step with certain "default" connections (i.e., inputs and outputs) based on the types of nodes in the workflow. This happens automatically upon instantiation of the `NomadWorkflow` class:
The workflow name will show up on top of the workflow graph visualization on the overview page of the workflow entry that we will create.
331
-
332
-
We can now use the generated graph to create the workflow YAML using the `build_nomad_workflow()` function:
333
-
334
-
```
335
-
workflow_graph_output = build_nomad_workflow(
336
-
workflow_metadata=workflow_metadata,
337
-
workflow_graph=nx.DiGraph(workflow_graph_input),
338
-
write_to_yaml=True,
324
+
nomad_workflow = NomadWorkflow(
325
+
workflow_graph=workflow_graph_input,
339
326
)
340
327
```
341
328
342
-
Another workflow graph is returned by this function:
329
+
Here, we create a `NomadWorkflow` using the workflow graph generated in the previous step. The resulting "filled" workflow graph can be visualized with:
343
330
344
-
```python
331
+
```javascript
345
332
gv.d3(
346
-
workflow_graph_output,
333
+
nomad_workflow.workflow_graph,
347
334
node_label_data_source='name',
348
335
edge_label_data_source='name',
349
336
zoom_factor=1.5,
@@ -358,7 +345,19 @@ gv.d3(
358
345
</label>
359
346
</div>
360
347
361
-
We see that our output graph looks signficantly different than the input. That's because `nomad-utility-workflow` is automatically adding some default inputs/outputs to ensure the proper node connections within the workflow visualizer. For nodes without an `entry_type`, these default connections work by simply adding inputs/outputs that point to the mainfile of one of the nodes connected by an edge in the graph.
348
+
We see that our output graph looks signficantly different than the input. The additional inputs/outputs ensure the proper node connections within NOMAD's workflow visualizer. For nodes without an `entry_type`, these default connections work by simply adding inputs/outputs that point to the mainfile of one of the nodes connected by an edge in the graph.
349
+
350
+
## Generating the workflow yaml
351
+
352
+
Finally, we can add some workflow metadata to the [`NomadWorkflow`](../reference/workflows.md#nomadworkflow) (i.e., the filename of the output yaml and the name of the workflow) and generate the workflow YAML file with the class method [`build_workflow_yaml()`](../reference/workflows.md#build_workflow_yaml):
0 commit comments