-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2951 from mturley/grpc-mock
Mock gRPC responses for MLMD cypress tests using ts-proto
- Loading branch information
Showing
22 changed files
with
28,374 additions
and
2 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { GetArtifactTypesResponse } from '~/__mocks__/third_party/mlmd'; | ||
import createGrpcResponse, { GrpcResponse } from './utils'; | ||
|
||
const mockedArtifactTypesResponse: GetArtifactTypesResponse = { | ||
artifactTypes: [ | ||
{ | ||
id: 14, | ||
name: 'system.Artifact', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 15, | ||
name: 'system.Dataset', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 16, | ||
name: 'system.Model', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 17, | ||
name: 'system.Metrics', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 18, | ||
name: 'system.ClassificationMetrics', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 19, | ||
name: 'system.Markdown', | ||
properties: {}, | ||
}, | ||
{ | ||
id: 20, | ||
name: 'system.HTML', | ||
properties: {}, | ||
}, | ||
], | ||
}; | ||
|
||
export const mockGetArtifactTypes = (): GrpcResponse => { | ||
const binary = GetArtifactTypesResponse.encode(mockedArtifactTypesResponse).finish(); | ||
return createGrpcResponse(binary); | ||
}; |
114 changes: 114 additions & 0 deletions
114
frontend/src/__mocks__/mlmd/mockGetArtifactsByContext.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,114 @@ | ||
import { Artifact, GetArtifactsByContextResponse } from '~/__mocks__/third_party/mlmd'; | ||
import createGrpcResponse, { GrpcResponse } from './utils'; | ||
|
||
const mockedScalarMetricArtifact: Artifact = { | ||
id: 7, | ||
typeId: 17, | ||
type: 'system.Metrics', | ||
uri: 's3://aballant-pipelines/metrics-visualization-pipeline/f0b586ba-3e7b-4369-8d48-592e83cbbf73/digit-classification/metrics', | ||
properties: {}, | ||
customProperties: { | ||
accuracy: { doubleValue: 92 }, | ||
displayName: { stringValue: 'metrics' }, | ||
}, | ||
state: 2, | ||
createTimeSinceEpoch: 1711765118976, | ||
lastUpdateTimeSinceEpoch: 1711765118976, | ||
}; | ||
|
||
const mockedConfusionMatrixArtifact: Artifact = { | ||
id: 8, | ||
typeId: 18, | ||
type: 'system.ClassificationMetrics', | ||
uri: 's3://aballant-pipelines/metrics-visualization-pipeline/ccdfe85e-06cc-4a63-b10d-a12d688d2ec3/iris-sgdclassifier/metrics', | ||
properties: {}, | ||
customProperties: { | ||
confusionMatrix: { | ||
structValue: { | ||
struct: { | ||
annotationSpecs: [ | ||
{ displayName: 'Setosa' }, | ||
{ displayName: 'Versicolour' }, | ||
{ displayName: 'Virginica' }, | ||
], | ||
rows: [ | ||
{ | ||
row: [38, 0, 0], | ||
}, | ||
{ | ||
row: [2, 19, 9], | ||
}, | ||
{ | ||
row: [1, 17, 19], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
displayName: { | ||
stringValue: 'metrics', | ||
}, | ||
}, | ||
state: 2, | ||
createTimeSinceEpoch: 1711765608345, | ||
lastUpdateTimeSinceEpoch: 1711765608345, | ||
}; | ||
|
||
const mockedRocCurveArtifact: Artifact = { | ||
id: 9, | ||
typeId: 18, | ||
type: 'system.ClassificationMetrics', | ||
uri: 's3://aballant-pipelines/metrics-visualization-pipeline/aa61378c-d507-4bde-aa18-9f8678b2beb6/wine-classification/metrics', | ||
properties: {}, | ||
customProperties: { | ||
confidenceMetrics: { | ||
structValue: { | ||
list: [ | ||
{ confidenceThreshold: 2, falsePositiveRate: 0, recall: 0 }, | ||
{ confidenceThreshold: 1, falsePositiveRate: 0, recall: 0.33962264150943394 }, | ||
{ confidenceThreshold: 0, falsePositiveRate: 0, recall: 0.6037735849056604 }, | ||
{ confidenceThreshold: 0.8, falsePositiveRate: 0, recall: 0.8490566037735849 }, | ||
{ confidenceThreshold: 0.6, falsePositiveRate: 0, recall: 0.8867924528301887 }, | ||
{ confidenceThreshold: 0.5, falsePositiveRate: 0.0125, recall: 0.9245283018867925 }, | ||
{ confidenceThreshold: 0.4, falsePositiveRate: 0.075, recall: 0.9622641509433962 }, | ||
{ confidenceThreshold: 0.3, falsePositiveRate: 0.0875, recall: 1 }, | ||
{ confidenceThreshold: 0.2, falsePositiveRate: 0.2375, recall: 1 }, | ||
{ confidenceThreshold: 0.1, falsePositiveRate: 0.475, recall: 1 }, | ||
{ confidenceThreshold: 0, falsePositiveRate: 1, recall: 1 }, | ||
], | ||
}, | ||
}, | ||
displayName: { | ||
stringValue: 'metrics', | ||
}, | ||
}, | ||
state: 2, | ||
createTimeSinceEpoch: 1711766424068, | ||
lastUpdateTimeSinceEpoch: 1711766424068, | ||
}; | ||
|
||
const mockedMarkdownArtifact: Artifact = { | ||
id: 16, | ||
typeId: 19, | ||
type: 'system.Markdown', | ||
uri: 's3://aballant-pipelines/metrics-visualization-pipeline/16dbff18-a3d5-4684-90ac-4e6198a9da0f/markdown-visualization/markdown_artifact', | ||
properties: {}, | ||
customProperties: { | ||
displayName: { stringValue: 'markdown_artifact' }, | ||
}, | ||
state: 2, | ||
createTimeSinceEpoch: 1712841455267, | ||
lastUpdateTimeSinceEpoch: 1712841455267, | ||
}; | ||
|
||
export const mockGetArtifactsByContext = (): GrpcResponse => { | ||
const binary = GetArtifactsByContextResponse.encode({ | ||
artifacts: [ | ||
mockedScalarMetricArtifact, | ||
mockedConfusionMatrixArtifact, | ||
mockedRocCurveArtifact, | ||
mockedMarkdownArtifact, | ||
], | ||
}).finish(); | ||
return createGrpcResponse(binary); | ||
}; |
34 changes: 34 additions & 0 deletions
34
frontend/src/__mocks__/mlmd/mockGetContextByTypeAndName.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,34 @@ | ||
/* eslint-disable camelcase */ | ||
|
||
import { Context, GetContextByTypeAndNameResponse } from '~/__mocks__/third_party/mlmd'; | ||
import createGrpcResponse, { GrpcResponse } from './utils'; | ||
|
||
const mockedContext: Context = { | ||
id: 106, // The id of the pipeline run to mock | ||
name: '${name}', | ||
typeId: 11, | ||
type: 'system.PipelineRun', | ||
properties: {}, | ||
customProperties: { | ||
bucket_session_info: { | ||
stringValue: | ||
'{"Region":"us-east-1","Endpoint":"https://s3.amazonaws.com","DisableSSL":false,"SecretName":"secret-3t3ar6","AccessKeyKey":"AWS_ACCESS_KEY_ID","SecretKeyKey":"AWS_SECRET_ACCESS_KEY"}', | ||
}, | ||
namespace: { | ||
stringValue: 'jps-fun-world', | ||
}, | ||
pipeline_root: { | ||
stringValue: 's3://aballant-pipelines/metrics-visualization-pipeline/${name}', | ||
}, | ||
resource_name: { | ||
stringValue: 'run-resource', | ||
}, | ||
}, | ||
createTimeSinceEpoch: 1712899519123, | ||
lastUpdateTimeSinceEpoch: 1712899519123, | ||
}; | ||
|
||
export const mockGetContextByTypeAndName = (): GrpcResponse => { | ||
const binary = GetContextByTypeAndNameResponse.encode({ context: mockedContext }).finish(); | ||
return createGrpcResponse(binary); | ||
}; |
Oops, something went wrong.