def testTaskChainWflow(self): """ Test loading a TaskChain like request into Workflow """ tChainSpec = {"RequestType": "TaskChain", "TaskChain": 3, "Campaign": "top-campaign", "RequestName": "whatever_name", "DbsUrl": "a_dbs_url", "SiteWhitelist": ["CERN", "FNAL", "DESY"], "SiteBlacklist": [], "Task1": {"InputDataset": "/task1/input-dataset/tier", "MCPileup": "/task1/mc-pileup/tier", "Campaign": "task1-campaign"}, "Task2": {"DataPileup": "/task2/data-pileup/tier", "Campaign": "task2-campaign"}, "Task3": {"MCPileup": "/task1/mc-pileup/tier", "Campaign": "task3-campaign"}, } wflow = Workflow(tChainSpec['RequestName'], tChainSpec) self.assertEqual(wflow.getName(), tChainSpec['RequestName']) self.assertEqual(wflow.getDbsUrl(), tChainSpec['DbsUrl']) self.assertItemsEqual(wflow.getSitelist(), tChainSpec['SiteWhitelist']) campaigns = ["%s-campaign" % c for c in {"task1", "task2", "task3"}] self.assertItemsEqual(wflow.getCampaigns(), campaigns) self.assertEqual(wflow.getInputDataset(), tChainSpec['Task1']['InputDataset']) pileups = [tChainSpec['Task1']['MCPileup'], tChainSpec['Task2']['DataPileup']] self.assertItemsEqual(wflow.getPileupDatasets(), pileups) self.assertFalse(wflow.hasParents()) self.assertEqual(wflow.getParentDataset(), "") self.assertEqual(wflow.getPrimaryBlocks(), {}) self.assertEqual(wflow.getSecondarySummary(), {}) self.assertEqual(wflow.getParentBlocks(), {}) self.assertEqual(wflow._getValue("NoKey"), None) self.assertEqual(len(wflow.getDataCampaignMap()), 3)
def testReRecoWflow(self): """ Test loading a ReReco like request into Workflow """ parentDset = "/rereco/parent-dataset/tier" rerecoSpec = {"RequestType": "ReReco", "InputDataset": "/rereco/input-dataset/tier", "Campaign": "any-campaign", "RequestName": "whatever_name", "DbsUrl": "a_dbs_url", "SiteWhitelist": ["CERN", "FNAL", "DESY"], "SiteBlacklist": ["FNAL"]} wflow = Workflow(rerecoSpec['RequestName'], rerecoSpec) self.assertEqual(wflow.getName(), rerecoSpec['RequestName']) self.assertEqual(wflow.getDbsUrl(), rerecoSpec['DbsUrl']) self.assertItemsEqual(wflow.getSitelist(), ["CERN", "DESY"]) self.assertItemsEqual(wflow.getCampaigns(), [rerecoSpec["Campaign"]]) self.assertEqual(wflow.getInputDataset(), rerecoSpec["InputDataset"]) self.assertItemsEqual(wflow.getPileupDatasets(), set()) self.assertFalse(wflow.hasParents()) self.assertEqual(wflow.getParentDataset(), "") self.assertEqual(wflow.getPrimaryBlocks(), {}) self.assertEqual(wflow.getSecondarySummary(), {}) self.assertEqual(wflow.getParentBlocks(), {}) self.assertEqual(wflow._getValue("NoKey"), None) self.assertEqual(len(wflow.getDataCampaignMap()), 1) wflow.setParentDataset(parentDset) self.assertEqual(wflow.getParentDataset(), parentDset) self.assertEqual(len(wflow.getDataCampaignMap()), 2)
def __call__(self, reqRecords): """ Run the unified transferor box :param reqRecords: input records :return: output records """ # obtain new unified Configuration uConfig = self.unifiedConfig() if not uConfig: self.logger.warning( "Failed to fetch the latest unified config. Skipping this cycle" ) return [] self.logger.info("Going to process %d requests.", len(reqRecords)) # create a Workflow object representing the request workflows = [] for record in reqRecords: wflow = Workflow(record['RequestName'], record, logger=self.logger) workflows.append(wflow) msg = "Processing request: %s, with campaigns: %s, " % ( wflow.getName(), wflow.getCampaigns()) msg += "and input data as:\n%s" % pformat( wflow.getDataCampaignMap()) self.logger.info(msg) # setup the Rucio token self.setupRucio() # get complete requests information (based on Unified Transferor logic) self.unified(workflows) return workflows
def testGetParam(self): """ Test the `getReqParam` method """ tChainSpec = {"RequestType": "StepChain", "StepChain": 1, "Campaign": "top-campaign", "RequestName": "whatever_name", "DbsUrl": "a_dbs_url", "TrustSitelists": True, "SiteWhitelist": ["CERN", "FNAL", "DESY"], "SiteBlacklist": [], "Step1": {"InputDataset": "/step1/input-dataset/tier", "MCPileup": "/step1/mc-pileup/tier", "Campaign": "step1-campaign"}, } wflow = Workflow(tChainSpec['RequestName'], tChainSpec) self.assertTrue(wflow.getReqParam("TrustSitelists")) self.assertIsNone(wflow.getReqParam("MCPileup")) self.assertEqual(wflow.getReqParam("RequestType"), wflow.getReqType()) self.assertEqual(wflow.getReqParam("RequestName"), wflow.getName())