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 set_spaces operation #4381

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented May 9, 2024

What changes are proposed in this pull request?

Add set_spaces operation to ctx.ops available in operators execute

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

Set workspace

import fiftyone.operators as foo
import fiftyone.operators.types as types
import fiftyone as fo

class SetSpaces(foo.Operator):
    @property
    def config(self):
        return foo.OperatorConfig(
            name="playground_py_set_spaces",
            label="Playground_Py: Set spaces"
        )

    def resolve_input(self, ctx):
        inputs = types.Object()
        inputs.enum(
            "workspace", ctx.dataset.list_workspaces(), label="Workspace", required=True
        )
        return types.Property(inputs)

    def execute(self, ctx):
        ctx.ops.set_spaces(name=ctx.params.get("workspace"))
        return {}

Set arbitrary space

import fiftyone.operators as foo
import fiftyone.operators.types as types
import fiftyone as fo

class SetSpaces(foo.Operator):
    @property
    def config(self):
        return foo.OperatorConfig(
            name="playground_py_set_spaces",
            label="Playground_Py: Set spaces"
        )

    def execute(self, ctx):
        samples_panel = fo.Panel(type="Samples", pinned=True)

        histograms_panel = fo.Panel(
            type="Histograms",
            state=dict(plot="Labels"),
        )

        embeddings_panel = fo.Panel(
            type="Embeddings",
            state=dict(brainResult="img_viz", colorByField="metadata.size_bytes"),
        )

        spaces = fo.Space(
            children=[
                fo.Space(
                    children=[
                        fo.Space(children=[samples_panel]),
                        fo.Space(children=[histograms_panel]),
                    ],
                    orientation="horizontal",
                ),
                fo.Space(children=[embeddings_panel]),
            ],
            orientation="vertical",
        )
        ctx.ops.set_spaces(spaces=spaces)

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.

See usage above

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
    • Enhanced workspace management functionality, allowing users to set and load workspaces by name directly within the application.

@imanjra imanjra requested a review from a team May 9, 2024 18:13
Copy link
Contributor

coderabbitai bot commented May 9, 2024

Walkthrough

The recent changes aim to streamline workspace management within the application. These updates introduce the LOAD_WORKSPACE_OPERATOR for dynamic workspace loading and refine the method for setting spaces, enhancing code readability and operational efficiency.

Changes

File Path Change Summary
.../built-in-operators.ts Added LOAD_WORKSPACE_OPERATOR import and updated SetSpaces class to handle workspace loading.
.../builtin.py Updated resolve_input method to directly use set_spaces and removed event triggering.
.../operations.py Added set_spaces method to facilitate setting spaces by name or workspace object.

🐰✨
In the code where spaces intertwine,
A rabbit hopped, leaving marks behind.
"Let's tidy this up," it said with glee,
Now workspaces load with such simplicity!
🌟📂🚀


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@imanjra imanjra force-pushed the workspaces-operations branch from f2e9587 to ebe7ee9 Compare May 9, 2024 18:14
@imanjra imanjra force-pushed the workspaces-operations branch from ebe7ee9 to 9773a8b Compare May 9, 2024 18:16
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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between f2e9587 and 9773a8b.
Files selected for processing (3)
  • app/packages/operators/src/built-in-operators.ts (2 hunks)
  • fiftyone/operators/builtin.py (1 hunks)
  • fiftyone/operators/operations.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/packages/operators/src/built-in-operators.ts
  • fiftyone/operators/operations.py
Additional Context Used
Ruff (1)
fiftyone/operators/builtin.py (1)

53-53: Local variable sample_ids is assigned to but never used

Additional comments not posted (1)
fiftyone/operators/builtin.py (1)

449-449: The integration of set_spaces in the LoadWorkspace class aligns with the PR's objectives to enhance workspace management. Ensure that the set_spaces method is implemented and tested across all relevant parts of the application.

Verification successful

The set_spaces method is implemented and utilized across various parts of the FiftyOne application, including operations handling, server mutations, and session management. This confirms the method's integration and alignment with the PR's objectives to enhance workspace management.

  • Operations Handling: Defined and triggered in fiftyone/operators/operations.py.
  • Server Mutations: Used in fiftyone/server/mutation.py to handle asynchronous server operations.
  • Session Management: Integrated into session events in fiftyone/core/session/session.py and client session handling in fiftyone/core/session/client.py.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation and usage of `set_spaces` across the application.

# Test: Search for the `set_spaces` method usage. Expect: Instances across various modules.
rg --type py $'set_spaces'

Length of output: 615

Copy link
Contributor

@sashankaryal sashankaryal left a comment

Choose a reason for hiding this comment

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

lgTm

@sashankaryal sashankaryal merged commit efebf95 into release/v0.24.0 May 9, 2024
15 of 16 checks passed
@sashankaryal sashankaryal deleted the workspaces-operations branch May 9, 2024 18:52
benjaminpkane pushed a commit that referenced this pull request May 20, 2024
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