本文整理汇总了Python中WMCore.ACDC.CouchCollection.CouchCollection.create方法的典型用法代码示例。如果您正苦于以下问题:Python CouchCollection.create方法的具体用法?Python CouchCollection.create怎么用?Python CouchCollection.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.ACDC.CouchCollection.CouchCollection
的用法示例。
在下文中一共展示了CouchCollection.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createCollection
# 需要导入模块: from WMCore.ACDC.CouchCollection import CouchCollection [as 别名]
# 或者: from WMCore.ACDC.CouchCollection.CouchCollection import create [as 别名]
def createCollection(self, collectionName, userName, groupName):
"""
_createCollection_
Create an empty AnalysisCollection
"""
if userName == None:
msg = "WMSpec does not contain an owner.name parameter"
raise RuntimeError(msg)
if groupName == None:
msg = "WMSpec does not contain an owner.group parameter"
raise RuntimeError(msg)
user = self.newOwner(groupName, userName)
collection = CouchCollection(
name=collectionName, type=CollectionTypes.AnalysisCollection, url=self.url, database=self.database
)
collection.setOwner(user)
collection.create()
return collection
示例2: testCreatePopulateDrop
# 需要导入模块: from WMCore.ACDC.CouchCollection import CouchCollection [as 别名]
# 或者: from WMCore.ACDC.CouchCollection.CouchCollection import create [as 别名]
def testCreatePopulateDrop(self):
"""
_testCreatePopulateDrop_
Test creating, populating and dropping a collection.
"""
testCollectionA = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "Thunderstruck")
testCollectionB = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "StruckThunder")
testCollectionA.setOwner(self.owner)
testCollectionB.setOwner(self.owner)
testCollectionA.create()
testCollectionB.create()
# There should be nothing in couch. Documents are only added for
# filesets and files.
testFilesA = []
for i in range(5):
testFile = File(lfn = makeUUID(), size = random.randint(1024, 4096),
events = random.randint(1024, 4096))
testFilesA.append(testFile)
testFilesB = []
for i in range(10):
testFile = File(lfn = makeUUID(), size = random.randint(1024, 4096),
events = random.randint(1024, 4096))
testFilesB.append(testFile)
testFilesetA = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetA")
testFilesetB = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetB")
testFilesetC = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetC")
testCollectionA.addFileset(testFilesetA)
testCollectionB.addFileset(testFilesetB)
testCollectionB.addFileset(testFilesetC)
testFilesetA.add(testFilesA)
testFilesetB.add(testFilesA)
testFilesetC.add(testFilesA)
testFilesetC.add(testFilesB)
# Drop testCollectionA
testCollectionA.drop()
# Try to populate testFilesetA
testCollectionC = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "ThunderStruck")
testCollectionC.setOwner(self.owner)
testCollectionC.populate()
self.assertEqual(len(testCollectionC["filesets"]), 0,
"Error: There should be no filesets in this collect.")
# Try to populate testFilesetB
testCollectionD = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "StruckThunder")
testCollectionD.setOwner(self.owner)
testCollectionD.populate()
for fileset in testCollectionD["filesets"]:
testFiles = testFilesA
if fileset["name"] == "TestFilesetC":
testFiles.extend(testFilesB)
self.assertEqual(len(testFiles), len(fileset.files.keys()),
"Error: Wrong number of files in fileset.")
for testFile in testFiles:
self.assertTrue(testFile["lfn"] in fileset.files.keys(),
"Error: File is missing.")
self.assertEqual(testFile["events"],
fileset.files[testFile["lfn"]]["events"],
"Error: Wrong number of events.")
self.assertEqual(testFile["size"],
fileset.files[testFile["lfn"]]["size"],
"Error: Wrong file size.")
return