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

𖭦 Ability to override stage on enqueue #89

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

asim-shrestha
Copy link
Contributor

@asim-shrestha asim-shrestha commented Nov 20, 2024

Closes #APE-345


Important

Add stage override capability to enqueue() in Harambe SDK with updated tests and version bump to 0.51.0.

  • Behavior:
    • Add stage parameter to enqueue() in core.py for stage override.
    • Introduce get_next_stage() in core.py to determine the next stage.
  • Observer:
    • Update on_queue_url() in observer.py to accept stage parameter.
  • Types:
    • Add "parent_category" to Stage in types.py.
  • Tests:
    • Add test_get_next_stage.py to test get_next_stage().
    • Update test_e2e.py, test_pagination.py, and test_sdk.py for stage parameter.
  • Versioning:
    • Update version to 0.51.0 in pyproject.toml and uv.lock for harambe-core and harambe-sdk.

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

Copy link

@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 d3b859d in 29 seconds

More details
  • Looked at 421 lines of code in 12 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. sdk/harambe/core.py:598
  • Draft comment:
    Consider handling unexpected previous_stage values more explicitly, perhaps by raising an exception or logging a warning, instead of defaulting to 'detail'.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_next_stage function should handle unexpected previous_stage values more gracefully. Currently, it defaults to 'detail', which might not be the best approach if the input is invalid.
2. sdk/harambe/observer.py:152
  • Draft comment:
    Ensure that the urls property in InMemoryObserver and other observers reflects the updated tuple structure, including the stage parameter.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The on_queue_url method in InMemoryObserver and other observers now includes a stage parameter, but the urls property in InMemoryObserver is not updated to reflect this change. This could lead to confusion or errors when accessing urls.
3. sdk/test/test_pagination.py:48
  • Draft comment:
    Consider using a valid stage value instead of None to ensure the test is meaningful and aligns with the intended use case.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The test_stop_pagination_observer_duplicate_url_error test function uses None for the stage parameter, which might not be the intended use case. It would be better to use a valid stage value to ensure the test is meaningful.

Workflow ID: wflow_I7gSZD95RrXfYaoZ


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

Copy link

@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 3177496 in 23 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_9qjDgXqdS0iTpel7


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

Copy link

@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 d677ae5 in 29 seconds

More details
  • Looked at 102 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. sdk/test/test_get_next_stage.py:29
  • Draft comment:
    The expected stage for None should be listing to match the get_previous_stage function's behavior.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment points out a potential issue with the test case for get_previous_stage. If the function's intended behavior is indeed to map None to listing, then the test case is incorrect. However, without additional context on the intended behavior of get_previous_stage, it's difficult to confirm the comment's validity. The comment is about a change made in the diff, specifically the new test case for get_previous_stage.
    I might be missing the intended behavior of the get_previous_stage function. The comment assumes a specific behavior without providing evidence from the code or documentation.
    The comment could be valid if there is documentation or code elsewhere that specifies the expected behavior of get_previous_stage. However, without such evidence, the comment remains speculative.
    The comment is speculative without strong evidence. It should be deleted unless there is clear documentation or code indicating the expected behavior of get_previous_stage.

Workflow ID: wflow_S7Bcw0vV4pLhi9tX


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



@pytest.mark.parametrize(
"previous_stage,expected_stage",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be introduced to harambe. The consumer of the observer should make this choice

"""
context = context or {}
options = options or {}
stage = stage or get_next_stage(self._stage)
Copy link
Member

Choose a reason for hiding this comment

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

Would recommend leaving the getnextstage outside of harambe (separation of concerns)

@@ -507,19 +510,23 @@ async def run_from_file(

tracker = FileDataTracker(domain, stage)

prev = "listing" if stage == "detail" else "category"
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove this run from file / stage stuff here too

Comment on lines +605 to +613
def get_next_stage(previous_stage: Stage | None) -> Stage:
if previous_stage == "parent_category":
return "category"
if previous_stage == "category":
return "listing"
return "detail"


def get_previous_stage(stage: Stage | None) -> Stage:
Copy link
Member

Choose a reason for hiding this comment

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

Ideally api stuff

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

Successfully merging this pull request may close these issues.

2 participants