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

Fix #4890 #4891

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
34 changes: 34 additions & 0 deletions app/packages/looker/src/elements/common/bubbles.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Schema } from "@fiftyone/utilities";
import {
CLASSIFICATIONS,
DYNAMIC_EMBEDDED_DOCUMENT_PATH,
EMBEDDED_DOCUMENT_FIELD,
LIST_FIELD,
STRING_FIELD,
TEMPORAL_DETECTIONS,
} from "@fiftyone/utilities";
import { describe, expect, it } from "vitest";
import { getBubbles, getField, unwind } from "./bubbles";
Expand Down Expand Up @@ -195,6 +197,38 @@ describe("text bubble tests", () => {
}
)
).toStrictEqual([field.fields.value, ["value"]]);

const classifications = {
...FIELD_DATA,
dbField: "classes",
ftype: EMBEDDED_DOCUMENT_FIELD,
embeddedDocType: CLASSIFICATIONS,
fields: {},
};

expect(
getBubbles(
"classes",
{ classes: { classifications: [{ label: "label" }] } },
{ classes: classifications }
)
);

const temporalDetections = {
...FIELD_DATA,
dbField: "temporal",
ftype: EMBEDDED_DOCUMENT_FIELD,
embeddedDocType: TEMPORAL_DETECTIONS,
fields: {},
};

expect(
getBubbles(
"temporal",
{ temporal: { detections: [{ label: "label" }] } },
{ temporal: temporalDetections }
)
);
});

it("getField gets field from a path keys", () => {
Expand Down
4 changes: 2 additions & 2 deletions app/packages/looker/src/elements/common/bubbles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export const getBubbles = (
}

if (field.embeddedDocType === withPath(LABELS_PATH, CLASSIFICATIONS)) {
out.values = out.values.flatMap(
out.values = unwind(field.dbField, out.values).flatMap(
Copy link
Contributor

Choose a reason for hiding this comment

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

What does out.values look like? Flat map should unnest arrays so it's weird that you would need to unwind first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

out.values is a list or single value of potentially renderable field data. flatMap flattens the nested classifications

(value) => value.classifications || []
) as Sample[];
break;
benjaminpkane marked this conversation as resolved.
Show resolved Hide resolved
}

if (field.embeddedDocType === withPath(LABELS_PATH, TEMPORAL_DETECTIONS)) {
out.values = out.values.flatMap(
out.values = unwind(field.dbField, out.values).flatMap(
(value) => value.detections || []
) as Sample[];
break;
Expand Down
Loading