Skip to content

Commit

Permalink
Fixes for azure-container-code-executor.ipynb (#4970)
Browse files Browse the repository at this point in the history
Fixes for azure-container-code-executor.ipyn
  • Loading branch information
jackgerrits authored Jan 9, 2025
1 parent 7c31ee0 commit c4302ee
Showing 1 changed file with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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"
]
},
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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."
]
Expand All @@ -219,7 +219,7 @@
"metadata": {},
"outputs": [],
"source": [
"executor = AzureContainerCodeExecutor(\n",
"executor = ACADynamicSessionsCodeExecutor(\n",
" pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT, credential=DefaultAzureCredential()\n",
")\n",
"\n",
Expand All @@ -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."
]
},
{
Expand All @@ -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,
Expand Down

0 comments on commit c4302ee

Please sign in to comment.