Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(configuration): merging global runner config to runner specific c…
…onfig (#2849) * merge global and runner specific instructions * tests * fix pep8 * remove breakpoing * flush * more asserts * close file to work in windows Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from tempfile import NamedTemporaryFile | ||
|
||
from bentoml._internal.configuration.containers import BentoMLConfiguration | ||
|
||
OVERRIDE_RUNNERS = """ | ||
runners: | ||
batching: | ||
enabled: False | ||
max_batch_size: 10 | ||
resources: | ||
cpu: 4 | ||
logging: | ||
access: | ||
enabled: False | ||
test_runner_1: | ||
resources: system | ||
test_runner_2: | ||
resources: | ||
cpu: 2 | ||
test_runner_gpu: | ||
resources: | ||
nvidia.com/gpu: 1 | ||
test_runner_batching: | ||
batching: | ||
enabled: True | ||
logging: | ||
access: | ||
enabled: True | ||
""" | ||
|
||
|
||
def test_bentoml_configuration_runner_override(): | ||
tmpfile = NamedTemporaryFile(mode="w+", delete=False) | ||
tmpfile.write(OVERRIDE_RUNNERS) | ||
tmpfile.flush() | ||
tmpfile.close() | ||
|
||
bentoml_cfg = BentoMLConfiguration(override_config_file=tmpfile.name).as_dict() | ||
runner_cfg = bentoml_cfg["runners"] | ||
|
||
# test_runner_1 | ||
test_runner_1 = runner_cfg["test_runner_1"] | ||
assert test_runner_1["batching"]["enabled"] is False | ||
assert test_runner_1["batching"]["max_batch_size"] == 10 | ||
assert test_runner_1["logging"]["access"]["enabled"] is False | ||
# assert test_runner_1["resources"]["cpu"] == 4 | ||
|
||
# test_runner_2 | ||
test_runner_2 = runner_cfg["test_runner_2"] | ||
assert test_runner_2["batching"]["enabled"] is False | ||
assert test_runner_2["batching"]["max_batch_size"] == 10 | ||
assert test_runner_2["logging"]["access"]["enabled"] is False | ||
assert test_runner_2["resources"]["cpu"] == 2 | ||
|
||
# test_runner_gpu | ||
test_runner_gpu = runner_cfg["test_runner_gpu"] | ||
assert test_runner_gpu["batching"]["enabled"] is False | ||
assert test_runner_gpu["batching"]["max_batch_size"] == 10 | ||
assert test_runner_gpu["logging"]["access"]["enabled"] is False | ||
assert test_runner_gpu["resources"]["cpu"] == 4 # should use global | ||
assert test_runner_gpu["resources"]["nvidia.com/gpu"] == 1 | ||
|
||
# test_runner_batching | ||
test_runner_batching = runner_cfg["test_runner_batching"] | ||
assert test_runner_batching["batching"]["enabled"] is True | ||
assert test_runner_batching["batching"]["max_batch_size"] == 10 | ||
assert test_runner_batching["logging"]["access"]["enabled"] is True | ||
assert test_runner_batching["resources"]["cpu"] == 4 # should use global |