def _createDatasetSubscriptionsInDBSBuffer(self): """ _createDatasetSubscriptionsInDBSBuffer_ Insert the subscriptions defined in the workload for the output datasets with the different options. """ subInfo = self.wmSpec.getSubscriptionInformation() for dataset in subInfo: dbsDataset = DBSBufferDataset(path = dataset) dbsDataset.create() dbsDataset.addSubscription(subInfo[dataset]) return
def _createDatasetSubscriptionsInDBSBuffer(self): """ _createDatasetSubscriptionsInDBSBuffer_ Insert the subscriptions defined in the workload for the output datasets with the different options. """ subInfo = self.wmSpec.getSubscriptionInformation() for dataset in subInfo: dbsDataset = DBSBufferDataset(path=dataset) dbsDataset.create() dbsDataset.addSubscription(subInfo[dataset]) return
def insertDatasetAlgo(self): """ _insertDatasetAlgo_ Insert the dataset and algorithm for this file into the DBS Buffer. """ newAlgoAction = self.daofactory(classname="NewAlgo") assocAction = self.daofactory(classname="AlgoDatasetAssoc") existingTransaction = self.beginTransaction() newAlgoAction.execute(appName=self["appName"], appVer=self["appVer"], appFam=self["appFam"], psetHash=self["psetHash"], configContent=self["configContent"], conn=self.getDBConn(), transaction=True) dbsbufferDataset = DBSBufferDataset( self["datasetPath"], processingVer=self['processingVer'], acquisitionEra=self['acquisitionEra'], validStatus=self['validStatus'], globalTag=self.get('globalTag', None), parent=self['datasetParent'], prep_id=self['prep_id']) if dbsbufferDataset.exists(): dbsbufferDataset.updateDataset() else: dbsbufferDataset.create() assocID = assocAction.execute(appName=self["appName"], appVer=self["appVer"], appFam=self["appFam"], psetHash=self["psetHash"], datasetPath=self["datasetPath"], conn=self.getDBConn(), transaction=True) self.commitTransaction(existingTransaction) return assocID
def testBasic(self): """ _testBasic_ Test the basic functions of the DBSBufferDataset, create, load, exists and also the ability to add subscriptions. """ originalDataset = DBSBufferDataset(path = '/bogus/bogus/go') originalDataset.create() myThread = threading.currentThread() result = myThread.dbi.processData("SELECT id FROM dbsbuffer_dataset")[0].fetchall() self.assertEqual(originalDataset.exists(), result[0][0]) duplicateDataset = DBSBufferDataset(path = '/bogus/bogus/go') duplicateDataset.create() self.assertEqual(originalDataset.exists(), duplicateDataset.exists()) result = myThread.dbi.processData("SELECT COUNT(id) FROM dbsbuffer_dataset")[0].fetchall() self.assertEqual(result[0][0], 1) loadedDataset = DBSBufferDataset(path = '/bogus/bogus/go') loadedDataset.load() self.assertEqual(loadedDataset.exists(), originalDataset.exists()) secondDataset = DBSBufferDataset(path = '/BogusPrimary/Run2012Z-PromptReco-v1/RECO') secondDataset.create() workload = WMWorkloadHelper() workload.load(os.path.join(getTestBase(), 'WMComponent_t/PhEDExInjector_t/specs/TestWorkload.pkl')) secondDataset.addSubscription(workload.getSubscriptionInformation()['/BogusPrimary/Run2012Z-PromptReco-v1/RECO']) secondDataset.addSubscription(workload.getSubscriptionInformation()['/BogusPrimary/Run2012Z-PromptReco-v1/RECO']) self.assertEqual(len(secondDataset['subscriptions']), 3) result = myThread.dbi.processData("SELECT COUNT(id) FROM dbsbuffer_dataset_subscription")[0].fetchall() self.assertEqual(result[0][0], 3) return
def insertDatasetAlgo(self): """ _insertDatasetAlgo_ Insert the dataset and algorithm for this file into the DBS Buffer. """ newAlgoAction = self.daofactory(classname="NewAlgo") assocAction = self.daofactory(classname="AlgoDatasetAssoc") existingTransaction = self.beginTransaction() newAlgoAction.execute(appName=self["appName"], appVer=self["appVer"], appFam=self["appFam"], psetHash=self["psetHash"], configContent=self["configContent"], conn=self.getDBConn(), transaction=True) dbsbufferDataset = DBSBufferDataset(self["datasetPath"], processingVer=self['processingVer'], acquisitionEra=self['acquisitionEra'], validStatus=self['validStatus'], globalTag=self.get('globalTag', None), parent=self['datasetParent'], prep_id=self['prep_id']) if dbsbufferDataset.exists(): dbsbufferDataset.updateDataset() else: dbsbufferDataset.create() assocID = assocAction.execute(appName=self["appName"], appVer=self["appVer"], appFam=self["appFam"], psetHash=self["psetHash"], datasetPath=self["datasetPath"], conn=self.getDBConn(), transaction=True) self.commitTransaction(existingTransaction) return assocID
def testBasic(self): """ _testBasic_ Test the basic functions of the DBSBufferDataset, create, load, exists and also the ability to add subscriptions. """ originalDataset = DBSBufferDataset(path='/bogus/bogus/go') originalDataset.create() myThread = threading.currentThread() result = myThread.dbi.processData( "SELECT id FROM dbsbuffer_dataset")[0].fetchall() self.assertEqual(originalDataset.exists(), result[0][0]) duplicateDataset = DBSBufferDataset(path='/bogus/bogus/go') duplicateDataset.create() self.assertEqual(originalDataset.exists(), duplicateDataset.exists()) result = myThread.dbi.processData( "SELECT COUNT(id) FROM dbsbuffer_dataset")[0].fetchall() self.assertEqual(result[0][0], 1) loadedDataset = DBSBufferDataset(path='/bogus/bogus/go') loadedDataset.load() self.assertEqual(loadedDataset.exists(), originalDataset.exists()) secondDataset = DBSBufferDataset( path='/BogusPrimary/Run2012Z-PromptReco-v1/RECO') secondDataset.create() workload = WMWorkloadHelper() workload.load( os.path.join( getTestBase(), 'WMComponent_t/PhEDExInjector_t/specs/TestWorkload.pkl')) secondDataset.addSubscription( workload.getSubscriptionInformation() ['/BogusPrimary/Run2012Z-PromptReco-v1/RECO']) secondDataset.addSubscription( workload.getSubscriptionInformation() ['/BogusPrimary/Run2012Z-PromptReco-v1/RECO']) self.assertEqual(len(secondDataset['subscriptions']), 3) result = myThread.dbi.processData( "SELECT COUNT(id) FROM dbsbuffer_dataset_subscription" )[0].fetchall() self.assertEqual(result[0][0], 3) return