[hotfix] [autoscaler] Address remaining comments on renaming instance => node (#10229)

* more renaming

* fix import
This commit is contained in:
Eric Liang
2020-08-20 14:37:41 -07:00
committed by GitHub
parent 85a6876119
commit 0baf992a4f
5 changed files with 64 additions and 66 deletions
@@ -14,7 +14,7 @@ from ray.autoscaler.node_provider import NODE_PROVIDERS
from ray.autoscaler.commands import get_or_create_head_node
from ray.autoscaler.tags import TAG_RAY_USER_NODE_TYPE
from ray.autoscaler.resource_demand_scheduler import _utilization_score, \
get_bin_pack_residual, get_instances_for
get_bin_pack_residual, get_nodes_for
from time import sleep
@@ -94,39 +94,39 @@ def test_bin_pack():
assert get_bin_pack_residual(arg, [{"GPU": 2}, {"GPU": 2}]) == [{"GPU": 2}]
def test_get_instances_packing_heuristic():
assert get_instances_for(TYPES_A, {}, 9999, [{"GPU": 8}]) == \
def test_get_nodes_packing_heuristic():
assert get_nodes_for(TYPES_A, {}, 9999, [{"GPU": 8}]) == \
[("p2.8xlarge", 1)]
assert get_instances_for(TYPES_A, {}, 9999, [{"GPU": 1}] * 6) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"GPU": 1}] * 6) == \
[("p2.8xlarge", 1)]
assert get_instances_for(TYPES_A, {}, 9999, [{"GPU": 1}] * 4) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"GPU": 1}] * 4) == \
[("p2.xlarge", 4)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 32, "GPU": 1}] * 3) \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 32, "GPU": 1}] * 3) \
== [("p2.8xlarge", 3)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 64, "GPU": 1}] * 3) \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 64, "GPU": 1}] * 3) \
== []
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 64}] * 3) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 64}] * 3) == \
[("m4.16xlarge", 3)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 64}, {"CPU": 1}]) \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 64}, {"CPU": 1}]) \
== [("m4.16xlarge", 1), ("m4.large", 1)]
assert get_instances_for(
assert get_nodes_for(
TYPES_A, {}, 9999, [{"CPU": 64}, {"CPU": 9}, {"CPU": 9}]) == \
[("m4.16xlarge", 1), ("m4.4xlarge", 2)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 16}] * 5) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 16}] * 5) == \
[("m4.16xlarge", 1), ("m4.4xlarge", 1)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 8}] * 10) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 8}] * 10) == \
[("m4.16xlarge", 1), ("m4.4xlarge", 1)]
assert get_instances_for(TYPES_A, {}, 9999, [{"CPU": 1}] * 100) == \
assert get_nodes_for(TYPES_A, {}, 9999, [{"CPU": 1}] * 100) == \
[("m4.16xlarge", 1), ("m4.4xlarge", 2), ("m4.large", 2)]
assert get_instances_for(
assert get_nodes_for(
TYPES_A, {}, 9999, [{"GPU": 1}] + ([{"CPU": 1}] * 64)) == \
[("m4.16xlarge", 1), ("p2.xlarge", 1)]
assert get_instances_for(
assert get_nodes_for(
TYPES_A, {}, 9999, ([{"GPU": 1}] * 8) + ([{"CPU": 1}] * 64)) == \
[("m4.16xlarge", 1), ("p2.8xlarge", 1)]
def test_get_instances_respects_max_limit():
def test_get_nodes_respects_max_limit():
types = {
"m4.large": {
"resources": {
@@ -141,18 +141,18 @@ def test_get_instances_respects_max_limit():
"max_workers": 99999,
},
}
assert get_instances_for(types, {}, 2, [{"CPU": 1}] * 10) == \
assert get_nodes_for(types, {}, 2, [{"CPU": 1}] * 10) == \
[("m4.large", 2)]
assert get_instances_for(types, {"m4.large": 9999}, 9999, [{
assert get_nodes_for(types, {"m4.large": 9999}, 9999, [{
"CPU": 1
}] * 10) == []
assert get_instances_for(types, {"m4.large": 0}, 9999, [{
assert get_nodes_for(types, {"m4.large": 0}, 9999, [{
"CPU": 1
}] * 10) == [("m4.large", 5)]
assert get_instances_for(types, {"m4.large": 7}, 4, [{
assert get_nodes_for(types, {"m4.large": 7}, 4, [{
"CPU": 1
}] * 10) == [("m4.large", 3)]
assert get_instances_for(types, {"m4.large": 7}, 2, [{
assert get_nodes_for(types, {"m4.large": 7}, 2, [{
"CPU": 1
}] * 10) == [("m4.large", 2)]