本文整理汇总了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
示例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)
示例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)