From c4302eecab6c34fb14e301fa2579d21aeedabf34 Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Thu, 9 Jan 2025 15:29:36 -0500 Subject: [PATCH] Fixes for azure-container-code-executor.ipynb (#4970) Fixes for azure-container-code-executor.ipyn --- .../azure-container-code-executor.ipynb | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb b/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb index 7bc7ef4da2..c71ee58e91 100644 --- a/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb +++ b/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb @@ -18,9 +18,9 @@ "\n", "Alternatively, you can use the [Azure CLI to create a session pool.](https://learn.microsoft.com/en-us/azure/container-apps/sessions-code-interpreter#create-a-session-pool-with-azure-cli)\n", "\n", - "## AzureContainerCodeExecutor\n", + "## ACADynamicSessionsCodeExecutor\n", "\n", - "The {py:class}`~autogen_ext.code_executor.aca_dynamic_sessions.AzureContainerCodeExecutor` class is a python code executor that creates and executes arbitrary python code on a default Serverless code interpreter session. Its interface is as follows\n", + "The {py:class}`~autogen_ext.code_executors.azure.ACADynamicSessionsCodeExecutor` class is a python code executor that creates and executes arbitrary python code on a default Serverless code interpreter session. Its interface is as follows\n", "\n", "### Initialization\n", "\n", @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -62,8 +62,8 @@ "\n", "from anyio import open_file\n", "from autogen_core import CancellationToken\n", - "from autogen_core.components.code_executor import CodeBlock\n", - "from autogen_ext.code_executor.aca_dynamic_sessions import AzureContainerCodeExecutor\n", + "from autogen_core.code_executor import CodeBlock\n", + "from autogen_ext.code_executors.azure import ACADynamicSessionsCodeExecutor\n", "from azure.identity import DefaultAzureCredential" ] }, @@ -84,7 +84,7 @@ "POOL_MANAGEMENT_ENDPOINT = \"...\"\n", "\n", "with tempfile.TemporaryDirectory() as temp_dir:\n", - " executor = AzureContainerCodeExecutor(\n", + " executor = ACADynamicSessionsCodeExecutor(\n", " pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT, credential=DefaultAzureCredential(), work_dir=temp_dir\n", " )\n", "\n", @@ -120,7 +120,7 @@ " assert os.path.isfile(os.path.join(temp_dir, test_file_1))\n", " assert os.path.isfile(os.path.join(temp_dir, test_file_2))\n", "\n", - " executor = AzureContainerCodeExecutor(\n", + " executor = ACADynamicSessionsCodeExecutor(\n", " pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT, credential=DefaultAzureCredential(), work_dir=temp_dir\n", " )\n", " await executor.upload_files([test_file_1, test_file_2], cancellation_token)\n", @@ -168,7 +168,7 @@ " assert not os.path.isfile(os.path.join(temp_dir, test_file_1))\n", " assert not os.path.isfile(os.path.join(temp_dir, test_file_2))\n", "\n", - " executor = AzureContainerCodeExecutor(\n", + " executor = ACADynamicSessionsCodeExecutor(\n", " pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT, credential=DefaultAzureCredential(), work_dir=temp_dir\n", " )\n", "\n", @@ -208,7 +208,7 @@ "source": [ "### New Sessions\n", "\n", - "Every instance of the {py:class}`~autogen_ext.code_executors.azure.AzureContainerCodeExecutor` class will have a unique session ID. Every call to a particular code executor will be executed on the same session until the {py:meth}`~autogen_ext.code_executors.azure.AzureContainerCodeExecutor.restart` function is called on it. Previous sessions cannot be reused.\n", + "Every instance of the {py:class}`~autogen_ext.code_executors.azure.ACADynamicSessionsCodeExecutor` class will have a unique session ID. Every call to a particular code executor will be executed on the same session until the {py:meth}`~autogen_ext.code_executors.azure.ACADynamicSessionsCodeExecutor.restart` function is called on it. Previous sessions cannot be reused.\n", "\n", "Here we'll run some code on the code session, restart it, then verify that a new session has been opened." ] @@ -219,7 +219,7 @@ "metadata": {}, "outputs": [], "source": [ - "executor = AzureContainerCodeExecutor(\n", + "executor = ACADynamicSessionsCodeExecutor(\n", " pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT, credential=DefaultAzureCredential()\n", ")\n", "\n", @@ -243,7 +243,7 @@ "source": [ "### Available Packages\n", "\n", - "Each code execution instance is pre-installed with most of the commonly used packages. However, the list of available packages and versions are not available outside of the execution environment. The packages list on the environment can be retrieved by calling the {py:meth}`~autogen_ext.code_executors.azure.AzureContainerCodeExecutor.get_available_packages` function on the code executor." + "Each code execution instance is pre-installed with most of the commonly used packages. However, the list of available packages and versions are not available outside of the execution environment. The packages list on the environment can be retrieved by calling the {py:meth}`~autogen_ext.code_executors.azure.ACADynamicSessionsCodeExecutor.get_available_packages` function on the code executor." ] }, { @@ -257,8 +257,22 @@ } ], "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.5" } }, "nbformat": 4,