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 support for setting view by name and slug #4178

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Mar 19, 2024

What changes are proposed in this pull request?

add support for setting view by name and slug

Usage: setting a view using the slug of a saved view

def execute(self, ctx):
    ctx.trigger("set_view", {"name": "my-saved-view-name"})

Usage: setting a view using the name of a saved view

def execute(self, ctx):
    ctx.trigger("set_view", {"name": "My Saved View Name"})

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

Using a test operator

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.

add support for setting view by name and slug

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

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 49 lines in your changes are missing coverage. Please review.

Project coverage is 28.84%. Comparing base (82ad6e0) to head (19f3974).
Report is 4 commits behind head on release/v0.23.7.

Files Patch % Lines
...ackages/core/src/hooks/useRefetchableSavedViews.ts 0.00% 21 Missing ⚠️
app/packages/operators/src/built-in-operators.ts 0.00% 21 Missing ⚠️
...ore/src/components/Sidebar/ViewSelection/index.tsx 0.00% 3 Missing ⚠️
...pp/packages/app/src/pages/datasets/DatasetPage.tsx 0.00% 1 Missing ⚠️
app/packages/core/src/hooks/index.ts 0.00% 1 Missing ⚠️
app/packages/core/src/index.ts 0.00% 1 Missing ⚠️
app/packages/operators/src/operators.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           release/v0.23.7    #4178      +/-   ##
===================================================
- Coverage            28.85%   28.84%   -0.01%     
===================================================
  Files                  766      768       +2     
  Lines                97004    97032      +28     
  Branches              1118     1120       +2     
===================================================
  Hits                 27988    27988              
- Misses               69016    69044      +28     
Flag Coverage Δ
app 16.02% <0.00%> (-0.01%) ⬇️
python 99.23% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imanjra imanjra requested a review from a team March 19, 2024 17:24
Array.isArray(savedViews) &&
savedViews.find((view) => name === view.name);
if (!savedView) {
throw new Error(`Saved view with name "${name}" does not exist.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

@imanjra do we have a JS implementation of the to_slug() utility?

Asking because, if so, then you could just do name = to_slug(name) here and then name could effectively be either a name or slug. The public interface validates that any new saved view name must be unique both as a name and a slug, so it wouldn't cause any views to be "unreachable".

One consequence of such an approach is that the error message could only read:

`Saved view with name or slug "${name}" does not exist`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Yeah, we do have it. I'll use that util here

@imanjra imanjra force-pushed the feat/set-view-by-name-and-slug branch from 1c5a479 to deb35e0 Compare March 19, 2024 17:42
@imanjra imanjra marked this pull request as ready for review March 19, 2024 17:43
@imanjra imanjra force-pushed the feat/set-view-by-name-and-slug branch 2 times, most recently from 953cd5f to e72d574 Compare March 19, 2024 18:10
@imanjra imanjra force-pushed the feat/set-view-by-name-and-slug branch from e72d574 to 19f3974 Compare March 19, 2024 18:11
Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

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

LGTM, tested by running voxel51/fiftyone-plugins#115 and also tested a case where a saved view didn't exist and I saw the error notification as expected. Very nice!

@imanjra imanjra merged commit 461dca6 into release/v0.23.7 Mar 19, 2024
16 checks passed
@imanjra imanjra deleted the feat/set-view-by-name-and-slug branch March 19, 2024 18:33
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