Skip to content

Commit bc7d1ee

Browse files
committed
Add example notebooks for executorlib
1 parent 9e31608 commit bc7d1ee

File tree

4 files changed

+5436
-0
lines changed

4 files changed

+5436
-0
lines changed

.github/workflows/pipeline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
cd example_workflows/nfdi/
7070
papermill aiida.ipynb aiida_out.ipynb -k "python3"
7171
papermill cwl.ipynb cwl_out.ipynb -k "python3"
72+
papermill executorlib.ipynb executorlib_out.ipynb -k "python3"
7273
papermill jobflow.ipynb jobflow_out.ipynb -k "python3"
7374
papermill pyiron_base.ipynb pyiron_base_out.ipynb -k "python3"
7475
papermill pyiron_workflow.ipynb pyiron_workflow_out.ipynb -k "python3"
@@ -104,6 +105,7 @@ jobs:
104105
cd example_workflows/quantum_espresso
105106
papermill aiida.ipynb aiida_out.ipynb -k "python3"
106107
papermill cwl.ipynb cwl_out.ipynb -k "python3"
108+
papermill executorlib.ipynb executorlib_out.ipynb -k "python3"
107109
papermill jobflow.ipynb jobflow_out.ipynb -k "python3"
108110
papermill pyiron_base.ipynb pyiron_base_out.ipynb -k "python3"
109111
papermill pyiron_workflow.ipynb pyiron_workflow_out.ipynb -k "python3"
@@ -133,6 +135,7 @@ jobs:
133135
cd example_workflows/arithmetic
134136
papermill aiida.ipynb aiida_out.ipynb -k "python3"
135137
papermill cwl.ipynb cwl_out.ipynb -k "python3"
138+
papermill executorlib.ipynb executorlib_out.ipynb -k "python3"
136139
papermill jobflow.ipynb jobflow_out.ipynb -k "python3"
137140
papermill pyiron_base.ipynb pyiron_base_out.ipynb -k "python3"
138141
papermill pyiron_workflow.ipynb pyiron_workflow_out.ipynb -k "python3"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"c39b76fb-259f-4e16-a44d-02a295c82386","cell_type":"markdown","source":"# executorlib","metadata":{}},{"id":"3638419b-a0cb-49e2-b157-7fbb1acde90f","cell_type":"markdown","source":"## Define workflow with executorlib","metadata":{}},{"id":"b4a78447-e87c-4fb4-8d17-d9a280eb7254","cell_type":"code","source":"from executorlib import SingleNodeExecutor, get_item_from_future","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"6d859dfff0c2df5c","cell_type":"code","source":"from workflow import get_sum, get_prod_and_div, get_square","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"77135b0c61898507","cell_type":"code","source":"workflow_json_filename = \"executorlib_arithmetic.json\"","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"07598344-0f75-433b-8902-bea21a42088c","cell_type":"code","source":"with SingleNodeExecutor(export_workflow_filename=workflow_json_filename) as exe:\n future_prod_and_div = exe.submit(get_prod_and_div, x=1, y=2)\n future_prod = get_item_from_future(future_prod_and_div, key=\"prod\")\n future_div = get_item_from_future(future_prod_and_div, key=\"div\")\n future_sum = exe.submit(get_sum, x=future_prod, y=future_div)\n future_result = exe.submit(get_square, x=future_sum)","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"bca646b2-0a9a-4271-966a-e5903a8c9031","cell_type":"code","source":"!cat {workflow_json_filename}","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"{\n \"version\": \"0.1.0\",\n \"nodes\": [\n {\n \"id\": 0,\n \"type\": \"function\",\n \"value\": \"workflow.get_prod_and_div\"\n },\n {\n \"id\": 1,\n \"type\": \"function\",\n \"value\": \"workflow.get_sum\"\n },\n {\n \"id\": 2,\n \"type\": \"function\",\n \"value\": \"workflow.get_square\"\n },\n {\n \"id\": 3,\n \"type\": \"input\",\n \"value\": 1,\n \"name\": \"x\"\n },\n {\n \"id\": 4,\n \"type\": \"input\",\n \"value\": 2,\n \"name\": \"y\"\n },\n {\n \"id\": 5,\n \"type\": \"output\",\n \"name\": \"result\"\n }\n ],\n \"edges\": [\n {\n \"target\": 0,\n \"targetPort\": \"x\",\n \"source\": 3,\n \"sourcePort\": null\n },\n {\n \"target\": 0,\n \"targetPort\": \"y\",\n \"source\": 4,\n \"sourcePort\": null\n },\n {\n \"target\": 1,\n \"targetPort\": \"x\",\n \"source\": 0,\n \"sourcePort\": \"prod\"\n },\n {\n \"target\": 1,\n \"targetPort\": \"y\",\n \"source\": 0,\n \"sourcePort\": \"div\"\n },\n {\n \"target\": 2,\n \"targetPort\": \"x\",\n \"source\": 1,\n \"sourcePort\": null\n },\n {\n \"target\": 5,\n \"targetPort\": null,\n \"source\": 2,\n \"sourcePort\": null\n }\n ]\n}"}],"execution_count":5},{"id":"a4c0faaf-e30d-4ded-8e9f-57f97f51b14c","cell_type":"markdown","source":"## Load Workflow with aiida","metadata":{}},{"id":"2ecc229f-daa1-49b9-9279-a6b5ae1aa4f2","cell_type":"code","source":"from aiida import load_profile\n\nload_profile()","metadata":{"trusted":true},"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"Profile<uuid='bd1f63d2692e4047b03c21069862af51' name='pwd'>"},"metadata":{}}],"execution_count":6},{"id":"68a56b32-9f99-43d7-aaee-0c1cd9522681","cell_type":"code","source":"from python_workflow_definition.aiida import load_workflow_json","metadata":{"trusted":true},"outputs":[{"traceback":["\u001b[31m---------------------------------------------------------------------------\u001b[39m","\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)","\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpython_workflow_definition\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01maiida\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m load_workflow_json\n","\u001b[31mModuleNotFoundError\u001b[39m: No module named 'python_workflow_definition'"],"ename":"ModuleNotFoundError","evalue":"No module named 'python_workflow_definition'","output_type":"error"}],"execution_count":7},{"id":"8f2a621d-b533-4ddd-8bcd-c22db2f922ec","cell_type":"code","source":"wg = load_workflow_json(file_name=workflow_json_filename)\nwg","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"cf80267d-c2b0-4236-bf1d-a57596985fc1","cell_type":"code","source":"\nwg.run()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"0c3503e1-0a32-40e1-845d-3fd9ec3c4c19","cell_type":"markdown","source":"## Load Workflow with jobflow","metadata":{}},{"id":"4abb0481-8e38-479d-ae61-6c46d091653e","cell_type":"code","source":"from python_workflow_definition.jobflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"8253dd7c283bf3f7","cell_type":"code","source":"from jobflow.managers.local import run_locally","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"4b45e83b-945f-48c5-8e20-9df0ce0a14a1","cell_type":"code","source":"flow = load_workflow_json(file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"8665c39c-220c-4982-b738-c31f6460530f","cell_type":"code","source":"result = run_locally(flow)\nresult","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"406fd07dd4bd8006","cell_type":"markdown","source":"## Load Workflow with pyiron_base","metadata":{}},{"id":"cf76f305-24de-45a7-be8e-cfe45cd6458e","cell_type":"code","source":"from python_workflow_definition.pyiron_base import load_workflow_json","metadata":{"ExecuteTime":{"end_time":"2025-05-24T08:25:33.797570Z","start_time":"2025-05-24T08:25:33.771214Z"},"trusted":true},"outputs":[],"execution_count":null},{"id":"5b442611457aa5a8","cell_type":"code","source":"delayed_object_lst = load_workflow_json(file_name=workflow_json_filename)\ndelayed_object_lst[-1].draw()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"2ca33c8590a54866","cell_type":"code","source":"delayed_object_lst[-1].pull()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"406d62d0-76eb-411f-a7fb-f866d5cec9c1","cell_type":"markdown","source":"## Load Workflow with pyiron_workflow","metadata":{}},{"id":"c8c95d7f-7a3b-4ff4-890e-3f9b0434b436","cell_type":"code","source":"from python_workflow_definition.pyiron_workflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"5c759f6d-d82d-44f8-8120-e7732988fe71","cell_type":"code","source":"wf = load_workflow_json(file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"fe6ab0eb-6078-413d-a8e2-f71a020b1036","cell_type":"code","source":"wf.draw(size=(10,10))","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"3c4971a2-b66f-4fda-b438-1039b41d8f8e","cell_type":"code","source":"wf.run()","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}

0 commit comments

Comments
 (0)