PythonTask(Python 任务基类)¶
evotoolkit.task.python_task.python_task.PythonTask
¶
Bases: BaseTask
Abstract base class for Python-based evolutionary optimization tasks.
This class unifies PythonEvaluator and PythonTaskConfig functionality, providing a common base for Python code evaluation tasks.
Source code in src/evotoolkit/task/python_task/python_task.py
__init__
¶
Initialize the Python task with input data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Task-specific input data. |
required |
timeout_seconds
|
float
|
Execution timeout for code evaluation. |
30.0
|
Source code in src/evotoolkit/task/python_task/python_task.py
get_task_type
¶
evaluate_code
¶
Evaluate Python code.
Default implementation provides basic error handling framework. Subclasses should override this method with specific evaluation logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate_code
|
str
|
Python code to evaluate |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvaluationResult |
EvaluationResult
|
Result of the evaluation |