def capResourceEstimates(jobGroups, constraints): """ _capResourceEstimates_ Checks the current job resource estimates and cap them based on the limits defined in the agent config file. """ for jobGroup in jobGroups: for j in jobGroup.jobs: if not j['estimatedJobTime'] or j[ 'estimatedJobTime'] < constraints['MinWallTimeSecs']: j['estimatedJobTime'] = constraints['MinWallTimeSecs'] if not j['estimatedDiskUsage'] or j[ 'estimatedDiskUsage'] < constraints['MinRequestDiskKB']: j['estimatedDiskUsage'] = constraints['MinRequestDiskKB'] j['estimatedJobTime'] = min(j['estimatedJobTime'], constraints['MaxWallTimeSecs']) j['estimatedDiskUsage'] = min(j['estimatedDiskUsage'], constraints['MaxRequestDiskKB']) # finally, quantize those j['estimatedJobTime'] = quantize(j['estimatedJobTime'], constraints['MinWallTimeSecs']) j['estimatedDiskUsage'] = quantize(j['estimatedDiskUsage'], constraints['MinRequestDiskKB']) return
def capResourceEstimates(jobGroups, constraints): """ _capResourceEstimates_ Checks the current job resource estimates and cap them based on the limits defined in the agent config file. """ for jobGroup in jobGroups: for j in jobGroup.jobs: if not j['estimatedJobTime'] or j['estimatedJobTime'] < constraints['MinWallTimeSecs']: j['estimatedJobTime'] = constraints['MinWallTimeSecs'] if not j['estimatedDiskUsage'] or j['estimatedDiskUsage'] < constraints['MinRequestDiskKB']: j['estimatedDiskUsage'] = constraints['MinRequestDiskKB'] j['estimatedJobTime'] = min(j['estimatedJobTime'], constraints['MaxWallTimeSecs']) j['estimatedDiskUsage'] = min(j['estimatedDiskUsage'], constraints['MaxRequestDiskKB']) # finally, quantize those j['estimatedJobTime'] = quantize(j['estimatedJobTime'], constraints['MinWallTimeSecs']) j['estimatedDiskUsage'] = quantize(j['estimatedDiskUsage'], constraints['MinRequestDiskKB']) return
def testQuantize(self): """ Test the quantize function """ self.assertEqual(quantize(15, 5), 15) self.assertEqual(quantize(14, 5), 15) self.assertEqual(quantize(16, 5), 20) self.assertEqual(quantize(15, 5.0), 15) self.assertEqual(quantize(14, 5.0), 15) self.assertEqual(quantize(16, 5.0), 20) self.assertRaises(ValueError, quantize, [1], 50) self.assertRaises(ValueError, quantize, {1}, 50) self.assertRaises(ValueError, quantize, 1, [50]) self.assertRaises(ValueError, quantize, 1, {50})