-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
In agave/tasks/sqs_tasks.py, the run_task function currently extracts request and response models on each execution using get_request_model(task_func) and get_response_model(task_func). Since the task function doesn't change between executions, this is unnecessary and inefficient.
Proposed Solution
Move the model extraction out of the run_task function so it happens only once when the task is defined or initialized, and then reuse these models for each task execution.
For example, this could be done in the task decorator or when creating a new task instance:
# Example implementation
def task(...):
def task_builder(task_func: Callable):
# Extract models once
request_model = get_request_model(task_func)
response_model = get_response_model(task_func)
request_log_config_fields = get_sensitive_fields(request_model)
response_log_config_fields = get_sensitive_fields(response_model)
@wraps(task_func)
async def start_task(*args, **kwargs) -> None:
# Pass pre-extracted models to run_task
...
return start_task
return task_builderThis optimization would improve performance for frequently executed tasks.
Related PR: #159 (comment)
Metadata
Metadata
Assignees
Labels
No labels