public virtual void Finish() { if (Exe == null || Exe.EndsWith("maml", StringComparison.OrdinalIgnoreCase) || Exe.EndsWith("maml.exe", StringComparison.OrdinalIgnoreCase)) { string currentDirectory = Path.GetDirectoryName(typeof(ExeConfigRunnerBase).Module.FullyQualifiedName); using (var ch = Host.Start("Finish")) using (AssemblyLoadingUtils.CreateAssemblyRegistrar(Host, currentDirectory)) { var runs = RunNums.ToArray(); var args = Utils.BuildArray(RunNums.Count + 2, i => { if (i == RunNums.Count) { return(string.Format(@"o={{{0}\{1}.summary.txt}}", OutputFolder, Prefix)); } if (i == RunNums.Count + 1) { return(string.Format("calledFromUnitTestSuite{0}", _calledFromUnitTestSuite ? "+" : "-")); } return(string.Format("{{{0}}}", GetFilePath(runs[i], "out"))); }); ResultProcessorInternal.ResultProcessor.Main(args); ch.Info(@"The summary of the run results has been saved to the file {0}\{1}.summary.txt", OutputFolder, Prefix); } } }
private static int MainWithProgress(string args) { string currentDirectory = Path.GetDirectoryName(typeof(Maml).Module.FullyQualifiedName); ConsoleEnvironment env = CreateEnvironment(); #pragma warning disable CS0618 // This is the command line project, so the usage here is OK. using (AssemblyLoadingUtils.CreateAssemblyRegistrar(env, currentDirectory)) #pragma warning restore CS0618 using (var progressCancel = new CancellationTokenSource()) { var progressTrackerTask = Task.Run(() => TrackProgress(env, progressCancel.Token)); try { return(MainCore(env, args, ShouldAlwaysPrintStacktrace())); } finally { progressCancel.Cancel(); progressTrackerTask.Wait(); // If the run completed so quickly that the progress task was cancelled before it even got a chance to start, // we need to gather the checkpoints. env.PrintProgress(); } } }
/// <summary> /// Read generic model from file. /// </summary> /// <typeparam name="TInput">Type for incoming data</typeparam> /// <typeparam name="TOutput">Type for output data</typeparam> /// <param name="stream">Stream with model</param> /// <returns>Model</returns> public static Task <PredictionModel <TInput, TOutput> > ReadAsync <TInput, TOutput>(Stream stream) where TInput : class where TOutput : class, new() { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using (var environment = new ConsoleEnvironment()) { AssemblyLoadingUtils.RegisterCurrentLoadedAssemblies(environment); BatchPredictionEngine <TInput, TOutput> predictor = environment.CreateBatchPredictionEngine <TInput, TOutput>(stream); return(Task.FromResult(new PredictionModel <TInput, TOutput>(predictor, stream))); } }
public void Run(int?columns) { #pragma warning disable CS0618 // The help command should be entirely within the command line anyway. AssemblyLoadingUtils.LoadAndRegister(_env, _extraAssemblies); #pragma warning restore CCS0618 using (var ch = _env.Start("Help")) using (var sw = new StringWriter(CultureInfo.InvariantCulture)) using (var writer = new IndentedTextWriter(sw, " ")) { if (_listKinds) { if (_component != null) { writer.WriteLine("Listing component kinds so ignoring specified component"); } else if (_kind != null) { writer.WriteLine("Listing component kinds so ignoring specified kind"); } ListKinds(writer); } else if (_component != null) { ShowHelp(writer, columns); } else if (_allComponents) { ShowAllHelp(writer, columns); } else { ShowComponents(writer); } ch.Info(sw.ToString()); } }
public void Run(int?columns) { AssemblyLoadingUtils.LoadAndRegister(_env, _extraAssemblies); using (var ch = _env.Start("Help")) using (var sw = new StringWriter(CultureInfo.InvariantCulture)) using (var writer = IndentingTextWriter.Wrap(sw)) { if (_listKinds) { if (_component != null) { writer.WriteLine("Listing component kinds so ignoring specified component"); } else if (_kind != null) { writer.WriteLine("Listing component kinds so ignoring specified kind"); } ListKinds(writer); } else if (_component != null) { ShowHelp(writer, columns); } else if (_allComponents) { ShowAllHelp(writer, columns); } else { ShowComponents(writer); } ch.Info(sw.ToString()); ch.Done(); } }