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 parsing of string version list of sample ids in _parse_sample_ids #3940

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fiftyone/core/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -8110,6 +8110,10 @@ def _params(self):

def _parse_sample_ids(arg):
if etau.is_str(arg):
# this might be a comma delimited string of ids
if arg.find(",") > -1:
return arg.split(","), False

return [arg], False

if isinstance(arg, (fos.Sample, fos.SampleView)):
Expand Down
14 changes: 14 additions & 0 deletions tests/unittests/view_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4268,6 +4268,20 @@ def test_make_optimized_select_view_group_dataset(self):
]
self.assertEqual(optimized_view._all_stages, expected_stages)

def test_make_optimized_select_view_group_dataset_with_strings_and_lists(
self,
):
dataset, sample_ids = self._make_group_dataset()

optimized_view = fov.make_optimized_select_view(
dataset, [sample_ids[0], sample_ids[0]], flatten=True
)
expected_stages = [
fosg.SelectGroupSlices(),
fosg.Select(f"{sample_ids[0]},{sample_ids[0]}"),
Copy link
Contributor

@brimoor brimoor Dec 18, 2023

Choose a reason for hiding this comment

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

I don't believe we've publicly documented anywhere that you can pass a comma-separated string list of IDs to Select(). Where did you encounter that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was a bug reported - TEAMS-2062 - the app passes it in as a comma delimited string in some scenarios via the viewbar, as a list of strings in other scenarios. Seemed the right place to fix it rather than identify all the places it could be used as input.

Copy link
Contributor

@brimoor brimoor Dec 20, 2023

Choose a reason for hiding this comment

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

I see. Actually this line:

"type": "list<id>|id",

is supposed to tell the App to parse "list,of,str" into ["list", "of", "str"], so it seems that is no longer working in certain cases? Or some new pathway for view stage parsing was added (didn't look at the ticket) that wasn't aware that it needed to support the type=list<> parameter definition.

cc @benjaminpkane can you help track down the root cause?

The type=list<> syntax is used in other view stages too, so I think that is actually the best place to fix the string parsing inconsistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've included a view bar fix in #3941 with c45be8a as it also contains ObjectId client-side validation

]
self.assertEqual(optimized_view._all_stages, expected_stages)

def test_make_optimized_select_view_select_group_slices_before_sample_selection(
self,
):
Expand Down
Loading