Beispiel #1
0
    def test_StepExecutor(self):
        """Test the list with several Complex"""
        fn = self.getOutputPath("protocol.sqlite")
        mapper = SqliteMapper(fn, globals())
        prot = MyProtocol(mapper=mapper,
                          n=2,
                          workingDir=self.getOutputPath(''))
        prot._stepsExecutor = StepExecutor(hostConfig=None)
        prot.run()

        self.assertEqual(prot._steps[0].getStatus(), STATUS_FINISHED)

        mapper2 = SqliteMapper(fn, globals())
        prot2 = mapper2.selectById(prot.getObjId())

        self.assertEqual(prot.endTime.get(), prot2.endTime.get())
Beispiel #2
0
 def createMapper(self, sqliteFn):
     """ Create a new SqliteMapper object and pass as classes dict
     all globas and update with data and protocols from em.
     """
     #TODO: REMOVE THE USE OF globals() here
     classesDict = dict(pwobj.__dict__)
     classesDict.update(em.getProtocols())
     classesDict.update(em.getObjects())
     return SqliteMapper(sqliteFn, classesDict)
Beispiel #3
0
 def createMapper(self, sqliteFn):
     """ Create a new SqliteMapper object and pass as classes dict
     all globas and update with data and protocols from em.
     """
     classesDict = dict(pwobj.__dict__)
     classesDict.update(em.getProtocols())
     classesDict.update(em.getObjects())
     mapper = SqliteMapper(sqliteFn, classesDict)
     if not self.chdir:
         mapper.setWorkingDir(self.path)
     return mapper
Beispiel #4
0
    def test_basicObjectOutput(self):
        """Test the list with several Complex"""
        fn = self.getOutputPath("protocol.sqlite")
        mapper = SqliteMapper(fn, globals())
        prot = ProtOutputTest(mapper=mapper,
                              n=2,
                              workingDir=self.getOutputPath(''))

        # Add and old style output, not in the outputs dictionary
        prot.output1 = EMObject()

        self.assertFalse(prot._useOutputList.get(),
                         "useOutputList wrongly initialized")

        outputs = [output for output in prot.iterOutputAttributes()]
        self.assertTrue(1, len(outputs))

        prot._stepsExecutor = StepExecutor(hostConfig=None)
        prot.run()

        self.assertEqual(prot._steps[0].getStatus(), STATUS_FINISHED)

        # Check there is an output
        self.assertOutput(prot)

        outputs = [output for output in prot.iterOutputAttributes()]

        # We are intentionally ignoring a protocol with output (EMObject)
        # That has been continued, We do not find a real case now.
        self.assertEqual(1,
                         len(outputs),
                         msg="Integer output not registered properly.")

        outputs = [output for output in prot.iterOutputAttributes(Integer)]

        # Test passing a filter
        self.assertEqual(1,
                         len(outputs),
                         msg="Integer not matched when filtering outputs.")
        # Test with non existing class
        outputs = [output for output in prot.iterOutputAttributes(DataSet)]

        # Test passing a class
        self.assertEqual(0,
                         len(outputs),
                         msg="Filter by class in iterOutputAttributes does "
                         "not work.")

        self.assertTrue(prot._useOutputList.get(),
                        "useOutputList not activated")
Beispiel #5
0
def saveConfig(filename):
    from pyworkflow.mapper import SqliteMapper
    from pyworkflow.object import String, Integer

    mapper = SqliteMapper(filename)
    o = Config()
    for k, v in globals().iteritems():
        if k.startswith('cfg'):
            if type(v) is str:
                value = String(v)
            else:
                value = Integer(v)
            setattr(o, k, value)
    mapper.insert(o)
    mapper.commit()