Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
6 changes: 4 additions & 2 deletions meilisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 topology

Parameters
----------
body:
Remote networks that are allowed
The network configuration dictionary. must contain either:
- 'remotes': A dictionary of instances in the network
- 'leader': The leader instance (should be a key in the `remotes` dictionary)

Returns
-------
Expand Down
23 changes: 21 additions & 2 deletions tests/client/test_client_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,9 +32,29 @@ 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 isinstance(response, dict)
assert REMOTE_MS_1 in response["remotes"]
assert response.get("leader") is None

reset_network_config(client)
2 changes: 1 addition & 1 deletion tests/settings/test_settings_embedders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down