Skip to content

Commit 545868a

Browse files
authored
Separate comparison table and plot ribbon revision orders (#2859)
1 parent d5f94aa commit 545868a

File tree

13 files changed

+421
-183
lines changed

13 files changed

+421
-183
lines changed

extension/src/plots/model/collect.test.ts

Lines changed: 277 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -365,72 +365,236 @@ describe('collectWorkspaceRaceConditionData', () => {
365365
describe('collectOverrideRevisionDetails', () => {
366366
it('should override the revision details for running checkpoint tips', () => {
367367
const runningId = 'b'
368-
369-
const { overrideOrder, overrideRevisions, unfinishedRunningExperiments } =
370-
collectOverrideRevisionDetails(
371-
['a', 'b', 'c', 'd'],
372-
[
373-
{ label: 'a' },
374-
{
375-
checkpoint_tip: 'b',
376-
displayColor: '#13adc7',
377-
id: runningId,
378-
label: 'b',
379-
sha: 'b',
380-
status: ExperimentStatus.RUNNING
381-
},
382-
{ label: 'c' },
383-
{ label: 'd' }
384-
] as SelectedExperimentWithColor[],
385-
new Set(['a', 'c', 'd', 'e']),
386-
new Set(),
387-
(id: string) => ({ [runningId]: [{ label: 'e' }] as Experiment[] }[id])
388-
)
389-
expect(overrideOrder).toStrictEqual(['a', 'e', 'c', 'd'])
368+
const runningGroup = `[${runningId}]`
369+
370+
const {
371+
overrideComparison,
372+
overrideRevisions,
373+
unfinishedRunningExperiments
374+
} = collectOverrideRevisionDetails(
375+
['a', 'b', 'c', 'd'],
376+
[
377+
{
378+
checkpoint_tip: 'b',
379+
displayColor: '#4299e1',
380+
id: 'a',
381+
label: 'a',
382+
logicalGroupName: 'a',
383+
sha: 'a',
384+
status: ExperimentStatus.SUCCESS
385+
},
386+
{
387+
checkpoint_tip: 'b',
388+
displayColor: '#13adc7',
389+
id: runningId,
390+
label: 'b',
391+
logicalGroupName: runningGroup,
392+
sha: 'b',
393+
status: ExperimentStatus.RUNNING
394+
},
395+
{
396+
checkpoint_tip: 'c',
397+
displayColor: '#48bb78',
398+
id: 'c',
399+
label: 'c',
400+
logicalGroupName: 'c',
401+
sha: 'c',
402+
status: ExperimentStatus.SUCCESS
403+
},
404+
{
405+
checkpoint_tip: 'd',
406+
displayColor: '#f56565',
407+
id: 'd',
408+
label: 'd',
409+
logicalGroupName: 'd',
410+
sha: 'd',
411+
status: ExperimentStatus.SUCCESS
412+
}
413+
] as SelectedExperimentWithColor[],
414+
new Set(['a', 'c', 'd', 'e']),
415+
new Set(),
416+
(id: string) =>
417+
({
418+
[runningId]: [
419+
{
420+
checkpoint_tip: 'f',
421+
id: 'f',
422+
label: 'f',
423+
logicalGroupName: runningGroup,
424+
sha: 'f',
425+
status: ExperimentStatus.SUCCESS
426+
},
427+
{
428+
checkpoint_tip: 'e',
429+
id: 'e',
430+
label: 'e',
431+
logicalGroupName: runningGroup,
432+
sha: 'e',
433+
status: ExperimentStatus.SUCCESS
434+
}
435+
] as Experiment[]
436+
}[id])
437+
)
438+
expect(overrideComparison.map(({ revision }) => revision)).toStrictEqual([
439+
'a',
440+
'e',
441+
'c',
442+
'd'
443+
])
390444
expect(overrideRevisions).toStrictEqual([
391-
{ label: 'a' },
445+
{
446+
displayColor: '#4299e1',
447+
fetched: true,
448+
group: 'a',
449+
id: 'a',
450+
revision: 'a'
451+
},
392452
{
393453
displayColor: '#13adc7',
394-
label: 'e'
454+
fetched: true,
455+
group: runningGroup,
456+
id: 'e',
457+
revision: 'e'
458+
},
459+
{
460+
displayColor: '#48bb78',
461+
fetched: true,
462+
group: 'c',
463+
id: 'c',
464+
revision: 'c'
395465
},
396-
{ label: 'c' },
397-
{ label: 'd' }
466+
467+
{
468+
displayColor: '#f56565',
469+
fetched: true,
470+
group: 'd',
471+
id: 'd',
472+
revision: 'd'
473+
}
398474
])
399475
expect(unfinishedRunningExperiments).toStrictEqual(new Set([runningId]))
400476
})
401477

402-
it('should override the revision details for finished but unfetched checkpoint tips', () => {
403-
const justFinishedRunningId = 'exp-was-running'
404-
const { overrideOrder, overrideRevisions, unfinishedRunningExperiments } =
478+
it('should order the comparison revisions according to the provided', () => {
479+
const runningId = 'b'
480+
const runningGroup = `[${runningId}]`
481+
482+
const { overrideComparison, overrideRevisions } =
405483
collectOverrideRevisionDetails(
406-
['a', 'b', 'c', 'd'],
484+
['a', 'b', 'c', 'd'].reverse(),
407485
[
408-
{ label: 'a' },
486+
{
487+
checkpoint_tip: 'b',
488+
displayColor: '#4299e1',
489+
id: 'a',
490+
label: 'a',
491+
logicalGroupName: 'a',
492+
sha: 'a',
493+
status: ExperimentStatus.SUCCESS
494+
},
409495
{
410496
checkpoint_tip: 'b',
411497
displayColor: '#13adc7',
412-
id: justFinishedRunningId,
498+
id: runningId,
413499
label: 'b',
500+
logicalGroupName: runningGroup,
414501
sha: 'b',
502+
status: ExperimentStatus.RUNNING
503+
},
504+
{
505+
checkpoint_tip: 'c',
506+
displayColor: '#48bb78',
507+
id: 'c',
508+
label: 'c',
509+
logicalGroupName: 'c',
510+
sha: 'c',
415511
status: ExperimentStatus.SUCCESS
416512
},
417-
{ label: 'c' },
418-
{ label: 'd' }
513+
{
514+
checkpoint_tip: 'd',
515+
displayColor: '#f56565',
516+
id: 'd',
517+
label: 'd',
518+
logicalGroupName: 'd',
519+
sha: 'd',
520+
status: ExperimentStatus.SUCCESS
521+
}
419522
] as SelectedExperimentWithColor[],
420523
new Set(['a', 'c', 'd', 'e']),
421-
new Set([justFinishedRunningId]),
524+
new Set(),
422525
(id: string) =>
423-
({ [justFinishedRunningId]: [{ label: 'e' }] as Experiment[] }[id])
526+
({
527+
[runningId]: [
528+
{
529+
checkpoint_tip: 'f',
530+
id: 'f',
531+
label: 'f',
532+
logicalGroupName: runningGroup,
533+
sha: 'f',
534+
status: ExperimentStatus.SUCCESS
535+
},
536+
{
537+
checkpoint_tip: 'e',
538+
id: 'e',
539+
label: 'e',
540+
logicalGroupName: runningGroup,
541+
sha: 'e',
542+
status: ExperimentStatus.SUCCESS
543+
}
544+
] as Experiment[]
545+
}[id])
424546
)
425-
expect(overrideOrder).toStrictEqual(['a', 'e', 'c', 'd'])
426-
expect(overrideRevisions).toStrictEqual([
427-
{ label: 'a' },
428-
{
429-
displayColor: '#13adc7',
430-
label: 'e'
431-
},
432-
{ label: 'c' },
433-
{ label: 'd' }
547+
expect(overrideComparison.map(({ revision }) => revision)).toStrictEqual([
548+
'd',
549+
'c',
550+
'e',
551+
'a'
552+
])
553+
expect(overrideRevisions.map(({ revision }) => revision)).toStrictEqual([
554+
'a',
555+
'e',
556+
'c',
557+
'd'
558+
])
559+
})
560+
561+
it('should override the revision details for finished but unfetched checkpoint tips', () => {
562+
const justFinishedRunningId = 'exp-was-running'
563+
const {
564+
overrideComparison,
565+
overrideRevisions,
566+
unfinishedRunningExperiments
567+
} = collectOverrideRevisionDetails(
568+
['a', 'b', 'c', 'd'],
569+
[
570+
{ label: 'a' },
571+
{
572+
checkpoint_tip: 'b',
573+
displayColor: '#13adc7',
574+
id: justFinishedRunningId,
575+
label: 'b',
576+
sha: 'b',
577+
status: ExperimentStatus.SUCCESS
578+
},
579+
{ label: 'c' },
580+
{ label: 'd' }
581+
] as SelectedExperimentWithColor[],
582+
new Set(['a', 'c', 'd', 'e']),
583+
new Set([justFinishedRunningId]),
584+
(id: string) =>
585+
({ [justFinishedRunningId]: [{ label: 'e' }] as Experiment[] }[id])
586+
)
587+
expect(overrideComparison.map(({ revision }) => revision)).toStrictEqual([
588+
'a',
589+
'e',
590+
'c',
591+
'd'
592+
])
593+
expect(overrideRevisions.map(({ revision }) => revision)).toStrictEqual([
594+
'a',
595+
'e',
596+
'c',
597+
'd'
434598
])
435599
expect(unfinishedRunningExperiments).toStrictEqual(
436600
new Set([justFinishedRunningId])
@@ -439,33 +603,74 @@ describe('collectOverrideRevisionDetails', () => {
439603

440604
it('should remove the id from the unfinishedRunningExperiments set once the revision has been fetched', () => {
441605
const justFinishedRunningId = 'exp-was-running'
442-
const { overrideOrder, overrideRevisions, unfinishedRunningExperiments } =
443-
collectOverrideRevisionDetails(
444-
['a', 'b', 'c', 'd'],
445-
[
446-
{ label: 'a' },
447-
{
448-
checkpoint_tip: 'b',
449-
displayColor: '#13adc7',
450-
id: justFinishedRunningId,
451-
label: 'b',
452-
sha: 'b',
453-
status: ExperimentStatus.SUCCESS
454-
},
455-
{ label: 'c' },
456-
{ label: 'd' }
457-
] as SelectedExperimentWithColor[],
458-
new Set(['a', 'b', 'c', 'd', 'e']),
459-
new Set([justFinishedRunningId]),
460-
(id: string) =>
461-
({ [justFinishedRunningId]: [{ label: 'e' }] as Experiment[] }[id])
462-
)
463-
expect(overrideOrder).toStrictEqual(['a', 'b', 'c', 'd'])
464-
expect(overrideRevisions).toStrictEqual([
465-
{ label: 'a' },
466-
expect.objectContaining({ label: 'b' }),
467-
{ label: 'c' },
468-
{ label: 'd' }
606+
const justFinishedRunningGroup = `[${justFinishedRunningId}]`
607+
const {
608+
overrideComparison,
609+
overrideRevisions,
610+
unfinishedRunningExperiments
611+
} = collectOverrideRevisionDetails(
612+
['a', 'b', 'c', 'd'],
613+
[
614+
{
615+
checkpoint_tip: 'b',
616+
displayColor: '#ed8936',
617+
id: 'a',
618+
label: 'a',
619+
logicalGroupName: justFinishedRunningGroup,
620+
sha: 'a'
621+
},
622+
{
623+
checkpoint_tip: 'b',
624+
displayColor: '#13adc7',
625+
id: justFinishedRunningId,
626+
label: 'b',
627+
logicalGroupName: justFinishedRunningGroup,
628+
sha: 'b',
629+
status: ExperimentStatus.SUCCESS
630+
},
631+
{
632+
checkpoint_tip: 'q',
633+
displayColor: '#48bb78',
634+
id: 'c',
635+
label: 'c',
636+
logicalGroupName: 'c',
637+
sha: 'c'
638+
},
639+
{
640+
checkpoint_tip: 'q',
641+
displayColor: '#f46837',
642+
id: 'd',
643+
label: 'd',
644+
logicalGroupName: 'c',
645+
sha: 'd'
646+
}
647+
] as SelectedExperimentWithColor[],
648+
new Set(['a', 'b', 'c', 'd', 'e']),
649+
new Set([justFinishedRunningId]),
650+
(id: string) =>
651+
({
652+
[justFinishedRunningId]: [
653+
{
654+
checkpoint_tip: 'b',
655+
id: 'e',
656+
label: 'e',
657+
logicalGroupName: justFinishedRunningGroup,
658+
sha: 'e'
659+
}
660+
] as Experiment[]
661+
}[id])
662+
)
663+
expect(overrideComparison.map(({ revision }) => revision)).toStrictEqual([
664+
'a',
665+
'b',
666+
'c',
667+
'd'
668+
])
669+
expect(overrideRevisions.map(({ revision }) => revision)).toStrictEqual([
670+
'a',
671+
'b',
672+
'c',
673+
'd'
469674
])
470675
expect(unfinishedRunningExperiments).toStrictEqual(new Set([]))
471676
})

0 commit comments

Comments
 (0)