DockerCommandLineCodeExecutor
autogen.coding.DockerCommandLineCodeExecutor #
DockerCommandLineCodeExecutor(image='python:3-slim', container_name=None, timeout=60, work_dir=None, bind_dir=None, auto_remove=True, stop_container=True, execution_policies=None)
Bases: CodeExecutor
(Experimental) A code executor class that executes code through a command line environment in a Docker container.
The executor first saves each code block in a file in the working directory, and then executes the code file in the container. The executor executes the code blocks in the order they are received. Currently, the executor only supports Python and shell scripts. For Python code, use the language "python" for the code block. For shell scripts, use the language "bash", "shell", or "sh" for the code block.
PARAMETER | DESCRIPTION |
---|---|
image | Docker image to use for code execution. Defaults to "python:3-slim". TYPE: |
container_name | Name of the Docker container which is created. If None, will autogenerate a name. Defaults to None. |
timeout | The timeout for code execution. Defaults to 60. TYPE: |
work_dir | The working directory for the code execution. Defaults to Path("."). |
bind_dir | The directory that will be bound |
auto_remove | If true, will automatically remove the Docker container when it is stopped. Defaults to True. TYPE: |
stop_container | If true, will automatically stop the container when stop is called, when the context manager exits or when the Python process exits with atext. Defaults to True. TYPE: |
RAISES | DESCRIPTION |
---|---|
ValueError | On argument error, or if the container fails to start. |
Source code in autogen/coding/docker_commandline_code_executor.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
DEFAULT_EXECUTION_POLICY class-attribute
#
DEFAULT_EXECUTION_POLICY = {'bash': True, 'shell': True, 'sh': True, 'pwsh': True, 'powershell': True, 'ps1': True, 'python': True, 'javascript': False, 'html': False, 'css': False}
code_extractor property
#
(Experimental) Export a code extractor that can be used by an agent.
execute_code_blocks #
(Experimental) Execute the code blocks and return the result.
PARAMETER | DESCRIPTION |
---|---|
code_blocks | The code blocks to execute. TYPE: |
RETURNS | DESCRIPTION |
---|---|
CommandlineCodeResult | The result of the code execution. TYPE: |
Source code in autogen/coding/docker_commandline_code_executor.py
restart #
(Experimental) Restart the code executor.