+{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.8","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":"c9e32d6d-5a26-43b3-8455-fae305761a5d","cell_type":"code","source":"import numpy as np","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"000bbd4a-f53c-4eea-9d85-76f0aa2ca10b","cell_type":"code","source":"from jobflow import job, Flow","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"b4a78447-e87c-4fb4-8d17-d9a280eb7254","cell_type":"code","source":"from pyiron_base import Project","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"06c2bd9e-b2ac-4b88-9158-fa37331c3418","cell_type":"code","source":"from python_workflow_definition.jobflow import write_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"fb6dbdaa-8cab-48b2-8307-448003eca3f5","cell_type":"code","source":"from python_workflow_definition.pyiron_base import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"id":"fb847d49-7bf9-4839-9b99-c116d1b0e9ee","cell_type":"code","source":"from simple_workflow import (\n add_x_and_y as _add_x_and_y, \n add_x_and_y_and_z as _add_x_and_y_and_z,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"id":"07598344-0f75-433b-8902-bea21a42088c","cell_type":"code","source":"add_x_and_y = job(_add_x_and_y, data=[\"x\", \"y\", \"z\"])\nadd_x_and_y_and_z = job(_add_x_and_y_and_z)","metadata":{"trusted":true},"outputs":[],"execution_count":7},{"id":"ecef1ed5-a8d3-48c3-9e01-4a40e55c1153","cell_type":"code","source":"obj = add_x_and_y(x=1, y=2)","metadata":{"trusted":true},"outputs":[],"execution_count":8},{"id":"2b88a30a-e26b-4802-89b7-79ca08cc0af9","cell_type":"code","source":"w = add_x_and_y_and_z(x=obj.output.x, y=obj.output.y, z=obj.output.z)","metadata":{"trusted":true},"outputs":[],"execution_count":9},{"id":"a5e5ca63-2906-47c9-bac6-adebf8643cba","cell_type":"code","source":"flow = Flow([obj, w])","metadata":{"trusted":true},"outputs":[],"execution_count":10},{"id":"e464da97-16a1-4772-9a07-0a47f152781d","cell_type":"code","source":"write_workflow_json(flow=flow, file_name=\"workflow_jobflow.json\")","metadata":{"trusted":true},"outputs":[],"execution_count":11},{"id":"bca646b2-0a9a-4271-966a-e5903a8c9031","cell_type":"code","source":"!cat workflow_jobflow.json","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"{\"nodes\": {\"0\": \"simple_workflow.add_x_and_y\", \"1\": \"simple_workflow.add_x_and_y_and_z\", \"2\": 1, \"3\": 2}, \"edges\": [{\"target\": 0, \"targetHandle\": \"x\", \"source\": 2, \"sourceHandle\": null}, {\"target\": 0, \"targetHandle\": \"y\", \"source\": 3, \"sourceHandle\": null}, {\"target\": 1, \"targetHandle\": \"x\", \"source\": 0, \"sourceHandle\": \"x\"}, {\"target\": 1, \"targetHandle\": \"y\", \"source\": 0, \"sourceHandle\": \"y\"}, {\"target\": 1, \"targetHandle\": \"z\", \"source\": 0, \"sourceHandle\": \"z\"}]}"}],"execution_count":12},{"id":"f45684a8-2613-415a-ab0a-5cb2bafaffea","cell_type":"code","source":"pr = Project(\"test\")\npr.remove_jobs(recursive=True, silently=True)","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"0it [00:00, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"1dc9fa2d8f8044c8977e1ad0669596b5"}},"metadata":{}}],"execution_count":13},{"id":"8f2a621d-b533-4ddd-8bcd-c22db2f922ec","cell_type":"code","source":"delayed_object = load_workflow_json(project=pr, file_name=\"workflow_jobflow.json\")\ndelayed_object.draw()","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.SVG object>","image/svg+xml":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"2387pt\" height=\"188pt\" viewBox=\"0.00 0.00 2386.99 188.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 184)\">\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-184 2382.99,-184 2382.99,4 -4,4\"/>\n<!-- create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40 -->\n<g id=\"node1\" class=\"node\">\n<title>create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1185.39\" cy=\"-18\" rx=\"483.67\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"1185.39\" y=\"-13.32\" font-family=\"Times,serif\" font-size=\"14.00\">create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7e21ef5bc560></text>\n</g>\n<!-- x_7bbe883cf8e84e98be86ef51b3b4b3f0 -->\n<g id=\"node2\" class=\"node\">\n<title>x_7bbe883cf8e84e98be86ef51b3b4b3f0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"387.39\" cy=\"-90\" rx=\"387.39\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"387.39\" y=\"-85.33\" font-family=\"Times,serif\" font-size=\"14.00\">x=<pyiron_base.project.delayed.DelayedObject object at 0x7e21ef56ffb0></text>\n</g>\n<!-- x_7bbe883cf8e84e98be86ef51b3b4b3f0->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40 -->\n<g id=\"edge1\" class=\"edge\">\n<title>x_7bbe883cf8e84e98be86ef51b3b4b3f0->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40</title>\n<path fill=\"none\" stroke=\"black\" d=\"M563.5,-73.55C689.83,-62.47 860.05,-47.54 990.46,-36.1\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"990.6,-39.6 1000.25,-35.24 989.99,-32.63 990.6,-39.6\"/>\n</g>\n<!-- x_1d847da32ecaabf6731c38f798c3d4ce -->\n<g id=\"node3\" class=\"node\">\n<title>x_1d847da32ecaabf6731c38f798c3d4ce</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1144.39\" cy=\"-162\" rx=\"31.74\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"1144.39\" y=\"-157.32\" font-family=\"Times,serif\" font-size=\"14.00\">x=1</text>\n</g>\n<!-- x_1d847da32ecaabf6731c38f798c3d4ce->x_7bbe883cf8e84e98be86ef51b3b4b3f0 -->\n<g id=\"edge2\" class=\"edge\">\n<title>x_1d847da32ecaabf6731c38f798c3d4ce->x_7bbe883cf8e84e98be86ef51b3b4b3f0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1113.31,-158.13C1022.35,-149.72 751.62,-124.68 567.75,-107.68\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"568.11,-104.2 557.83,-106.76 567.46,-111.17 568.11,-104.2\"/>\n</g>\n<!-- y_8ac62ebe82912d404811d7b4f684816a -->\n<g id=\"node4\" class=\"node\">\n<title>y_8ac62ebe82912d404811d7b4f684816a</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1185.39\" cy=\"-90\" rx=\"392.13\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"1185.39\" y=\"-85.33\" font-family=\"Times,serif\" font-size=\"14.00\">y=<pyiron_base.project.delayed.DelayedObject object at 0x7e21ef5bc200></text>\n</g>\n<!-- x_1d847da32ecaabf6731c38f798c3d4ce->y_8ac62ebe82912d404811d7b4f684816a -->\n<g id=\"edge3\" class=\"edge\">\n<title>x_1d847da32ecaabf6731c38f798c3d4ce->y_8ac62ebe82912d404811d7b4f684816a</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1154.11,-144.41C1158.67,-136.62 1164.23,-127.14 1169.39,-118.33\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1172.37,-120.15 1174.41,-109.75 1166.33,-116.61 1172.37,-120.15\"/>\n</g>\n<!-- z_5e7b48ebebaa407e4bfec5ab40e64557 -->\n<g id=\"node5\" class=\"node\">\n<title>z_5e7b48ebebaa407e4bfec5ab40e64557</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1987.39\" cy=\"-90\" rx=\"391.6\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"1987.39\" y=\"-85.33\" font-family=\"Times,serif\" font-size=\"14.00\">z=<pyiron_base.project.delayed.DelayedObject object at 0x7e21ef5bc170></text>\n</g>\n<!-- x_1d847da32ecaabf6731c38f798c3d4ce->z_5e7b48ebebaa407e4bfec5ab40e64557 -->\n<g id=\"edge4\" class=\"edge\">\n<title>x_1d847da32ecaabf6731c38f798c3d4ce->z_5e7b48ebebaa407e4bfec5ab40e64557</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1167.64,-149.58C1173.02,-147.37 1178.81,-145.33 1184.39,-144 1235.46,-131.83 1503.39,-115.68 1715.92,-104.42\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1715.96,-107.92 1725.76,-103.9 1715.59,-100.93 1715.96,-107.92\"/>\n</g>\n<!-- y_8ac62ebe82912d404811d7b4f684816a->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40 -->\n<g id=\"edge8\" class=\"edge\">\n<title>y_8ac62ebe82912d404811d7b4f684816a->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1185.39,-71.7C1185.39,-64.41 1185.39,-55.73 1185.39,-47.54\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1188.89,-47.62 1185.39,-37.62 1181.89,-47.62 1188.89,-47.62\"/>\n</g>\n<!-- z_5e7b48ebebaa407e4bfec5ab40e64557->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40 -->\n<g id=\"edge9\" class=\"edge\">\n<title>z_5e7b48ebebaa407e4bfec5ab40e64557->create_function_job_2c457c823cb47e0ef9ae0df5b2d1fb40</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1809.9,-73.51C1682.91,-62.42 1511.99,-47.51 1381.06,-36.08\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1381.49,-32.6 1371.23,-35.22 1380.88,-39.58 1381.49,-32.6\"/>\n</g>\n<!-- y_a9ec4f5f33f0d64e74ed5d9900bceac6 -->\n<g id=\"node6\" class=\"node\">\n<title>y_a9ec4f5f33f0d64e74ed5d9900bceac6</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1225.39\" cy=\"-162\" rx=\"31.74\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"1225.39\" y=\"-157.32\" font-family=\"Times,serif\" font-size=\"14.00\">y=2</text>\n</g>\n<!-- y_a9ec4f5f33f0d64e74ed5d9900bceac6->x_7bbe883cf8e84e98be86ef51b3b4b3f0 -->\n<g id=\"edge5\" class=\"edge\">\n<title>y_a9ec4f5f33f0d64e74ed5d9900bceac6->x_7bbe883cf8e84e98be86ef51b3b4b3f0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1202.15,-149.58C1196.76,-147.37 1190.97,-145.33 1185.39,-144 1134.58,-131.88 867.73,-115.7 656.4,-104.41\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"656.8,-100.93 646.62,-103.89 656.42,-107.92 656.8,-100.93\"/>\n</g>\n<!-- y_a9ec4f5f33f0d64e74ed5d9900bceac6->y_8ac62ebe82912d404811d7b4f684816a -->\n<g id=\"edge6\" class=\"edge\">\n<title>y_a9ec4f5f33f0d64e74ed5d9900bceac6->y_8ac62ebe82912d404811d7b4f684816a</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1215.91,-144.41C1211.46,-136.62 1206.04,-127.14 1201.01,-118.33\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1204.11,-116.71 1196.11,-109.76 1198.04,-120.18 1204.11,-116.71\"/>\n</g>\n<!-- y_a9ec4f5f33f0d64e74ed5d9900bceac6->z_5e7b48ebebaa407e4bfec5ab40e64557 -->\n<g id=\"edge7\" class=\"edge\">\n<title>y_a9ec4f5f33f0d64e74ed5d9900bceac6->z_5e7b48ebebaa407e4bfec5ab40e64557</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1256.68,-158.13C1348.21,-149.72 1620.63,-124.69 1805.7,-107.69\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1805.79,-111.2 1815.43,-106.8 1805.15,-104.23 1805.79,-111.2\"/>\n</g>\n</g>\n</svg>"},"metadata":{}}],"execution_count":14},{"id":"cf80267d-c2b0-4236-bf1d-a57596985fc1","cell_type":"code","source":"delayed_object.pull()","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"The job add_x_and_y_68901482a2c5221cc845f828aabebd27 was saved and received the ID: 1\nThe job add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d was saved and received the ID: 2\n"},{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"6"},"metadata":{}}],"execution_count":15}]}
0 commit comments