Skip to content

Commit

Permalink
add tests for field migration
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed May 25, 2023
1 parent 4dbd53b commit 02a1432
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bentoml/_internal/configuration/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,14 @@ def migration(*, override_config: dict[str, t.Any]):
current=f"{namespace}.timeout",
replace_with=f"{namespace}.traffic.timeout",
)
for key in override_config:
if key.startswith("runners."):
runner_name = key.split(".")[1]
if any(key.schema == runner_name for key in _RUNNER_CONFIG):
continue
rename_fields(
override_config,
current=f"runners.{runner_name}.timeout",
replace_with=f"runners.{runner_name}.traffic.timeout",
)
return unflatten(override_config)
3 changes: 3 additions & 0 deletions tests/unit/_internal/configuration/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ def test_runner_timeouts(container_from_file: t.Callable[[str], ConfigDictType])
timeout: 100
test_runner_2:
resources: system
test_runner_3:
timeout: 60
"""
bentoml_cfg = container_from_file(RUNNER_TIMEOUTS)
runner_cfg = bentoml_cfg["runners"]
assert runner_cfg["traffic"]["timeout"] == 50
assert runner_cfg["test_runner_1"]["traffic"]["timeout"] == 100
assert runner_cfg["test_runner_2"]["traffic"]["timeout"] == 50
assert runner_cfg["test_runner_3"]["traffic"]["timeout"] == 60

0 comments on commit 02a1432

Please sign in to comment.