Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize SQS task performance by extracting models once #162

Open
coderabbitai bot opened this issue Mar 5, 2025 · 0 comments
Open

Optimize SQS task performance by extracting models once #162

coderabbitai bot opened this issue Mar 5, 2025 · 0 comments
Assignees

Comments

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2025

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_builder

This optimization would improve performance for frequently executed tasks.

Related PR: #159 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant