From 0fa99bf294d318790d2f4112cc9582e024ed9e63 Mon Sep 17 00:00:00 2001 From: Orbin Sunny <91816511+orbin123@users.noreply.github.com> Date: Tue, 30 Dec 2025 13:15:07 +0530 Subject: [PATCH 1/5] fix/1185-network-api-compat --- .code-samples.meilisearch.yaml | 12 ++++++++++++ meilisearch/client.py | 6 ++++-- tests/client/test_client_network.py | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index bf7062f3..d119b7bb 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -3,6 +3,18 @@ # the documentation on build # You can read more on https://github.com/meilisearch/documentation/tree/master/.vuepress/code-samples --- +get_network_1: |- + client.get_all_networks() + +update_network_1: |- + client.add_or_update_networks({ + "remotes": { + "http://localhost:7700": { + "searchApiKey": "masterKey" + } + }, + "leader": None + }) get_one_index_1: |- client.get_index('movies') list_all_indexes_1: |- diff --git a/meilisearch/client.py b/meilisearch/client.py index 99f8a5da..a581480e 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -898,12 +898,14 @@ def generate_tenant_token( return jwt_token def add_or_update_networks(self, body: Union[MutableMapping[str, Any], None]) -> Dict[str, str]: - """Set all the Remote Networks + """Configure the Network High Availability (Leader/Followers). Parameters ---------- body: - Remote networks that are allowed + The network configuration dictionary. must contain either: + - 'remotes': A dictionary of follower instances (Star Topology). + - 'leader': A string URL of the leader instance. Returns ------- diff --git a/tests/client/test_client_network.py b/tests/client/test_client_network.py index adf4dec0..5e64f0aa 100644 --- a/tests/client/test_client_network.py +++ b/tests/client/test_client_network.py @@ -16,7 +16,6 @@ def test_get_all_networks(client): def test_add_or_update_networks(client): """Tests upsert network remote instance.""" body = { - "self": REMOTE_MS_1, "remotes": { REMOTE_MS_1: { "url": "http://localhost:7700", @@ -33,9 +32,23 @@ def test_add_or_update_networks(client): response = client.add_or_update_networks(body=body) assert isinstance(response, dict) - assert response["self"] == REMOTE_MS_1 assert len(response["remotes"]) >= 2 assert REMOTE_MS_2 in response["remotes"] assert REMOTE_MS_1 in response["remotes"] reset_network_config(client) + +@pytest.mark.usefixtures("enable_network_options") +def test_configure_as_leader(client): + """Test configuring the current instance as a Leader with one follower.""" + body = { + "remotes": { + REMOTE_MS_1: { + "url": "http://localhost:7701", + "searchApiKey": "remoteSearchKey" + } + }, + "leader": None + } + response = client.add_or_update_networks(body) + assert REMOTE_MS_1 in response["remotes"] From d411e24428383533b25d9ec95c00b3a862b68858 Mon Sep 17 00:00:00 2001 From: Orbin Sunny <91816511+orbin123@users.noreply.github.com> Date: Tue, 30 Dec 2025 14:32:10 +0530 Subject: [PATCH 2/5] Update test_client_network.py --- tests/client/test_client_network.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/client/test_client_network.py b/tests/client/test_client_network.py index 5e64f0aa..dbcf6c26 100644 --- a/tests/client/test_client_network.py +++ b/tests/client/test_client_network.py @@ -45,10 +45,15 @@ def test_configure_as_leader(client): "remotes": { REMOTE_MS_1: { "url": "http://localhost:7701", - "searchApiKey": "remoteSearchKey" + "searchApiKey": "remoteSearchKey", } }, - "leader": None + "leader": None, } response = client.add_or_update_networks(body) + + assert isinstance(response, dict) assert REMOTE_MS_1 in response["remotes"] + assert response.get("leader") is None + + reset_network_config(client) From 330c13c9804779171b03dd248060f576f9e90c0f Mon Sep 17 00:00:00 2001 From: Orbin Sunny <91816511+orbin123@users.noreply.github.com> Date: Tue, 30 Dec 2025 14:35:54 +0530 Subject: [PATCH 3/5] style: fix black formatting --- tests/client/test_client_network.py | 8 +++----- tests/settings/test_settings_embedders.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/client/test_client_network.py b/tests/client/test_client_network.py index 5e64f0aa..5c02a2a9 100644 --- a/tests/client/test_client_network.py +++ b/tests/client/test_client_network.py @@ -38,17 +38,15 @@ def test_add_or_update_networks(client): reset_network_config(client) + @pytest.mark.usefixtures("enable_network_options") def test_configure_as_leader(client): """Test configuring the current instance as a Leader with one follower.""" body = { "remotes": { - REMOTE_MS_1: { - "url": "http://localhost:7701", - "searchApiKey": "remoteSearchKey" - } + REMOTE_MS_1: {"url": "http://localhost:7701", "searchApiKey": "remoteSearchKey"} }, - "leader": None + "leader": None, } response = client.add_or_update_networks(body) assert REMOTE_MS_1 in response["remotes"] diff --git a/tests/settings/test_settings_embedders.py b/tests/settings/test_settings_embedders.py index 178106ef..0265d6c3 100644 --- a/tests/settings/test_settings_embedders.py +++ b/tests/settings/test_settings_embedders.py @@ -95,7 +95,7 @@ def test_huggingface_embedder_format(empty_index): } } response = index.update_embedders(huggingface_embedder) - index.wait_for_task(response.task_uid, timeout_in_ms=60000) # embedder config can take longer. + index.wait_for_task(response.task_uid, timeout_in_ms=60000) # embedder config can take longer. embedders = index.get_embedders() assert embedders.embedders["huggingface"].source == "huggingFace" assert embedders.embedders["huggingface"].model == "BAAI/bge-base-en-v1.5" From 8e57d39a7a685a308d2e2dec5d5e65a7eb3dc38a Mon Sep 17 00:00:00 2001 From: Orbin Sunny <91816511+orbin123@users.noreply.github.com> Date: Wed, 31 Dec 2025 21:04:40 +0530 Subject: [PATCH 4/5] Update meilisearch/client.py Co-authored-by: Laurent Cazanove --- meilisearch/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meilisearch/client.py b/meilisearch/client.py index a581480e..836a38c0 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -904,8 +904,8 @@ def add_or_update_networks(self, body: Union[MutableMapping[str, Any], None]) -> ---------- body: The network configuration dictionary. must contain either: - - 'remotes': A dictionary of follower instances (Star Topology). - - 'leader': A string URL of the leader instance. + - 'remotes': A dictionary of instances in the network + - 'leader': The leader instance (should be a key in the `remotes` dictionary) Returns ------- From 05036e5cdf66db349c52c83d0fdbf289d8ed0356 Mon Sep 17 00:00:00 2001 From: Orbin Sunny <91816511+orbin123@users.noreply.github.com> Date: Wed, 31 Dec 2025 21:05:14 +0530 Subject: [PATCH 5/5] Update meilisearch/client.py Co-authored-by: Laurent Cazanove --- meilisearch/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meilisearch/client.py b/meilisearch/client.py index 836a38c0..d50a5724 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -898,7 +898,7 @@ def generate_tenant_token( return jwt_token def add_or_update_networks(self, body: Union[MutableMapping[str, Any], None]) -> Dict[str, str]: - """Configure the Network High Availability (Leader/Followers). + """Configure the network topology Parameters ----------