def test_each_node_half_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3], [{ "slots": 4 }, { "slots": 20 }, { "slots": 12 }], instance_properties) expected = 5 self.assertEqual(nodes, expected)
def test_each_node_one_vcpu_except_max(self): nodes = utils.get_optimal_nodes([1, 5, 3], [{ "slots": 1 }, { "slots": 40 }, { "slots": 1 }], instance_properties) expected = 8 self.assertEqual(nodes, expected)
def test_each_node_at_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3], [{ "slots": 8 }, { "slots": 40 }, { "slots": 24 }], instance_properties) expected = 9 self.assertEqual(nodes, expected)
def test_each_node_partial_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3, 2], [{ "slots": 6 }, { "slots": 35 }, { "slots": 1 }, { "slots": 1 }], instance_properties) expected = 6 self.assertEqual(nodes, expected)
def get_required_nodes(instance_properties, max_size): log.info("Computing number of required nodes for submitted jobs") pending_jobs = get_pending_jobs_info( max_slots_filter=instance_properties.get("slots"), max_nodes_filter=max_size, filter_by_pending_reasons=PENDING_RESOURCES_REASONS, ) slots_requested = [] nodes_requested = [] for job in pending_jobs: slots_requested.append(job.cpus_total) nodes_requested.append(job.nodes) return get_optimal_nodes(nodes_requested, slots_requested, instance_properties)
def get_required_nodes(instance_properties, max_size): log.info("Computing number of required nodes for submitted jobs") pending_jobs = get_pending_jobs_info( instance_properties=instance_properties, max_nodes_filter=max_size, filter_by_pending_reasons=PENDING_RESOURCES_REASONS, ) logging.info("Found the following pending jobs:\n%s", pending_jobs) resources_requested = [] nodes_requested = [] for job in pending_jobs: resources_for_job = {} resources_for_job["gpus"] = process_gpus_total_for_job(job) resources_for_job["slots"] = job.cpus_total resources_requested.append(resources_for_job) nodes_requested.append(job.nodes) return get_optimal_nodes(nodes_requested, resources_requested, instance_properties)
def test_empty_lists(self): nodes = utils.get_optimal_nodes([], [], instance_properties["slots"]) expected = 0 self.assertEqual(nodes, expected)
def test_each_node_partial_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3, 2], [6, 35, 1, 1], instance_properties) expected = 6 self.assertEqual(nodes, expected)
def test_each_node_half_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3], [4, 20, 12], instance_properties) expected = 5 self.assertEqual(nodes, expected)
def test_slots_requested_greater_than_available(self): nodes = utils.get_optimal_nodes([1], [9], instance_properties) expected = 2 self.assertEqual(nodes, expected)
def test_each_node_at_capacity(self): nodes = utils.get_optimal_nodes([1, 5, 3], [8, 40, 24], instance_properties) expected = 9 self.assertEqual(nodes, expected)