matrixone-python-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- matrixone/__init__.py +155 -0
- matrixone/account.py +723 -0
- matrixone/async_client.py +3913 -0
- matrixone/async_metadata_manager.py +311 -0
- matrixone/async_orm.py +123 -0
- matrixone/async_vector_index_manager.py +633 -0
- matrixone/base_client.py +208 -0
- matrixone/client.py +4672 -0
- matrixone/config.py +452 -0
- matrixone/connection_hooks.py +286 -0
- matrixone/exceptions.py +89 -0
- matrixone/logger.py +782 -0
- matrixone/metadata.py +820 -0
- matrixone/moctl.py +219 -0
- matrixone/orm.py +2277 -0
- matrixone/pitr.py +646 -0
- matrixone/pubsub.py +771 -0
- matrixone/restore.py +411 -0
- matrixone/search_vector_index.py +1176 -0
- matrixone/snapshot.py +550 -0
- matrixone/sql_builder.py +844 -0
- matrixone/sqlalchemy_ext/__init__.py +161 -0
- matrixone/sqlalchemy_ext/adapters.py +163 -0
- matrixone/sqlalchemy_ext/dialect.py +534 -0
- matrixone/sqlalchemy_ext/fulltext_index.py +895 -0
- matrixone/sqlalchemy_ext/fulltext_search.py +1686 -0
- matrixone/sqlalchemy_ext/hnsw_config.py +194 -0
- matrixone/sqlalchemy_ext/ivf_config.py +252 -0
- matrixone/sqlalchemy_ext/table_builder.py +351 -0
- matrixone/sqlalchemy_ext/vector_index.py +1721 -0
- matrixone/sqlalchemy_ext/vector_type.py +948 -0
- matrixone/version.py +580 -0
- matrixone_python_sdk-0.1.0.dist-info/METADATA +706 -0
- matrixone_python_sdk-0.1.0.dist-info/RECORD +122 -0
- matrixone_python_sdk-0.1.0.dist-info/WHEEL +5 -0
- matrixone_python_sdk-0.1.0.dist-info/entry_points.txt +5 -0
- matrixone_python_sdk-0.1.0.dist-info/licenses/LICENSE +200 -0
- matrixone_python_sdk-0.1.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +19 -0
- tests/offline/__init__.py +20 -0
- tests/offline/conftest.py +77 -0
- tests/offline/test_account.py +703 -0
- tests/offline/test_async_client_query_comprehensive.py +1218 -0
- tests/offline/test_basic.py +54 -0
- tests/offline/test_case_sensitivity.py +227 -0
- tests/offline/test_connection_hooks_offline.py +287 -0
- tests/offline/test_dialect_schema_handling.py +609 -0
- tests/offline/test_explain_methods.py +346 -0
- tests/offline/test_filter_logical_in.py +237 -0
- tests/offline/test_fulltext_search_comprehensive.py +795 -0
- tests/offline/test_ivf_config.py +249 -0
- tests/offline/test_join_methods.py +281 -0
- tests/offline/test_join_sqlalchemy_compatibility.py +276 -0
- tests/offline/test_logical_in_method.py +237 -0
- tests/offline/test_matrixone_version_parsing.py +264 -0
- tests/offline/test_metadata_offline.py +557 -0
- tests/offline/test_moctl.py +300 -0
- tests/offline/test_moctl_simple.py +251 -0
- tests/offline/test_model_support_offline.py +359 -0
- tests/offline/test_model_support_simple.py +225 -0
- tests/offline/test_pinecone_filter_offline.py +377 -0
- tests/offline/test_pitr.py +585 -0
- tests/offline/test_pubsub.py +712 -0
- tests/offline/test_query_update.py +283 -0
- tests/offline/test_restore.py +445 -0
- tests/offline/test_snapshot_comprehensive.py +384 -0
- tests/offline/test_sql_escaping_edge_cases.py +551 -0
- tests/offline/test_sqlalchemy_integration.py +382 -0
- tests/offline/test_sqlalchemy_vector_integration.py +434 -0
- tests/offline/test_table_builder.py +198 -0
- tests/offline/test_unified_filter.py +398 -0
- tests/offline/test_unified_transaction.py +495 -0
- tests/offline/test_vector_index.py +238 -0
- tests/offline/test_vector_operations.py +688 -0
- tests/offline/test_vector_type.py +174 -0
- tests/offline/test_version_core.py +328 -0
- tests/offline/test_version_management.py +372 -0
- tests/offline/test_version_standalone.py +652 -0
- tests/online/__init__.py +20 -0
- tests/online/conftest.py +216 -0
- tests/online/test_account_management.py +194 -0
- tests/online/test_advanced_features.py +344 -0
- tests/online/test_async_client_interfaces.py +330 -0
- tests/online/test_async_client_online.py +285 -0
- tests/online/test_async_model_insert_online.py +293 -0
- tests/online/test_async_orm_online.py +300 -0
- tests/online/test_async_simple_query_online.py +802 -0
- tests/online/test_async_transaction_simple_query.py +300 -0
- tests/online/test_basic_connection.py +130 -0
- tests/online/test_client_online.py +238 -0
- tests/online/test_config.py +90 -0
- tests/online/test_config_validation.py +123 -0
- tests/online/test_connection_hooks_new_online.py +217 -0
- tests/online/test_dialect_schema_handling_online.py +331 -0
- tests/online/test_filter_logical_in_online.py +374 -0
- tests/online/test_fulltext_comprehensive.py +1773 -0
- tests/online/test_fulltext_label_online.py +433 -0
- tests/online/test_fulltext_search_online.py +842 -0
- tests/online/test_ivf_stats_online.py +506 -0
- tests/online/test_logger_integration.py +311 -0
- tests/online/test_matrixone_query_orm.py +540 -0
- tests/online/test_metadata_online.py +579 -0
- tests/online/test_model_insert_online.py +255 -0
- tests/online/test_mysql_driver_validation.py +213 -0
- tests/online/test_orm_advanced_features.py +2022 -0
- tests/online/test_orm_cte_integration.py +269 -0
- tests/online/test_orm_online.py +270 -0
- tests/online/test_pinecone_filter.py +708 -0
- tests/online/test_pubsub_operations.py +352 -0
- tests/online/test_query_methods.py +225 -0
- tests/online/test_query_update_online.py +433 -0
- tests/online/test_search_vector_index.py +557 -0
- tests/online/test_simple_fulltext_online.py +915 -0
- tests/online/test_snapshot_comprehensive.py +998 -0
- tests/online/test_sqlalchemy_engine_integration.py +336 -0
- tests/online/test_sqlalchemy_integration.py +425 -0
- tests/online/test_transaction_contexts.py +1219 -0
- tests/online/test_transaction_insert_methods.py +356 -0
- tests/online/test_transaction_query_methods.py +288 -0
- tests/online/test_unified_filter_online.py +529 -0
- tests/online/test_vector_comprehensive.py +706 -0
- tests/online/test_version_management.py +291 -0
@@ -0,0 +1,264 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
|
3
|
+
# Copyright 2021 - 2022 Matrix Origin
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
"""
|
18
|
+
MatrixOne Python SDK - MatrixOne Version Parsing Tests
|
19
|
+
|
20
|
+
Test suite for MatrixOne-specific version parsing logic.
|
21
|
+
"""
|
22
|
+
|
23
|
+
import unittest
|
24
|
+
import sys
|
25
|
+
import os
|
26
|
+
import re
|
27
|
+
from typing import Optional
|
28
|
+
|
29
|
+
# Add the matrixone package to the path
|
30
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'matrixone'))
|
31
|
+
|
32
|
+
from matrixone.version import VersionManager, VersionInfo, VersionComparison
|
33
|
+
|
34
|
+
|
35
|
+
class TestMatrixOneVersionParsing(unittest.TestCase):
|
36
|
+
"""Test MatrixOne-specific version parsing functionality"""
|
37
|
+
|
38
|
+
def setUp(self):
|
39
|
+
self.version_manager = VersionManager()
|
40
|
+
|
41
|
+
def test_development_version_parsing(self):
|
42
|
+
"""Test parsing development version strings"""
|
43
|
+
test_cases = [
|
44
|
+
("8.0.30-MatrixOne-v", "999.0.0"),
|
45
|
+
("10.5.2-MatrixOne-v", "999.0.0"),
|
46
|
+
("1.0.0-MatrixOne-v", "999.0.0"),
|
47
|
+
]
|
48
|
+
|
49
|
+
for version_string, expected in test_cases:
|
50
|
+
with self.subTest(version=version_string):
|
51
|
+
parsed_version = self.version_manager._parse_matrixone_version(version_string)
|
52
|
+
self.assertEqual(parsed_version, expected)
|
53
|
+
|
54
|
+
# Verify it's recognized as development version
|
55
|
+
if parsed_version:
|
56
|
+
version_info = self.version_manager.parse_version(parsed_version)
|
57
|
+
self.assertTrue(self.version_manager.is_development_version(version_info))
|
58
|
+
|
59
|
+
def test_release_version_parsing(self):
|
60
|
+
"""Test parsing release version strings"""
|
61
|
+
test_cases = [
|
62
|
+
("8.0.30-MatrixOne-v3.0.0", "3.0.0"),
|
63
|
+
("10.5.2-MatrixOne-v2.1.5", "2.1.5"),
|
64
|
+
("1.0.0-MatrixOne-v1.0.0", "1.0.0"),
|
65
|
+
("15.20.30-MatrixOne-v4.5.6", "4.5.6"),
|
66
|
+
]
|
67
|
+
|
68
|
+
for version_string, expected in test_cases:
|
69
|
+
with self.subTest(version=version_string):
|
70
|
+
parsed_version = self.version_manager._parse_matrixone_version(version_string)
|
71
|
+
self.assertEqual(parsed_version, expected)
|
72
|
+
|
73
|
+
# Verify it's NOT a development version
|
74
|
+
if parsed_version:
|
75
|
+
version_info = self.version_manager.parse_version(parsed_version)
|
76
|
+
self.assertFalse(self.version_manager.is_development_version(version_info))
|
77
|
+
|
78
|
+
def test_fallback_version_parsing(self):
|
79
|
+
"""Test fallback version parsing for other formats"""
|
80
|
+
test_cases = [
|
81
|
+
("MatrixOne 3.0.1", "3.0.1"),
|
82
|
+
("Version 2.5.0", "2.5.0"),
|
83
|
+
("3.0.1", "3.0.1"),
|
84
|
+
]
|
85
|
+
|
86
|
+
for version_string, expected in test_cases:
|
87
|
+
with self.subTest(version=version_string):
|
88
|
+
parsed_version = self.version_manager._parse_matrixone_version(version_string)
|
89
|
+
self.assertEqual(parsed_version, expected)
|
90
|
+
|
91
|
+
def test_invalid_version_parsing(self):
|
92
|
+
"""Test parsing invalid version strings"""
|
93
|
+
invalid_versions = [
|
94
|
+
"", # Empty string
|
95
|
+
None, # None value
|
96
|
+
"invalid", # Completely invalid
|
97
|
+
"8.0.30-MatrixOne", # Missing version part
|
98
|
+
"8.0.30-MatrixOne-v-", # Invalid format
|
99
|
+
]
|
100
|
+
|
101
|
+
for invalid_version in invalid_versions:
|
102
|
+
with self.subTest(version=invalid_version):
|
103
|
+
parsed_version = self.version_manager._parse_matrixone_version(invalid_version)
|
104
|
+
self.assertIsNone(parsed_version)
|
105
|
+
|
106
|
+
def test_development_version_comparison(self):
|
107
|
+
"""Test that development version (999.0.0) is higher than any release version"""
|
108
|
+
dev_version = "999.0.0"
|
109
|
+
release_versions = ["1.0.0", "2.5.0", "3.0.0", "10.0.0", "99.99.99"]
|
110
|
+
|
111
|
+
for release_version in release_versions:
|
112
|
+
with self.subTest(release=release_version):
|
113
|
+
result = self.version_manager.compare_versions(dev_version, release_version)
|
114
|
+
self.assertEqual(result, VersionComparison.GREATER)
|
115
|
+
|
116
|
+
# Test reverse comparison
|
117
|
+
result_reverse = self.version_manager.compare_versions(release_version, dev_version)
|
118
|
+
self.assertEqual(result_reverse, VersionComparison.LESS)
|
119
|
+
|
120
|
+
def test_development_version_compatibility(self):
|
121
|
+
"""Test version compatibility with development version"""
|
122
|
+
version_manager = VersionManager()
|
123
|
+
version_manager.set_backend_version("999.0.0") # Development version
|
124
|
+
|
125
|
+
# Development version should be compatible with any required version
|
126
|
+
test_requirements = ["1.0.0", "2.5.0", "3.0.0", "10.0.0", "99.99.99"]
|
127
|
+
|
128
|
+
for required_version in test_requirements:
|
129
|
+
with self.subTest(required=required_version):
|
130
|
+
# Test >= operator
|
131
|
+
self.assertTrue(version_manager.is_version_compatible(required_version, operator=">="))
|
132
|
+
# Test > operator
|
133
|
+
self.assertTrue(version_manager.is_version_compatible(required_version, operator=">"))
|
134
|
+
# Test == operator
|
135
|
+
self.assertFalse(version_manager.is_version_compatible(required_version, operator="=="))
|
136
|
+
|
137
|
+
def test_feature_availability_with_development_version(self):
|
138
|
+
"""Test feature availability checking with development version"""
|
139
|
+
from matrixone.version import FeatureRequirement
|
140
|
+
|
141
|
+
version_manager = VersionManager()
|
142
|
+
version_manager.set_backend_version("999.0.0") # Development version
|
143
|
+
|
144
|
+
# Register a feature with high version requirement
|
145
|
+
feature = FeatureRequirement(
|
146
|
+
feature_name="future_feature",
|
147
|
+
min_version=VersionInfo(10, 0, 0),
|
148
|
+
description="Future feature requiring version 10.0.0+",
|
149
|
+
)
|
150
|
+
version_manager.register_feature_requirement(feature)
|
151
|
+
|
152
|
+
# Development version should have all features available
|
153
|
+
self.assertTrue(version_manager.is_feature_available("future_feature"))
|
154
|
+
|
155
|
+
# Test with a feature that has maximum version constraint
|
156
|
+
# Note: Development version (999.0.0) is higher than any realistic max version
|
157
|
+
# so it should NOT have access to features with max version constraints
|
158
|
+
feature_with_max = FeatureRequirement(
|
159
|
+
feature_name="legacy_feature",
|
160
|
+
max_version=VersionInfo(5, 0, 0),
|
161
|
+
description="Legacy feature only available up to version 5.0.0",
|
162
|
+
)
|
163
|
+
version_manager.register_feature_requirement(feature_with_max)
|
164
|
+
|
165
|
+
# Development version should NOT have access to features with max version constraints
|
166
|
+
# because 999.0.0 > 5.0.0
|
167
|
+
self.assertFalse(version_manager.is_feature_available("legacy_feature"))
|
168
|
+
|
169
|
+
def test_version_display_strings(self):
|
170
|
+
"""Test version display and string representation"""
|
171
|
+
# Test development version display
|
172
|
+
dev_version = VersionInfo(999, 0, 0)
|
173
|
+
self.assertEqual(str(dev_version), "999.0.0")
|
174
|
+
|
175
|
+
# Test regular version display
|
176
|
+
regular_version = VersionInfo(3, 0, 1)
|
177
|
+
self.assertEqual(str(regular_version), "3.0.1")
|
178
|
+
|
179
|
+
|
180
|
+
class TestClientVersionDetection(unittest.TestCase):
|
181
|
+
"""Test client version detection methods"""
|
182
|
+
|
183
|
+
def test_parse_matrixone_version_method(self):
|
184
|
+
"""Test the _parse_matrixone_version method directly"""
|
185
|
+
# This would normally be tested through the client, but we can test the logic
|
186
|
+
import re
|
187
|
+
|
188
|
+
def parse_matrixone_version(version_string: str) -> Optional[str]:
|
189
|
+
"""Simulate the client's version parsing logic"""
|
190
|
+
if not version_string:
|
191
|
+
return None
|
192
|
+
|
193
|
+
# Pattern 1: Development version "8.0.30-MatrixOne-v" (v后面为空)
|
194
|
+
dev_pattern = r'(\d+\.\d+\.\d+)-MatrixOne-v$'
|
195
|
+
dev_match = re.search(dev_pattern, version_string.strip())
|
196
|
+
if dev_match:
|
197
|
+
return "999.0.0"
|
198
|
+
|
199
|
+
# Pattern 2: Release version "8.0.30-MatrixOne-v3.0.0" (v后面有版本号)
|
200
|
+
release_pattern = r'(\d+\.\d+\.\d+)-MatrixOne-v(\d+\.\d+\.\d+)'
|
201
|
+
release_match = re.search(release_pattern, version_string.strip())
|
202
|
+
if release_match:
|
203
|
+
return release_match.group(2)
|
204
|
+
|
205
|
+
# Pattern 3: Fallback format
|
206
|
+
fallback_pattern = r'(\d+\.\d+\.\d+)'
|
207
|
+
fallback_match = re.search(fallback_pattern, version_string)
|
208
|
+
if fallback_match:
|
209
|
+
return fallback_match.group(1)
|
210
|
+
|
211
|
+
return None
|
212
|
+
|
213
|
+
# Test cases
|
214
|
+
test_cases = [
|
215
|
+
("8.0.30-MatrixOne-v", "999.0.0"),
|
216
|
+
("8.0.30-MatrixOne-v3.0.0", "3.0.0"),
|
217
|
+
("MatrixOne 3.0.1", "3.0.1"),
|
218
|
+
("", None),
|
219
|
+
("invalid", None),
|
220
|
+
]
|
221
|
+
|
222
|
+
for version_string, expected in test_cases:
|
223
|
+
with self.subTest(version=version_string):
|
224
|
+
result = parse_matrixone_version(version_string)
|
225
|
+
self.assertEqual(result, expected)
|
226
|
+
|
227
|
+
|
228
|
+
def run_tests():
|
229
|
+
"""Run all tests"""
|
230
|
+
# Create test suite
|
231
|
+
test_suite = unittest.TestSuite()
|
232
|
+
|
233
|
+
# Add test classes
|
234
|
+
test_classes = [TestMatrixOneVersionParsing, TestClientVersionDetection]
|
235
|
+
|
236
|
+
for test_class in test_classes:
|
237
|
+
tests = unittest.TestLoader().loadTestsFromTestCase(test_class)
|
238
|
+
test_suite.addTests(tests)
|
239
|
+
|
240
|
+
# Run tests
|
241
|
+
runner = unittest.TextTestRunner(verbosity=2)
|
242
|
+
result = runner.run(test_suite)
|
243
|
+
|
244
|
+
return result.wasSuccessful()
|
245
|
+
|
246
|
+
|
247
|
+
if __name__ == "__main__":
|
248
|
+
print("MatrixOne Python SDK - MatrixOne Version Parsing Test Suite")
|
249
|
+
print("=" * 60)
|
250
|
+
|
251
|
+
success = run_tests()
|
252
|
+
|
253
|
+
if success:
|
254
|
+
print("\n✓ All MatrixOne version parsing tests passed!")
|
255
|
+
print("\nMatrixOne Version Parsing Features:")
|
256
|
+
print("✓ Development version parsing (8.0.30-MatrixOne-v -> 999.0.0)")
|
257
|
+
print("✓ Release version parsing (8.0.30-MatrixOne-v3.0.0 -> 3.0.0)")
|
258
|
+
print("✓ Fallback version parsing (MatrixOne 3.0.1 -> 3.0.1)")
|
259
|
+
print("✓ Development version has highest priority")
|
260
|
+
print("✓ Development version compatibility with all features")
|
261
|
+
print("✓ Proper error handling for invalid versions")
|
262
|
+
else:
|
263
|
+
print("\n✗ Some tests failed!")
|
264
|
+
sys.exit(1)
|