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

Vision Data Explorer Flyout tests #2208

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ffaf951
ckpt
Advitya17 Jul 20, 2023
2efd461
test ckpt
Advitya17 Jul 20, 2023
345d3bb
constant button test ckpt
Advitya17 Jul 21, 2023
c326fb6
merge conflict fixes
Advitya17 Jul 21, 2023
4ba30d6
test ckpt
Advitya17 Jul 24, 2023
0bd2f1e
image explorer test ckpt
Advitya17 Jul 24, 2023
66f5fb2
merge conflict fix
Advitya17 Jul 24, 2023
ec3815a
readding constants
Advitya17 Jul 24, 2023
530c630
test fixes
Advitya17 Jul 24, 2023
88282ac
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Jul 24, 2023
594835f
line limit fix
Advitya17 Jul 25, 2023
f83688c
python lint fixes
Advitya17 Jul 25, 2023
c657628
added flyout constants
Advitya17 Jul 25, 2023
2dd58e2
reverted flyout test
Advitya17 Jul 25, 2023
2960f82
auto lint fixes
Advitya17 Jul 25, 2023
cdcf3d7
image click ckpt
Advitya17 Jul 26, 2023
24cc135
flyout test ckpt
Advitya17 Jul 26, 2023
2520b60
Flyout working test ckpt
Advitya17 Jul 27, 2023
8a95dcf
removed non-flyout tests/logic
Advitya17 Aug 2, 2023
9602285
merge conflict fix
Advitya17 Aug 2, 2023
13f11b1
reverted refactor
Advitya17 Aug 2, 2023
7d449c7
lint fixes + cy wait
Advitya17 Aug 3, 2023
8dea6b0
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 3, 2023
213a2f0
flyout test tweak
Advitya17 Aug 18, 2023
2972b36
merge conflict fixes
Advitya17 Aug 18, 2023
60a489a
typo fix
Advitya17 Aug 18, 2023
b5a6a8d
auto lint fixes
Advitya17 Aug 18, 2023
e999763
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 21, 2023
a234d0d
testing ckpt
Advitya17 Aug 21, 2023
e2ac173
notebook example tweak for EA on ubuntu
Advitya17 Aug 21, 2023
ce0268c
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 21, 2023
d57893e
simplified od test
Advitya17 Aug 22, 2023
f0bb62c
trying with wait inside and
Advitya17 Aug 29, 2023
71f42e0
syntax fix
Advitya17 Aug 29, 2023
6af68aa
added timeout
Advitya17 Aug 29, 2023
e0c2d17
wait until logic
Advitya17 Aug 29, 2023
bc32b25
tests without image loading
Advitya17 Aug 29, 2023
b416db4
waitUntil refactor
Advitya17 Aug 29, 2023
173c46b
build fix
Advitya17 Aug 29, 2023
7c52d29
condition tweak
Advitya17 Aug 30, 2023
c41d0e1
test case tweak
Advitya17 Aug 30, 2023
8e42a85
latest dependency update
Advitya17 Sep 6, 2023
c3e86a9
added import
Advitya17 Sep 6, 2023
d821b24
test tweak with waitUntil
Advitya17 Sep 6, 2023
d46b4a0
Merge branch 'main' into agemawat/vision_flyout_tests
Advitya17 Sep 6, 2023
f6ce2d2
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Sep 14, 2023
270e512
Merge branch 'agemawat/vision_flyout_tests' of https://github.com/mic…
Advitya17 Sep 19, 2023
c76bf88
get chained after waitUntil
Advitya17 Sep 19, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
describeVisionDataExplorer,
modelAssessmentDatasets
} from "@responsible-ai/e2e";
const datasetShape =
modelAssessmentDatasets.FridgeImageClassificationModelDebugging;
describeVisionDataExplorer(
datasetShape,
"FridgeImageClassificationModelDebugging"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
describeVisionDataExplorer,
modelAssessmentDatasets
} from "@responsible-ai/e2e";
const datasetShape = modelAssessmentDatasets.FridgeMultilabelModelDebugging;
describeVisionDataExplorer(datasetShape, "FridgeMultilabelModelDebugging");
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
describeVisionDataExplorer,
modelAssessmentDatasets
} from "@responsible-ai/e2e";
const datasetShape =
modelAssessmentDatasets.FridgeObjectDetectionModelDebugging;
describeVisionDataExplorer(datasetShape, "FridgeObjectDetectionModelDebugging");
1 change: 1 addition & 0 deletions libs/e2e/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export * from "./lib/describer/modelAssessment/modelOverview/describeModelOvervi
export * from "./lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIf";
export * from "./lib/describer/modelAssessment/datasets/modelAssessmentDatasets";
export * from "./lib/describer/modelAssessment/IModelAssessmentData";
export * from "./lib/describer/modelAssessment/visionDataExplorer/describeVisionDataExplorer";
export * from "./util/visit";
17 changes: 16 additions & 1 deletion libs/e2e/src/lib/describer/modelAssessment/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,20 @@ export enum Locators {
AggregateBalanceMeasuresHeader = "#aggregateBalanceMeasures #aggregateBalanceMeasuresHeader",
AggregateBalanceMeasuresTable = "#aggregateBalanceMeasures .ms-DetailsList",
AggregateBalanceMeasuresTableColumns = "#aggregateBalanceMeasures .ms-DetailsList-headerWrapper div[aria-label]",
AggregateBalanceMeasuresTableRows = "#aggregateBalanceMeasures .ms-DetailsRow"
AggregateBalanceMeasuresTableRows = "#aggregateBalanceMeasures .ms-DetailsRow",
VisionDataAnalysisPivot = "#visionDataAnalysisPivot",
VisionDataAnalysisTab = "#visionDataAnalysisPivot .ms-Pivot-link",
VisionDataBalancePivotItem = "#visionDataAnalysisPivot button[name='Data balance']",
VisionDataExplorer = "#VisionDataExplorer",
VisionDataExplorerImageExplorerViewButton = "#VisionDataExplorer button[name='Image explorer view']",
VisionDataExplorerImageExplorerViewSuccessImage = "#VisionDataExplorer #visionImage_0",
VisionDataExplorerFlyoutPredictionTitle = "#flyoutPredictionTitle",
VisionDataExplorerFlyoutPredictionLabel = "#flyoutPredLabel",
VisionDataExplorerFlyoutGroundTruthLabel = "#flyoutGtLabel",
VisionDataExplorerFlyoutImage = "#flyoutImage_0",
VisionDataExplorerFlyoutExplanationImage = "#flyoutExplanationImage_0",
VisionDataExplorerFlyoutMetadata = "#flyoutMetadata",
VisionDataExplorerFlyoutCloseButton = "button[aria-label='Close']",
VisionDataExplorerFlyoutCanvasToolsImageContainer = "#canvasToolsDiv #selectionDiv #editorDiv",
VisionDataExplorerFlyoutObjectSelection = "#Object Selection"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface IModelAssessmentData {
modelStatisticsData?: IModelStatisticsData;
modelOverviewData?: IModelOverviewData;
datasetExplorerData?: IDatasetExplorerData;
visionDataExplorerData?: IVisionDataExplorerData;
featureImportanceData?: IFeatureImportanceData;
dataBalanceData?: IDataBalanceData;
causalAnalysisData?: ICausalAnalysisData;
Expand Down Expand Up @@ -89,6 +90,12 @@ export interface IDatasetExplorerData {
cohortDatasetNewValue?: string;
}

export interface IVisionDataExplorerData {
hasVisionDataExplorerComponent?: boolean;
errorInstances?: number;
successInstances?: number;
}

export interface IDEWhiskerPlotData {
featureList?: string[];
defaultYAxis?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ export const FridgeImageClassificationModelDebugging = {
name: "CohortCreateE2E-image-classification",
sampleSize: "5"
}
},
visionDataExplorerData: {
errorInstances: 0,
hasVisionDataExplorerComponent: true,
successInstances: 10
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ export const FridgeMultilabelModelDebugging = {
name: "CohortCreateE2E-multilabel",
sampleSize: "3"
}
},
visionDataExplorerData: {
errorInstances: 0,
hasVisionDataExplorerComponent: true,
successInstances: 10
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ export const FridgeObjectDetectionModelDebugging = {
name: "CohortCreateE2E-object-detection",
sampleSize: "2"
}
},
visionDataExplorerData: {
errorInstances: 0,
hasVisionDataExplorerComponent: true,
successInstances: 5
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { visit } from "../../../../util/visit";
import { Locators } from "../Constants";
import { modelAssessmentDatasets } from "../datasets/modelAssessmentDatasets";
import { IModelAssessmentData } from "../IModelAssessmentData";

import { ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent } from "./ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent";

const testName = "Vision Data Explorer";

export function describeVisionDataExplorer(
datasetShape: IModelAssessmentData,
name?: keyof typeof modelAssessmentDatasets,
isNotebookTest = true
): void {
describe(testName, () => {
if (isNotebookTest) {
before(() => {
visit(name);
});
} else {
before(() => {
cy.visit(`#/modelAssessmentVision/${name}/light/english/Version-2`);
});
}

if (datasetShape.visionDataExplorerData?.hasVisionDataExplorerComponent) {
it("should should Flyout view components when selected", () => {
Advitya17 marked this conversation as resolved.
Show resolved Hide resolved
ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent(
datasetShape
);
});
} else {
it("should not have 'VisionDataExplorer' component", () => {
cy.get(Locators.VisionDataExplorer).should("not.exist");
});
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { expect } from "chai";

import { Locators } from "../Constants";
import { IModelAssessmentData } from "../IModelAssessmentData";

export function ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent(
datasetShape: IModelAssessmentData
): void {
cy.get(Locators.VisionDataExplorerImageExplorerViewButton).click();

cy.wait(10000);

Check failure on line 14 in libs/e2e/src/lib/describer/modelAssessment/visionDataExplorer/ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent.ts

View workflow job for this annotation

GitHub Actions / ci-typescript (16.x)

Do not wait for arbitrary time periods

Check failure on line 14 in libs/e2e/src/lib/describer/modelAssessment/visionDataExplorer/ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent.ts

View workflow job for this annotation

GitHub Actions / ci-typescript (12.x)

Do not wait for arbitrary time periods

cy.get(Locators.VisionDataExplorerImageExplorerViewSuccessImage)
.should("be.visible")
.and(($image) => {
// verifies the image is loaded
expect(($image[0] as HTMLImageElement).naturalWidth).to.be.greaterThan(0);
expect(($image[0] as HTMLImageElement).naturalHeight).to.be.greaterThan(
0
);
});
// before
cy.get(Locators.VisionDataExplorerImageExplorerViewSuccessImage).click();

cy.get(Locators.VisionDataExplorerFlyoutPredictionTitle).should("exist");

cy.get(Locators.VisionDataExplorerFlyoutPredictionLabel)
.invoke("text")
.then((predLabel) => {
cy.get(Locators.VisionDataExplorerFlyoutGroundTruthLabel)
.invoke("text")
.should((gtLabel) => {
expect(predLabel.split(": ")[1]).to.equal(gtLabel.split(": ")[1]);
});
});

cy.get(Locators.VisionDataExplorerFlyoutImage)
.should("be.visible")
.and(($image) => {
// verifies the image is loaded
expect(($image[0] as HTMLImageElement).naturalWidth).to.be.greaterThan(0);
expect(($image[0] as HTMLImageElement).naturalHeight).to.be.greaterThan(
0
);
});

if (datasetShape.isObjectDetection) {
cy.get(Locators.VisionDataExplorerFlyoutObjectSelection).should("exist");
} else {
cy.get(Locators.VisionDataExplorerFlyoutExplanationImage).should("exist");
}
cy.get(Locators.VisionDataExplorerFlyoutMetadata).should("exist");

cy.get(Locators.VisionDataExplorerFlyoutCloseButton).click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ export class DataCharacteristics extends React.Component<
this.props.selectItem(item);
};

private getPageHeight = (): number => {
return this.rowHeight;
};
private getPageHeight = (): number => this.rowHeight;

private getItemCountForPageWrapper = (
index: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
}
/>
</Stack.Item>
<Stack.Item>
<Stack.Item id="flyoutPredictionTitle">
{predictedY !== trueY ? (
<Text
variant="large"
Expand Down Expand Up @@ -179,13 +179,13 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{item?.index}
</Text>
</Stack.Item>
<Stack.Item>
<Stack.Item id="flyoutPredLabel">
<Text variant="large">
{localization.InterpretVision.Dashboard.predictedY}
{predictedY}
</Text>
</Stack.Item>
<Stack.Item>
<Stack.Item id="flyoutGtLabel">
<Text variant="large">
{localization.InterpretVision.Dashboard.trueY}
{trueY}
Expand All @@ -195,6 +195,7 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
</Stack.Item>
<Stack.Item className={classNames.imageContainer}>
<Image
id={`flyoutImage_${item?.index}`}
src={`data:image/jpg;base64,${item?.image}`}
className={classNames.image}
imageFit={ImageFit.contain}
Expand All @@ -217,6 +218,7 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{!this.props.loadingExplanation[0][index] ? (
<Stack.Item>
<Image
id={`flyoutExplanationImage_${item?.index}`}
src={`data:image/jpg;base64,${this.props.explanations
.get(0)
?.get(index)}`}
Expand Down Expand Up @@ -244,7 +246,10 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{localization.InterpretVision.Dashboard.panelInformation}
</Text>
</Stack.Item>
<Stack.Item className={classNames.featureListContainer}>
<Stack.Item
id="flyoutMetadata"
className={classNames.featureListContainer}
>
<List
items={this.state.metadata}
onRenderCell={this.onRenderCell}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class FlyoutObjectDetection extends React.Component<
}
/>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutPredictionTitle">
{predictedY !== trueY ? (
<FluentUI.Text
variant="large"
Expand Down Expand Up @@ -158,13 +158,13 @@ export class FlyoutObjectDetection extends React.Component<
{item?.index}
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutPredLabel">
<FluentUI.Text variant="large">
{localization.InterpretVision.Dashboard.predictedY}
{predictedY}
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutGtLabel">
<FluentUI.Text variant="large">
{localization.InterpretVision.Dashboard.trueY}
{trueY}
Expand Down Expand Up @@ -194,6 +194,7 @@ export class FlyoutObjectDetection extends React.Component<
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item
id="flyoutMetadata"
className={classNames.featureListContainer}
>
<FluentUI.List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class ImageList extends React.Component<
<Image
{...imageProps}
alt={alt}
id={`visionImage_${item?.index}`}
src={`data:image/jpg;base64,${item?.image}`}
onClick={this.callbackWrapper(item)}
width={this.props.imageDim}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class VisionExplanationDashboard extends React.Component<
<Stack
horizontal={false}
grow
id="VisionDataExplorer"
tokens={{ childrenGap: "l1", padding: "m 40px" }}
>
<Stack.Item>
Expand Down Expand Up @@ -111,6 +112,7 @@ export class VisionExplanationDashboard extends React.Component<
<Stack
horizontal={false}
grow
id="VisionDataExplorer"
tokens={{ childrenGap: "l1", padding: "m 40px" }}
>
<VisionExplanationDashboardCommon
Expand Down
6 changes: 4 additions & 2 deletions notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@ def test_responsibleaidashboard_fridge_image_classification_model_debugging():
@pytest.mark.vision_notebooks
def test_responsibleaidashboard_fridge_multilabel_ic_model_debugging():
nb_path = RESPONSIBLEAIDASHBOARD
nb_name = "responsibleaidashboard-fridge-multilabel-" + \
"image-classification-model-debugging"
nb_name = (
"responsibleaidashboard-fridge-multilabel-"
"image-classification-model-debugging"
)

test_values = {}
assay_one_notebook(nb_path, nb_name, test_values)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"dependencies": {
"@fluentui/react": "8.58.0",
"canvas": "^2.11.2",
"chai": "^4.3.5",
"core-js": "^3.6.5",
"d3-array": "^2.8.0",
"d3-color": "^2.0.0",
Expand Down
Loading