diff --git a/aiida_workgraph/node.py b/aiida_workgraph/node.py
index 22f466f2..fcbb2875 100644
--- a/aiida_workgraph/node.py
+++ b/aiida_workgraph/node.py
@@ -111,3 +111,8 @@ def _repr_mimebundle_(self, *args: Any, **kwargs: Any) -> any:
return self._widget._repr_mimebundle_(*args, **kwargs)
else:
return self._widget._ipython_display_(*args, **kwargs)
+
+ def to_html(self, output: str = None, **kwargs):
+ """Write a standalone html file to visualize the node."""
+ self._widget.from_node(self)
+ return self._widget.to_html(output=output, **kwargs)
diff --git a/aiida_workgraph/widget/src/widget/__init__.py b/aiida_workgraph/widget/src/widget/__init__.py
index e86ed6ce..05a02b21 100644
--- a/aiida_workgraph/widget/src/widget/__init__.py
+++ b/aiida_workgraph/widget/src/widget/__init__.py
@@ -44,9 +44,25 @@ def from_node(self, node: Any) -> None:
ndata.pop("node_class", None)
ndata.pop("process", None)
ndata["label"] = ndata["metadata"]["identifier"]
- wgdata = {"nodes": {node.name: ndata}, "links": []}
+ wgdata = {"name": node.name, "nodes": {node.name: ndata}, "links": []}
self.value = wgdata
+ def to_html(self, output: str = None, width: str = "100%", height: str = "600px"):
+ """Write a standalone html file to visualize the workgraph."""
+ from IPython.display import IFrame
+ from .html_template import html_template
+ import json
+
+ if output is None:
+ output = f"{self.value['name']}.html"
+ # Replace the placeholder with the actual workgraphData
+ html_content = html_template.replace(
+ "__WORKGRAPH_DATA__", json.dumps(self.value)
+ )
+ with open(output, "w") as f:
+ f.write(html_content)
+ return IFrame(output, width=width, height=height)
+
@traitlets.observe("positions")
def _observe_positions(self, change: Dict[str, Any]) -> None:
if not self.parent:
diff --git a/aiida_workgraph/widget/src/widget/html_template.py b/aiida_workgraph/widget/src/widget/html_template.py
new file mode 100644
index 00000000..815c5914
--- /dev/null
+++ b/aiida_workgraph/widget/src/widget/html_template.py
@@ -0,0 +1,244 @@
+html_template = """
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+"""
diff --git a/aiida_workgraph/workgraph.py b/aiida_workgraph/workgraph.py
index 1cba5518..3e2847a9 100644
--- a/aiida_workgraph/workgraph.py
+++ b/aiida_workgraph/workgraph.py
@@ -381,3 +381,8 @@ def _repr_mimebundle_(self, *args, **kwargs):
return self._widget._repr_mimebundle_(*args, **kwargs)
else:
return self._widget._ipython_display_(*args, **kwargs)
+
+ def to_html(self, output: str = None, **kwargs):
+ """Write a standalone html file to visualize the workgraph."""
+ self._widget.from_workgraph(self)
+ return self._widget.to_html(output=output, **kwargs)
diff --git a/docs/source/add0.html b/docs/source/add0.html
new file mode 100644
index 00000000..a0cfed4c
--- /dev/null
+++ b/docs/source/add0.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/atomization_energy.html b/docs/source/atomization_energy.html
new file mode 100644
index 00000000..1cddfd75
--- /dev/null
+++ b/docs/source/atomization_energy.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 31f336fb..9fc5f5f4 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -12,6 +12,8 @@
#
import os
import sys
+import shutil
+from pathlib import Path
sys.path.insert(0, os.path.abspath("../.."))
@@ -61,3 +63,22 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
+
+
+# Function to copy HTML files
+def copy_html_files(src, dst):
+ """
+ Copy all .html files from src to dst, maintaining the directory structure.
+ """
+ src_path = Path(src)
+ for html_file in src_path.rglob("*.html"):
+ relative_path = html_file.relative_to(src_path)
+ destination_file = Path(dst) / relative_path
+ destination_file.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy(html_file, destination_file)
+
+
+def setup(app):
+ app.connect(
+ "build-finished", lambda app, exception: copy_html_files("source", app.outdir)
+ )
diff --git a/docs/source/eos.html b/docs/source/eos.html
new file mode 100644
index 00000000..8d9a039c
--- /dev/null
+++ b/docs/source/eos.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/first_workflow.html b/docs/source/first_workflow.html
new file mode 100644
index 00000000..1e9ee8df
--- /dev/null
+++ b/docs/source/first_workflow.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/howto/Electronic Structure.html b/docs/source/howto/Electronic Structure.html
new file mode 100644
index 00000000..42694b26
--- /dev/null
+++ b/docs/source/howto/Electronic Structure.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/howto/WorkGraph.html b/docs/source/howto/WorkGraph.html
new file mode 100644
index 00000000..911d6018
--- /dev/null
+++ b/docs/source/howto/WorkGraph.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/howto/combine_workgraph.ipynb b/docs/source/howto/combine_workgraph.ipynb
index 56eb9f70..e0f26cf2 100644
--- a/docs/source/howto/combine_workgraph.ipynb
+++ b/docs/source/howto/combine_workgraph.ipynb
@@ -17,25 +17,17 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"id": "c6b83fb5",
"metadata": {},
"outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The aiida extension is already loaded. To reload it, use:\n",
- " %reload_ext aiida\n"
- ]
- },
{
"data": {
"text/plain": [
"Profile"
]
},
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
@@ -59,22 +51,29 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"id": "1d04eea7",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "74b0cc0818d145bbb4fd2da7c5209538",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…"
+ ""
]
},
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
@@ -85,7 +84,7 @@
"load_profile()\n",
"\n",
"bands_wg = bands_workgraph(run_relax=False)\n",
- "bands_wg"
+ "bands_wg.to_html()"
]
},
{
@@ -98,22 +97,29 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 3,
"id": "16c26bd4",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "38ac0d9eaaf544ee81368640cbcde0cb",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…"
+ ""
]
},
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -121,7 +127,7 @@
"source": [
"from workgraph_collections.qe.pdos import pdos_workgraph\n",
"pdos_wg = pdos_workgraph(run_scf=True)\n",
- "pdos_wg"
+ "pdos_wg.to_html()"
]
},
{
@@ -143,9 +149,9 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "af256013c6324e96bf06dfc8c7d318c4",
+ "model_id": "2d414ff5308d4ae3bcdda49cc1cb3248",
"version_major": 2,
- "version_minor": 0
+ "version_minor": 1
},
"text/plain": [
"NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'Electro…"
@@ -186,13 +192,20 @@
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "af256013c6324e96bf06dfc8c7d318c4",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(positions={'relax': [30, 30]}, settings={'minimap': True}, style={'width': '90%', 'height': '6…"
+ ""
]
},
"execution_count": 6,
@@ -207,7 +220,7 @@
"# adjust the links\n",
"wg.links.new(relax_node.outputs['output_structure'], wg.nodes['bands_scf'].inputs['pw.structure'])\n",
"wg.links.new(relax_node.outputs['output_structure'], wg.nodes['pdos_scf'].inputs['pw.structure'])\n",
- "wg"
+ "wg.to_html()"
]
},
{
@@ -228,13 +241,20 @@
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "677a83d3198041dd998b63802aeaf66b",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'Electro…"
+ ""
]
},
"execution_count": 7,
@@ -249,7 +269,7 @@
"pdos_job = wg.nodes.new(pdos_workgraph, name='pdos_group')\n",
"wg.links.new(relax_node.outputs['output_structure'], bands_job.inputs['structure'])\n",
"wg.links.new(relax_node.outputs['output_structure'], pdos_job.inputs['structure'])\n",
- "wg"
+ "wg.to_html()"
]
},
{
diff --git a/docs/source/if_node.html b/docs/source/if_node.html
new file mode 100644
index 00000000..acfbda09
--- /dev/null
+++ b/docs/source/if_node.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/quick_start.ipynb b/docs/source/quick_start.ipynb
index 8d319b74..e9d3240f 100644
--- a/docs/source/quick_start.ipynb
+++ b/docs/source/quick_start.ipynb
@@ -71,26 +71,10 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 8,
"id": "11e3bca1-dda6-44e9-9585-54feeda7e7db",
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e6cc9bc2e73949d0bc7d26ad9fce8319",
- "version_major": 2,
- "version_minor": 1
- },
- "text/plain": [
- "NodeGraphWidget(settings={'minmap': False}, style={'width': '80%', 'height': '600px'}, value={'nodes': {'add0'…"
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from aiida_workgraph import node\n",
"\n",
@@ -102,10 +86,7 @@
"# define multiply node\n",
"@node.calcfunction()\n",
"def multiply(x, y):\n",
- " return x*y\n",
- "\n",
- "# visualize the node in Jupiter-notebook\n",
- "add.node()"
+ " return x*y\n"
]
},
{
@@ -115,28 +96,65 @@
"source": [
"\n",
"#### Visualize the node\n",
- "If you are running in a Jupiter notebook, you can visualize the node.\n",
- "
\n",
+ "If you are running in a Jupiter notebook, you can visualize the node by adding the following code to the last line of the cell:\n",
"\n",
- "\n",
- "The input sockets are generated automatically based on the function arguments. The default name of the output socket is `result`. There are also some built-in sockets for all nodes, like `_wait` and `_outputs`. In case of `calcfunction`, it also has several built-in sockets, such as `metadata`. One can also create a node instance and inpsect its inputs and outputs:"
+ "```python\n",
+ "add.node()\n",
+ "```\n"
]
},
{
"cell_type": "code",
- "execution_count": 3,
- "id": "13adc082",
+ "execution_count": 9,
+ "id": "b6eb5dad",
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Inputs: ['metadata', 'metadata.store_provenance', 'metadata.description', 'metadata.label', 'metadata.call_link_label', 'x', 'y', '_wait']\n",
- "Outputs: ['result', '_outputs', '_wait']\n"
- ]
+ "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
+ "source": [
+ "\n",
+ "# export the node to html file so that it can be visualized in a browser\n",
+ "add.node().to_html()\n",
+ "\n",
+ "# visualize the node in jupyter-notebook\n",
+ "# add.node()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e99dbcb5",
+ "metadata": {},
+ "source": [
+ "The input sockets are generated automatically based on the function arguments. The default name of the output socket is `result`. There are also some built-in sockets for all nodes, like `_wait` and `_outputs`. In case of `calcfunction`, it also has several built-in sockets, such as `metadata`. One can also create a node instance and inpsect its inputs and outputs:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "13adc082",
+ "metadata": {},
+ "outputs": [],
"source": [
"add1 = add.node()\n",
"print(\"Inputs:\", add1.inputs.keys())\n",
@@ -154,19 +172,10 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"id": "eef6b12f",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Inputs: ['metadata', 'metadata.store_provenance', 'metadata.description', 'metadata.label', 'metadata.call_link_label', 'x', 'y', '_wait']\n",
- "Outputs: ['sum', 'difference', '_outputs', '_wait']\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# define add calcfunction node\n",
"@node.calcfunction(outputs=[[\"General\", \"sum\"],\n",
@@ -200,29 +209,38 @@
"\n",
"\n",
"#### Visualize the workgraph\n",
- "If you are running in a Jupiter notebook, you can visualize the workgraph.\n",
+ "If you are running in a Jupiter notebook, you can visualize the workgraph by adding the following code to the last line of the cell:\n",
"\n",
- "
"
+ "```python\n",
+ "wg\n",
+ "```\n"
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 3,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "416be46a0f83461c91b4da034ec9cca1",
- "version_major": 2,
- "version_minor": 1
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'first_w…"
+ ""
]
},
- "execution_count": 5,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -236,8 +254,10 @@
"wg.nodes.new(multiply, name=\"multiply\", y=Int(4.0))\n",
"wg.links.new(wg.nodes[\"add\"].outputs[0], wg.nodes[\"multiply\"].inputs[\"x\"])\n",
"\n",
- "# visualize the workgraph\n",
- "wg"
+ "# export the workgraph to html file so that it can be visualized in a browser\n",
+ "wg.to_html()\n",
+ "# visualize the workgraph in jupyter-notebook\n",
+ "# wg"
]
},
{
@@ -250,21 +270,10 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"id": "9ebf35aa",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WorkGraph node created, PK: 44955\n",
- "State of WorkGraph: FINISHED\n",
- "Result of add : uuid: bf5b9b9a-e35b-453d-818e-9e9e18446c6e (pk: 44957) value: 5\n",
- "Result of multiply : uuid: 7e58fd41-80d4-472a-b9bf-691674c621ea (pk: 44959) value: 20\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"wg.submit(wait=True)\n",
"\n",
@@ -283,167 +292,10 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"id": "0060e380",
"metadata": {},
- "outputs": [
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 7,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from aiida_workgraph.utils import generate_node_graph\n",
"generate_node_graph(wg.pk)"
@@ -462,22 +314,29 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 12,
"id": "f57573bd",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "8f2dc9d226ff4246a9a8a60a7edff0cf",
- "version_major": 2,
- "version_minor": 1
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'first_w…"
+ ""
]
},
- "execution_count": 16,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -495,10 +354,14 @@
"def multiply(x, y):\n",
" return x*y\n",
"\n",
- "wg = WorkGraph(\"first_workflow\")\n",
+ "wg = WorkGraph(\"second_workflow\")\n",
"wg.nodes.new(add, name=\"add\", run_remotely=True)\n",
"wg.nodes.new(multiply, name=\"multiply\", x=wg.nodes[\"add\"].outputs[0], run_remotely=True)\n",
- "wg"
+ "\n",
+ "# export the workgraph to html file so that it can be visualized in a browser\n",
+ "wg.to_html()\n",
+ "# visualize the workgraph in jupyter-notebook\n",
+ "# wg"
]
},
{
@@ -528,194 +391,10 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": null,
"id": "f6865793",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WorkGraph node created, PK: 44961\n",
- "\n",
- "Result of multiply is uuid: 8e46221e-15b5-4d13-83c0-7be55d38eb11 (pk: 44978) value: 20 \n",
- "\n",
- "\n"
- ]
- },
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 17,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from aiida_workgraph.utils import generate_node_graph\n",
"\n",
@@ -754,34 +433,31 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 13,
"id": "265dcd9f",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "a7831ebabe0e49afa4a0c26f66787532",
- "version_major": 2,
- "version_minor": 1
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'first_w…"
+ ""
]
},
+ "execution_count": 13,
"metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WorkGraph node created, PK: 44980\n",
- "\n",
- "Result of multiply is uuid: 62dcca06-9fbe-4fc5-b2a4-11673a8f7cd4 (pk: 44998) value: 17 \n",
- "\n",
- "\n"
- ]
+ "output_type": "execute_result"
}
],
"source": [
@@ -801,15 +477,44 @@
" z = int(f.read())\n",
" return x*y + z\n",
"\n",
- "wg = WorkGraph(\"first_workflow\")\n",
+ "wg = WorkGraph(\"third_workflow\")\n",
"wg.nodes.new(add, name=\"add\", run_remotely=True)\n",
"wg.nodes.new(multiply, name=\"multiply\",\n",
" parent_folder=wg.nodes[\"add\"].outputs[\"remote_folder\"],\n",
" run_remotely=True,\n",
" )\n",
"\n",
+ "wg.to_html()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "83e7d2bc",
+ "metadata": {},
+ "source": [
+ "Submit the calculation"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "c8323395",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "WorkGraph node created, PK: 49497\n",
+ "\n",
+ "Result of multiply is uuid: c0020724-b5bf-4e8b-8dbb-014e68999cc5 (pk: 49511) value: 17 \n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
"#------------------------- Submit the calculation -------------------\n",
- "display(wg)\n",
"wg.submit(inputs = {\"add\": {\"x\": 2, \"y\": 3, \"computer\": \"localhost\"},\n",
" \"multiply\": {\"x\": 3, \"y\": 4, \"computer\": \"localhost\"}},\n",
" wait=True)\n",
@@ -829,38 +534,29 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 10,
"id": "d05167e6",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "d3f4ab991b4d4ced90ba33f607f166ee",
- "version_major": 2,
- "version_minor": 1
- },
- "text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'test_ad…"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WorkGraph node created, PK: 45003\n"
- ]
- },
- {
- "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 19,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -876,8 +572,7 @@
"add1 = wg.nodes.new(ArithmeticAddCalculation, name=\"add1\", x=Int(2), y=Int(3), code=code)\n",
"add2 = wg.nodes.new(ArithmeticAddCalculation, name=\"add2\", y=Int(3), code=code)\n",
"wg.links.new(wg.nodes[\"add1\"].outputs[\"sum\"], wg.nodes[\"add2\"].inputs[\"x\"])\n",
- "display(wg)\n",
- "wg.submit(wait=True)"
+ "wg.to_html()\n"
]
},
{
@@ -885,12 +580,12 @@
"id": "a357ba7e",
"metadata": {},
"source": [
- "Get the result of the nodes:"
+ "Submit the workgraph and wait for the result."
]
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 11,
"id": "fbbb4f10",
"metadata": {},
"outputs": [
@@ -898,265 +593,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Result of node add1: uuid: 139bf2e4-ef2b-4368-b9f5-7fc87121be35 (pk: 45011) value: 8\n"
+ "WorkGraph node created, PK: 49516\n",
+ "Result of node add1: uuid: 7e3b768d-efdd-4d78-bc3d-289aa12df210 (pk: 49524) value: 8\n"
]
}
],
"source": [
+ "wg.submit(wait=True)\n",
"print('Result of node add1: {}'.format(wg.nodes[\"add2\"].outputs[\"sum\"].value))"
]
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": null,
"id": "dce628d4",
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/home/xing/miniconda3/envs/aiida/lib/python3.11/site-packages/aiida/orm/nodes/data/code/legacy.py:172: AiidaDeprecationWarning: `Code.get_description` method is deprecated, use the `description` property instead. (this will be removed in v3)\n",
- " warn_deprecation(\n"
- ]
- },
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 21,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from aiida_workgraph.utils import generate_node_graph\n",
"\n",
@@ -1179,7 +631,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": null,
"id": "7c9d6ed8",
"metadata": {},
"outputs": [],
@@ -1220,19 +672,10 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": null,
"id": "a4d961eb",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WorkGraph node created, PK: 45025\n",
- "Worktree state: FINISHED\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"\n",
"from aiida_workgraph import WorkGraph\n",
@@ -1258,373 +701,20 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": null,
"id": "bccf4f63",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Result of node add_multiply1: uuid: ae059be8-70f6-488e-a880-18412e07679b (pk: 45030) value: 20\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"print('Result of node add_multiply1: {}'.format(add_multiply1.outputs[\"result\"].value))"
]
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": null,
"id": "788aea02",
"metadata": {},
- "outputs": [
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 28,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"generate_node_graph(wg.pk)"
]
@@ -1655,12 +745,6 @@
"| [Tutorials](tutorial/index.rst) | Real-world examples in computational materials science and more. |\n",
"| [HowTo](howto/index.rst) | Advanced topics and tips, e.g flow control using `if`, `for`, `while` and `context`. |"
]
- },
- {
- "cell_type": "markdown",
- "id": "6ff140c8",
- "metadata": {},
- "source": []
}
],
"metadata": {
diff --git a/docs/source/relax_eos.html b/docs/source/relax_eos.html
new file mode 100644
index 00000000..f9d0d4eb
--- /dev/null
+++ b/docs/source/relax_eos.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/second_workflow.html b/docs/source/second_workflow.html
new file mode 100644
index 00000000..c9c4b6cd
--- /dev/null
+++ b/docs/source/second_workflow.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/test_add_multiply.html b/docs/source/test_add_multiply.html
new file mode 100644
index 00000000..eb99bd18
--- /dev/null
+++ b/docs/source/test_add_multiply.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/third_workflow.html b/docs/source/third_workflow.html
new file mode 100644
index 00000000..c4e5ad6f
--- /dev/null
+++ b/docs/source/third_workflow.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/tutorial/eos.ipynb b/docs/source/tutorial/eos.ipynb
index 84e5aa7d..bd00ee5d 100644
--- a/docs/source/tutorial/eos.ipynb
+++ b/docs/source/tutorial/eos.ipynb
@@ -83,7 +83,7 @@
"- link the output and input sockets for the nodes.\n",
"\n",
"### Visualize the workgraph\n",
- "If you are running in a Jupiter notebook, you can visualize the workgraph directly."
+ "If you are running in a jupyter notebook, you can visualize the workgraph directly."
]
},
{
diff --git a/docs/source/tutorial/pw1.html b/docs/source/tutorial/pw1.html
new file mode 100644
index 00000000..52611ba8
--- /dev/null
+++ b/docs/source/tutorial/pw1.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ Rete.js with React in Vanilla JS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/source/tutorial/qe.ipynb b/docs/source/tutorial/qe.ipynb
index 796e440f..fc4505a5 100644
--- a/docs/source/tutorial/qe.ipynb
+++ b/docs/source/tutorial/qe.ipynb
@@ -80,22 +80,29 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"id": "01bedd69",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e6efbe02f6f444acab07a4610be2429f",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minmap': False}, style={'width': '40%', 'height': '600px'}, value={'nodes': {'pw1':…"
+ ""
]
},
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
@@ -106,7 +113,10 @@
"\n",
"wg = WorkGraph(\"energy_n2\")\n",
"pw1 = wg.nodes.new(PwCalculation, name=\"pw1\")\n",
- "pw1"
+ "pw1.to_html()\n",
+ "\n",
+ "# visualize the node in jupyter-notebook\n",
+ "# pw1"
]
},
{
@@ -511,6 +521,24 @@
"atomization = wg.nodes.new(atomization_energy, name=\"atomization_energy\")\n",
"wg.links.new(pw_n.outputs[\"output_parameters\"], atomization.inputs[\"output_atom\"])\n",
"wg.links.new(pw_n2.outputs[\"output_parameters\"], atomization.inputs[\"output_mol\"])\n",
+ "wg.to_html()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "202f236d",
+ "metadata": {},
+ "source": [
+ "Submit the workgraph and print the atomization energy."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "0763c7da",
+ "metadata": {},
+ "outputs": [],
+ "source": [
"wg.submit(wait=True, timeout=300)\n",
"print('Atomization energy: {:0.3f} eV'.format(atomization.outputs[\"result\"].value.value))"
]
diff --git a/docs/source/zero_to_hero.ipynb b/docs/source/zero_to_hero.ipynb
index 84f142d9..4dfb238b 100644
--- a/docs/source/zero_to_hero.ipynb
+++ b/docs/source/zero_to_hero.ipynb
@@ -97,7 +97,7 @@
"- link the output of the `add` node to one of the `x` input of the `multiply` node.\n",
"\n",
"\n",
- "In a Jupiter notebook, you can visualize the workgraph directly."
+ "In a jupyter notebook, you can visualize the workgraph directly."
]
},
{
@@ -108,13 +108,20 @@
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "2799477b57ba474e8632f11728b36843",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'first_w…"
+ ""
]
},
"execution_count": 3,
@@ -128,8 +135,10 @@
"wg = WorkGraph(\"first_workflow\")\n",
"wg.nodes.new(add, name=\"add1\")\n",
"wg.nodes.new(multiply, name=\"multiply1\", x = wg.nodes[\"add1\"].outputs[\"result\"])\n",
- "# visualize the workgraph\n",
- "wg"
+ "# export the workgraph to html file so that it can be visualized in a browser\n",
+ "wg.to_html()\n",
+ "# visualize the workgraph in jupyter-notebook\n",
+ "# wg"
]
},
{
@@ -484,22 +493,29 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 4,
"id": "01bedd69",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "9c7265f8da80419698a3b256614d3a97",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'atomiza…"
+ ""
]
},
- "execution_count": 7,
+ "execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -523,7 +539,10 @@
"wg.nodes.new(atomization_energy, name=\"atomization_energy\",\n",
" output_atom=pw_atom.outputs[\"output_parameters\"],\n",
" output_mol=pw_mol.outputs[\"output_parameters\"])\n",
- "wg"
+ "# export the workgraph to html file so that it can be visualized in a browser\n",
+ "wg.to_html()\n",
+ "# visualize the workgraph in jupyter-notebook\n",
+ "# wg"
]
},
{
@@ -1054,22 +1073,29 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 5,
"id": "5740bb79",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "b704edce426e45e8999e3cd3b9306757",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'if_node…"
+ ""
]
},
- "execution_count": 9,
+ "execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -1096,7 +1122,7 @@
"wg.nodes.new(add, name=\"add1\")\n",
"wg.nodes.new(add_multiply_if_generator, name=\"add_multiply_if1\", x = wg.nodes[\"add1\"].outputs[\"result\"])\n",
"wg.nodes.new(add, name=\"add2\", x = wg.nodes[\"add_multiply_if1\"].outputs[\"result\"])\n",
- "wg\n"
+ "wg.to_html()\n"
]
},
{
@@ -1147,7 +1173,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 7,
"id": "9d859c51",
"metadata": {},
"outputs": [],
@@ -1212,22 +1238,29 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 8,
"id": "f97040fe",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "29b4d95f63894ba8aadfc21da41bc978",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'eos', '…"
+ ""
]
},
- "execution_count": 28,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -1239,7 +1272,7 @@
"scale_structure1 = wg.nodes.new(scale_structure, name=\"scale_structure1\")\n",
"all_scf1 = wg.nodes.new(all_scf, name=\"all_scf1\", structures=scale_structure1.outputs[\"structures\"])\n",
"eos1 = wg.nodes.new(eos, name=\"eos1\", datas=all_scf1.outputs[\"result\"])\n",
- "wg"
+ "wg.to_html()"
]
},
{
@@ -1252,22 +1285,29 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 9,
"id": "5d6a4528",
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "c5c615d30a754e5fa67f051730d9e72c",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'relax_e…"
+ ""
]
},
- "execution_count": 29,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -1291,7 +1331,7 @@
"wg = WorkGraph(\"relax_eos\")\n",
"relax_node = wg.nodes.new(PwCalculation, name=\"relax1\")\n",
"eos_wg_node = wg.nodes.new(eos_workgraph, name=\"eos1\", structure=relax_node.outputs[\"output_structure\"])\n",
- "wg"
+ "wg.to_html()"
]
},
{