Ejemplo n.º 1
0
    def setUp(self):

        # load pomset from path
        pomsetContext = ContextModule.loadPomset(
            path=TestParameterToEdit1.TEST_DATA_PATH)

        self.pomset = pomsetContext.pomset()
        return
Ejemplo n.º 2
0
    def setUp(self):

        # load pomset from path
        pomsetContext = ContextModule.loadPomset(
            path=TestDefinition2.TEST_DATA_PATH)

        self.pomset = pomsetContext.pomset()
        return
Ejemplo n.º 3
0
def main(args):

    # TODO:
    # integrate opts parsing

    if len(args) < 2:
        raise NotImplementedError('need to specify pomset to execute')

    # TODO:
    # opts needed:
    # config file: static configuration of listed args below
    # threadpool: local, remote, cloud
    # number of threads: easy for local/remote.  how about cloud?

    pomsetPath = args[1]
    pomsetContext = ContextModule.loadPomset(pomsetPath)
    pomset = pomsetContext.reference()

    automaton = AutomatonModule.Automaton()
    automaton.setThreadPool(None, CloudModule.Pool(1))
    automaton.commandManager(CommandPatternModule.CommandManager())
    
    requestKwds = generateRequestKwds()

    compositeTask = TaskModule.CompositeTask()

    try:
        compositeTask = automaton.executePomset(
            task = compositeTask,
            pomset=pomset, requestKwds=requestKwds,
            shouldWait=True)

        request = compositeTask.workRequest()
        if request.exception:
            raise ErrorModule.ExecutionError('erroed on execution')

    except ErrorModule.ExecutionError, e:

        # here we can output various info
        # including execution errors
        workRequest = compositeTask.workRequest()
            
        erroredTasks = [x for x in compositeTask.getErroredChildTasks()]

        print "%s errored tasks" % len(erroredTasks)
        for erroredTask in erroredTasks:
            taskInfo = erroredTask.workRequest().kwds
            print "task: %s" % erroredTask.definition().name()
            if taskInfo.get('executed command', None):
                # this is only available only if the command was actually executed
                print "\tcommand: %s" % taskInfo.get('executed command')
            if taskInfo.get('exception type', None):
                # this should always be available
                print '\t' + ' '.join([taskInfo.get('exception type', None),
                                       taskInfo.get('exception value', None)])

            pass
        pass
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
    def testLoad1(self):
        """
        This verifies that a pomset saved out still references
        the same library definition, even across sessions
        when the library definitions have been reloaded as well
        
        - create a pomset that references the two library definitions
        - save out the pomset
        - reset the location of the library, to an empty directory
        - load the pomset again
        - assert the references are identical, using Python's "is"        
        """
    
        library = self.initializeLibrary()
        
        request = self.automaton.runBootstrapLoader(library)
        assert not request.exception
            
        # TODO:
        # implement something that will re-generate
        # the pomset for the test
        pomsetContext = ContextModule.loadPomset(
            path=os.path.join(os.getcwd(), 'resources', 'testdata', 'TestLibrary', 'foo.pomset'))
        definition = pomsetContext.pomset()

        
        # at this point, the definitions are different
        filter = RelationalModule.ColumnValueFilter(
            'definition',
            FilterModule.IdFilter(TestDefinitionModule.ID_WORDCOUNT))
        libraryDefinition = library.getDefinition(filter)

        assert definition.nodes()[0].definitionToReference() is not libraryDefinition
        
        # update the references
        library.updateWithLibraryDefinitions(definition)
        
        # now, the definitions should be the same
        assert definition.nodes()[0].definitionToReference() is libraryDefinition
        
        return
Ejemplo n.º 6
0
    def loadFromFullFilePath(self, fullPath):
        context = ContextModule.loadPomset(path=fullPath)

        self.addPomsetContext(context)

        return context