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

Observer artifact creation #1345

Merged
merged 1 commit into from
Dec 7, 2024
Merged

Observer artifact creation #1345

merged 1 commit into from
Dec 7, 2024

Conversation

wintonzheng
Copy link
Contributor

@wintonzheng wintonzheng commented Dec 7, 2024

Important

Add support for observer artifact creation in ArtifactManager with new schema models and database updates.

  • Artifact Manager:
    • Adds create_observer_thought_artifact() in manager.py for creating observer thought artifacts.
    • Introduces _create_artifact() as a helper method in manager.py.
  • Schemas:
    • Adds ObserverCruise and ObserverThought models in schemas/observers.py.
    • Defines ObserverCruiseStatus enum for cruise status.
  • Database Models:
    • Renames ObserverCruise to ObserverCruiseModel and ObserverThought to ObserverThoughtModel in models.py.
  • Storage:
    • Adds build_observer_thought_uri() and build_observer_cruise_uri() in base.py, local.py, and s3.py for URI construction.
  • Misc:
    • Updates convert_to_artifact() in utils.py to handle new fields.

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

<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Add support for observer artifact creation in `ArtifactManager` with new schema models and database updates.
>
>   - **Artifact Manager**:
>     - Adds `create_observer_thought_artifact()` in `manager.py` for creating observer thought artifacts.
>     - Introduces `_create_artifact()` as a helper method in `manager.py`.
>   - **Schemas**:
>     - Adds `ObserverCruise` and `ObserverThought` models in `schemas/observers.py`.
>     - Defines `ObserverCruiseStatus` enum for cruise status.
>   - **Database Models**:
>     - Renames `ObserverCruise` to `ObserverCruiseModel` and `ObserverThought` to `ObserverThoughtModel` in `models.py`.
>   - **Storage**:
>     - Adds `build_observer_thought_uri()` and `build_observer_cruise_uri()` in `base.py`, `local.py`, and `s3.py` for URI construction.
>   - **Misc**:
>     - Updates `convert_to_artifact()` in `utils.py` to handle new fields.
>
> <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 5f69680cb82830e452c7c57c248e9805f9a0c12e. 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.

👍 Looks good to me! Incremental review on 3fca676 in 31 seconds

More details
  • Looked at 425 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. skyvern/forge/sdk/artifact/manager.py:111
  • Draft comment:
    The use of Literal for the primary_key parameter is unnecessary. Consider using a simple string type instead for better readability and simplicity.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in manager.py has a potential issue with the use of Literal for the primary_key parameter in update_artifact_data. The use of Literal is not necessary here and can be replaced with a simple string type, as it doesn't provide any additional type safety or functionality in this context.
2. skyvern/forge/sdk/artifact/manager.py:23
  • Draft comment:
    Ensure that aio_task_primary_key is a valid key in upload_aiotasks_map to prevent potential KeyErrors.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In manager.py, the _create_artifact method has a potential issue with the aio_task_primary_key parameter. It is used to index the upload_aiotasks_map, but there is no check to ensure that this key is valid or exists. This could lead to potential KeyErrors if the key is not present in the map.
3. skyvern/forge/sdk/artifact/manager.py:71
  • Draft comment:
    Consider refactoring the repeated pattern of generating artifact_id and building a URI into a helper function to reduce code duplication.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In manager.py, the create_artifact and create_observer_thought_artifact methods both generate a new artifact_id and then immediately use it to build a URI. This pattern is repeated and could be refactored into a helper function to reduce code duplication and improve maintainability.
4. skyvern/forge/sdk/artifact/storage/local.py:39
  • Draft comment:
    Consider refactoring the file path and directory handling logic into a helper method to reduce code duplication in store_artifact and store_artifact_from_path.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In local.py, the store_artifact and store_artifact_from_path methods both have similar logic for handling file paths and directories. This logic could be refactored into a helper method to reduce code duplication and improve maintainability.
5. skyvern/forge/sdk/artifact/storage/s3.py:42
  • Draft comment:
    Consider adding error handling for async_client operations to manage potential upload failures.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In s3.py, the store_artifact and store_artifact_from_path methods both use the async_client to upload files. If the async_client fails, there is no error handling to manage this situation, which could lead to unhandled exceptions.

Workflow ID: wflow_xCqiovgSWMfjigKu


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! Reviewed everything up to 3fca676 in 1 minute and 26 seconds

More details
  • Looked at 425 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. skyvern/forge/sdk/artifact/manager.py:111
  • Draft comment:
    Consider using an Enum instead of Literal for the primary_key parameter to ensure type safety and avoid potential runtime errors.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of Literal for the primary_key parameter in the update_artifact_data method is not ideal. It would be better to use an Enum to ensure type safety and avoid potential runtime errors.
2. skyvern/forge/sdk/artifact/manager.py:64
  • Draft comment:
    Consider extracting the logic for generating artifact_id and uri into a helper function to reduce code duplication in create_artifact and create_observer_thought_artifact.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The create_artifact and create_observer_thought_artifact methods have similar logic for generating artifact_id and uri. This logic can be extracted into a helper function to reduce code duplication.
3. skyvern/forge/sdk/artifact/storage/local.py:27
  • Draft comment:
    Consider extracting the URI construction logic into a shared utility function to reduce code duplication between LocalStorage and S3Storage.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The build_observer_thought_uri and build_observer_cruise_uri methods in LocalStorage and S3Storage have similar logic for constructing URIs. This logic can be extracted into a shared utility function to reduce code duplication.
4. skyvern/forge/sdk/artifact/storage/s3.py:30
  • Draft comment:
    Consider extracting the URI construction logic into a shared utility function to reduce code duplication between LocalStorage and S3Storage.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The build_observer_thought_uri and build_observer_cruise_uri methods in LocalStorage and S3Storage have similar logic for constructing URIs. This logic can be extracted into a shared utility function to reduce code duplication.
5. skyvern/forge/sdk/db/utils.py:150
  • Draft comment:
    Ensure that artifact_model.artifact_type is a valid key in ArtifactType to avoid potential KeyError. Consider using get with a default value or handling the exception.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The convert_to_artifact function uses ArtifactType[artifact_model.artifact_type.upper()] which assumes that the artifact_type is always a valid key in the ArtifactType enum. This could lead to a KeyError if the artifact_type is not valid. It would be safer to handle this potential error.

Workflow ID: wflow_fxvMvb5VsuQ2VlQF


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

@wintonzheng wintonzheng merged commit 127f25c into main Dec 7, 2024
2 checks passed
@wintonzheng wintonzheng deleted the shu/observer_artifacts branch December 7, 2024 20:22
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.

1 participant