예제 #1
0
 def test_iteration(self):
     study_config = self.study_config
     pipeline = Pipeline()
     pipeline.set_study_config(study_config)
     pipeline.add_iterative_process(
         'dummy',
         'capsul.attributes.test.test_attributed_process.DummyProcess',
         ['truc', 'bidule'])
     pipeline.autoexport_nodes_parameters()
     cm = ProcessCompletionEngine.get_completion_engine(pipeline)
     atts = cm.get_attribute_values()
     atts.center = ['muppets']
     atts.subject = ['kermit', 'piggy', 'stalter', 'waldorf']
     cm.complete_parameters()
     self.assertEqual([os.path.normpath(p) for p in pipeline.truc], [
         os.path.normpath(p) for p in [
             '/tmp/in/DummyProcess_truc_muppets_kermit',
             '/tmp/in/DummyProcess_truc_muppets_piggy',
             '/tmp/in/DummyProcess_truc_muppets_stalter',
             '/tmp/in/DummyProcess_truc_muppets_waldorf'
         ]
     ])
     self.assertEqual([os.path.normpath(p) for p in pipeline.bidule], [
         os.path.normpath(p) for p in [
             '/tmp/out/DummyProcess_bidule_muppets_kermit',
             '/tmp/out/DummyProcess_bidule_muppets_piggy',
             '/tmp/out/DummyProcess_bidule_muppets_stalter',
             '/tmp/out/DummyProcess_bidule_muppets_waldorf'
         ]
     ])
예제 #2
0
    def test_run_iteraton_swf(self):
        study_config = self.study_config
        tmp_dir = tempfile.mkdtemp(prefix='capsul_')
        self.temps.append(tmp_dir)

        study_config.input_directory = os.path.join(tmp_dir, 'in')
        study_config.output_directory = os.path.join(tmp_dir, 'out')
        os.mkdir(study_config.input_directory)
        os.mkdir(study_config.output_directory)

        pipeline = Pipeline()
        pipeline.set_study_config(study_config)
        pipeline.add_iterative_process(
            'dummy',
            'capsul.attributes.test.test_attributed_process.DummyProcess',
            ['truc', 'bidule'])
        pipeline.autoexport_nodes_parameters()
        cm = ProcessCompletionEngine.get_completion_engine(pipeline)
        atts = cm.get_attribute_values()
        atts.center = ['muppets']
        atts.subject = ['kermit', 'piggy', 'stalter', 'waldorf']
        cm.complete_parameters()

        # create input files
        for s in atts.subject:
            open(
                os.path.join(study_config.input_directory,
                             'DummyProcess_truc_muppets_%s' % s),
                'w').write('%s\n' % s)

        # run
        study_config.use_soma_workflow = True
        study_config.run(pipeline)

        # check outputs
        out_files = [
            os.path.join(study_config.output_directory,
                         'DummyProcess_bidule_muppets_%s' % s)
            for s in atts.subject
        ]
        for s, out_file in zip(atts.subject, out_files):
            self.assertTrue(os.path.isfile(out_file))
            self.assertTrue(open(out_file).read() == '%s\n' % s)
예제 #3
0
    def test_run_iteraton_swf(self):
        study_config = self.study_config
        tmp_dir = tempfile.mkdtemp(prefix='capsul_')
        self.temps.append(tmp_dir)

        study_config.input_directory = os.path.join(tmp_dir, 'in')
        study_config.output_directory = os.path.join(tmp_dir, 'out')
        os.mkdir(study_config.input_directory)
        os.mkdir(study_config.output_directory)

        pipeline = Pipeline()
        pipeline.set_study_config(study_config)
        pipeline.add_iterative_process(
            'dummy',
            'capsul.attributes.test.test_attributed_process.DummyProcess',
            ['truc', 'bidule'])
        pipeline.autoexport_nodes_parameters()
        cm = ProcessCompletionEngine.get_completion_engine(pipeline)
        atts = cm.get_attribute_values()
        atts.center = ['muppets']
        atts.subject = ['kermit', 'piggy', 'stalter', 'waldorf']
        cm.complete_parameters()

        # create input files
        for s in atts.subject:
            open(os.path.join(
                study_config.input_directory,
                'DummyProcess_truc_muppets_%s' % s), 'w').write('%s\n' %s)

        # run
        study_config.use_soma_workflow = True
        study_config.run(pipeline)

        # check outputs
        out_files = [
            os.path.join(
                study_config.output_directory,
                'DummyProcess_bidule_muppets_%s' % s) for s in atts.subject]
        for s, out_file in zip(atts.subject, out_files):
            self.assertTrue(os.path.isfile(out_file))
            self.assertTrue(open(out_file).read() == '%s\n' % s)
예제 #4
0
 def test_iteration(self):
     study_config = self.study_config
     pipeline = Pipeline()
     pipeline.set_study_config(study_config)
     pipeline.add_iterative_process(
         'dummy',
         'capsul.attributes.test.test_attributed_process.DummyProcess',
         ['truc', 'bidule'])
     pipeline.autoexport_nodes_parameters()
     cm = ProcessCompletionEngine.get_completion_engine(pipeline)
     atts = cm.get_attribute_values()
     atts.center = ['muppets']
     atts.subject = ['kermit', 'piggy', 'stalter', 'waldorf']
     cm.complete_parameters()
     self.assertEqual(pipeline.truc,
                      ['/tmp/in/DummyProcess_truc_muppets_kermit',
                       '/tmp/in/DummyProcess_truc_muppets_piggy',
                       '/tmp/in/DummyProcess_truc_muppets_stalter',
                       '/tmp/in/DummyProcess_truc_muppets_waldorf'])
     self.assertEqual(pipeline.bidule,
                      ['/tmp/out/DummyProcess_bidule_muppets_kermit',
                       '/tmp/out/DummyProcess_bidule_muppets_piggy',
                       '/tmp/out/DummyProcess_bidule_muppets_stalter',
                       '/tmp/out/DummyProcess_bidule_muppets_waldorf'])