@@ -18,7 +18,7 @@ public class RunInfo
1818 public string RunID => this . Run . Id ;
1919 public Run Run { get ; private set ; }
2020 //public Project Project { get; private set; }
21- public UserPermission ProjectCloudPermission { get ; private set ; }
21+ public UserPermission ProjectCloudPermission { get ; private set ; }
2222 public string ProjectOwner { get ; private set ; }
2323 public string ProjectName { get ; private set ; }
2424 public string ProjectSlug => $ "{ ProjectOwner } /{ ProjectName } ";
@@ -28,7 +28,7 @@ public class RunInfo
2828
2929 //[IgnoreDataMember]
3030 //public string Logs { get; set; }
31- public RunInfo ( Project proj , string runID ) : this ( proj , GetRun ( proj , runID ) )
31+ public RunInfo ( Project proj , string runID ) : this ( proj , GetRun ( proj , runID ) )
3232 {
3333 }
3434
@@ -63,6 +63,7 @@ public RunInfo(ScheduledJobInfo localJob)
6363 this . ProjectOwner = proj [ 0 ] ;
6464 this . ProjectName = proj [ 1 ] ;
6565 this . Recipe = localJob . Recipe ;
66+
6667 }
6768
6869 public RunInfo ( string localRunFolder )
@@ -286,28 +287,43 @@ private static RecipeInterface GetRecipe(string owner, string name, string tag =
286287 var json = File . ReadAllText ( file ) ;
287288 var args = LBTNewtonsoft . Newtonsoft . Json . JsonConvert . DeserializeObject < Dictionary < string , object > > ( json ) ;
288289
289- var recipeInputs = this . Recipe . InputList ;
290- var stepInputs = new List < Interface . Io . Inputs . IStep > ( ) ;
291- foreach ( var input in recipeInputs )
290+ var recipeInputs = this . Recipe . InputList . ToList ( ) ;
291+ var stepInputs = new Interface . Io . Inputs . IStep [ recipeInputs . Count ] ;
292+ var userInputs = new List < Interface . Io . Inputs . IStep > ( ) ;
293+ foreach ( var arg in args )
292294 {
293- if ( ! args . TryGetValue ( input . Name , out var value ) )
294- value = input . GetDefaultValue ( ) ;
295+ var argName = arg . Key ;
296+ var reciptInputIndex = recipeInputs . FindIndex ( _ => _ . Name == argName ) ;
297+ if ( reciptInputIndex >= 0 )
298+ {
299+ var reciptInput = recipeInputs [ reciptInputIndex ] ;
300+ var value = arg . Value ;
301+ if ( value == null )
302+ value = reciptInput . GetDefaultValue ( ) ;
303+ if ( reciptInput . Required == false && value == null )
304+ continue ;
305+ var sinput = reciptInput . ToStepInput ( value ) ;
306+ stepInputs [ reciptInputIndex ] = sinput ;
307+ }
308+ else
309+ {
310+ // users string input
311+ var value = arg . Value ;
312+ var sinput = new StepStringInput ( argName , value ? . ToString ( ) ) ;
313+ userInputs . Add ( sinput ) ;
295314
296- if ( input . Required == false && value == null )
297- continue ;
315+ }
298316
299- var sinput = input . ToStepInput ( value ) ;
300- stepInputs . Add ( sinput ) ;
301317 }
302-
303- return stepInputs ;
318+ var allInputs = stepInputs . Concat ( userInputs ) . Where ( _ => _ != null ) . ToList ( ) ;
319+ return allInputs ;
304320 }
305321
306322 public List < Interface . Io . Inputs . IStep > GetInputs ( )
307323 {
308- var inputs =
309- this . IsLocalRun ?
310- GetLocalInputs ( ) :
324+ var inputs =
325+ this . IsLocalRun ?
326+ GetLocalInputs ( ) :
311327 this . Run . Status . Inputs
312328 . OfType < Interface . Io . Inputs . IStep > ( ) . ToList ( ) ;
313329
@@ -355,7 +371,7 @@ public List<RunAssetBase> LoadLocalRunAssets(List<RunAssetBase> runAssets, strin
355371 updatedAssets . Add ( dup ) ;
356372 continue ;
357373 }
358-
374+
359375 var relativePath = dup . RelativePath ;
360376 if ( dup is RunInputAsset input )
361377 {
@@ -376,20 +392,20 @@ public List<RunAssetBase> LoadLocalRunAssets(List<RunAssetBase> runAssets, strin
376392 var dir = Directory . GetDirectories ( root , "*" , SearchOption . AllDirectories ) . OrderBy ( _ => _ . Length ) . FirstOrDefault ( _ => _ . EndsWith ( relativeOutPath ) ) ;
377393 dup . LocalPath = dir ;
378394 }
379-
395+
380396 }
381397
382398
383399 if ( ! dup . IsSaved ( ) )
384400 throw new ArgumentException ( $ "Failed to find asset: { relativePath } in { root } ") ;
385-
401+
386402
387403 dup . LocalPath = Path . GetFullPath ( dup . LocalPath ) ;
388404 // copy to saveAsDir
389405 if ( ! string . IsNullOrEmpty ( saveAsDir ) )
390406 {
391407 var jobName = Path . GetFileName ( root ) ;
392- var newPath = Path . Combine ( saveAsDir , jobName , relativePath ) ;
408+ var newPath = Path . Combine ( saveAsDir , jobName , relativePath ) ;
393409 newPath = Path . GetFullPath ( newPath ) ;
394410 var newRoot = Path . GetDirectoryName ( newPath ) ;
395411 Directory . CreateDirectory ( newRoot ) ;
@@ -423,7 +439,7 @@ public async Task<List<RunAssetBase>> DownloadRunAssetsAsync(List<RunAssetBase>
423439 var dir = string . IsNullOrEmpty ( saveAsDir ) ? Helper . GenTempFolder ( ) : saveAsDir ;
424440 var simuID = this . RunID . Substring ( 0 , 8 ) ;
425441 dir = Path . Combine ( dir , simuID ) ;
426-
442+
427443 var allAssets = runAssets ;
428444
429445 // check if cached
@@ -462,7 +478,7 @@ public override string ToString()
462478 public bool IsValid => Total > 0 ;
463479 }
464480
465-
481+
466482
467483
468484 /// <summary>
@@ -492,15 +508,18 @@ private static List<Task<RunAssetBase>> DownloadAssets(RunInfo runInfo, IEnumera
492508 var dir = isInputAsset ? inputDir : outputDir ;
493509 dir = Path . Combine ( dir , assetName ) ;
494510
495- Action < int > individualProgress = ( percent ) => {
511+ Action < int > individualProgress = ( percent ) =>
512+ {
496513 reportProgressAction ? . Invoke ( $ "{ assetName } : { percent } %") ;
497514 } ;
498- Action overAllProgress = ( ) => {
515+ Action overAllProgress = ( ) =>
516+ {
499517 completed ++ ;
500518 reportProgressAction ? . Invoke ( $ "OVERALL: { completed } /{ total } ") ;
501519 } ;
502520
503- var task = Task . Run ( async ( ) => {
521+ var task = Task . Run ( async ( ) =>
522+ {
504523 var url = string . Empty ;
505524
506525 if ( isInputAsset )
@@ -543,6 +562,6 @@ private static List<Task<RunAssetBase>> DownloadAssets(RunInfo runInfo, IEnumera
543562 return tasks ;
544563
545564 }
546-
565+
547566 }
548567}
0 commit comments