mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Fixes for azure-container-code-executor.ipynb (#4970)
Fixes for azure-container-code-executor.ipyn
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user