@@ -13,7 +13,12 @@ import {
1313 ExperimentAugmented ,
1414 ExperimentWithType
1515} from './filterBy/collect'
16- import { collectColoredStatus , collectSelected } from './status/collect'
16+ import {
17+ collectColoredStatus ,
18+ collectFinishedRunningExperiments ,
19+ collectSelected ,
20+ collectStartedRunningExperiments
21+ } from './status/collect'
1722import { Color , copyOriginalColors } from './status/colors'
1823import {
1924 canSelect ,
@@ -23,7 +28,12 @@ import {
2328 UNSELECTED
2429} from './status'
2530import { collectFlatExperimentParams } from './modify/collect'
26- import { Experiment , isQueued , Row } from '../webview/contract'
31+ import {
32+ Experiment ,
33+ isQueued ,
34+ Row ,
35+ RunningExperiment
36+ } from '../webview/contract'
2737import {
2838 definedAndNonEmpty ,
2939 reorderListSubset ,
@@ -68,7 +78,9 @@ export class ExperimentsModel extends ModelWithPersistence {
6878 private useFiltersForSelection = false
6979
7080 private currentSorts : SortDefinition [ ]
71- private hasRunning = false
81+ private running : RunningExperiment [ ] = [ ]
82+ private finishedRunning : { [ id : string ] : string } = { }
83+ private startedRunning : Set < string > = new Set ( )
7284
7385 constructor ( dvcRoot : string , workspaceState : Memento ) {
7486 super ( dvcRoot , workspaceState )
@@ -107,16 +119,15 @@ export class ExperimentsModel extends ModelWithPersistence {
107119 branches,
108120 experimentsByBranch,
109121 checkpointsByTip,
110- hasRunning
122+ runningExperiments
111123 } = collectExperiments ( data )
112124
113125 this . workspace = workspace
114126 this . branches = branches
115127 this . experimentsByBranch = experimentsByBranch
116128 this . checkpointsByTip = checkpointsByTip
117- this . hasRunning = hasRunning
118129
119- this . setColoredStatus ( )
130+ this . setColoredStatus ( runningExperiments )
120131 }
121132
122133 public toggleStars ( ids : string [ ] ) {
@@ -151,7 +162,17 @@ export class ExperimentsModel extends ModelWithPersistence {
151162 }
152163
153164 public hasRunningExperiment ( ) {
154- return this . hasRunning
165+ return this . running . length > 0
166+ }
167+
168+ public setRevisionCollected ( revisions : string [ ] ) {
169+ this . getFlattenedExperiments ( )
170+ . filter ( ( { label } ) => revisions . includes ( label ) )
171+ . map ( ( { id } ) => {
172+ if ( this . finishedRunning [ id ] ) {
173+ delete this . finishedRunning [ id ]
174+ }
175+ } )
155176 }
156177
157178 public canSelect ( ) {
@@ -420,6 +441,10 @@ export class ExperimentsModel extends ModelWithPersistence {
420441 } ) )
421442 }
422443
444+ public getFinishedExperiments ( ) {
445+ return this . finishedRunning
446+ }
447+
423448 private getSubRows ( experiments : Experiment [ ] , filters = this . getFilters ( ) ) {
424449 return experiments
425450 . map ( experiment => {
@@ -510,7 +535,9 @@ export class ExperimentsModel extends ModelWithPersistence {
510535 )
511536 }
512537
513- private setColoredStatus ( ) {
538+ private setColoredStatus ( runningExperiments : RunningExperiment [ ] ) {
539+ this . setRunning ( runningExperiments )
540+
514541 if ( this . useFiltersForSelection ) {
515542 this . setSelectedToFilters ( )
516543 return
@@ -520,14 +547,34 @@ export class ExperimentsModel extends ModelWithPersistence {
520547 this . checkpointsByTip ,
521548 this . experimentsByBranch ,
522549 this . coloredStatus ,
523- this . availableColors
550+ this . availableColors ,
551+ this . startedRunning ,
552+ this . finishedRunning
524553 )
554+ this . startedRunning = new Set ( )
525555
526556 this . setColors ( coloredStatus , availableColors )
527557
528558 this . persistStatus ( )
529559 }
530560
561+ private setRunning ( stillRunning : RunningExperiment [ ] ) {
562+ this . startedRunning = collectStartedRunningExperiments (
563+ this . running ,
564+ stillRunning
565+ )
566+
567+ this . finishedRunning = collectFinishedRunningExperiments (
568+ { ...this . finishedRunning } ,
569+ this . getFlattenedExperiments ( ) ,
570+ this . running ,
571+ stillRunning ,
572+ this . coloredStatus
573+ )
574+
575+ this . running = stillRunning
576+ }
577+
531578 private setColors ( coloredStatus : ColoredStatus , availableColors : Color [ ] ) {
532579 this . coloredStatus = coloredStatus
533580 this . availableColors = availableColors
0 commit comments