示例#1
0
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
示例#2
0
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
示例#3
0
    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})
示例#4
0
    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})