@@ -9,6 +9,7 @@ import { extractColumns } from '../columns/extract'
99import {
1010 CommitData ,
1111 Experiment ,
12+ GitRemoteStatus ,
1213 RunningExperiment ,
1314 isQueued ,
1415 isRunning
@@ -29,6 +30,7 @@ import { RegisteredCommands } from '../../commands/external'
2930import { Resource } from '../../resourceLocator'
3031import { shortenForLabel } from '../../util/string'
3132import { COMMITS_SEPARATOR } from '../../cli/git/constants'
33+ import { trimAndSplit } from '../../util/stdout'
3234
3335export type ExperimentItem = {
3436 command ?: {
@@ -233,6 +235,21 @@ const collectExecutorInfo = (
233235 }
234236}
235237
238+ const collectRemoteStatus = (
239+ experiment : Experiment ,
240+ remoteExpShas : Set < string >
241+ ) : void => {
242+ if (
243+ ! experiment . sha ||
244+ ! [ undefined , ExperimentStatus . SUCCESS ] . includes ( experiment . status )
245+ ) {
246+ return
247+ }
248+ experiment . gitRemoteStatus = remoteExpShas . has ( experiment . sha )
249+ ? GitRemoteStatus . ON_REMOTE
250+ : GitRemoteStatus . NOT_ON_REMOTE
251+ }
252+
236253const collectRunningExperiment = (
237254 acc : ExperimentsAccumulator ,
238255 experiment : Experiment
@@ -249,7 +266,8 @@ const collectRunningExperiment = (
249266const collectExpRange = (
250267 acc : ExperimentsAccumulator ,
251268 baseline : Experiment ,
252- expRange : ExpRange
269+ expRange : ExpRange ,
270+ remoteExpShas : Set < string >
253271) : void => {
254272 const { revs, executor } = expRange
255273 if ( ! revs ?. length ) {
@@ -289,6 +307,7 @@ const collectExpRange = (
289307 }
290308
291309 collectExecutorInfo ( experiment , executor )
310+ collectRemoteStatus ( experiment , remoteExpShas )
292311 collectRunningExperiment ( acc , experiment )
293312
294313 addToMapArray ( acc . experimentsByCommit , baselineId , experiment )
@@ -340,10 +359,20 @@ const collectCliError = (
340359 }
341360}
342361
362+ const collectRemoteExpShas = ( remoteExpRefs : string ) : Set < string > => {
363+ const remoteExpShas = new Set < string > ( )
364+ for ( const ref of trimAndSplit ( remoteExpRefs ) ) {
365+ const [ sha ] = ref . split ( / \s / )
366+ remoteExpShas . add ( sha )
367+ }
368+ return remoteExpShas
369+ }
370+
343371export const collectExperiments = (
344372 expShow : ExpShowOutput ,
345373 gitLog : string ,
346- dvcLiveOnly : boolean
374+ dvcLiveOnly : boolean ,
375+ remoteExpRefs : string
347376) : ExperimentsAccumulator => {
348377 const acc : ExperimentsAccumulator = {
349378 cliError : undefined ,
@@ -358,6 +387,7 @@ export const collectExperiments = (
358387 }
359388
360389 const commitData = collectCommitsData ( gitLog )
390+ const remoteExpShas = collectRemoteExpShas ( remoteExpRefs )
361391
362392 for ( const expState of expShow ) {
363393 const baseline = collectExpState ( acc , expState , commitData )
@@ -368,7 +398,7 @@ export const collectExperiments = (
368398 }
369399
370400 for ( const expRange of experiments ) {
371- collectExpRange ( acc , baseline , expRange )
401+ collectExpRange ( acc , baseline , expRange , remoteExpShas )
372402 }
373403 }
374404
0 commit comments