Skip to content

Commit 68f553a

Browse files
jfrancoaclaude
andcommitted
Add --async_replication_config reset and use replace semantics
Support "reset" keyword to revert all async replication settings to server defaults. Use `is not None` checks so empty dict (reset) is correctly forwarded as an empty async_config() call. Update version references to v1.34.18. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3d4a8a7 commit 68f553a

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

test/unittests/test_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,19 @@ def test_parse_async_replication_config_invalid_value():
445445
def test_parse_async_replication_config_missing_equals():
446446
with pytest.raises(ValueError, match="Expected key=value"):
447447
parse_async_replication_config(("max_workers",))
448+
449+
450+
def test_parse_async_replication_config_reset():
451+
result = parse_async_replication_config(("reset",))
452+
assert result == {}
453+
454+
455+
def test_parse_async_replication_config_reset_case_insensitive():
456+
assert parse_async_replication_config(("Reset",)) == {}
457+
assert parse_async_replication_config(("RESET",)) == {}
458+
assert parse_async_replication_config((" reset ",)) == {}
459+
460+
461+
def test_parse_async_replication_config_reset_with_other_keys():
462+
with pytest.raises(ValueError, match="Expected key=value"):
463+
parse_async_replication_config(("reset", "max_workers=10"))

weaviate_cli/managers/collection_manager.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ def create_collection(
244244
f"Error: Collection '{collection}' already exists in Weaviate. Delete using <delete collection> command."
245245
)
246246

247-
if async_replication_config and not async_enabled:
247+
if async_replication_config is not None and not async_enabled:
248248
raise Exception(
249249
"Error: --async_replication_config requires --async_enabled to be set."
250250
)
251251

252-
if async_replication_config and older_than_version(self.client, "1.34.18"):
252+
if async_replication_config is not None and older_than_version(
253+
self.client, "1.34.18"
254+
):
253255
click.echo(
254256
"Warning: --async_replication_config requires Weaviate >= v1.34.18. "
255257
"The server may ignore or reject these settings."
@@ -570,7 +572,7 @@ def create_collection(
570572
wvc.Configure.Replication.async_config(
571573
**async_replication_config
572574
)
573-
if async_replication_config
575+
if async_replication_config is not None
574576
else None
575577
),
576578
),
@@ -650,12 +652,14 @@ def update_collection(
650652
raise Exception(
651653
"object_ttl_property_name is only valid when object_ttl_type is 'property'."
652654
)
653-
if async_replication_config and async_enabled is False:
655+
if async_replication_config is not None and async_enabled is False:
654656
raise Exception(
655657
"Error: --async_replication_config cannot be used when --async_enabled is False."
656658
)
657659

658-
if async_replication_config and older_than_version(self.client, "1.34.18"):
660+
if async_replication_config is not None and older_than_version(
661+
self.client, "1.34.18"
662+
):
659663
click.echo(
660664
"Warning: --async_replication_config requires Weaviate >= v1.34.18. "
661665
"The server may ignore or reject these settings."
@@ -750,7 +754,7 @@ def update_collection(
750754
wvc.Reconfigure.Replication.async_config(
751755
**async_replication_config
752756
)
753-
if async_replication_config
757+
if async_replication_config is not None
754758
else None
755759
),
756760
)

weaviate_cli/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def pp_objects(response, main_properties, json_output: bool = False):
134134
}
135135

136136

137+
ASYNC_REPLICATION_CONFIG_RESET = "reset"
138+
137139
ASYNC_REPLICATION_CONFIG_HELP = (
138140
"Async replication config as key=value pairs. Can be specified multiple times. "
139141
"Valid keys: " + ", ".join(sorted(ASYNC_REPLICATION_CONFIG_KEYS)) + ". "
@@ -149,17 +151,22 @@ def parse_async_replication_config(
149151
"""Parse async replication config key=value tuples into a dict.
150152
151153
Args:
152-
config_tuples: Tuple of "key=value" strings, e.g. ("max_workers=10", "frequency=60")
154+
config_tuples: Tuple of "key=value" strings, e.g. ("max_workers=10", "frequency=60"),
155+
or a single "reset" to revert all settings to server defaults.
153156
154157
Returns:
155-
Dict mapping parameter names to integer values, or None if empty/None.
158+
Dict mapping parameter names to integer values, empty dict for "reset",
159+
or None if empty/None.
156160
157161
Raises:
158162
ValueError: If a key is unknown or a value is not a valid integer.
159163
"""
160164
if not config_tuples:
161165
return None
162166

167+
if len(config_tuples) == 1 and config_tuples[0].strip().lower() == "reset":
168+
return {}
169+
163170
result = {}
164171
for item in config_tuples:
165172
if "=" not in item:

0 commit comments

Comments
 (0)