-
Notifications
You must be signed in to change notification settings - Fork 590
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 nested-dynamic-groups-as-video bug #4548
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fda5bd9
add 'slices' in filter when dynamic groups of groups
sashankaryal 7cd1aee
upgrade e2e deps
sashankaryal 1c07464
add e2e
sashankaryal d772352
eslint updates
benjaminpkane 8ad2fcd
format python
benjaminpkane 3b3e36a
fix sidebar e2e
sashankaryal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
e2e-pw/src/oss/specs/groups/nested-dynamic-groups.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import { test as base } from "src/oss/fixtures"; | ||
import { GridPom } from "src/oss/poms/grid"; | ||
import { ModalPom } from "src/oss/poms/modal"; | ||
import { SidebarPom } from "src/oss/poms/sidebar"; | ||
import { getUniqueDatasetNameWithPrefix } from "src/oss/utils"; | ||
import { createBlankImage } from "src/shared/media-factory/image"; | ||
|
||
const test = base.extend<{ | ||
grid: GridPom; | ||
modal: ModalPom; | ||
sidebar: SidebarPom; | ||
}>({ | ||
grid: async ({ page, eventUtils }, use) => { | ||
await use(new GridPom(page, eventUtils)); | ||
}, | ||
modal: async ({ page, eventUtils }, use) => { | ||
await use(new ModalPom(page, eventUtils)); | ||
}, | ||
sidebar: async ({ page }, use) => { | ||
await use(new SidebarPom(page)); | ||
}, | ||
}); | ||
|
||
const nestedDynamicGroupsDatasetName = getUniqueDatasetNameWithPrefix( | ||
"nested-dynamic-groups" | ||
); | ||
|
||
function* orderGenerator() { | ||
while (true) { | ||
yield 1; | ||
yield 1; | ||
yield 2; | ||
yield 2; | ||
} | ||
} | ||
|
||
const orderGen = orderGenerator(); | ||
|
||
// file format: g{groupNum}sl{sliceName}sc{sceneNum}o{orderNum}.png | ||
const imagePaths = [1, 2, 3, 4] | ||
.map((groupNum, idx) => [ | ||
`g${groupNum}sl1sc${idx > 1 ? "2" : "1"}`, | ||
`g${groupNum}sl2sc${idx > 1 ? "2" : "1"}`, | ||
]) | ||
.flat() | ||
.map((imgName) => `/tmp/${imgName}o${orderGen.next().value}.png`); | ||
|
||
test.beforeAll(async ({ fiftyoneLoader }) => { | ||
// create a dataset with two groups, each with 2 image samples | ||
const imageCreatePromises = imagePaths.map( | ||
async (imgPath) => | ||
await createBlankImage({ | ||
outputPath: imgPath, | ||
width: 100, | ||
height: 100, | ||
watermarkString: imgPath.split("/").pop().split(".")[0], | ||
}) | ||
); | ||
|
||
await Promise.all(imageCreatePromises); | ||
|
||
const pythonCode = ` | ||
import fiftyone as fo | ||
import json | ||
|
||
dataset = fo.Dataset("${nestedDynamicGroupsDatasetName}") | ||
dataset.persistent = True | ||
|
||
samples = [] | ||
|
||
image_paths = ${JSON.stringify(imagePaths)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very clever 😄 |
||
|
||
for i in range(1, 5): | ||
group = fo.Group() | ||
|
||
group_id = i | ||
|
||
file1 = image_paths[(group_id - 1) * 2] | ||
file2 = image_paths[(group_id - 1) * 2 + 1] | ||
|
||
# extract scene_id from filename | ||
file1_name = file1.split("/").pop().split(".")[0] | ||
file2_name = file2.split("/").pop().split(".")[0] | ||
|
||
scene_id = file1_name[-3] | ||
order_id_1 = file1_name[-1] | ||
order_id_2 = file2_name[-1] | ||
|
||
s1 = fo.Sample( | ||
filepath=file1, | ||
group=group.element("1"), | ||
scene_key=scene_id, | ||
order_key=order_id_1, | ||
) | ||
s2 = fo.Sample( | ||
filepath=file2, | ||
group=group.element("2"), | ||
scene_key=scene_id, | ||
order_key=order_id_2, | ||
) | ||
|
||
samples.extend([s1, s2]) | ||
|
||
dataset.add_samples(samples) | ||
`; | ||
await fiftyoneLoader.executePythonCode(pythonCode); | ||
}); | ||
|
||
test.beforeEach(async ({ page, fiftyoneLoader }) => { | ||
await fiftyoneLoader.waitUntilGridVisible( | ||
page, | ||
nestedDynamicGroupsDatasetName | ||
); | ||
}); | ||
|
||
test(`dynamic groups of groups works`, async ({ grid, modal, sidebar }) => { | ||
await grid.assert.isLookerCountEqualTo(4); | ||
await grid.assert.isEntryCountTextEqualTo("4 groups with slice"); | ||
|
||
await sidebar.clickFieldCheckbox("scene_key"); | ||
await sidebar.clickFieldCheckbox("order_key"); | ||
|
||
await grid.assert.nthSampleHasTagValue(0, "order_key", "1"); | ||
await grid.assert.nthSampleHasTagValue(1, "order_key", "2"); | ||
await grid.assert.nthSampleHasTagValue(2, "order_key", "1"); | ||
await grid.assert.nthSampleHasTagValue(3, "order_key", "2"); | ||
|
||
const groupByRefresh = grid.getWaitForGridRefreshPromise(); | ||
await grid.actionsRow.toggleCreateDynamicGroups(); | ||
await grid.actionsRow.groupBy("scene_key", "order_key"); | ||
await groupByRefresh; | ||
|
||
const gridRefreshPromiseSetRenderFramesAsVideo = | ||
grid.getWaitForGridRefreshPromise(); | ||
await grid.actionsRow.toggleDisplayOptions(); | ||
await grid.actionsRow.displayActions.toggleRenderFramesAsVideo(); | ||
await gridRefreshPromiseSetRenderFramesAsVideo; | ||
|
||
await grid.assert.isLookerCountEqualTo(2); | ||
await grid.assert.isEntryCountTextEqualTo("2 groups with slice"); | ||
|
||
await grid.assert.nthSampleHasTagValue(0, "scene_key", "1"); | ||
await grid.assert.nthSampleHasTagValue(1, "scene_key", "2"); | ||
await grid.assert.nthSampleHasTagValue(0, "order_key", "1"); | ||
await grid.assert.nthSampleHasTagValue(1, "order_key", "1"); | ||
|
||
await grid.openFirstSample(); | ||
await modal.waitForSampleLoadDomAttribute(); | ||
|
||
await modal.sidebar.assert.verifySidebarEntryTexts({ | ||
scene_key: "1", | ||
order_key: "1", | ||
}); | ||
await modal.video.playUntilFrames("2 / 2", true); | ||
|
||
await modal.sidebar.assert.verifySidebarEntryTexts({ | ||
scene_key: "1", | ||
order_key: "2", | ||
}); | ||
await modal.navigateNextSample(); | ||
|
||
await modal.sidebar.assert.verifySidebarEntryTexts({ | ||
scene_key: "2", | ||
order_key: "1", | ||
}); | ||
|
||
await modal.video.playUntilFrames("2 / 2", true); | ||
|
||
await modal.sidebar.assert.verifySidebarEntryTexts({ | ||
scene_key: "2", | ||
// todo: investigate why this is failing intermittently :/ | ||
// order_key: "2", | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy