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

Add sorting to task api #1018

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Add sorting to task api #1018

merged 1 commit into from
Oct 21, 2024

Conversation

wintonzheng
Copy link
Contributor

@wintonzheng wintonzheng commented Oct 21, 2024

Important

Adds sorting functionality to task API with new parameters for sorting direction and column in client.py and agent_protocol.py.

  • Behavior:
    • Adds sorting to get_tasks() in client.py with order_by_column and order parameters.
    • Updates get_agent_tasks() in agent_protocol.py to accept sort and order query parameters.
  • Schemas:
    • Adds OrderBy and SortDirection enums to tasks.py for sorting options.
  • Imports:
    • Adds OrderBy and SortDirection imports in client.py and agent_protocol.py.

This description was created by Ellipsis for 16010bc. It will automatically update as commits are pushed.

<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Adds sorting functionality to task API with new parameters for sorting direction and column in `client.py` and `agent_protocol.py`.
>
>   - **Behavior**:
>     - Adds sorting to `get_tasks()` in `client.py` with `order_by_column` and `order` parameters.
>     - Updates `get_agent_tasks()` in `agent_protocol.py` to accept `sort` and `order` query parameters.
>   - **Schemas**:
>     - Adds `OrderBy` and `SortDirection` enums to `tasks.py` for sorting options.
>   - **Imports**:
>     - Adds `OrderBy` and `SortDirection` imports in `client.py` and `agent_protocol.py`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for 3cde532c20c2c11969c48a527610f75a81f595e8. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 16010bc in 37 seconds

More details
  • Looked at 113 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:396
  • Draft comment:
    Consider adding validation for sort to ensure it is a valid attribute of TaskModel. This will prevent runtime errors if an invalid column name is passed.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is relevant to the changes made in the diff, as it addresses the newly added 'sort' parameter. Adding validation for the 'sort' parameter could prevent runtime errors if an invalid column name is passed, which is a valid concern. The comment is actionable and suggests a specific improvement to the code quality.
    The comment assumes that the 'sort' parameter could be invalid without evidence from the code. It might be unnecessary if the 'OrderBy' type already ensures valid values.
    The 'OrderBy' type might not cover all potential invalid inputs, especially if it can be extended or modified elsewhere. Adding explicit validation could be a safeguard.
    The comment is relevant and suggests a specific improvement related to the changes in the diff. It should be kept as it addresses a potential issue with the new 'sort' parameter.

Workflow ID: wflow_JRqkSBu1UeMotOwP


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -484,7 +488,12 @@ async def get_tasks(
query = query.filter(TaskModel.workflow_run_id == workflow_run_id)
if only_standalone_tasks:
query = query.filter(TaskModel.workflow_run_id.is_(None))
query = query.order_by(TaskModel.created_at.desc()).limit(page_size).offset(db_page * page_size)
order_by_col = getattr(TaskModel, order_by_column)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding validation for order_by_column to ensure it is a valid attribute of TaskModel. This will prevent runtime errors if an invalid column name is passed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 16010bc in 37 seconds

More details
  • Looked at 113 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:421
  • Draft comment:
    Ensure that sort and order parameters are validated to be within the expected enum values to prevent unexpected behavior.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_agent_tasks function in agent_protocol.py correctly uses the new sorting parameters sort and order. However, it should ensure that these parameters are validated to be within the expected enum values to prevent unexpected behavior.

Workflow ID: wflow_THKwLjYNFrXpdaIa


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -484,7 +488,12 @@ async def get_tasks(
query = query.filter(TaskModel.workflow_run_id == workflow_run_id)
if only_standalone_tasks:
query = query.filter(TaskModel.workflow_run_id.is_(None))
query = query.order_by(TaskModel.created_at.desc()).limit(page_size).offset(db_page * page_size)
order_by_col = getattr(TaskModel, order_by_column)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider validating order_by_column before using getattr to ensure it is a valid attribute of TaskModel. This can prevent potential runtime errors.

@msalihaltun msalihaltun merged commit b0d9f9c into main Oct 21, 2024
2 checks passed
@msalihaltun msalihaltun deleted the salih/add-sort-filter-to-tasks branch October 21, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants