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 scheduled state for delegated_ops collection #4810

Merged
merged 8 commits into from
Sep 20, 2024

Conversation

CamronStaley
Copy link
Contributor

@CamronStaley CamronStaley commented Sep 17, 2024

What changes are proposed in this pull request?

Add scheduled state for delegated operations collection

How is this patch tested? If it is not, please explain why.

tested in fiftyone celery poc

Total currently running or pending jobs: 1
Total currently running or pending jobs: 1
Executing operation: 66e8ccd98cecb3ff22558ad1
Celery task id: d45b78b2-f4ff-4f7f-b050-28275f09b0eb
Total currently running or pending jobs: 2

image

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Added support for a new 'SCHEDULED' state in the command-line interface (CLI) for operation management.
    • Introduced new sorting options, including 'SCHEDULED_AT' and 'PENDING_AT'.
    • Added methods to retrieve scheduled and pending operations for improved management.
    • Enhanced state management with the addition of 'PENDING' and 'SCHEDULED' enumeration values.
  • Bug Fixes

    • Updated help text for CLI arguments to reflect new operation states and sorting options.
  • Documentation

    • Enhanced CLI documentation to include new operation states and sorting capabilities.

Copy link
Contributor

coderabbitai bot commented Sep 17, 2024

Walkthrough

The pull request introduces modifications to the command-line interface (CLI) documentation and the codebase to incorporate a new operation state, 'SCHEDULED', and its associated sorting option, 'SCHEDULED_AT'. Updates include changes to help text for command-line arguments, the addition of new methods for managing operation states, and enhancements to the DelegatedOperation class to support scheduled operations. These changes collectively improve the granularity of operation management and state handling within the system.

Changes

Files Change Summary
docs/source/cli/index.rst Updated CLI documentation to include 'SCHEDULED' in --state and 'SCHEDULED_AT' in --sort-by.
fiftyone/core/cli.py Modified help text for --state, --sort-by, and --delete-state to reflect new 'SCHEDULED' options.
fiftyone/factory/__init__.py Added SCHEDULED_AT constant to SortByField class for sorting operations.
fiftyone/factory/repos/delegated_operation.py Introduced get_scheduled_operations, get_pending_operations, and get_running_operations methods in DelegatedOperation class.
fiftyone/factory/repos/delegated_operation_doc.py Added scheduled_at attribute to track scheduled operations.
fiftyone/operators/delegated.py Added set_scheduled, get_scheduled_operations, and get_pending_operations methods for state management.
fiftyone/operators/executor.py Introduced SCHEDULED enumeration value to ExecutionRunState class.
tests/unittests/delegated_operators_tests.py Updated test method to reflect changes in operation state retrieval methods.

Possibly related PRs

  • Hotfix pymongo #4822: The changes in this PR involve updates to the setup.py file, which are related to the main PR's modifications in the same file, specifically regarding the version specification for the pymongo package.

Suggested reviewers

  • mwoodson1
  • jacobmarks
  • camronstaley

🐇 In the garden where bunnies hop,
New states arise, we can't stop!
With 'SCHEDULED' now in our array,
Operations flourish, come what may!
Sorting and filtering, oh what a treat,
Hopping along, our tasks are neat! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CamronStaley CamronStaley changed the title add pending and pending_at states delegated_ops collection add pending state for delegated_ops collection Sep 17, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
fiftyone/factory/repos/delegated_operation_doc.py (1)

72-72: Consider using doc.get("pending_at", None) for conciseness.

The static analysis tool suggests using doc.get("pending_at", None) instead of an if block. This is a more concise way to extract the pending_at value from the document dictionary and default to None if it doesn't exist.

Apply this diff to refactor the code:

-self.pending_at = doc["pending_at"] if "pending_at" in doc else None
+self.pending_at = doc.get("pending_at", None)
Tools
Ruff

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

fiftyone/operators/executor.py (1)

Line range hint 1-1: Annotate the remaining changes for review.

The rest of the changes in this file are not annotated with line numbers. Please annotate the remaining changes so they can be thoroughly reviewed.

fiftyone/core/cli.py (1)

Line range hint 12-24: Consider adjusting the fee structure or discount percentages.

The current implementation of adding a flat $20 fee to any discounted bill could negate the discount benefit, especially for smaller purchases or lower loyalty tiers. For example, a $100 purchase with a 10% discount for 3 years of loyalty would become $110 after the fee, which is more than the original price.

This might frustrate customers who barely qualify for a discount tier, as the fee could cost them more than the discount saves them. It may also disincentivize customers from maintaining loyalty if the discounts are not worthwhile after the fee.

Consider revising either the discount percentages or the flat fee structure to better align with the goal of rewarding customer loyalty. The fees and discounts should combine to benefit the customer.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2173d35 and ff04f07.

Files selected for processing (7)
  • docs/source/cli/index.rst (1 hunks)
  • fiftyone/core/cli.py (2 hunks)
  • fiftyone/factory/init.py (1 hunks)
  • fiftyone/factory/repos/delegated_operation.py (3 hunks)
  • fiftyone/factory/repos/delegated_operation_doc.py (2 hunks)
  • fiftyone/operators/delegated.py (2 hunks)
  • fiftyone/operators/executor.py (1 hunks)
Additional context used
Ruff
fiftyone/factory/repos/delegated_operation_doc.py

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

Additional comments not posted (12)
fiftyone/factory/__init__.py (1)

15-15: LGTM!

The addition of the PENDING_AT constant is a valid extension to the SortByField class. It expands the sorting options for delegated operations, allowing them to be sorted based on their pending status. This change is consistent with the existing constants and is unlikely to introduce any issues.

fiftyone/factory/repos/delegated_operation_doc.py (1)

49-49: LGTM!

The initialization of the pending_at attribute to None in the constructor is a valid way to declare a new optional attribute.

fiftyone/operators/delegated.py (3)

104-113: LGTM!

The set_pending method is implemented correctly and follows the existing coding style. The method is properly documented, and the logic is straightforward.


249-261: LGTM!

The get_pending_operations method is implemented correctly and follows the existing coding style. The method is properly documented, and the logic is straightforward. The optional filtering parameters provide flexibility in querying the pending operations.


263-275: LGTM!

The get_running_operations method is implemented correctly and follows the existing coding style. The method is properly documented, and the logic is straightforward. The optional filtering parameters provide flexibility in querying the running operations.

fiftyone/factory/repos/delegated_operation.py (5)

67-73: LGTM!

The function declaration looks good. It follows the existing pattern of defining a base method that subclasses must implement.


75-81: LGTM!

The function declaration looks good. It follows the existing pattern of defining a base method that subclasses must implement.


286-289: Looks good!

The updated condition correctly handles the new PENDING state alongside the RUNNING state.


363-372: Great implementation!

The get_pending_operations method leverages the existing list_operations method to retrieve pending operations, promoting code reuse and consistency.


374-383: Great implementation!

The get_running_operations method leverages the existing list_operations method to retrieve running operations, promoting code reuse and consistency.

fiftyone/operators/executor.py (1)

40-40: Looks good! The new PENDING state is a helpful addition.

The PENDING state provides more granular insight into the operation lifecycle by representing the state where an operation has been triggered but is not yet running. This will allow for better tracking and management of operations.

docs/source/cli/index.rst (1)

992-994: LGTM!

The addition of the 'PENDING' state and 'PENDING_AT' sort option to the fiftyone delegated list command looks good. It expands the filtering and sorting capabilities without impacting existing usage.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
fiftyone/factory/repos/delegated_operation_doc.py (1)

72-72: Consider simplifying the code using the get method.

The code segment correctly extracts the pending_at value from the document dictionary and assigns it to the pending_at attribute of the class instance.

As suggested by the static analysis hint, you can simplify the code by using the get method of the dictionary:

self.pending_at = doc.get("pending_at", None)

This will provide a default value of None if the "pending_at" key does not exist in the dictionary, avoiding the need for an explicit if block.

Tools
Ruff

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9408726 and dd1ea7a.

Files selected for processing (7)
  • docs/source/cli/index.rst (1 hunks)
  • fiftyone/core/cli.py (2 hunks)
  • fiftyone/factory/init.py (1 hunks)
  • fiftyone/factory/repos/delegated_operation.py (3 hunks)
  • fiftyone/factory/repos/delegated_operation_doc.py (2 hunks)
  • fiftyone/operators/delegated.py (2 hunks)
  • fiftyone/operators/executor.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • fiftyone/factory/init.py
Files skipped from review as they are similar to previous changes (5)
  • docs/source/cli/index.rst
  • fiftyone/core/cli.py
  • fiftyone/factory/repos/delegated_operation.py
  • fiftyone/operators/delegated.py
  • fiftyone/operators/executor.py
Additional context used
Ruff
fiftyone/factory/repos/delegated_operation_doc.py

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

Additional comments not posted (1)
fiftyone/factory/repos/delegated_operation_doc.py (1)

49-49: LGTM!

The initialization of the pending_at attribute to None in the constructor is a valid way to indicate that the attribute is not set initially. The attribute name follows the naming convention used for other timestamp attributes in the class.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
fiftyone/factory/repos/delegated_operation_doc.py (1)

72-72: Consider refactoring the code to use doc.get("pending_at", None).

The current code correctly extracts the pending_at value from the document dictionary if it exists, otherwise sets it to None. However, as suggested by the static analysis hint, using doc.get("pending_at", None) is a more concise and Pythonic way to achieve the same result. This would improve the readability of the code.

Apply this diff to refactor the code:

-self.pending_at = doc["pending_at"] if "pending_at" in doc else None
+self.pending_at = doc.get("pending_at", None)
Tools
Ruff

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dd1ea7a and fd78b12.

Files selected for processing (7)
  • docs/source/cli/index.rst (1 hunks)
  • fiftyone/core/cli.py (2 hunks)
  • fiftyone/factory/init.py (1 hunks)
  • fiftyone/factory/repos/delegated_operation.py (3 hunks)
  • fiftyone/factory/repos/delegated_operation_doc.py (2 hunks)
  • fiftyone/operators/delegated.py (2 hunks)
  • fiftyone/operators/executor.py (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • docs/source/cli/index.rst
  • fiftyone/core/cli.py
  • fiftyone/factory/init.py
  • fiftyone/factory/repos/delegated_operation.py
  • fiftyone/operators/delegated.py
  • fiftyone/operators/executor.py
Additional context used
Ruff
fiftyone/factory/repos/delegated_operation_doc.py

72-72: Use doc.get("pending_at", None) instead of an if block

Replace with doc.get("pending_at", None)

(SIM401)

Additional comments not posted (1)
fiftyone/factory/repos/delegated_operation_doc.py (1)

49-49: LGTM!

The initialization of the pending_at attribute to None in the constructor is a valid way to indicate that the attribute is not set initially. The attribute name clearly conveys its purpose of tracking a pending state timestamp.

Comment on lines 69 to 75
doc["completed_at"] if "completed_at" in doc else None
)
self.failed_at = doc["failed_at"] if "failed_at" in doc else None
self.pending_at = doc["pending_at"] if "pending_at" in doc else None
self.pinned = doc["pinned"] if "pinned" in doc else None
self.dataset_id = doc["dataset_id"] if "dataset_id" in doc else None
self.run_link = doc["run_link"] if "run_link" in doc else None
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I agree with a suggestion from coderabbit, can we just simply replace all of these doc["thing"] if "thing" in doc else None with doc.get("thing")

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that the 'if thing in doc' syntax should be simplified to just 'get' but is it possible doc is None and if so, should it throw? If not maybe what's needed here is just a 'if doc'?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's possible. It would throw before and it would throw now

Copy link
Contributor

@swheaton swheaton left a comment

Choose a reason for hiding this comment

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

Please add to tests/unittests/delegated_operators_tests.py for new state / functions.

@swheaton
Copy link
Contributor

fiftyone/core/cli.py (1)
Line range hint 12-24: Consider adjusting the fee structure or discount percentages.

The current implementation of adding a flat $20 fee to any discounted bill could negate the discount benefit, especially for smaller purchases or lower loyalty tiers. For example, a $100 purchase with a 10% discount for 3 years of loyalty would become $110 after the fee, which is more than the original price.

This might frustrate customers who barely qualify for a discount tier, as the fee could cost them more than the discount saves them. It may also disincentivize customers from maintaining loyalty if the discounts are not worthwhile after the fee.

Consider revising either the discount percentages or the flat fee structure to better align with the goal of rewarding customer loyalty. The fees and discounts should combine to benefit the customer.

lol @coderabbitai this is a wild hallucination, cli.py has nothing even close to this 😆

Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Tip

For best results, initiate chat on the files or code changes.

@swheaton, I apologize for the confusion earlier. It seems my previous comment was not relevant to cli.py. Thank you for pointing that out.

(_/)
( ..)
(")
(")


Learnings added
Learnt from: swheaton
URL: https://github.com/voxel51/fiftyone/pull/4810

Timestamp: 2024-09-20T14:09:31.672Z
Learning: Ensure that code review comments on `fiftyone/core/cli.py` are accurate and relevant to the actual code changes.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
fiftyone/factory/repos/delegated_operation_doc.py (2)

57-57: Looks good! Here's a minor suggestion.

Using doc.get("operator") is a cleaner way to retrieve the value. As a small nitpick, you can remove the None default value since get already returns None if the key is missing.

-self.operator = doc.get("operator")
+self.operator = doc.get("operator")

62-72: The changes look good! Here's a minor suggestion.

Using doc.get(field, None) is a cleaner way to retrieve optional fields. As a small nitpick, you can remove the None default value in all these cases since get already returns None if the key is missing.

Apply this diff:

-self.delegation_target = doc.get("delegation_target", None)
+self.delegation_target = doc.get("delegation_target")
-self.started_at = doc.get("started_at", None) 
+self.started_at = doc.get("started_at")
-self.completed_at = doc.get("completed_at", None)
+self.completed_at = doc.get("completed_at") 
-self.failed_at = doc.get("failed_at", None)
+self.failed_at = doc.get("failed_at")
-self.pending_at = doc.get("pending_at", None)
+self.pending_at = doc.get("pending_at")
-self.pinned = doc.get("pinned", None)
+self.pinned = doc.get("pinned")
-self.dataset_id = doc.get("dataset_id", None)
+self.dataset_id = doc.get("dataset_id")
-self.run_link = doc.get("run_link", None)
+self.run_link = doc.get("run_link")
-self.metadata = doc.get("metadata", None)
+self.metadata = doc.get("metadata") 
-self.label = doc.get("label", None)
+self.label = doc.get("label")
-self.updated_at = doc.get("updated_at", None)
+self.updated_at = doc.get("updated_at")
Tools
Ruff

62-62: Use doc.get("delegation_target") instead of doc.get("delegation_target", None)

Replace doc.get("delegation_target", None) with doc.get("delegation_target")

(SIM910)


63-63: Use doc.get("started_at") instead of doc.get("started_at", None)

Replace doc.get("started_at", None) with doc.get("started_at")

(SIM910)


64-64: Use doc.get("completed_at") instead of doc.get("completed_at", None)

Replace doc.get("completed_at", None) with doc.get("completed_at")

(SIM910)


65-65: Use doc.get("failed_at") instead of doc.get("failed_at", None)

Replace doc.get("failed_at", None) with doc.get("failed_at")

(SIM910)


66-66: Use doc.get("pending_at") instead of doc.get("pending_at", None)

Replace doc.get("pending_at", None) with doc.get("pending_at")

(SIM910)


67-67: Use doc.get("pinned") instead of doc.get("pinned", None)

Replace doc.get("pinned", None) with doc.get("pinned")

(SIM910)


68-68: Use doc.get("dataset_id") instead of doc.get("dataset_id", None)

Replace doc.get("dataset_id", None) with doc.get("dataset_id")

(SIM910)


69-69: Use doc.get("run_link") instead of doc.get("run_link", None)

Replace doc.get("run_link", None) with doc.get("run_link")

(SIM910)


70-70: Use doc.get("metadata") instead of doc.get("metadata", None)

Replace doc.get("metadata", None) with doc.get("metadata")

(SIM910)


71-71: Use doc.get("label") instead of doc.get("label", None)

Replace doc.get("label", None) with doc.get("label")

(SIM910)


72-72: Use doc.get("updated_at") instead of doc.get("updated_at", None)

Replace doc.get("updated_at", None) with doc.get("updated_at")

(SIM910)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd78b12 and 0c21123.

Files selected for processing (2)
  • fiftyone/factory/repos/delegated_operation_doc.py (1 hunks)
  • tests/unittests/delegated_operators_tests.py (3 hunks)
Additional context used
Ruff
fiftyone/factory/repos/delegated_operation_doc.py

62-62: Use doc.get("delegation_target") instead of doc.get("delegation_target", None)

Replace doc.get("delegation_target", None) with doc.get("delegation_target")

(SIM910)


63-63: Use doc.get("started_at") instead of doc.get("started_at", None)

Replace doc.get("started_at", None) with doc.get("started_at")

(SIM910)


64-64: Use doc.get("completed_at") instead of doc.get("completed_at", None)

Replace doc.get("completed_at", None) with doc.get("completed_at")

(SIM910)


65-65: Use doc.get("failed_at") instead of doc.get("failed_at", None)

Replace doc.get("failed_at", None) with doc.get("failed_at")

(SIM910)


66-66: Use doc.get("pending_at") instead of doc.get("pending_at", None)

Replace doc.get("pending_at", None) with doc.get("pending_at")

(SIM910)


67-67: Use doc.get("pinned") instead of doc.get("pinned", None)

Replace doc.get("pinned", None) with doc.get("pinned")

(SIM910)


68-68: Use doc.get("dataset_id") instead of doc.get("dataset_id", None)

Replace doc.get("dataset_id", None) with doc.get("dataset_id")

(SIM910)


69-69: Use doc.get("run_link") instead of doc.get("run_link", None)

Replace doc.get("run_link", None) with doc.get("run_link")

(SIM910)


70-70: Use doc.get("metadata") instead of doc.get("metadata", None)

Replace doc.get("metadata", None) with doc.get("metadata")

(SIM910)


71-71: Use doc.get("label") instead of doc.get("label", None)

Replace doc.get("label", None) with doc.get("label")

(SIM910)


72-72: Use doc.get("updated_at") instead of doc.get("updated_at", None)

Replace doc.get("updated_at", None) with doc.get("updated_at")

(SIM910)

Additional comments not posted (5)
fiftyone/factory/repos/delegated_operation_doc.py (4)

49-49: LGTM!

Initializing the new pending_at attribute to None in the constructor is a valid approach. It will likely store a timestamp related to pending operations.


58-58: LGTM!

Using doc.get("queued_at") is a cleaner way to retrieve the value. The change looks good.


59-59: Looks good!

Using doc.get("run_state") is a cleaner way to retrieve the value. The change is valid.


74-76: LGTM!

Setting the internal fields id and _doc after retrieving the optional fields is a reasonable order. The change looks good.

tests/unittests/delegated_operators_tests.py (1)

Line range hint 229-317: LGTM! The test coverage has been improved.

The changes in the test_list_operations function enhance the test coverage by:

  • Verifying the behavior of listing operations in different states (queued, running, pending) using dedicated service methods.
  • Updating the assertions to ensure the expected behavior is maintained.
  • Renaming the test to accurately reflect the expanded scope.

These improvements contribute to a more comprehensive test suite.

@swheaton
Copy link
Contributor

Per offline discussion, pending will now become scheduled. Naming not behavior change for this PR.

@CamronStaley CamronStaley changed the title add pending state for delegated_ops collection add scheduled state for delegated_ops collection Sep 20, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (8)
fiftyone/factory/repos/delegated_operation_doc.py (8)

62-62: Simplify the retrieval of the delegation_target field.

The static analysis hint suggests using doc.get("delegation_target") instead of doc.get("delegation_target", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.delegation_target = doc.get("delegation_target", None)
+self.delegation_target = doc.get("delegation_target")
Tools
Ruff

62-62: Use doc.get("delegation_target") instead of doc.get("delegation_target", None)

Replace doc.get("delegation_target", None) with doc.get("delegation_target")

(SIM910)


63-63: Simplify the retrieval of the started_at field.

The static analysis hint suggests using doc.get("started_at") instead of doc.get("started_at", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.started_at = doc.get("started_at", None)
+self.started_at = doc.get("started_at")
Tools
Ruff

63-63: Use doc.get("started_at") instead of doc.get("started_at", None)

Replace doc.get("started_at", None) with doc.get("started_at")

(SIM910)


64-64: Simplify the retrieval of the completed_at field.

The static analysis hint suggests using doc.get("completed_at") instead of doc.get("completed_at", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.completed_at = doc.get("completed_at", None)
+self.completed_at = doc.get("completed_at")
Tools
Ruff

64-64: Use doc.get("completed_at") instead of doc.get("completed_at", None)

Replace doc.get("completed_at", None) with doc.get("completed_at")

(SIM910)


65-65: Simplify the retrieval of the failed_at field.

The static analysis hint suggests using doc.get("failed_at") instead of doc.get("failed_at", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.failed_at = doc.get("failed_at", None)
+self.failed_at = doc.get("failed_at")
Tools
Ruff

65-65: Use doc.get("failed_at") instead of doc.get("failed_at", None)

Replace doc.get("failed_at", None) with doc.get("failed_at")

(SIM910)


66-66: Simplify the retrieval of the scheduled_at field.

The static analysis hint suggests using doc.get("scheduled_at") instead of doc.get("scheduled_at", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.scheduled_at = doc.get("scheduled_at", None)
+self.scheduled_at = doc.get("scheduled_at")
Tools
Ruff

66-66: Use doc.get("scheduled_at") instead of doc.get("scheduled_at", None)

Replace doc.get("scheduled_at", None) with doc.get("scheduled_at")

(SIM910)


67-67: Simplify the retrieval of the pinned field.

The static analysis hint suggests using doc.get("pinned") instead of doc.get("pinned", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.pinned = doc.get("pinned", None)
+self.pinned = doc.get("pinned")
Tools
Ruff

67-67: Use doc.get("pinned") instead of doc.get("pinned", None)

Replace doc.get("pinned", None) with doc.get("pinned")

(SIM910)


68-68: Simplify the retrieval of the dataset_id field.

The static analysis hint suggests using doc.get("dataset_id") instead of doc.get("dataset_id", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.dataset_id = doc.get("dataset_id", None)
+self.dataset_id = doc.get("dataset_id")
Tools
Ruff

68-68: Use doc.get("dataset_id") instead of doc.get("dataset_id", None)

Replace doc.get("dataset_id", None) with doc.get("dataset_id")

(SIM910)


69-69: Simplify the retrieval of the run_link field.

The static analysis hint suggests using doc.get("run_link") instead of doc.get("run_link", None). The default value of None is redundant, as the get method already returns None if the key is not found in the dictionary.

Apply this diff to simplify the code:

-self.run_link = doc.get("run_link", None)
+self.run_link = doc.get("run_link")
Tools
Ruff

69-69: Use doc.get("run_link") instead of doc.get("run_link", None)

Replace doc.get("run_link", None) with doc.get("run_link")

(SIM910)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0c21123 and 831eb89.

Files selected for processing (8)
  • docs/source/cli/index.rst (1 hunks)
  • fiftyone/core/cli.py (2 hunks)
  • fiftyone/factory/init.py (1 hunks)
  • fiftyone/factory/repos/delegated_operation.py (3 hunks)
  • fiftyone/factory/repos/delegated_operation_doc.py (1 hunks)
  • fiftyone/operators/delegated.py (2 hunks)
  • fiftyone/operators/executor.py (1 hunks)
  • tests/unittests/delegated_operators_tests.py (3 hunks)
Files skipped from review as they are similar to previous changes (6)
  • docs/source/cli/index.rst
  • fiftyone/core/cli.py
  • fiftyone/factory/init.py
  • fiftyone/factory/repos/delegated_operation.py
  • fiftyone/operators/executor.py
  • tests/unittests/delegated_operators_tests.py
Additional context used
Ruff
fiftyone/factory/repos/delegated_operation_doc.py

62-62: Use doc.get("delegation_target") instead of doc.get("delegation_target", None)

Replace doc.get("delegation_target", None) with doc.get("delegation_target")

(SIM910)


63-63: Use doc.get("started_at") instead of doc.get("started_at", None)

Replace doc.get("started_at", None) with doc.get("started_at")

(SIM910)


64-64: Use doc.get("completed_at") instead of doc.get("completed_at", None)

Replace doc.get("completed_at", None) with doc.get("completed_at")

(SIM910)


65-65: Use doc.get("failed_at") instead of doc.get("failed_at", None)

Replace doc.get("failed_at", None) with doc.get("failed_at")

(SIM910)


66-66: Use doc.get("scheduled_at") instead of doc.get("scheduled_at", None)

Replace doc.get("scheduled_at", None) with doc.get("scheduled_at")

(SIM910)


67-67: Use doc.get("pinned") instead of doc.get("pinned", None)

Replace doc.get("pinned", None) with doc.get("pinned")

(SIM910)


68-68: Use doc.get("dataset_id") instead of doc.get("dataset_id", None)

Replace doc.get("dataset_id", None) with doc.get("dataset_id")

(SIM910)


69-69: Use doc.get("run_link") instead of doc.get("run_link", None)

Replace doc.get("run_link", None) with doc.get("run_link")

(SIM910)


70-70: Use doc.get("metadata") instead of doc.get("metadata", None)

Replace doc.get("metadata", None) with doc.get("metadata")

(SIM910)


71-71: Use doc.get("label") instead of doc.get("label", None)

Replace doc.get("label", None) with doc.get("label")

(SIM910)


72-72: Use doc.get("updated_at") instead of doc.get("updated_at", None)

Replace doc.get("updated_at", None) with doc.get("updated_at")

(SIM910)

Additional comments not posted (7)
fiftyone/factory/repos/delegated_operation_doc.py (4)

49-49: LGTM!

The initialization of self.scheduled_at to None in the constructor is consistent with the initialization of other optional fields.


57-57: LGTM!

The use of the get method for retrieving the operator field from the doc dictionary is consistent with the suggestion from the past review comments.


58-58: LGTM!

The use of the get method for retrieving the queued_at field from the doc dictionary is consistent with the suggestion from the past review comments.


59-59: LGTM!

The use of the get method for retrieving the run_state field from the doc dictionary is consistent with the suggestion from the past review comments.

fiftyone/operators/delegated.py (3)

104-113: LGTM!

The set_scheduled method is implemented correctly. It updates the run state of a delegated operation to ExecutionRunState.SCHEDULED using the provided doc_id.


249-261: LGTM!

The get_scheduled_operations method is implemented correctly. It retrieves all scheduled delegated operations from the repository, with optional filtering by operator and dataset_name.


263-275: LGTM!

The get_running_operations method is implemented correctly. It retrieves all running delegated operations from the repository, with optional filtering by operator and dataset_name.

Comment on lines +57 to +59
self.operator = doc.get("operator")
self.queued_at = doc.get("queued_at")
self.run_state = doc.get("run_state")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't really need to use get() for these as they're required to be set. It just pushes the errors to later

self.pinned = doc["pinned"] if "pinned" in doc else None
self.dataset_id = doc["dataset_id"] if "dataset_id" in doc else None
self.run_link = doc["run_link"] if "run_link" in doc else None
self.delegation_target = doc.get("delegation_target", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

technically None is already the default so not necessary, but it's fine to leave it

Copy link
Contributor

@swheaton swheaton left a comment

Choose a reason for hiding this comment

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

couple minor things but overall lgtm

@CamronStaley CamronStaley merged commit 12aec6e into develop Sep 20, 2024
13 checks passed
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.

3 participants