/// <summary> /// Compute derived results for each session in the dataset. /// </summary> /// <typeparam name="TResult">The type of data of the derived result.</typeparam> /// <param name="computeDerived">The action to be invoked to derive results.</param> /// <returns>List of results.</returns> public IReadOnlyList <TResult> ComputeDerived <TResult>( Action <Pipeline, SessionImporter, TResult> computeDerived) where TResult : class, new() { var results = new List <TResult>(); foreach (var session in this.Sessions) { // the first partition is where we put the data if output is not specified var inputPartition = session.Partitions.FirstOrDefault(); // create and run the pipeline using (var pipeline = Pipeline.Create()) { var importer = SessionImporter.Open(pipeline, session); var result = new TResult(); computeDerived(pipeline, importer, result); var startTime = DateTime.Now; Console.WriteLine($"Computing derived features on {inputPartition.StorePath} ..."); pipeline.Run(ReplayDescriptor.ReplayAll); var finishTime = DateTime.Now; Console.WriteLine($" - Time elapsed: {(finishTime - startTime).TotalMinutes:0.00} min."); results.Add(result); } } return(results); }
/// <summary> /// Runs the batch processing task. /// </summary> /// <param name="pipeline">The pipeline to run the task on.</param> /// <param name="sessionImporter">The session importer.</param> /// <param name="exporter">The exporter.</param> /// <param name="configuration">The task configuration.</param> public void Run(Pipeline pipeline, SessionImporter sessionImporter, Exporter exporter, BatchProcessingTaskConfiguration configuration) { if (this.IsMethodBased) { this.batchProcessingTaskMethodInfo.Invoke(null, new object[] { pipeline, sessionImporter, exporter }); } else { var batchProcessingTask = Activator.CreateInstance(this.batchProcessingTaskType) as IBatchProcessingTask; batchProcessingTask.Run(pipeline, sessionImporter, exporter, configuration); } }