Skip to content

Commit

Permalink
Fix the number of available revisions for multi view plots (#2836)
Browse files Browse the repository at this point in the history
* Fix the aspect ratio of multi view plots

* Revert to old aspect ratio formula

* Fix the number of available revisions for multi view plots

* Revert "Fix the aspect ratio of multi view plots"

This reverts commit 71cd961.

* patch flexible plot test

Co-authored-by: Matt Seddon <mattseddon@hotmail.com>
  • Loading branch information
sroy3 and mattseddon authored Nov 26, 2022
1 parent 9706efc commit 43c4d12
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
14 changes: 8 additions & 6 deletions extension/src/plots/model/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ const transformRevisionData = (
): { revisions: string[]; datapoints: unknown[] } => {
const field = multiSourceEncodingUpdate.strokeDash?.field
const isMultiSource = !!field

const availableRevisions = selectedRevisions.filter(rev =>
Object.keys(revisionData).includes(rev)
)
const transformNeeded =
isMultiSource && (isMultiView || isConcatenatedField(field))

Expand All @@ -551,7 +553,7 @@ const transformRevisionData = (
datapoints: selectedRevisions
.flatMap(revision => revisionData?.[revision]?.[path])
.filter(Boolean),
revisions: selectedRevisions
revisions: availableRevisions
}
}

Expand All @@ -562,12 +564,12 @@ const transformRevisionData = (
datapoints: updateDatapoints(
path,
revisionData,
selectedRevisions,
availableRevisions,
'rev',
fields
),
revisions: updateRevisions(
selectedRevisions,
availableRevisions,
multiSourceEncodingUpdate.strokeDash.scale.domain
)
}
Expand All @@ -577,11 +579,11 @@ const transformRevisionData = (
datapoints: updateDatapoints(
path,
revisionData,
selectedRevisions,
availableRevisions,
field,
fields
),
revisions: selectedRevisions
revisions: availableRevisions
}
}

Expand Down
6 changes: 3 additions & 3 deletions extension/src/test/fixtures/plotsDiff/multiSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9660,7 +9660,7 @@ const data = {
}
}
],
HEAD: [
main: [
{
fpr: 0.0,
tpr: 0.0,
Expand Down Expand Up @@ -38250,7 +38250,7 @@ const data = {
}
}
],
HEAD: [
main: [
{
precision: 0.36728395061728397,
recall: 1.0,
Expand Down Expand Up @@ -197286,7 +197286,7 @@ const data = {
}
}
],
HEAD: [
main: [
{
actual: '0',
predicted: '0',
Expand Down
13 changes: 9 additions & 4 deletions extension/src/test/suite/plots/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import * as Telemetry from '../../../telemetry'
import { EventName } from '../../../telemetry/constants'
import { ExperimentStatus } from '../../../cli/dvc/contract'
import { SelectedExperimentWithColor } from '../../../experiments/model'
import { Experiments } from '../../../experiments'

suite('Plots Test Suite', () => {
const disposable = Disposable.fn()
Expand Down Expand Up @@ -763,14 +764,18 @@ suite('Plots Test Suite', () => {
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should send the correct data to the webview for flexible plots', async () => {
const { plots, messageSpy, mockPlotsDiff, experiments } =
await buildPlots(disposable, multiSourcePlotsDiffFixture)

stub(experiments, 'getSelectedRevisions').returns([
stub(Experiments.prototype, 'getSelectedRevisions').returns([
{ label: 'workspace' },
{ label: 'main' }
] as SelectedExperimentWithColor[])

stub(Experiments.prototype, 'getBranchRevisions').returns([])

const { plots, messageSpy, mockPlotsDiff } = await buildPlots(
disposable,
multiSourcePlotsDiffFixture
)

const webview = await plots.showWebview()
await webview.isReady()

Expand Down

0 comments on commit 43c4d12

Please sign in to comment.