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

[Docs] Treat delegated execution separately #5184

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Nov 23, 2024

Summary by CodeRabbit

  • Documentation

    • Revised documentation for using plugins, clarifying the removal of the delegate parameter from the compute_metadata operator.
    • Enhanced explanations and examples for delegating function calls.
    • Improved overall structure and organization of the documentation for better usability.
    • Expanded content and new examples added for developing plugins, including a "Hello World" example.
  • Bug Fixes

    • Updated error handling in the execution of delegated operations to prevent potential errors when inputs is None.

@brimoor brimoor requested review from ritch and imanjra November 23, 2024 17:53
Copy link
Contributor

coderabbitai bot commented Nov 23, 2024

Walkthrough

The pull request includes significant updates to the documentation for using plugins in FiftyOne, particularly regarding the compute_metadata operator. The delegate parameter has been removed from its method signature, simplifying its usage. Additionally, the documentation structure has been improved, especially in sections related to delegation. In the codebase, error handling in the execute_or_delegate_operator function has been enhanced to prevent potential exceptions when dealing with None inputs. Overall, these changes aim to improve clarity and robustness in both documentation and functionality.

Changes

File Change Summary
docs/source/plugins/using_plugins.rst Updated documentation to remove the delegate parameter from the compute_metadata operator's call; restructured delegation section for clarity; improved overall organization.
fiftyone/operators/executor.py Modified error handling in execute_or_delegate_operator to check if inputs is None before calling to_json(), enhancing robustness against AttributeError.
docs/source/plugins/developing_plugins.rst Restructured and expanded documentation on developing plugins, including new examples, clearer sections, and detailed explanations of operator and panel interfaces.

Possibly related PRs

Suggested labels

documentation, enhancement

Suggested reviewers

  • swheaton
  • ritch

Poem

🐇 In the garden of code, we hop and play,
Removing the clutter, making way.
With clearer paths and no more dread,
Delegation shines, as we forge ahead!
So let’s celebrate, with joy we sing,
For simpler plugins, oh what joy they bring! 🌼


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.

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: 1

🧹 Outside diff range and nitpick comments (3)
docs/source/plugins/using_plugins.rst (2)

656-705: Consider adding error handling documentation.

While the delegation example is clear, it would be helpful to document how errors in delegated operations are handled and how users can monitor the operation's status.


Line range hint 767-858: Consider documenting limitations and best practices.

The section provides excellent examples of delegating function calls. Consider adding:

  1. Any limitations on the types of functions that can be delegated
  2. Best practices for handling long-running delegated operations
  3. Memory considerations for large datasets
fiftyone/operators/executor.py (1)

264-270: LGTM! Consider enhancing the error message.

The added error handling for inputs schema serialization is a good defensive programming practice. The code gracefully handles potential serialization failures without blocking the delegation process.

Consider including the error type in the warning message for better debugging:

-                        f"Failed to resolve inputs schema for the operation: {str(e)}"
+                        f"Failed to resolve inputs schema for the operation: {type(e).__name__}: {str(e)}"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b26d1d9 and 0bc217e.

📒 Files selected for processing (2)
  • docs/source/plugins/using_plugins.rst (5 hunks)
  • fiftyone/operators/executor.py (1 hunks)
🔇 Additional comments (2)
docs/source/plugins/using_plugins.rst (2)

597-598: LGTM! Clear and concise example.

The example effectively demonstrates how to compute metadata using the operator.


712-712: LGTM! Clear section introduction.

The introduction effectively sets up the direct execution section.

@@ -893,7 +927,7 @@ delegated operations and execute them serially in its process.

You must also ensure that the
:ref:`allow_legacy_orchestrators <configuring-fiftyone>` config flag is set
in the environment where you run the App, e.g. by setting:
in the environment where you run the App/SDK, e.g. by setting:
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider highlighting this requirement more prominently.

This environment configuration is crucial for using delegated operations. Consider moving this information to the beginning of the delegated operations section or adding it to a "Prerequisites" subsection.


Here's some examples of delegating common tasks that can be expressed in the
above forms:
In fact, the
Copy link
Contributor

@ritch ritch Nov 25, 2024

Choose a reason for hiding this comment

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

I think we need a kitchen sink example of __call__, request_delegation, allow_delegated_execution, adding a delegate property, and determining if an operator was scheduled (which we know is missing). In other words, an example operator that illustrates everything that you should do when implementing allow_delegated_execution.

Copy link
Contributor Author

@brimoor brimoor Nov 25, 2024

Choose a reason for hiding this comment

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

determining if an operator was scheduled (which we know is missing)

I fixed this here: it is available via ctx.delegated

adding a delegate property

This is now effectively deprecated. Plugin devs should always use execution_options() as pictured here, since the plugin framework can be trusted as authoritative on which execution modes the current deployment supports

I think we need a kitchen sink example of call, request_delegation, allow_delegated_execution,

That's what I tried to do here. There are multiple examples of increasing complexity here, including a last one that links over to here for additional context

Copy link
Contributor

Choose a reason for hiding this comment

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

@brimoor brimoor requested a review from ritch November 25, 2024 18:46
@brimoor
Copy link
Contributor Author

brimoor commented Nov 25, 2024

@ritch I'd like to go ahead and merge this as-is if you're onboard. We can upgrade the docs further in a follow-up PR if needed.

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)
docs/source/plugins/using_plugins.rst (2)

656-695: Consider adding a note about backward compatibility.

While the documentation clearly explains the new delegation approach using request_delegation=True, it might be helpful to add a note about backward compatibility for users migrating from older versions.

@@ -661,6 +661,11 @@
 `request_delegation=True` flag to
 :func:`execute_operator() <fiftyone.operators.execute_operator>`.

+.. note::
+
+    This approach replaces the previous method of using the `delegate` parameter
+    directly in operator calls, providing a more consistent way to handle
+    delegated execution across all operators.

800-858: Consider adding error handling examples.

The new section on delegating function calls provides comprehensive examples but could benefit from examples of error handling and status checking.

@@ -857,6 +857,15 @@
        persistent=True,
    )

+    # Example with error handling
+    try:
+        result = delegate(
+            "compute_metadata",
+            dataset=dataset,
+            timeout=3600  # optional timeout in seconds
+        )
+    except fo.DelegatedOperationError as e:
+        print(f"Operation failed: {e}")
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc217e and 241726a.

📒 Files selected for processing (2)
  • docs/source/plugins/developing_plugins.rst (3 hunks)
  • docs/source/plugins/using_plugins.rst (5 hunks)
🔇 Additional comments (6)
docs/source/plugins/using_plugins.rst (3)

597-598: LGTM: Clear and concise example of compute_metadata usage.

The example effectively demonstrates the basic usage of the compute_metadata operator without unnecessary complexity.


699-705: LGTM: Clear example of delegated execution.

The example effectively demonstrates how to schedule a delegated operation using the new approach.


929-929: Consider highlighting this requirement more prominently.

The environment configuration is crucial for using delegated operations. Consider moving this information to the beginning of the delegated operations section.

docs/source/plugins/developing_plugins.rst (3)

1145-1148: LGTM! Well-structured section header

The section header is properly formatted and provides a clear introduction to the execution options content.


1186-1189: LGTM! Clear subsection header

The subsection header is well-formatted and appropriately introduces the dynamic execution options content.


1241-1243: LGTM! Clear explanation of fallback behavior

The text effectively explains what happens when resolve_delegation() is not implemented or returns None, which is crucial information for plugin developers.

@brimoor brimoor merged commit ac6799c into release/v1.1.0 Nov 26, 2024
13 checks passed
@brimoor brimoor deleted the use-ctx-delegate branch November 26, 2024 15:41
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