Skip to content

Commit

Permalink
Update jupyter notebook & fix doc
Browse files Browse the repository at this point in the history
Signed-off-by: Mecoli1219 <[email protected]>
  • Loading branch information
Mecoli1219 committed Oct 28, 2024
1 parent b442fba commit 712019d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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`. "
]
},
{
Expand All @@ -36,12 +36,12 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">23:40:27.971008 </span><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> remote.py:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">230</span> - Jupyter notebook and interactive task \n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">21:39:52.768159 </span><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> remote.py:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273</span> - Jupyter notebook and interactive task \n",
"<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> support is still alpha. \n",
"</pre>\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"
]
},
Expand All @@ -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",
")"
]
},
Expand Down Expand Up @@ -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)"
]
},
{
Expand All @@ -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)"
]
},
{
Expand All @@ -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!"
]
Expand Down Expand Up @@ -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)"
Expand All @@ -261,7 +267,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "flytekit3.12",
"language": "python",
"name": "python3"
},
Expand All @@ -275,7 +281,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 712019d

Please sign in to comment.