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: README.md
+75-58
Original file line number
Diff line number
Diff line change
@@ -65,9 +65,10 @@ For this example to work, you will need:
65
65
</ul>
66
66
</details>
67
67
68
+
68
69
### Converted Workflow with ZnTrack
69
70
70
-
To make this workflow reproducible, we convert it into a graph structure:
71
+
To make this workflow reproducible, we convert it into a **directed graph structure** where each step is represented as a **Node**. Nodes define their inputs, outputs, and the computational logic to execute. Here's the graph structure for our example:
Within ZnTrack, each Node is defined by a class. The class attributes define the
82
-
inputs and outputs for each Node, while the `run` method provides the actual
83
-
code that will be executed at runtime.
82
+
In ZnTrack, each **Node** is defined as a Python class. The class attributes define the **inputs** (parameters and dependencies) and **outputs**, while the `run` method contains the computational logic to be executed.
84
83
85
-
> [INFO] ZnTrack uses Python dataclasses under the hood to provide you with an
86
-
> automatic `__init__`. Starting from Python 3.11 most IDEs should also reliably
87
-
> provide type hints for ZnTrack nodes.
84
+
> [!NOTE]
85
+
> ZnTrack uses Python dataclasses under the hood, providing an automatic `__init__` method. Starting from Python 3.11, most IDEs should reliably provide type hints for ZnTrack Nodes.
88
86
89
-
> [NOTE] For files produces during the `run`, ZnTrack provides a unique node
90
-
> working directort (`zntrack.nwd`) which should be used to store files within.
87
+
> [!TIP]
88
+
> For files produced during the `run` method, ZnTrack provides a unique **Node Working Directory**(`zntrack.nwd`). Always use this directory to store files to ensure reproducibility and avoid conflicts.
91
89
92
90
```python
93
91
import zntrack
94
92
import ase.io
95
93
from pathlib import Path
96
94
97
95
classSmiles2Conformers(zntrack.Node):
98
-
smiles: str= zntrack.params() # a required parameter
withself.state.fs.open(self.frames_path, "r") as f: # we use the node state filesystem to read the Node to enable automatic data download and comparison of results. This will become important later.
109
+
# Load the frames from the output file using the node's filesystem
110
+
withself.state.fs.open(self.frames_path, "r") as f:
110
111
returnlist(ase.io.iread(f, ":", format="extxyz"))
111
112
112
113
113
114
classPack(zntrack.Node):
114
-
data: list[list[ase.Atoms]] = zntrack.deps() # in addition to parameters we can define dependencies as inputs
115
-
counts: list[int] = zntrack.params()
116
-
density: float= zntrack.params()
115
+
data: list[list[ase.Atoms]] = zntrack.deps() # Input dependency (list of ASE Atoms)
116
+
counts: list[int] = zntrack.params()# Parameter (list of counts)
box = Pack(data=[etoh.frames], counts=[32], density=789) # Pack the structures
199
+
optm = StructureOptimization(model=model, data=box.frames, data_id=-1, fmax=0.5) # Optimize the structure
200
+
201
+
# Execute the workflow
202
+
project.repro()
203
+
```
204
+
205
+
> **TIP**
206
+
> If you don’t want to execute the graph immediately, use `project.build()` instead. You can run the graph later using `dvc repro` or the [paraffin](https://github.com/zincware/paraffin) package.
190
207
191
208
#### Accessing Results
192
209
193
-
Once the graph has been executed, the respective files will have been written.
194
-
For example, you could load the `nodes/StructureOptimization/frames.traj`
195
-
trajectory directly from the file path.
210
+
Once the workflow has been executed, the results are stored in the respective files. For example, the optimized trajectory is saved in `nodes/StructureOptimization/frames.traj`.
196
211
197
-
Alternatively, you can load ZnTrack nodes after they have been executed and need
198
-
not to worry about where the file was stored or in which format, because you can
199
-
look at the `list[ase.Atoms]` direclty from within Python by loading the node as
200
-
follows:
212
+
You can load the results directly using ZnTrack, without worrying about file paths or formats:
0 commit comments