Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Updates parallel notebook for google collab

Stefan Krawczyk326fa012b28b
diff --git a/docs/concepts/tracking.rst b/docs/concepts/tracking.rst
index 6b527067..01047d32 100644
--- a/docs/concepts/tracking.rst
+++ b/docs/concepts/tracking.rst
@@ -105,3 +105,10 @@ This will print the URL to access the Burr UI web app.
%burr_ui
"Burr UI: http://127.0.0.1:7241"
+
+.. code-block:: python
+
+ # But you need to expose the port to the browser:
+ from google.colab import output
+ output.serve_kernel_port_as_window(7241) # this will open a new window
+ output.serve_kernel_port_as_iframe(7241) # this will inline in an iframe
diff --git a/examples/parallelism/notebook.ipynb b/examples/parallelism/notebook.ipynb
index e5fa2b2c..9a45c59e 100644
--- a/examples/parallelism/notebook.ipynb
+++ b/examples/parallelism/notebook.ipynb
@@ -99,14 +99,48 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 75,
"id": "e59f1418-68f8-47c2-8034-4b928211acbe",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The burr.integrations.notebook extension is already loaded. To reload it, use:\n",
+ " %reload_ext burr.integrations.notebook\n",
+ "Burr UI: http://127.0.0.1:7241\n"
+ ]
+ }
+ ],
"source": [
"# let's load up some jupyter UI magics\n",
"%load_ext burr.integrations.notebook\n",
- "# %burr_ui # this starts the UI in a background process"
+ "%burr_ui # this starts the UI in a background process"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "77bc7268-26ec-462c-9219-c7eede3bd325",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# if in google collab we need to expose the port\n",
+ "from google.colab import output\n",
+ "# output.serve_kernel_port_as_iframe(7241) # can expose as an iframe directly\n",
+ "output.serve_kernel_port_as_window(7241) # can expose as a new tab -- take note of the URL and provide it below."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 79,
+ "id": "4778dbb2-75a0-4490-86b8-7be206832d92",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "URL_FOR_UI = \"http://localhost:7241\" # this is the default -- replace with google collab domain (without trailing /)\n",
+ "# e.g. URL_FOR_UI = \"https://cg2cjmb1mmu-496ff2e9c6d22116-7241-colab.googleusercontent.com\""
]
},
{
@@ -129,7 +163,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 77,
"id": "0998576a-c8cb-45a2-94ce-d8ce326e3be7",
"metadata": {},
"outputs": [],
@@ -181,7 +215,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 78,
"id": "27ee761e-f7e8-4da7-82f2-349653cc6a7e",
"metadata": {},
"outputs": [
@@ -256,10 +290,10 @@
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x12cdd4070>"
+ "<burr.core.application.Application at 0x1306644c0>"
]
},
- "execution_count": 18,
+ "execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
@@ -302,7 +336,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 80,
"id": "c99f7a75-1410-4aa6-b60d-16a592c3ae5f",
"metadata": {},
"outputs": [
@@ -313,7 +347,7 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"700px\"\n",
- " src=\"http://localhost:7241/project/parallelism_example/null/38cbf653-5d58-479d-b094-1a645d201a1a\"\n",
+ " src=\"http://localhost:7241/project/parallelism_example/null/e58b9895-46e9-4e0d-b125-9748e5387465\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
@@ -321,17 +355,17 @@
" "
],
"text/plain": [
- "<IPython.lib.display.IFrame at 0x12cda7910>"
+ "<IPython.lib.display.IFrame at 0x1306674f0>"
]
},
- "execution_count": 19,
+ "execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# setup UI to see the run - hit the live button to see it run live\n",
- "IFrame(f'http://localhost:7241/project/parallelism_example/null/{app.uid}', width=\"100%\", height=\"700px\")"
+ "IFrame(f'{URL_FOR_UI}/project/parallelism_example/null/{app.uid}', width=\"100%\", height=\"700px\")"
]
},
{
@@ -528,7 +562,7 @@
],
"source": [
"# hit the \"live button\" to see things run live\n",
- "IFrame(f'http://localhost:7241/project/parallelism_example/null/{app_recursion.uid}', width=\"100%\", height=\"700px\")"
+ "IFrame(f'{URL_FOR_UI}/project/parallelism_example/null/{app_recursion.uid}', width=\"100%\", height=\"700px\")"
]
},
{
@@ -724,7 +758,7 @@
],
"source": [
"# hit the \"live button\" to see things run live\n",
- "IFrame(f'http://localhost:7241/project/parallelism_example/null/{app_parallelism.uid}', width=\"100%\", height=\"700px\")"
+ "IFrame(f'{URL_FOR_UI}/project/parallelism_example/null/{app_parallelism.uid}', width=\"100%\", height=\"700px\")"
]
},
{
@@ -1330,14 +1364,6 @@
"# )"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "0062c42e-ae8b-4c57-bd03-a4069858dc3f",
- "metadata": {},
- "outputs": [],
- "source": []
- },
{
"cell_type": "markdown",
"id": "c9444365-7c84-473a-8f9f-fd20e9863d94",