Skip to content

Commit

Permalink
Add warning and reorder jupyter executor docs (microsoft#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored Mar 7, 2024
1 parent 0652db0 commit 5a4651a
Showing 1 changed file with 42 additions and 44 deletions.
86 changes: 42 additions & 44 deletions website/docs/topics/code-execution/jupyter-code-executor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\n",
"AutoGen is able to execute code in a stateful Jupyter kernel, this is in contrast to the command line code executor where each code block is executed in a new process. This means that you can define variables in one code block and use them in another. One of the interesting properties of this is that when an error is encountered, only the failing code needs to be re-executed, and not the entire script.\n",
"\n",
"To use the [`JupyterCodeExecutor`](/docs/reference/coding/jupyter/jupyter_code_executor#jupytercodeexecutor) you need a Jupyter server running. This can be local, in Docker or even a remove server. Then, when constructing the [`JupyterCodeExecutor`](/docs/reference/coding/jupyter/jupyter_code_executor#jupytercodeexecutor) you pass it the server it should connect to.\n",
"To use the [`JupyterCodeExecutor`](/docs/reference/coding/jupyter/jupyter_code_executor#jupytercodeexecutor) you need a Jupyter server running. This can be in Docker, local, or even a remove server. Then, when constructing the [`JupyterCodeExecutor`](/docs/reference/coding/jupyter/jupyter_code_executor#jupytercodeexecutor) you pass it the server it should connect to.\n",
"\n",
"## Dependencies\n",
"\n",
Expand All @@ -20,49 +20,6 @@
"\n",
"## Jupyter Server\n",
"\n",
"### Local\n",
"\n",
"To run a local Jupyter server, the [`LocalJupyterServer`](/docs/reference/coding/jupyter/local_jupyter_server#localjupyterserver) can be used.\n",
"\n",
"````{=mdx}\n",
":::warning\n",
"The [`LocalJupyterServer`](/docs/reference/coding/jupyter/local_jupyter_server#localjupyterserver) does not function on Windows due to a bug. In this case, you can use the [`DockerJupyterServer`](/docs/reference/coding/jupyter/docker_jupyter_server#dockerjupyterserver) instead or use the [`EmbeddedIPythonCodeExecutor`](/docs/reference/coding/jupyter/embedded_ipython_code_executor). Do note that the intention is to remove the [`EmbeddedIPythonCodeExecutor`](/docs/reference/coding/jupyter/embedded_ipython_code_executor) when the bug is fixed.\n",
":::\n",
"````"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"exit_code=0 output='Hello, World!\\n' output_files=[]\n"
]
}
],
"source": [
"from autogen.coding import CodeBlock\n",
"from autogen.coding.jupyter import LocalJupyterServer, JupyterCodeExecutor\n",
"\n",
"with LocalJupyterServer() as server:\n",
" executor = JupyterCodeExecutor(server)\n",
" print(\n",
" executor.execute_code_blocks(\n",
" code_blocks=[\n",
" CodeBlock(language=\"python\", code=\"print('Hello, World!')\"),\n",
" ]\n",
" )\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Docker\n",
"\n",
"To run a Docker based Jupyter server, the [`DockerJupyterServer`](/docs/reference/coding/jupyter/docker_jupyter_server#dockerjupyterserver) can be used."
Expand Down Expand Up @@ -175,6 +132,47 @@
"```\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Local\n",
"\n",
"````mdx-code-block\n",
":::danger\n",
"The local version will run code on your local system. Use it with caution.\n",
":::\n",
"````\n",
"\n",
"To run a local Jupyter server, the [`LocalJupyterServer`](/docs/reference/coding/jupyter/local_jupyter_server#localjupyterserver) can be used.\n",
"\n",
"````{=mdx}\n",
":::warning\n",
"The [`LocalJupyterServer`](/docs/reference/coding/jupyter/local_jupyter_server#localjupyterserver) does not function on Windows due to a bug. In this case, you can use the [`DockerJupyterServer`](/docs/reference/coding/jupyter/docker_jupyter_server#dockerjupyterserver) instead or use the [`EmbeddedIPythonCodeExecutor`](/docs/reference/coding/jupyter/embedded_ipython_code_executor). Do note that the intention is to remove the [`EmbeddedIPythonCodeExecutor`](/docs/reference/coding/jupyter/embedded_ipython_code_executor) when the bug is fixed.\n",
":::\n",
"````"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from autogen.coding import CodeBlock\n",
"from autogen.coding.jupyter import LocalJupyterServer, JupyterCodeExecutor\n",
"\n",
"with LocalJupyterServer() as server:\n",
" executor = JupyterCodeExecutor(server)\n",
" print(\n",
" executor.execute_code_blocks(\n",
" code_blocks=[\n",
" CodeBlock(language=\"python\", code=\"print('Hello, World!')\"),\n",
" ]\n",
" )\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 5a4651a

Please sign in to comment.