mirror of
https://github.com/katanemo/plano.git
synced 2026-06-11 15:05:14 +02:00
fix(config_generator): bump version to v0.4.0 up front in migration
Move the v0.3.0 -> v0.4.0 version bump to the top of migrate_inline_routing_preferences so it runs unconditionally, including for configs that already declare top-level routing_preferences at v0.3.0. Previously the bump only fired when inline migration produced entries, leaving top-level v0.3.0 configs rejected by brightstaff's v0.4.0 gate. Tests updated to cover the new behavior and to confirm we never downgrade newer versions.
This commit is contained in:
parent
4206522ad9
commit
7e99368c1d
2 changed files with 30 additions and 9 deletions
|
|
@ -70,10 +70,16 @@ def migrate_inline_routing_preferences(config_yaml):
|
|||
errored, so existing v0.3.0 configs keep compiling. Any top-level
|
||||
preference already defined by the user is preserved as-is.
|
||||
|
||||
Also bumps ``version`` to ``v0.4.0`` when migration produced any entry,
|
||||
so brightstaff's v0.4.0 gate for top-level ``routing_preferences``
|
||||
accepts the rendered config.
|
||||
Also bumps ``version`` to ``v0.4.0`` up front (when the config is
|
||||
``v0.3.0`` or older) so brightstaff's v0.4.0 gate for top-level
|
||||
``routing_preferences`` accepts the rendered config, including configs
|
||||
that already declare top-level ``routing_preferences`` on a v0.3.0
|
||||
version string.
|
||||
"""
|
||||
current_version = str(config_yaml.get("version", ""))
|
||||
if _version_tuple(current_version) < (0, 4, 0):
|
||||
config_yaml["version"] = "v0.4.0"
|
||||
|
||||
model_providers = config_yaml.get("model_providers") or []
|
||||
if not model_providers:
|
||||
return
|
||||
|
|
@ -129,10 +135,6 @@ def migrate_inline_routing_preferences(config_yaml):
|
|||
merged.append(entry)
|
||||
config_yaml["routing_preferences"] = merged
|
||||
|
||||
current_version = str(config_yaml.get("version", ""))
|
||||
if _version_tuple(current_version) < (0, 4, 0):
|
||||
config_yaml["version"] = "v0.4.0"
|
||||
|
||||
print(
|
||||
"WARNING: inline routing_preferences under model_providers is deprecated "
|
||||
"and has been auto-migrated to top-level routing_preferences. Update your "
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ model_providers:
|
|||
assert "wildcard" in str(excinfo.value).lower()
|
||||
|
||||
|
||||
def test_migration_noop_when_no_inline_preferences():
|
||||
def test_migration_bumps_version_even_without_inline_preferences():
|
||||
plano_config = """
|
||||
version: v0.3.0
|
||||
|
||||
|
|
@ -689,4 +689,23 @@ model_providers:
|
|||
migrate_inline_routing_preferences(config_yaml)
|
||||
|
||||
assert "routing_preferences" not in config_yaml
|
||||
assert config_yaml["version"] == "v0.3.0"
|
||||
assert config_yaml["version"] == "v0.4.0"
|
||||
|
||||
|
||||
def test_migration_does_not_downgrade_newer_versions():
|
||||
plano_config = """
|
||||
version: v0.5.0
|
||||
|
||||
listeners:
|
||||
- type: model
|
||||
name: model_listener
|
||||
port: 12000
|
||||
|
||||
model_providers:
|
||||
- model: openai/gpt-4o
|
||||
access_key: $OPENAI_API_KEY
|
||||
"""
|
||||
config_yaml = yaml.safe_load(plano_config)
|
||||
migrate_inline_routing_preferences(config_yaml)
|
||||
|
||||
assert config_yaml["version"] == "v0.5.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue