From 2d176b847d67c6d923c2b58e4a321cad2e780c5c Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Mon, 9 Dec 2024 16:53:23 +0000 Subject: [PATCH] fix: deal with weaviate multiple network issues --- README.md | 13 +++++++++++++ scripts/import_packages.py | 14 +++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e6e9787..66398230 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,19 @@ source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e ".[dev]" ``` +### Running locally with several network interfaces + +By default weaviate is picking the default route as the ip for the cluster nodes. It may cause +some issues when dealing with multiple interfaces. To make it work, localhost needs to be the +default route: + +```bash +sudo route delete default +sudo route add default 127.0.0.1 +sudo route add -net 0.0.0.0/1 +sudo route add -net 128.0.0.0/1 +``` + ### Testing ```bash pytest diff --git a/scripts/import_packages.py b/scripts/import_packages.py index 9d6df68f..fd3b578a 100644 --- a/scripts/import_packages.py +++ b/scripts/import_packages.py @@ -3,6 +3,7 @@ import os import shutil + import weaviate from weaviate.classes.config import DataType, Property from weaviate.embedded import EmbeddedOptions @@ -53,11 +54,14 @@ def take_backup(self): shutil.rmtree(backup_path) #  take a backup of the data - self.client.backup.create( - backup_id=os.getenv("BACKUP_TARGET_ID", "backup"), - backend="filesystem", - wait_for_completion=True, - ) + try: + self.client.backup.create( + backup_id=os.getenv("BACKUP_TARGET_ID", "backup"), + backend="filesystem", + wait_for_completion=True, + ) + except Exception as e: + print(f"Failed to take backup: {e}") def setup_schema(self): if not self.client.collections.exists("Package"):