autogen-fargate-executor


Nameautogen-fargate-executor JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/imankamyabi/autogen-fargate-executor
SummaryAWS Fargate code executor for AutoGen - Run code securely and scale beyond local resources
upload_time2024-11-13 22:41:48
maintainerNone
docs_urlNone
authorIman Kamyabi
requires_python<4.0,>=3.8
licenseMIT
keywords autogen aws fargate executor serverless ai code-execution
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AutoGen Fargate Executor

A code execution backend for AutoGen that runs code in AWS Fargate containers. This executor allows you to run untrusted code in isolated containers, making it suitable for production environments where code execution needs to be sandboxed.

## Author
**Iman Kamyabi**  
Email: engkamyabi@gmail.com

## Features

- Executes code in isolated AWS Fargate containers
- Automatic creation of required AWS resources (ECS cluster, IAM roles, CloudWatch log groups)
- Support for installing pip dependencies
- Support for custom environment variables
- Support for requirements.txt file
- Integration with AutoGen's code execution interface

## Installation

```bash
pip install autogen-fargate-executor
```

Or using Poetry:

```bash
poetry add autogen-fargate-executor
```

## Prerequisites

1. AWS credentials configured either through environment variables, AWS CLI, or IAM roles
2. VPC with subnets and security groups configured for Fargate tasks
3. Required AWS permissions to create:
   - IAM roles and policies
   - ECS clusters and tasks
   - CloudWatch log groups

## Usage

### Basic Usage with AutoGen

```python
from autogen_fargate_executor import FargateCodeExecutor
from autogen import ConversableAgent

# Initialize executor
executor = FargateCodeExecutor(
    image_uri='python:3.11',
    subnet_ids=['subnet-xxx'],
    security_groups=['sg-xxx'],
)

# Create AutoGen agent with Fargate executor
agent = ConversableAgent(
    name="CodeExecutor",
    llm_config=False,
    code_execution_config={"executor": executor},
    is_termination_msg=lambda msg: "TERMINATE" in msg.get("content", "").strip().upper(),
)
```

### Advanced Configuration

```python
executor = FargateCodeExecutor(
    region_name='us-west-2',             # AWS region
    image_uri='python:3.11',             # Docker image to use
    subnet_ids=['subnet-xxx'],           # List of subnet IDs
    security_groups=['sg-xxx'],          # List of security group IDs
    cluster_name='my-cluster',           # Optional custom cluster name
    cpu='512',                          # CPU units for Fargate task
    memory='1024',                      # Memory (MB) for Fargate task
    timeout_seconds=600,                # Maximum execution time
    requirements_file='requirements.txt', # Optional requirements file
    pip_dependencies=['pandas', 'requests'], # Optional pip packages
    environment_variables={              # Optional environment variables
        'API_KEY': 'xxx',
        'DEBUG': 'true'
    }
)
```

## AWS Resources

The executor will automatically create and manage these AWS resources:

1. ECS Cluster (default name: autogen-executor-cluster)
2. IAM Role (name: ecsTaskExecutionRoleAutoGenFargate)
3. CloudWatch Log Group (name: /ecs/autogen-task)

## Security Considerations

1. Each code execution runs in its own isolated container
2. Containers are terminated after code execution
3. Resources are isolated within your VPC
4. Task execution role follows principle of least privilege
5. All container logs are captured in CloudWatch

## Cost Considerations

This executor uses AWS Fargate, which bills based on:
1. vCPU and memory used per second
2. CloudWatch logs storage and ingestion
3. Data transfer costs

Consider configuring appropriate CPU and memory settings based on your workload.

## Development

### Running Tests

```bash
poetry install
poetry run pytest tests/
```

## License

MIT

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/imankamyabi/autogen-fargate-executor",
    "name": "autogen-fargate-executor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "autogen, aws, fargate, executor, serverless, ai, code-execution",
    "author": "Iman Kamyabi",
    "author_email": "engkamyabi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/09/273fb1069bd9610a1d510dd7519468ec9d876059923cfa122aa3ec699ae9/autogen_fargate_executor-0.1.1.tar.gz",
    "platform": null,
    "description": "# AutoGen Fargate Executor\n\nA code execution backend for AutoGen that runs code in AWS Fargate containers. This executor allows you to run untrusted code in isolated containers, making it suitable for production environments where code execution needs to be sandboxed.\n\n## Author\n**Iman Kamyabi**  \nEmail: engkamyabi@gmail.com\n\n## Features\n\n- Executes code in isolated AWS Fargate containers\n- Automatic creation of required AWS resources (ECS cluster, IAM roles, CloudWatch log groups)\n- Support for installing pip dependencies\n- Support for custom environment variables\n- Support for requirements.txt file\n- Integration with AutoGen's code execution interface\n\n## Installation\n\n```bash\npip install autogen-fargate-executor\n```\n\nOr using Poetry:\n\n```bash\npoetry add autogen-fargate-executor\n```\n\n## Prerequisites\n\n1. AWS credentials configured either through environment variables, AWS CLI, or IAM roles\n2. VPC with subnets and security groups configured for Fargate tasks\n3. Required AWS permissions to create:\n   - IAM roles and policies\n   - ECS clusters and tasks\n   - CloudWatch log groups\n\n## Usage\n\n### Basic Usage with AutoGen\n\n```python\nfrom autogen_fargate_executor import FargateCodeExecutor\nfrom autogen import ConversableAgent\n\n# Initialize executor\nexecutor = FargateCodeExecutor(\n    image_uri='python:3.11',\n    subnet_ids=['subnet-xxx'],\n    security_groups=['sg-xxx'],\n)\n\n# Create AutoGen agent with Fargate executor\nagent = ConversableAgent(\n    name=\"CodeExecutor\",\n    llm_config=False,\n    code_execution_config={\"executor\": executor},\n    is_termination_msg=lambda msg: \"TERMINATE\" in msg.get(\"content\", \"\").strip().upper(),\n)\n```\n\n### Advanced Configuration\n\n```python\nexecutor = FargateCodeExecutor(\n    region_name='us-west-2',             # AWS region\n    image_uri='python:3.11',             # Docker image to use\n    subnet_ids=['subnet-xxx'],           # List of subnet IDs\n    security_groups=['sg-xxx'],          # List of security group IDs\n    cluster_name='my-cluster',           # Optional custom cluster name\n    cpu='512',                          # CPU units for Fargate task\n    memory='1024',                      # Memory (MB) for Fargate task\n    timeout_seconds=600,                # Maximum execution time\n    requirements_file='requirements.txt', # Optional requirements file\n    pip_dependencies=['pandas', 'requests'], # Optional pip packages\n    environment_variables={              # Optional environment variables\n        'API_KEY': 'xxx',\n        'DEBUG': 'true'\n    }\n)\n```\n\n## AWS Resources\n\nThe executor will automatically create and manage these AWS resources:\n\n1. ECS Cluster (default name: autogen-executor-cluster)\n2. IAM Role (name: ecsTaskExecutionRoleAutoGenFargate)\n3. CloudWatch Log Group (name: /ecs/autogen-task)\n\n## Security Considerations\n\n1. Each code execution runs in its own isolated container\n2. Containers are terminated after code execution\n3. Resources are isolated within your VPC\n4. Task execution role follows principle of least privilege\n5. All container logs are captured in CloudWatch\n\n## Cost Considerations\n\nThis executor uses AWS Fargate, which bills based on:\n1. vCPU and memory used per second\n2. CloudWatch logs storage and ingestion\n3. Data transfer costs\n\nConsider configuring appropriate CPU and memory settings based on your workload.\n\n## Development\n\n### Running Tests\n\n```bash\npoetry install\npoetry run pytest tests/\n```\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "AWS Fargate code executor for AutoGen - Run code securely and scale beyond local resources",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://github.com/imankamyabi/autogen-fargate-executor#readme",
        "Homepage": "https://github.com/imankamyabi/autogen-fargate-executor",
        "Repository": "https://github.com/imankamyabi/autogen-fargate-executor"
    },
    "split_keywords": [
        "autogen",
        " aws",
        " fargate",
        " executor",
        " serverless",
        " ai",
        " code-execution"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "972197f2d67075d2fa888c44dff3065db415df6bb192d510d6b565ec1c3247ce",
                "md5": "467f778ab77e1aac4caeeee0ee84b1f8",
                "sha256": "dc9461d46b55fa5bd15833db541ef5c95ee75538b4df541a2fa37ede18cf533b"
            },
            "downloads": -1,
            "filename": "autogen_fargate_executor-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "467f778ab77e1aac4caeeee0ee84b1f8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 7346,
            "upload_time": "2024-11-13T22:41:46",
            "upload_time_iso_8601": "2024-11-13T22:41:46.867004Z",
            "url": "https://files.pythonhosted.org/packages/97/21/97f2d67075d2fa888c44dff3065db415df6bb192d510d6b565ec1c3247ce/autogen_fargate_executor-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f09273fb1069bd9610a1d510dd7519468ec9d876059923cfa122aa3ec699ae9",
                "md5": "91e92806a972d0537be0085e24855d38",
                "sha256": "48a3ceb3a9f7ba0b8a8e0775b4c5064640ac9316879e865a8db9685fb517d348"
            },
            "downloads": -1,
            "filename": "autogen_fargate_executor-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "91e92806a972d0537be0085e24855d38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 6651,
            "upload_time": "2024-11-13T22:41:48",
            "upload_time_iso_8601": "2024-11-13T22:41:48.096881Z",
            "url": "https://files.pythonhosted.org/packages/0f/09/273fb1069bd9610a1d510dd7519468ec9d876059923cfa122aa3ec699ae9/autogen_fargate_executor-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-13 22:41:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "imankamyabi",
    "github_project": "autogen-fargate-executor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "autogen-fargate-executor"
}
        
Elapsed time: 0.46270s