def main(argv=None):

    if argv is None:
        argv = []
        
    if len(argv) < 2:
        raise ValueError('need to specify directory to output the definitions')
    outputDir = argv[1]
    
    baseDefinition = DefinitionModule.createPomsetContainingParameterSweep()
    ContextModule.pickleDefinition(
        os.path.join(outputDir, 'mr_wordcount.pomset'), baseDefinition)
    DefinitionModule.bindParameterSweepDefinitionParameters(baseDefinition)
    ContextModule.pickleDefinition(
        os.path.join(outputDir, 'mr_wordcount_staging.pomset'), baseDefinition)

    
    baseDefinition = DefinitionModule.createPomsetContainingLoopDefinition()
    ContextModule.pickleDefinition(
        os.path.join(outputDir, 'loop_wordcount.pomset'), baseDefinition)
    DefinitionModule.bindLoopDefinitionParameters(baseDefinition)
    ContextModule.pickleDefinition(
        os.path.join(outputDir, 'loop_wordcount_staging.pomset'), baseDefinition)

    
    return
Exemple #2
0
 def createDefinition(self):
     definition = GeneratePomsetsModule.createPomsetContainingLoopDefinition()
     
     # GeneratePomsetsModule.bindLoopDefinitionParameters(definition)
     nodes = [x for x in definition.nodes() if x.id() == 'loop']
     loopNode = nodes[0]
 
     # set the parameter bindings on loopNode
     loopNode.setParameterBinding(
         DefinitionModule.LoopDefinition.PARAMETER_INITIAL_STATE, 
         TestLoop1.INDEX_INITIAL)
     loopNode.setParameterBinding(
         DefinitionModule.LoopDefinition.PARAMETER_CONTINUE_CONDITION,
         "lambda x: x<%s" % TestLoop1.INDEX_FINAL)
     loopNode.setParameterBinding(
         DefinitionModule.LoopDefinition.PARAMETER_STATE_TRANSITION,
         "lambda x: x+1")
     loopNode.setParameterBinding(
         DefinitionModule.LoopDefinition.PARAMETER_STATE_CONFIGURATION,
         # set the value of input file
         # set the value of output file
         [
             # for some reason
             # exec is missing
             # we we need to do this using multiple strings
             "childTask.setParameterBinding('input file', ['/tmp/loop' + str(parentTask.getParameterBinding(DefinitionModule.LoopDefinition.PARAMETER_STATE))])",
             "childTask.setParameterBinding('output file', ['/tmp/loop' + str(parentTask.getParameterBinding(DefinitionModule.LoopDefinition.PARAMETER_STATE)+1)])"
         ]
     )
     
     return definition