//! A top-level function taking in a complete profile and two lists <string>. /*! * \param model_data Object representing the model and all it's possible parameter values. * \param build_input List<string> List of the OME input overrides written in OME format * \param build_output List<string> List of LRP output strings. */ public static void nameCreator(modelProfile model_data, List <string> build_input, List <string> build_output) { //Calculate all combinations, fill in output file names and input string to engine accordingly List <paramLRP> pd = model_data.plist; List <List <string> > all_combos = new List <List <string> >(); List <List <string> > combo_result = new List <List <string> >(); //Create the list consisting of list's of values each paramater can take up //In OME input format. Additionally hashes the corresponding output var name foreach (var entry in pd) { all_combos.Add(entry.enumVals(model_data.name_map)); } //Now develop each combination and add it to the build inputs and outputs. combo_result = AllCombinationsOf(all_combos); //Merge each list of strings into the command for OME Engine //and the output string for the csv files foreach (var string_list in combo_result) { build_input.Add(Concat(string_list, null)); build_output.Add(Concat(string_list, model_data.name_map)); } }
//! A void member taking in path as string //Add the new modelProfile object to the list public void BaseProfileFactory(string directory_path) { string[] file_paths = Directory.GetFiles(directory_path, "profile*"); //We get each file path, need to open it and parse it, filling in all the values in the modelProfile foreach (string each in file_paths) { modelProfile prof = new modelProfile(); prof.fill_profile(each); profile_prints.Add(prof); } }
//! A top level function taking in 5 arguments. /*! * \param args Input parameters for OMEEngine (see OMEEngine.cpp). * \param output_fp File path for output data as a csv. * \param model_base Profile object, used primarily for keeping track of running processes. * \param log_file Log file in case of an error occuring. */ //The engine arguments and each base model along with its parameters are passed in public static void LaunchOMEMultiProc(string result_Path, string eng_args, modelProfile model) { string startTime = DateTime.Now.ToString("h:mm:ss tt"); Console.WriteLine("Time started: {0}\r\n", startTime); Queue model_queue = new Queue(); Console.WriteLine("Amount of Processers: {0}", Environment.ProcessorCount); //First get the amount of combinations to get the file count //List of models to be ran with complete path //Add this list to Queue string exec_path = AppDomain.CurrentDomain.BaseDirectory; string test_path = Path.GetFullPath(Path.Combine(exec_path, @"..\..\OMEMultiProc\items\compiled_tests")); string main_path = Directory.GetFiles(test_path, "*.omec")[0]; List <string> out_fnames = new List <string>(); List <string> input_params = new List <string>(); Logger log_file = new Logger(test_path, model_queue.Count); //Fill all the input/output names. nameCreator(model, input_params, out_fnames); // Merge both lists into a list of tuples and chuck it into a queue IEnumerable <Tuple <string, string> > in_out = input_params.Zip(out_fnames, (a, b) => Tuple.Create(a, b)); foreach (var atuple in in_out) { model_queue.Enqueue(atuple); } Console.WriteLine("Finished processing files, starting the Engines..."); int idx = main_path.LastIndexOf('\\'); while (model_queue.Count > 0) { //Retrieve the next item and build the output string Tuple <string, string> int_out = (Tuple <string, string>)model_queue.Dequeue(); string out_path = paramLRP.outputStr(result_Path + "\\..\\LRP_results\\", model.base_name, int_out.Item2); string in_path = eng_args + "-f\"" + out_path + "\" " + int_out.Item1 + "\"" + main_path + "\""; launchEngines(in_path, out_path, model, log_file); model.IncrementProcCounter(); log_file.printLog(model.ProcCounter, model_queue.Count, model.base_name); } Console.WriteLine("Finished starting last set of processes. Please wait for these to complete, then press any button to exit"); Console.WriteLine("Time started: {0}\r\n", startTime); Console.WriteLine("Time ended: {0}\r\n", DateTime.Now.ToString("h:mm:ss tt")); }
//! A top level function taking in 5 arguments. /*! * \param args Input parameters for OMEEngine (see OMEEngine.cpp). * \param output_fp File path for output data as a csv. * \param model_base Profile object, used primarily for keeping track of running processes. * \param log_file Log file in case of an error occuring. */ public static void launchEngines(string args, string output_fp, modelProfile model_base, Logger log_file) { //Prepare a process to start up OMEengine with the proper filepaths and flags Process proc_engine = new Process(); proc_engine.StartInfo.FileName = "OMEEngine.exe";; proc_engine.StartInfo.Arguments = args; proc_engine.EnableRaisingEvents = true; proc_engine.StartInfo.CreateNoWindow = true; proc_engine.StartInfo.UseShellExecute = false; //proc_engine.StartInfo.RedirectStandardOutput = true; //proc_engine.StartInfo.RedirectStandardError = true; //Manage the amount of processes running at once to maximize performace //Console.Write(process_cntr); while (model_base.ProcCounter > Environment.ProcessorCount) { System.Threading.Thread.Sleep(1000); } //listener for each process, signals when they exit proc_engine.Exited += (sender, EventArgs) => { model_base.DecrementProcCounter(); if (proc_engine.ExitCode != 0) { Console.WriteLine("Error occured, check log for details."); //log_file.appendLog(proc_engine.StandardError.ReadToEnd()); //log_file.appendLog(proc_engine.StandardOutput.ReadToEnd()); log_file.appendLog(Environment.NewLine + "Error occured with the following input: \n\n " + proc_engine.StartInfo.Arguments + Environment.NewLine + Environment.NewLine + "The file in question is: " + output_fp.Split('\\').Last()); } //Source: //https://msdn.microsoft.com/en-us/library/system.diagnostics.process.enableraisingevents(v=vs.110).aspx }; //Start up the given subprocess consisting of a call to OMEENGINE proc_engine.Start(); //Console.ReadLine(); }