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

Render flexible plots #2403

Merged
merged 19 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MIN_CLI_VERSION = '2.24.0'
export const MIN_CLI_VERSION = '2.0.0'
mattseddon marked this conversation as resolved.
Show resolved Hide resolved
mattseddon marked this conversation as resolved.
Show resolved Hide resolved
export const LATEST_TESTED_CLI_VERSION = '2.26.2'
export const MAX_CLI_VERSION = '3'

Expand Down
173 changes: 172 additions & 1 deletion extension/src/plots/model/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
collectTemplates,
collectMetricOrder,
collectWorkspaceRunningCheckpoint,
collectWorkspaceRaceConditionData
collectWorkspaceRaceConditionData,
collectMultiSourceData
} from './collect'
import plotsDiffFixture from '../../test/fixtures/plotsDiff/output'
import expShowFixture from '../../test/fixtures/expShow/output'
Expand Down Expand Up @@ -358,3 +359,173 @@ describe('collectWorkspaceRaceConditionData', () => {
)
})
})

describe('collectMultiSourceData', () => {
it('should return an empty object given no multi source data', () => {
const multiSourceKeys = collectMultiSourceData({
path: [{ field: 'x', filename: 'path' }]
})
expect(multiSourceKeys).toStrictEqual({})
})

it('should return an object containing a filename strokeDash given data with varying filenames', () => {
const otherPath = join('other', 'path')
const multiSourceKeys = collectMultiSourceData({
combined: [
{ field: 'x', filename: 'path' },
{ field: 'x', filename: otherPath }
]
})
expect(multiSourceKeys).toStrictEqual({
combined: {
strokeDash: {
field: 'filename',
scale: {
domain: [otherPath, 'path'],
range: [
[1, 0],
[8, 8]
]
}
}
}
})
})

it('should return an object containing a field strokeDash given data with varying fields', () => {
const multiSourceKeys = collectMultiSourceData({
path: [
{ field: 'x', filename: 'path' },
{ field: 'z', filename: 'path' }
]
})
expect(multiSourceKeys).toStrictEqual({
path: {
strokeDash: {
field: 'field',
scale: {
domain: ['x', 'z'],
range: [
[1, 0],
[8, 8]
]
}
}
}
})
})

it('should return an object containing a filename and field strokeDash given data with varying filename and fields', () => {
const otherPath = join('other', 'path')
const multiSourceKeys = collectMultiSourceData({
combined: [
{ field: 'x', filename: 'path' },
{ field: 'z', filename: otherPath }
]
})
expect(multiSourceKeys).toStrictEqual({
combined: {
strokeDash: {
field: 'filename::field',
scale: {
domain: [`${otherPath}::z`, 'path::x'],
range: [
[1, 0],
[8, 8]
]
}
}
}
})
})

it('should return an object containing a filename strokeDash and field shape given data with differently varying filename and field', () => {
const multiSourceKeys = collectMultiSourceData({
combined: [
{ field: 'x', filename: 'path' },
{ field: 'z', filename: 'path' },
{ field: 'z', filename: join('other', 'path') }
]
})
expect(multiSourceKeys).toStrictEqual({
combined: {
shape: {
field: 'field',
scale: { domain: ['x', 'z'], range: ['square', 'circle'] }
},
strokeDash: {
field: 'filename',
scale: {
domain: [join('other', 'path'), 'path'],
range: [
[1, 0],
[8, 8]
]
}
}
}
})
})

it('should return an object containing a filename strokeDash and field shape given data with varying filename and similar field', () => {
const multiSourceKeys = collectMultiSourceData({
combined: [
{ field: 'x', filename: join('first', 'path') },
{ field: 'z', filename: join('second', 'path') },
{ field: 'z', filename: join('third', 'path') }
]
})
expect(multiSourceKeys).toStrictEqual({
combined: {
shape: {
field: 'field',
scale: { domain: ['x', 'z'], range: ['square', 'circle'] }
},
strokeDash: {
field: 'filename',
scale: {
domain: [
join('first', 'path'),
join('second', 'path'),
join('third', 'path')
],
range: [
[1, 0],
[8, 8],
[8, 4]
]
}
}
}
})
})

it('should return an object containing a filename strokeDash and field shape given data with varying filename and similar field 2', () => {
const multiSourceKeys = collectMultiSourceData({
combined: [
{ field: 'x', filename: join('first', 'path') },
{ field: 'z', filename: join('second', 'path') },
{ field: 'q', filename: join('third', 'path') }
]
})
expect(multiSourceKeys).toStrictEqual({
combined: {
strokeDash: {
field: 'filename::field',
scale: {
domain: [
`${join('first', 'path')}::x`,
`${join('second', 'path')}::z`,
`${join('third', 'path')}::q`
],
range: [
[1, 0],
[8, 8],
[8, 4]
]
}
}
}
})
})
})
Loading