1- import { ExpShowOutput } from '../../cli/dvc/contract'
2- import { uniqueValues } from '../../util/array'
1+ import { ExpData , ExpShowOutput , MetricsOrParams } from '../../cli/dvc/contract'
32import { getExpData } from '../columns/collect'
43
4+ const collectFilesFromKeys = (
5+ acc : Set < string > ,
6+ metricsOrParams : MetricsOrParams | null | undefined
7+ ) : void => {
8+ for ( const file of Object . keys ( metricsOrParams || { } ) ) {
9+ if ( ! file ) {
10+ continue
11+ }
12+ acc . add ( file )
13+ }
14+ }
15+
16+ const collectFilesFromExperiment = (
17+ acc : Set < string > ,
18+ data : ExpData | undefined
19+ ) => {
20+ if ( ! data ) {
21+ return
22+ }
23+ collectFilesFromKeys ( acc , data . params )
24+ collectFilesFromKeys ( acc , data . metrics )
25+ }
26+
527export const collectFiles = (
628 output : ExpShowOutput ,
729 existingFiles : string [ ]
@@ -10,17 +32,25 @@ export const collectFiles = (
1032 return existingFiles
1133 }
1234
13- const [ workspace ] = output
35+ const acc = new Set ( existingFiles )
1436
15- const data = getExpData ( workspace )
37+ for ( const commit of output ) {
38+ const data = getExpData ( commit )
39+ collectFilesFromExperiment ( acc , data )
40+
41+ const { experiments } = commit
42+
43+ if ( ! experiments ?. length ) {
44+ continue
45+ }
46+
47+ for ( const { revs } of experiments ) {
48+ const [ experiment ] = revs
49+ collectFilesFromExperiment ( acc , getExpData ( experiment ) )
50+ }
51+ }
1652
17- return uniqueValues ( [
18- ...Object . keys ( {
19- ...data ?. params ,
20- ...data ?. metrics
21- } ) . filter ( Boolean ) ,
22- ...existingFiles
23- ] )
53+ return [ ...acc ]
2454}
2555
2656const isCurrentBranch = ( branch : string ) => branch . indexOf ( '*' ) === 0
0 commit comments