Skip to content

Commit 5672c3e

Browse files
afourneyqingyun-wu
andauthored
Addresses issue microsoft#199 (microsoft#200)
* Addresses issue microsoft#199 * Fixed comment to align with new behavior. --------- Co-authored-by: Qingyun Wu <[email protected]>
1 parent ca1c735 commit 5672c3e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

autogen/code_utils.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def execute_code(
218218
timeout: Optional[int] = None,
219219
filename: Optional[str] = None,
220220
work_dir: Optional[str] = None,
221-
use_docker: Optional[Union[List[str], str, bool]] = True,
221+
use_docker: Optional[Union[List[str], str, bool]] = None,
222222
lang: Optional[str] = "python",
223223
) -> Tuple[int, str, str]:
224224
"""Execute code in a docker container.
@@ -257,14 +257,18 @@ def execute_code(
257257
logger.error(error_msg)
258258
raise AssertionError(error_msg)
259259

260-
# Warn if docker was requested but cannot be provided. In this case
261-
# the current behavior is to fall back to run natively, but this behavior
260+
# Warn if use_docker was unspecified (or None), and cannot be provided (the default).
261+
# In this case the current behavior is to fall back to run natively, but this behavior
262262
# is subject to change.
263-
if use_docker and docker is None:
264-
use_docker = False
265-
logger.warning(
266-
"execute_code was called with use_docker evaluating to True, but the python docker package is not available. Falling back to native code execution. Note: this fallback behavior is subject to change"
267-
)
263+
if use_docker is None:
264+
if docker is None:
265+
use_docker = False
266+
logger.warning(
267+
"execute_code was called without specifying a value for use_docker. Since the python docker package is not available, code will be run natively. Note: this fallback behavior is subject to change"
268+
)
269+
else:
270+
# Default to true
271+
use_docker = True
268272

269273
timeout = timeout or DEFAULT_TIMEOUT
270274
original_filename = filename

0 commit comments

Comments
 (0)