mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 11:08:33 +00:00
Address PR feedback: Add validation, refactor code duplication, enhance tests
- Add regex pattern validation for execution_image parameter - Refactor get_code_execution_tools() to eliminate code duplication using tool_kwargs - Add comprehensive tests for invalid Docker image format validation - Add tests for various valid Docker image formats - Update documentation with best practices section for custom Docker images - Fix lint issues: remove unused imports and variables Addresses feedback from joaomdmoura in PR #2934 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -108,6 +108,30 @@ programmer_agent = Agent(
|
||||
)
|
||||
```
|
||||
|
||||
### Best Practices for Custom Docker Images
|
||||
|
||||
When using custom Docker images for code execution, consider the following best practices:
|
||||
|
||||
- **Use specific version tags**: Instead of `latest`, use specific version tags like `python:3.11-slim` for reproducible builds
|
||||
- **Security scanning**: Ensure your custom images are regularly scanned for security vulnerabilities
|
||||
- **Image size optimization**: Consider using slim or alpine variants to reduce image size and improve performance
|
||||
- **Pre-installed dependencies**: Include commonly used libraries in your custom image to avoid repeated installations
|
||||
- **Registry accessibility**: Ensure the Docker registry hosting your custom image is accessible from your execution environment
|
||||
|
||||
Example with a custom image containing data science libraries:
|
||||
|
||||
```python Code
|
||||
# Custom image with pre-installed data science packages
|
||||
data_scientist_agent = Agent(
|
||||
role="Data Scientist",
|
||||
goal="Analyze datasets and create visualizations",
|
||||
backstory="Expert in data analysis with access to specialized tools",
|
||||
allow_code_execution=True,
|
||||
execution_image="my-registry.com/datascience:python3.11-pandas-numpy",
|
||||
verbose=True,
|
||||
)
|
||||
```
|
||||
|
||||
### Enabling `unsafe_mode`
|
||||
|
||||
```python Code
|
||||
|
||||
Reference in New Issue
Block a user