Exemple #1
0
        public static void Main(string[] args)
        {
            try
            {
                // parse command line arguments
                string projectConnStr = args[0];
                string originalSubjectID = args[1];
                string[] configIDs = args.Skip(2).ToArray();

                if (projectConnStr.StartsWith("MGA=") == false)
                {
                    // use the full absolute path
                    projectConnStr = "MGA=" + Path.GetFullPath(projectConnStr);
                }
                
                MgaProject project = new MgaProject();
                bool ro_mode;
                project.Open(projectConnStr, out ro_mode);

                try
                {
                    // get an instance of the master interpreter
                    using (var master = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI(project))
                    {
                        // create a configuration for the run
                        var configLight = new CyPhyMasterInterpreter.ConfigurationSelectionLight();
                        configLight.ContextId = originalSubjectID;
                        configLight.SelectedConfigurationIds = configIDs;
                        configLight.KeepTemporaryModels = false;
                        configLight.PostToJobManager = true;

                        // run master interpreter on configuration
                        var results = master.RunInTransactionWithConfigLight(configLight);

                        // summarize results
                        master.WriteSummary(results);
                    }
                }
                finally
                {
                    project.Close(true);
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.ToString());
                System.Environment.Exit(5);
            }
        }
Exemple #2
0
        public CyPhyMasterInterpreter.MasterInterpreterResult Test(string tbpath, string configPath, int jobRunTimeout)
        {
            string tbId;
            string configId;

            project.BeginTransactionInNewTerr();
            try
            {
                var tb = project.RootFolder.ObjectByPath[tbpath];
                if (tb == null)
                {
                    throw new ApplicationException("Could not find " + tbpath);
                }
                tbId = tb.ID;
                var config = project.RootFolder.ObjectByPath[configPath];
                if (config == null)
                {
                    throw new ApplicationException("Could not find " + configPath);
                }
                configId = config.ID;
            }
            finally
            {
                project.AbortTransaction();
            }


            var configurationSelection = new CyPhyMasterInterpreter.ConfigurationSelectionLight()
            {
                PostToJobManager         = true,
                ContextId                = tbId,
                SelectedConfigurationIds = new string[] { configId }
            };

            if (masterApi != null)
            {
                masterApi.Dispose();
            }
            masterApi = new CyPhyMasterInterpreter.CyPhyMasterInterpreterAPI();
            masterApi.Initialize(project);
            var results = masterApi.RunInTransactionWithConfigLight(configurationSelection);

            if (results.First().Success == false)
            {
                throw new ApplicationException("MasterInterpreter run failed");
            }

            while (true)
            {
                Job job;
                if (jobUpdates.TryTake(out job, jobRunTimeout))
                {
                    if (Job.IsFailedStatus(job.Status))
                    {
                        // TODO dump logs, stdout.txt, stderr.txt
                        throw new ApplicationException("Remote run failed: " + job.Status);
                    }
                    else if (job.Status == Job.StatusEnum.Succeeded)
                    {
                        break;
                    }
                }
                else
                {
                    throw new TimeoutException();
                }
            }
            return(results[0]);
        }