def testNoProb(self): err = MultiIssueConfigurationError() self.assertFalse(err.hasProblems()) self.assertEqual(str(err), self.unspecified) probs = err.getProblems() self.assertEqual(len(probs), 0)
def checkConfiguration(self, care=1, issueExc=None): """Runs checks that ensure that the Workflow has been properly set up. Raises ------ MultiIssueConfigurationError if problems are found Parameters ---------- care : `int` the thoroughness of the checks. In general, a higher number will result in more checks. issueExc : `MultiIssueConfigurationError` An instance of MultiIssueConfigurationError to add problems to. If not None, this function will not raise an exception when problems are encountered; they will merely be added to the instance. It is assumed that the caller will raise that exception is necessary. """ log.debug("WorkflowManager:createConfiguration") myProblems = issueExc if myProblems is None: myProblems = MultiIssueConfigurationError("problems encountered while checking configuration") # do the checks # raise exception if problems found if not issueExc and myProblems.hasProblems(): raise myProblems
def checkConfiguration(self, care=1, issueExc=None): """Carry out production-wide configuration checks. Parameters ---------- care : `int` throughness level of the checks issueExc : `MultiIssueConfigurationError` an instance of MultiIssueConfigurationError to add problems to Raises ------ `MultiIssueConfigurationError` If issueExc is None, and a configuration error is detected. Notes ----- If issueExc is not None, this method will not raise an exception when problems are encountered; they will merely be added to the instance. It is assumed that the caller will raise the exception as necessary. """ log.debug("checkConfiguration") myProblems = issueExc if myProblems is None: myProblems = MultiIssueConfigurationError("problems encountered while checking configuration") for dbconfig in self._databaseConfigurators: print("-> dbconfig = ", dbconfig) dbconfig.checkConfiguration(care, issueExc) if not issueExc and myProblems.hasProblems(): raise myProblems
def checkConfiguration(self, care=1, issueExc=None): """Carry out production-wide configuration checks. Parameters ---------- care : `int` throughness level of the checks issueExc : `MultiIssueConfigurationError` an instance of MultiIssueConfigurationError to add problems to Raises ------ `MultiIssueConfigurationError` If issueExc is None, and a configuration error is detected. Notes ----- If issueExc is not None, this method will not raise an exception when problems are encountered; they will merely be added to the instance. It is assumed that the caller will raise the exception as necessary. """ log.debug("checkConfiguration") myProblems = issueExc if myProblems is None: myProblems = MultiIssueConfigurationError( "problems encountered while checking configuration") for dbconfig in self._databaseConfigurators: print("-> dbconfig = ", dbconfig) dbconfig.checkConfiguration(care, issueExc) if not issueExc and myProblems.hasProblems(): raise myProblems
def testOneProb(self): msg = "first problem" err = MultiIssueConfigurationError(problem=msg) self.assertEqual(str(err), msg) probs = err.getProblems() self.assertEqual(len(probs), 1) self.assertEqual(probs[0], msg)
def testTwoProbs(self): msg = "first problem" err = MultiIssueConfigurationError(problem=msg) self.assertEqual(str(err), msg) msg2 = "second problem" err.addProblem(msg2) self.assertEqual(str(err), self.generic) probs = err.getProblems() self.assertEqual(len(probs), 2) self.assertEqual(probs[0], msg) self.assertEqual(probs[1], msg2)
def checkConfiguration(self, care=1, issueExc=None): log.debug("checkConfiguration") myProblems = issueExc if myProblems is None: myProblems = MultiIssueConfigurationError("problems encountered while checking configuration") for dbconfig in self._databaseConfigurators: print "-> dbconfig = ",dbconfig dbconfig.checkConfiguration(care, issueExc) if not issueExc and myProblems.hasProblems(): raise myProblems
def configure(self, workflowVerbosity): """Configure this production run Parameters ---------- workflowVerbosity : `int` verbosity level of the workflows Returns ------- mgrs : [ wfMgr1, wfMgr2 ] list of workflow managers, one per workflow """ log.debug("ProductionRunConfigurator:configure") # TODO - IMPORTANT - NEXT TWO LINES ARE FOR PROVENANCE # -------------- # self._provSetup = ProvenanceSetup() # self._provSetup.addAllProductionConfigFiles(self._prodConfigFile, self.repository) # -------------- # # setup the database for each database listed in production config. # cache the configurators in case we want to check the configuration # later. # databaseConfigs = self.prodConfig.database for databaseName in databaseConfigs: databaseConfig = databaseConfigs[databaseName] cfg = self.createDatabaseConfigurator(databaseConfig) cfg.setup(self._provSetup) self._databaseConfigurators.append(cfg) # # do specialized production level configuration, if it exists # if self.prodConfig.production.configuration.configurationClass is not None: specialConfigurationConfig = self.prodConfig.production.configuration # XXX - specialConfigurationConfig maybe? self.specializedConfigure(specialConfigurationConfig) workflowConfigs = self.prodConfig.workflow workflowManagers = [] for wfName in workflowConfigs: wfConfig = workflowConfigs[wfName] # copy in appropriate production level info into workflow Node -- ? workflowManager = self.createWorkflowManager( self.prodConfig, wfName, wfConfig) workflowLauncher = workflowManager.configure( self._provSetup, workflowVerbosity) if workflowLauncher is None: raise MultiIssueConfigurationError( "error configuring workflowLauncher") workflowManagers.append(workflowManager) return workflowManagers
def testGenericMsg(self): msg = "problems encountered while checking configuration" err = MultiIssueConfigurationError(msg) self.assertEqual(str(err), self.unspecified) msg1 = "first problem" err.addProblem(msg1) self.assertEqual(str(err), msg1) err.addProblem("2nd problem") self.assertEqual(str(err), msg)