Skip to content

Commit a6f16a8

Browse files
authored
refactor(api): update for CE protobuf refactoring and Python 3.13 support (#290)
### Because - The protobuf definitions were refactored in CE, renaming `Catalog` to `KnowledgeBase` and restructuring the artifact service APIs - Credit and subscription management endpoints were removed from the CE version of the mgmt API - Python 3.13 support is needed for the SDK - Multiple dependency conflicts existed between newer packages required for Python 3.13 and older transitive dependencies ### This commit - **Refactors ArtifactClient** (`instill/clients/artifact.py`): - Renames all `catalog` methods to `knowledge_base` methods - Updates imports to reflect new protobuf file structure (`artifact_pb2` → `file_pb2`, `knowledge_base_pb2`) - Adds new methods: `list_knowledge_base_runs()`, `get_chunk()` - Removes deprecated methods: `process_catalog_files()`, `question_answering()`, `get_file_catalog()` - Updates `search_chunks()` with new parameters: `chunk_type`, `file_media_type`, `file_ids`, `tags` - Fixes mypy type errors by properly constructing protobuf requests instead of using dict unpacking - Adds type ignore comments for protobuf enum assignments - **Updates MgmtClient** (`instill/clients/mgmt.py`): - Removes CE-specific credit endpoints: `get_remaining_credit()`, `list_credit_consumption_chart_records()` - Removes CE-specific subscription endpoints: `get_authenticated_subscription()`, `get_organization_subscription()` - **Fixes file processing utility** (`instill/utils/process_file.py`): - Updates imports from `artifact_pb2` to `file_pb2` for File message - Changes enum handling from string format (`"FILE_TYPE_TEXT"`) to protobuf enum constants (`file_interface.File.TYPE_TEXT`) - Fixes field name from `name` to `filename` in File construction - Returns proper enum values instead of strings from `get_file_type()` - **Updates tests** (`instill/tests/test_utils.py`): - Adds `file_interface` import for protobuf enums - Updates all assertions to use enum constants instead of string values - Fixes field references from `result.name` to `result.filename` - Separates CSV type testing from TEXT type (CSV has its own `TYPE_CSV`) - Adds pylint disable comment for protobuf module false positives - **Upgrades dependencies for Python 3.13 support** (`pyproject.toml`): - Updates Python version constraint: `>=3.9,<3.13` → `>=3.9,<3.14` - Updates core dependencies: - `grpcio`: `^1.59.0` → `^1.68.0` (Python 3.13 support) - `grpcio-tools`: `1.62.0` → `^1.68.0` (Python 3.13 build support) - `protobuf`: `4.25.8` → `^5.28.0` (required by grpcio 1.68+) - `types-protobuf`: `^4.24.0.1` → `^5.28.0` - `numpy`: `^1.21.0` → `>=1.26,<1.28` (Python 3.13 support while avoiding scipy/cupy conflicts) - `pillow`: `^10.1.0` → `^11.0.0` - `pyinstaller`: `6.0.0` → `^6.16.0` - `google-api-core`: `^2.11.1` → `{version = "^2.22.0", extras = ["grpc"]}` - `ray`: `2.47.0` → `{version = "^2.47.0", extras = ["default"]}` - Restricts incompatible macOS dev dependencies to Python < 3.13: - `MacFSEvents = {version = "*", platform = "darwin", python = "<3.13"}` - `sniffer = {version = "*", python = "<3.13"}` - Explicitly upgrades opentelemetry packages to resolve protobuf 5.x conflicts: - `opentelemetry-proto = "^1.29.0"` - `opentelemetry-exporter-otlp = "^1.29.0"` - `opentelemetry-exporter-otlp-proto-common = "^1.29.0"` - `opentelemetry-exporter-otlp-proto-grpc = "^1.29.0"` - `opentelemetry-exporter-otlp-proto-http = "^1.29.0"` - **Resolves all dependency conflicts**: - Eliminates numpy version warnings from scipy/cupy by using numpy 1.26-1.27 - Fixes opentelemetry-proto protobuf <5.0 requirement by upgrading to 1.29+ - Ensures all opentelemetry exporters are compatible versions ### Testing - All mypy type checks pass - All pylint checks pass (excluding pre-existing warnings) - File type enum handling verified through test updates - Dependency installation completes without conflicts ### Breaking Changes - Method names in `ArtifactClient` changed from `*_catalog*` to `*_knowledge_base*` - Removed methods: `process_catalog_files()`, `question_answering()`, `get_file_catalog()` - Removed methods in `MgmtClient`: `get_remaining_credit()`, `list_credit_consumption_chart_records()`, `get_authenticated_subscription()`, `get_organization_subscription()` - `process_file()` utility now returns protobuf enum values instead of strings for file types
1 parent 592e5d7 commit a6f16a8

File tree

8 files changed

+1672
-556
lines changed

8 files changed

+1672
-556
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
10+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1111

1212
steps:
1313
- uses: actions/checkout@v4
1414
with:
15-
submodules: "true"
15+
submodules: "recursive"
1616

1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v5
@@ -28,6 +28,15 @@ jobs:
2828
path: .venv
2929
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
3030

31+
- name: Configure Poetry
32+
run: poetry config virtualenvs.in-project true
33+
34+
- name: Regenerate lock file for CI
35+
run: poetry lock
36+
37+
- name: Stage lock file to avoid git diff errors
38+
run: git add poetry.lock
39+
3140
- name: Install dependencies
3241
run: make install
3342

0 commit comments

Comments
 (0)