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

new API to the workflow run page #1400

Merged
merged 6 commits into from
Dec 18, 2024
Merged

new API to the workflow run page #1400

merged 6 commits into from
Dec 18, 2024

Conversation

wintonzheng
Copy link
Contributor

@wintonzheng wintonzheng commented Dec 17, 2024

Important

Adds get_workflow_run_events API endpoint, a database index for ObserverThoughtModel, and refactors parse_actions function.

  • API:
    • Adds get_workflow_run_events endpoint in agent_protocol.py to retrieve events for a workflow run, including tasks, actions, and observer thoughts.
  • Database:
    • Adds index observer_cruise_index to ObserverThoughtModel in models.py and corresponding Alembic migration.
  • Refactoring:
    • Moves parse_actions function to parse_actions.py from actions.py.

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

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 d24d9ce in 58 seconds

More details
  • Looked at 649 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/webeye/actions/parse_actions.py:124
  • Draft comment:
    Redundant check for action_type == "null". This is already covered by action_type == ActionType.NULL_ACTION. Consider removing this check.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment seems to suggest a redundancy that doesn't exist in the code. There is no ActionType.NULL_ACTION in the code, so the check for action_type == "null" is not redundant. The comment appears to be incorrect.
    I might be missing some context about the ActionType enum. If ActionType.NULL_ACTION is defined elsewhere, the comment could be valid. However, based on the provided code, it seems incorrect.
    Given the provided code, there is no evidence of ActionType.NULL_ACTION, so the comment is likely incorrect. If ActionType.NULL_ACTION existed, it would be imported or defined in the code.
    The comment is incorrect because there is no ActionType.NULL_ACTION in the code, making the check for action_type == "null" necessary. The comment should be deleted.

Workflow ID: wflow_WsGUVdYKKzMmxxCd


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.

modified_at=thought.modified_at,
)
)
workflow_run_events.sort(key=lambda x: x.created_at, reverse=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider optimizing the retrieval and sorting of workflow run events to handle large datasets efficiently. Sorting in memory can be inefficient for large datasets.

@@ -325,6 +325,25 @@ async def get_task_actions(self, task_id: str, organization_id: str | None = Non
LOG.error("UnexpectedError", exc_info=True)
raise

async def get_tasks_actions(self, task_ids: list[str], organization_id: str | None = None) -> list[Action]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle the case where task_ids is an empty list to avoid unnecessary database queries. This is applicable to similar methods as well.

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.

👍 Looks good to me! Reviewed everything up to d24d9ce in 1 minute and 9 seconds

More details
  • Looked at 649 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:648
  • Draft comment:
    Consider adding a response model to the get_workflow_run_events function to ensure consistent API responses.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_workflow_run_events function in agent_protocol.py is missing a response model. This can lead to inconsistencies in the API response format and make it harder to maintain and understand the API contract.
2. skyvern/forge/sdk/routes/agent_protocol.py:701
  • Draft comment:
    Using datetime.datetime.utcnow() as a fallback for created_at and modified_at can lead to inconsistencies. Consider ensuring these fields are always set correctly in the database.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_tasks_actions method in client.py and get_workflow_run_events in agent_protocol.py both use datetime.datetime.utcnow() as a fallback for created_at and modified_at. This can lead to inconsistencies if the database already has a value for these fields.
3. skyvern/forge/sdk/db/client.py:1824
  • Draft comment:
    Consider adding error handling for NotFoundError in the get_observer_cruise_thoughts method to handle cases where the observer cruise is not found.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_observer_cruise_thoughts method in client.py is missing error handling for NotFoundError. This can lead to unhandled exceptions if the observer cruise is not found.

Workflow ID: wflow_rp0n3zMpJkFc7yGl


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@wintonzheng wintonzheng force-pushed the shu/workflow_endpoint_v2 branch from d24d9ce to 7027527 Compare December 17, 2024 07:09
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.

👍 Looks good to me! Incremental review on 7027527 in 16 seconds

More details
  • Looked at 37 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. alembic/versions/2024_12_17_0651-cf45479f484c_add_index_to_observerthoughtmodel_db_.py:20
  • Draft comment:
    Consider adding docstrings to the upgrade and downgrade functions for clarity and maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The Alembic migration script is missing a docstring for the upgrade and downgrade functions, which is a best practice for clarity and maintainability.

Workflow ID: wflow_rGcYw7TFanRclvN5


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

type=WorkflowRunEventType.block,
block=WorkflowRunBlock(
workflow_run_id=workflow_run_id,
block_type=BlockType.TASK,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why always task? not navigation/action/...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's currently no way to tell right now. We need to integrate WorkflowRunTask but that has not been built.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh i can use navigation_goal and extraction_goal to tell. good point

wintonzheng and others added 3 commits December 17, 2024 02:02
<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Adds `get_workflow_run_events` API endpoint and database index for `ObserverThoughtModel`, and refactors `parse_actions` function.
>
>   - **API**:
>     - Adds `get_workflow_run_events` endpoint in `agent_protocol.py` to retrieve events for a workflow run, including tasks, actions, and observer thoughts.
>   - **Database**:
>     - Adds index `observer_cruise_index` to `ObserverThoughtModel` in `models.py` and corresponding Alembic migration.
>   - **Refactoring**:
>     - Moves `parse_actions` function to `parse_actions.py` from `actions.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 29096b0ad914a522589edb557c6ce8f3b44bbb40. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
@wintonzheng wintonzheng force-pushed the shu/workflow_endpoint_v2 branch from 7027527 to 43aff9b Compare December 17, 2024 10:05
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.

👍 Looks good to me! Incremental review on 43aff9b in 37 seconds

More details
  • Looked at 36 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:666
  • Draft comment:
    Add a check to ensure tasks is not empty before iterating over it to prevent potential errors.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment suggests a change that is not necessary. Iterating over an empty list in Python is safe and does not cause errors. The code handles the case where 'tasks' is empty by simply not appending any events to 'workflow_run_events'. Therefore, the comment does not point out a required code change.
    I might be overlooking a specific requirement or context where an empty 'tasks' list should be handled differently, but based on standard Python behavior, iterating over an empty list is not problematic.
    The standard behavior of iterating over an empty list is well-understood and does not require additional checks unless specified by additional requirements, which are not evident here.
    The comment is unnecessary because iterating over an empty list is safe and does not require additional checks. The comment should be deleted.
2. skyvern/forge/sdk/routes/agent_protocol.py:698
  • Draft comment:
    Add a check to ensure actions is not empty before iterating over it to prevent potential errors.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_kBCuidtm4yIBbzOb


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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.

👍 Looks good to me! Incremental review on 53166d5 in 17 seconds

More details
  • Looked at 33 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:669
  • Draft comment:
    Consider using a dictionary to map task.task_type to BlockType to simplify the block_type determination logic. This will make the code cleaner and easier to maintain.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code for determining block_type in the get_workflow_run_events function is repetitive and can be simplified by using a dictionary mapping task.task_type to BlockType. This will make the code cleaner and easier to maintain.

Workflow ID: wflow_uVYhjJsnNS5DDv89


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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.

👍 Looks good to me! Incremental review on 1cd472c in 17 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/routes/agent_protocol.py:729
  • Draft comment:
    The change in sorting order from descending to ascending might affect the logic that relies on the order of events. Ensure this change aligns with the intended behavior.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_J48oD0o7eqSoAcgQ


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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.

👍 Looks good to me! Incremental review on 24597e7 in 21 seconds

More details
  • Looked at 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/db/client.py:1822
  • Draft comment:
    Consider creating a utility function for ordering by created_at as this pattern is repeated in multiple functions (e.g., get_task_steps, get_tasks_actions, get_artifacts_for_observer_cruise, etc.).
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The order_by clause in the get_observer_cruise_thoughts function is correct and aligns with the PR description. However, the same order_by clause is used in multiple functions, which could be optimized by creating a utility function for ordering by created_at.

Workflow ID: wflow_QPiz94oFReYJ4LlT


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@wintonzheng wintonzheng merged commit 58413db into main Dec 18, 2024
2 checks passed
@wintonzheng wintonzheng deleted the shu/workflow_endpoint_v2 branch December 18, 2024 01:17
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