def generateLoaderWithFailure2(outputDir): definitionsToLoad = [] defToLoadDef = generateBootstrapper() ContextModule.pickleDefinition( os.path.join(outputDir, 'loadLibraryDefinition.pomset'), defToLoadDef) context = ContextModule.wrapPomsetInContext(defToLoadDef) definitionsToLoad.append(context) wcDefinition = DefinitionTestModule.createWordCountDefinition() wcDefinitionPath = wcDefinition.id() + '.pomset' wcDefinition.url(wcDefinitionPath) # we purposely do not pickle it # to ensure that the loading fails context = ContextModule.wrapPomsetInContext(wcDefinition) definitionsToLoad.append(context) wcrDefinition = DefinitionTestModule.createWordCountReduceDefinition() wcrDefinitionPath = wcrDefinition.id() + '.pomset' wcrDefinition.url(wcrDefinitionPath) ContextModule.pickleDefinition( os.path.join(outputDir, wcrDefinitionPath), wcrDefinition) context = ContextModule.wrapPomsetInContext(wcrDefinition) definitionsToLoad.append(context) library = LibraryModule.Library() map(library.addPomsetContext, definitionsToLoad) defToLoadDefs = library.generateBootstrapLoaderPomset() ContextModule.pickleDefinition( os.path.join(outputDir, 'loadLibraryDefinitions.pomset'), defToLoadDefs) return
def createNewAtomicPomset(self, name=None, executableObject=None, commandBuilderType=None, executeEnvironmentType=None, *args, **kwds): newAtomicPomset = DefinitionModule.AtomicDefinition(*args, **kwds) if name is None: name = 'pomset %s' % uuid.uuid4().hex[:3] newAtomicPomset.name(name) newAtomicPomset.functionToExecute( DefinitionModule.executeTaskInEnvironment) newAtomicPomset.executable(executableObject) # create the parameter orderings parameterOrderings = DefinitionModule.createParameterOrderingTable() newAtomicPomset.parameterOrderingTable(parameterOrderings) if commandBuilderType is None: commandBuilderType = 'shell process' newAtomicPomset.commandBuilderType(commandBuilderType) if executeEnvironmentType is None: executeEnvironmentType = 'shell process' newAtomicPomset.executeEnvironmentType(executeEnvironmentType) newPomsetContext = ContextModule.wrapPomsetInContext(newAtomicPomset) return newPomsetContext
def generateDefaultLoader(outputDir): definitionsToLoad = [] defToLoadDef = generateBootstrapper() ContextModule.pickleDefinition( os.path.join(outputDir, 'loadLibraryDefinition.pomset'), defToLoadDef) context = ContextModule.wrapPomsetInContext(defToLoadDef) definitionsToLoad.append(context) wcDefinition = DefinitionTestModule.createWordCountDefinition() wcDefinitionPath = wcDefinition.id() + '.pomset' wcDefinition.url(wcDefinitionPath) ContextModule.pickleDefinition( os.path.join(outputDir, wcDefinitionPath), wcDefinition) context = ContextModule.wrapPomsetInContext(wcDefinition) definitionsToLoad.append(context) wcrDefinition = DefinitionTestModule.createWordCountReduceDefinition() wcrDefinitionPath = wcrDefinition.id() + '.pomset' wcrDefinition.url(wcrDefinitionPath) ContextModule.pickleDefinition( os.path.join(outputDir, wcrDefinitionPath), wcrDefinition) context = ContextModule.wrapPomsetInContext(wcrDefinition) definitionsToLoad.append(context) loadValuesDefinition = \ DefinitionTestModule.createLoadListValuesFromFilesDefinition() loadValuesDefinitionPath = loadValuesDefinition.id() + '.pomset' loadValuesDefinition.url(loadValuesDefinitionPath) ContextModule.pickleDefinition( os.path.join(outputDir, loadValuesDefinitionPath), loadValuesDefinition) context = ContextModule.wrapPomsetInContext(loadValuesDefinition) definitionsToLoad.append(context) library = LibraryModule.Library() map(library.addPomsetContext, definitionsToLoad) defToLoadDefs = library.generateBootstrapLoaderPomset() ContextModule.pickleDefinition( os.path.join(outputDir, 'loadLibraryDefinitions.pomset'), defToLoadDefs) return
def saveBootstrapLoaderPomset(self, outputPath=None): # default to the library's specified dir if outputPath is None: outputPath = os.path.join( self.bootstrapLoaderDefinitionsDir(), 'loadLibraryDefinitions.pomset') pomset = self.generateBootstrapLoaderPomset() pomsetContext = ContextModule.wrapPomsetInContext(pomset) ContextModule.savePomsetAs(pomsetContext, outputPath) return
def createNewNestPomset(self, name=None): """ """ #TODO: this should construct a command to create the new pomset # and execute the command (or send an event to execute the command) # within the command framework, the command should also # create an event to update the GUI newPomset = DefinitionModule.getNewNestDefinition() if name is None: name = 'pomset %s' % uuid.uuid4().hex[:3] newPomset.name(name) newPomsetContext = ContextModule.wrapPomsetInContext(newPomset) return newPomsetContext
def pickleAndReloadDefinition(path, definition): # try pickling the definition # and the reloading it filesToDelete = [] try: pomsetContext = ContextModule.wrapPomsetInContext(definition) ContextModule.savePomsetAs(pomsetContext, path) filesToDelete.append(path) pomsetContext = ContextModule.loadPomset(path) definition = pomsetContext.reference() except Exception, e: logging.error("errored with msg >> %s" % e) raise
def test1(self): pomset = createTestPomset1(self.builder) context = ContextModule.wrapPomsetInContext(pomset) errors = [x for x in context.reference().parameterBindingErrors()] self.assertEquals(len(errors), 2) for expectedInfo, actualInfo in zip([ ('input file', KeyError), ('output file', KeyError)], errors): expectedParameterName, expectedErrorClass = expectedInfo actualParameter, actualError = actualInfo self.assertEquals(expectedParameterName, actualParameter.id()) self.assertEquals(expectedErrorClass, actualError.__class__) pass self.assertRaises(ErrorModule.ValidationError, context.reference().validateParameterBindings) return