@@ -10,6 +10,7 @@ import { collectExperiments, collectMutableRevisions } from './collect'
1010import {
1111 collectFiltered ,
1212 collectFilteredCounts ,
13+ ExperimentAugmented ,
1314 ExperimentWithType
1415} from './filterBy/collect'
1516import { collectColoredStatus , collectSelected } from './status/collect'
@@ -228,7 +229,7 @@ export class ExperimentsModel extends ModelWithPersistence {
228229 }
229230
230231 public getMutableRevisions ( hasCheckpoints : boolean ) {
231- return collectMutableRevisions ( this . getExperiments ( ) , hasCheckpoints )
232+ return collectMutableRevisions ( this . getAllExperiments ( ) , hasCheckpoints )
232233 }
233234
234235 public getSelectedRevisions ( ) {
@@ -264,7 +265,7 @@ export class ExperimentsModel extends ModelWithPersistence {
264265
265266 public getUnfilteredExperiments ( filters = this . getFilters ( ) ) {
266267 const unfilteredExperiments = this . getSubRows (
267- this . getExperiments ( ) ,
268+ this . getAllExperiments ( ) ,
268269 filters
269270 )
270271
@@ -285,11 +286,7 @@ export class ExperimentsModel extends ModelWithPersistence {
285286 )
286287 }
287288
288- public getExperiments ( ) : ( ExperimentWithType & {
289- hasChildren : boolean
290- selected ?: boolean
291- starred : boolean
292- } ) [ ] {
289+ public getExperiments ( ) : ExperimentAugmented [ ] {
293290 return [
294291 {
295292 ...this . addDetails ( this . workspace ) ,
@@ -299,22 +296,17 @@ export class ExperimentsModel extends ModelWithPersistence {
299296 ...this . branches . map ( branch => {
300297 return {
301298 ...this . addDetails ( branch ) ,
302- hasChildren : false ,
299+ hasChildren : ! ! this . experimentsByBranch . get ( branch . label ) ,
303300 type : ExperimentType . BRANCH
304301 }
305- } ) ,
306- ...this . getFlattenedExperiments ( ) . map ( experiment => ( {
307- ...experiment ,
308- hasChildren : definedAndNonEmpty (
309- this . checkpointsByTip . get ( experiment . id )
310- ) ,
311- type : experiment . queued
312- ? ExperimentType . QUEUED
313- : ExperimentType . EXPERIMENT
314- } ) )
302+ } )
315303 ]
316304 }
317305
306+ public getAllExperiments ( ) {
307+ return [ ...this . getExperiments ( ) , ...this . getFlattenedExperiments ( ) ]
308+ }
309+
318310 public getErrors ( ) {
319311 return new Set (
320312 this . getCombinedList ( )
@@ -325,7 +317,7 @@ export class ExperimentsModel extends ModelWithPersistence {
325317
326318 public getExperimentsWithCheckpoints ( ) : ExperimentWithCheckpoints [ ] {
327319 const experimentsWithCheckpoints : ExperimentWithCheckpoints [ ] = [ ]
328- for ( const experiment of this . getExperiments ( ) ) {
320+ for ( const experiment of this . getAllExperiments ( ) ) {
329321 const { id, queued } = experiment
330322 if ( queued ) {
331323 continue
@@ -342,7 +334,7 @@ export class ExperimentsModel extends ModelWithPersistence {
342334 }
343335
344336 public getExperimentParams ( id : string ) {
345- const params = this . getExperiments ( ) . find (
337+ const params = this . getAllExperiments ( ) . find (
346338 experiment => experiment . id === id
347339 ) ?. params
348340
@@ -416,6 +408,16 @@ export class ExperimentsModel extends ModelWithPersistence {
416408 ]
417409 }
418410
411+ public getExperimentsByBranchForTree ( branch : Experiment ) {
412+ return this . getExperimentsByBranch ( branch ) ?. map ( experiment => ( {
413+ ...experiment ,
414+ hasChildren : definedAndNonEmpty ( this . checkpointsByTip . get ( experiment . id ) ) ,
415+ type : experiment . queued
416+ ? ExperimentType . QUEUED
417+ : ExperimentType . EXPERIMENT
418+ } ) )
419+ }
420+
419421 private getSubRows ( experiments : Experiment [ ] , filters = this . getFilters ( ) ) {
420422 return experiments
421423 . map ( experiment => {
@@ -514,6 +516,7 @@ export class ExperimentsModel extends ModelWithPersistence {
514516 const { coloredStatus, availableColors } = collectColoredStatus (
515517 this . getExperiments ( ) ,
516518 this . checkpointsByTip ,
519+ this . experimentsByBranch ,
517520 this . coloredStatus ,
518521 this . availableColors
519522 )
@@ -571,6 +574,7 @@ export class ExperimentsModel extends ModelWithPersistence {
571574 if ( ! hasKey ( this . coloredStatus , id ) ) {
572575 return {
573576 ...experiment ,
577+ selected : false ,
574578 starred
575579 }
576580 }
0 commit comments