Repository navigation
Update the weaviate v4 migration docs and script - #616
Conversation
🌐 Multi-language Sync✅ Created sync PR #617 Synced 2 files to cn + jp Both PRs can merge independently. Future commits here will auto-update the sync PR. |
…d script (#617) * 🌐 Initial translations for PR #616 Auto-generated translations for documentation changes in PR #616. Last-Processed-Commit: dca5a24 Original-PR: #616 Languages: Chinese (zh), Japanese (ja) 🤖 Generated with GitHub Actions * Update weaviate-v4-migration.mdx * Update migration instructions in weaviate-v4 document Clarified instructions for running schema migration. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Riskey <36894937+RiskeyL@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request updates the Weaviate v4 migration documentation and the accompanying Python migration script to improve clarity, fix bugs, and add support for running the migration inside Docker containers.
Key changes:
- Enhanced migration documentation with additional options for running scripts inside containers and fixing orphaned LSM data
- Updated Python migration script to use environment variables for configuration, enabling execution within Docker containers
- Switched from offset-based to cursor-based pagination to handle large collections more reliably
- Improved formatting consistency throughout the documentation (standardized colon placement in bold labels)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| en/self-host/troubleshooting/weaviate-v4-migration.mdx | Comprehensive documentation updates including new container-based migration options, formatting standardization (colons after bold text), additional troubleshooting section for Dify 1.11.0+ permission issues, and improved step-by-step instructions with both host and container execution options |
| assets/migrate_weaviate_collections.py | Refactored to use environment variables for Weaviate connection configuration, implemented cursor-based pagination for large collection handling, increased batch size from 100 to 1000, added detailed attribution and change notes in docstring, and fixed empty collection migration handling |
Comments suppressed due to low confidence (1)
assets/migrate_weaviate_collections.py:373
- Variable migrated_count is not used.
migrated_count = migrate_collection_data(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if success and migrated_count > 0: | ||
|
|
||
| if success: |
There was a problem hiding this comment.
The condition on line 380 was changed from checking "success and migrated_count > 0" to just "success". While the commit message mentions fixing an issue with empty collections, this change means the replace_old_collection function will now be called even for empty collections. However, the replace_old_collection function doesn't handle the edge case where there are zero objects to migrate, which could lead to unnecessary operations and confusing output messages claiming "0 objects" were successfully migrated.
| WEAVIATE_ENDPOINT = os.getenv("WEAVIATE_ENDPOINT", "http://weaviate:8080") | ||
| WEAVIATE_GRPC_ENDPOINT = os.getenv("WEAVIATE_GRPC_ENDPOINT", "grpc://weaviate:50051") | ||
| WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY", "WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih") | ||
| BATCH_SIZE = 1000 |
There was a problem hiding this comment.
The BATCH_SIZE has been increased from 100 to 1000, which is a 10x increase. While this can improve performance for large datasets, it may cause memory issues or timeout problems for systems with limited resources or slow network connections. Consider documenting this change in the script's docstring or adding it as a configurable environment variable so users can adjust it based on their system capabilities.
| WEAVIATE_API_KEY = "WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih" | ||
| BATCH_SIZE = 100 | ||
| WEAVIATE_ENDPOINT = os.getenv("WEAVIATE_ENDPOINT", "http://weaviate:8080") | ||
| WEAVIATE_GRPC_ENDPOINT = os.getenv("WEAVIATE_GRPC_ENDPOINT", "grpc://weaviate:50051") |
There was a problem hiding this comment.
The default value for WEAVIATE_GRPC_ENDPOINT includes the protocol prefix "grpc://" which contradicts the documentation. According to the migration guide (lines 495-522 in the .mdx file), the WEAVIATE_GRPC_ENDPOINT should NOT include protocol prefixes and should only use the format "hostname:port". This default should be "weaviate:50051" instead of "grpc://weaviate:50051".
| WEAVIATE_GRPC_ENDPOINT = os.getenv("WEAVIATE_GRPC_ENDPOINT", "grpc://weaviate:50051") | |
| WEAVIATE_GRPC_ENDPOINT = os.getenv("WEAVIATE_GRPC_ENDPOINT", "weaviate:50051") |
| BATCH_SIZE = 1000 | ||
| WEAVIATE_HOST = WEAVIATE_ENDPOINT.split("//")[-1].split(":")[0] | ||
| WEAVIATE_PORT = int(WEAVIATE_ENDPOINT.split(":")[-1]) | ||
| WEAVIATE_GRPC_PORT = int(WEAVIATE_GRPC_ENDPOINT.split(":")[-1]) |
There was a problem hiding this comment.
The parsing logic on line 33 will fail when WEAVIATE_GRPC_ENDPOINT contains the "grpc://" protocol prefix. Since the code splits by ":" and takes the last element, it would try to parse "//weaviate:50051" as an integer, causing a ValueError. The parsing should handle the potential protocol prefix, or the default value should be corrected to not include it.
| WEAVIATE_GRPC_ENDPOINT = os.getenv("WEAVIATE_GRPC_ENDPOINT", "grpc://weaviate:50051") | ||
| WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY", "WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih") | ||
| BATCH_SIZE = 1000 | ||
| WEAVIATE_HOST = WEAVIATE_ENDPOINT.split("//")[-1].split(":")[0] |
There was a problem hiding this comment.
The protocol prefix parsing on line 31 assumes the format will always be "protocol://host:port", but if no protocol is provided (as recommended in the documentation), splitting by "//" and taking index -1 will just return the original string. This works correctly for the documented format, but the variable name suggests it should only contain the host. Consider renaming to WEAVIATE_HOST_WITH_PORT or parsing more explicitly to handle both cases.
| ``` | ||
|
|
||
| 2. **Run the [migration script](https://github.com/langgenius/dify-docs/blob/main/assets/migrate_weaviate_collections.py):** | ||
| 2. **Run the [migration script](https://github.com/langgenius/dify-docs/blob/main/assets/migrate_weaviate_collections.py)** either locally or inside the Worker container.\ |
There was a problem hiding this comment.
The backslash at the end of this line creates an unintended line continuation in Markdown. This will cause the two options to render incorrectly. Remove the trailing backslash to properly separate the option descriptions.
| 2. **Run the [migration script](https://github.com/langgenius/dify-docs/blob/main/assets/migrate_weaviate_collections.py)** either locally or inside the Worker container.\ | |
| 2. **Run the [migration script](https://github.com/langgenius/dify-docs/blob/main/assets/migrate_weaviate_collections.py)** either locally or inside the Worker container. |
| #### Step B2: Run the Schema Migration | ||
|
|
||
| Follow the same commands as [Step A5](#step-a5:-migrate-the-schema). Create the virtualenv if needed, install `weaviate-client` 4.x, run `migrate_weaviate_collections.py`, then restart `api`, `worker`, and `worker_beat`. | ||
| Follow the same commands as [Step A5](#step-a5%3A-migrate-the-schema). You can run the script locally or inside the Worker container: |
There was a problem hiding this comment.
The anchor link format should use lowercase and hyphens for URL encoding. The correct format should be "#step-a5-migrate-the-schema" instead of "#step-a5%3A-migrate-the-schema". While the percent-encoded colon (%3A) may work, using the standard hyphen format is more consistent with common Markdown conventions.
| Follow the same commands as [Step A5](#step-a5%3A-migrate-the-schema). You can run the script locally or inside the Worker container: | |
| Follow the same commands as [Step A5](#step-a5-migrate-the-schema). You can run the script locally or inside the Worker container: |
No description provided.