Fix serve long running test (#8268)

This commit is contained in:
Edward Oakes
2020-05-01 14:35:56 -07:00
committed by SangBin Cho
parent f3bed48826
commit 40bb225d7a
3 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -44,8 +44,8 @@ def echo(_):
serve.create_endpoint("echo", "/echo")
config = serve.BackendConfig(num_replicas=30, max_batch_size=16)
serve.create_backend(echo, "echo:v1", backend_config=config)
config = {"num_replicas": 30, "max_batch_size": 16}
serve.create_backend("echo:v1", echo, config=config)
serve.set_traffic("echo", {"echo:v1": 1})
print("Warming up")
@@ -54,7 +54,7 @@ for _ in range(5):
print(resp)
time.sleep(0.5)
connections = int(config.num_replicas * config.max_batch_size * 0.75)
connections = int(config["num_replicas"] * config["max_batch_size"] * 0.75)
while True:
proc = subprocess.Popen(
+3
View File
@@ -11,6 +11,9 @@ def _callable_accepts_batch(func_or_class):
class BackendConfig:
def __init__(self, config_dict, accepts_batches=False):
assert isinstance(config_dict, dict)
# Make a copy so that we don't modify the input dict.
config_dict = config_dict.copy()
self.accepts_batches = accepts_batches
self.num_replicas = config_dict.pop("num_replicas", 1)
self.max_batch_size = config_dict.pop("max_batch_size", None)
+5
View File
@@ -9,6 +9,11 @@ def test_backend_config_validation():
with pytest.raises(ValueError, match="unknown_key"):
BackendConfig({"unknown_key": -1})
# Test that the input dict isn't modified.
config = {"num_replicas": 2}
BackendConfig(config)
assert len(config) == 1 and config["num_replicas"] == 2
# Test num_replicas validation.
BackendConfig({"num_replicas": 1})
with pytest.raises(TypeError):