diff --git a/examples/jupyter_notebook_basics/jupyter_notebook_basics/__init__.py b/examples/jupyter_notebook_basics/jupyter_notebook_basics/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/jupyter_notebook_basics/jupyter_notebook_basics.ipynb b/examples/jupyter_notebook_basics/jupyter_notebook_basics/jupyter_notebook_basics.ipynb similarity index 84% rename from examples/jupyter_notebook_basics/jupyter_notebook_basics.ipynb rename to examples/jupyter_notebook_basics/jupyter_notebook_basics/jupyter_notebook_basics.ipynb index df1adeea0..02097ea25 100644 --- a/examples/jupyter_notebook_basics/jupyter_notebook_basics.ipynb +++ b/examples/jupyter_notebook_basics/jupyter_notebook_basics/jupyter_notebook_basics.ipynb @@ -25,7 +25,7 @@ "\n", "Before starting to develop and run the tasks and workflows remotely via Jupiter Notebook, let's setup the interface via [flytekit.remote](https://docs.flyte.org/projects/flytekit/en/latest/design/control_plane.html) to interact with the Flyte backend. \n", "\n", - "**Make sure to set `interactive_mode_enabled` to `True` to support auto pickling and registering entities to backend from Jupyter Notebook environment.**" + "If you are running in Jupyter Notebook, it should automatically enable the interactive mode. However, you can also enable it explicitly by setting `interactive_mode_enabled` to `True`. " ] }, { @@ -36,12 +36,12 @@ { "data": { "text/html": [ - "
23:40:27.971008 WARNING remote.py:230 - Jupyter notebook and interactive task \n", + "21:39:52.768159 WARNING remote.py:273 - Jupyter notebook and interactive task \n", " support is still alpha. \n", "\n" ], "text/plain": [ - "\u001b[2;36m23:40:27.971008\u001b[0m\u001b[2;36m \u001b[0m\u001b[33mWARNING \u001b[0m remote.py:\u001b[1;36m230\u001b[0m - Jupyter notebook and interactive task \n", + "\u001b[2;36m21:39:52.768159\u001b[0m\u001b[2;36m \u001b[0m\u001b[33mWARNING \u001b[0m remote.py:\u001b[1;36m273\u001b[0m - Jupyter notebook and interactive task \n", "\u001b[2;36m \u001b[0m support is still alpha. \n" ] }, @@ -58,7 +58,7 @@ " Config.for_sandbox(), \n", " default_project=\"flytesnacks\", \n", " default_domain=\"development\", \n", - " interactive_mode_enabled=True,\n", + " interactive_mode_enabled=True, # This is not necessary if you are in a notebook.\n", ")" ] }, @@ -113,23 +113,23 @@ "name": "stdout", "output_type": "stream", "text": [ - "http://localhost:30080/console/projects/flytesnacks/domains/development/executions/alnrr5cmh4gbrbfcvp8k\n", + "http://localhost:30080/console/projects/flytesnacks/domains/development/executions/ah5cm5s482w9fl5jzz7c\n", "{'o0': 'Hello Flyte!'}\n" ] } ], "source": [ "# Execute the task\n", - "out = remote.execute(hello, inputs={\"name\": \"Flyte\"})\n", + "exe = remote.execute(hello, inputs={\"name\": \"Flyte\"})\n", "\n", "# This will print the URL to the console\n", - "print(remote.generate_console_url(out))\n", + "print(exe.execution_url)\n", "\n", "# Wait for the task to complete\n", - "out = remote.wait(out)\n", + "exe = exe.wait(poll_interval=1)\n", "\n", "# Print the outputs\n", - "print(out.outputs)" + "print(exe.outputs)" ] }, { @@ -154,10 +154,10 @@ ], "source": [ "# Execute the workflow and wait for it to complete\n", - "out = remote.execute(hello, inputs={\"name\": \"world\"}, wait=True)\n", + "exe = remote.execute(hello, inputs={\"name\": \"world\"}, wait=True)\n", "\n", "# Print the outputs\n", - "print(out.outputs)" + "print(exe.outputs)" ] }, { @@ -182,17 +182,20 @@ ], "source": [ "# Execute the workflow and wait for it to complete\n", - "out = remote.execute(wf, inputs={\"name\": \"world\"}, wait=True)\n", + "exe = remote.execute(wf, inputs={\"name\": \"world\"})\n", + "\n", + "# Wait for the task to complete\n", + "exe = exe.wait(poll_interval=1)\n", "\n", "# Print the outputs\n", - "print(out.outputs)" + "print(exe.outputs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "If you repeat the execution, it will not re-register the entities to the backend, instead it will reuse the existing entities. However, if you update and run the cells that define the tasks or workflows, it will register the updated entities to the backend when you execute them.\n", + "If you repeat the execution, it will not re-register the entities to the backend, instead it will reuse the existing entities. However, if you re-execute the cells that define the tasks or workflows, it will register the updated entities to the backend when you execute them.\n", "\n", "Feel free to update the tasks and workflows definition and see how it works!" ] @@ -252,7 +255,10 @@ ], "source": [ "# Execute the workflow with map_task and wait for it to complete\n", - "out = remote.execute(workflow_with_maptask, inputs={\"data\": [1, 2, 3], \"y\": 4}, wait=True)\n", + "out = remote.execute(workflow_with_maptask, inputs={\"data\": [1, 2, 3], \"y\": 4})\n", + "\n", + "# Wait for the task to complete\n", + "out = out.wait(poll_interval=1)\n", "\n", "# Print the outputs\n", "print(out.outputs)" @@ -261,7 +267,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "flytekit3.12", "language": "python", "name": "python3" }, @@ -275,7 +281,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.0" } }, "nbformat": 4,