当前位置: 首页>>代码示例>>Python>>正文


Python CouchWorkQueueElement.save方法代码示例

本文整理汇总了Python中WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement.save方法的典型用法代码示例。如果您正苦于以下问题:Python CouchWorkQueueElement.save方法的具体用法?Python CouchWorkQueueElement.save怎么用?Python CouchWorkQueueElement.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement的用法示例。


在下文中一共展示了CouchWorkQueueElement.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insertElements

# 需要导入模块: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement import CouchWorkQueueElement [as 别名]
# 或者: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement import save [as 别名]
    def insertElements(self, units, parent = None):
        """
        Insert element to database

        @param parent is the parent WorkQueueObject these element's belong to.
                                            i.e. a workflow which has been split
        """
        if not units:
            return
        # store spec file separately - assume all elements share same spec
        self.insertWMSpec(units[0]['WMSpec'])
        for unit in units:

            # cast to couch
            if not isinstance(unit, CouchWorkQueueElement):
                unit = CouchWorkQueueElement(self.db, elementParams = dict(unit))

            if parent:
                unit['ParentQueueId'] = parent.id
                unit['TeamName'] = parent['TeamName']
                unit['WMBSUrl'] = parent['WMBSUrl']

            if unit._couch.documentExists(unit.id):
                self.logger.info('Element "%s" already exists, skip insertion.' % unit.id)
                continue
            unit.save()

        unit._couch.commit(all_or_nothing = True)
        return
开发者ID:ticoann,项目名称:WMCore,代码行数:31,代码来源:WorkQueueBackend.py

示例2: testIdSaved

# 需要导入模块: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement import CouchWorkQueueElement [as 别名]
# 或者: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement import save [as 别名]
 def testIdSaved(self):
     """Generated id used as db id"""
     ele = CouchWorkQueueElement(self.couch_db, elementParams = {'RequestName' : 'test'})
     ele.save()
     self.couch_db.commit(timestamp = True)
     self.assertTrue(self.couch_db.documentExists(ele.id))
     self.assertEqual(self.couch_db.info()['doc_count'], 1)
开发者ID:AndrewLevin,项目名称:WMCore,代码行数:9,代码来源:CouchWorkQueueElement_t.py

示例3: testIdFromDbImmutable

# 需要导入模块: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement import CouchWorkQueueElement [as 别名]
# 或者: from WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement import save [as 别名]
 def testIdFromDbImmutable(self):
     """Modifying element id algorithm doesn't change existing id's"""
     ele = CouchWorkQueueElement(self.couch_db, elementParams = {'RequestName' : 'test'})
     ele.save()
     self.couch_db.commit(timestamp = True)
     ele2 = CouchWorkQueueElement(self.couch_db, id = ele.id).load()
     ele2['RequestName'] = 'ThisWouldCauseIdToChange'
     # id should not change
     self.assertEqual(ele.id, ele2.id)
     # save should modify existing element
     ele2.save()
     self.couch_db.commit(timestamp = True)
     self.assertEqual(self.couch_db.info()['doc_count'], 1)
开发者ID:AndrewLevin,项目名称:WMCore,代码行数:15,代码来源:CouchWorkQueueElement_t.py


注:本文中的WMCore.WorkQueue.DataStructs.CouchWorkQueueElement.CouchWorkQueueElement.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。