Skip to main content

A code executor that leverages Docker Container

Project description

Docker Code Executor

This is borrowed from https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py

and converted into an independent package with some minor modifications and adjustments.

Install

pip install docker-code-executor

Usage

import asyncio

from docker_code_executor import CancellationToken, CodeBlock, CommandLineCodeResult, DockerCommandLineCodeExecutor

executor = DockerCommandLineCodeExecutor()
await executor.start()

code_blocks = [
    CodeBlock(
        code="""
import os
for k, v in os.environ.items():
    print(f"{k}={v}")
""",
        language="python",
    )
]

cancel_token = CancellationToken()

result: CommandLineCodeResult = await executor.execute_code_blocks(code_blocks, cancel_token)
print(result.output)

await executor.stop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker_code_executor-0.0.2.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docker_code_executor-0.0.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file docker_code_executor-0.0.2.tar.gz.

File metadata

  • Download URL: docker_code_executor-0.0.2.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for docker_code_executor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c7b2668c80d9ee83c6c27e4b14e7b405f17642561d8f96f80c2edfdcd6d55d17
MD5 b1a0eace48167839f6ff10b70f3af630
BLAKE2b-256 d3d18b1554f5a1c54a455af75844639548ec621813730365b43f2731e5fc86f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for docker_code_executor-0.0.2.tar.gz:

Publisher: publish.yaml on ksachdeva/code-executors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docker_code_executor-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for docker_code_executor-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 313c37f179aa0d1e257efdf590c5a47fb21dd6ea71260d6976ddb0d5704148a3
MD5 295b7fb0e4d75d61908d56149c092cb6
BLAKE2b-256 b7da3ef01077edc3fb8c95f22178c4d031f3ad85f72a1dc85ddfa5c644e5ec00

See more details on using hashes here.

Provenance

The following attestation bundles were made for docker_code_executor-0.0.2-py3-none-any.whl:

Publisher: publish.yaml on ksachdeva/code-executors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page