Auto-format: Fix code style for CI compliance

🤖 Automated formatting applied by CI test script
- Ensures 100% compliance with Python style guidelines
- No functional changes, only formatting improvements

Generated by: run_complete_ci_test.sh
pull/22551/head
yunqiqiliang 10 months ago
parent 0985b54e0f
commit 18230d12f9

@ -187,4 +187,4 @@ Clickzetta supports advanced full-text search with multiple analyzers:
- [Clickzetta Vector Search Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/vector-search.md) - [Clickzetta Vector Search Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/vector-search.md)
- [Clickzetta Inverted Index Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/inverted-index.md) - [Clickzetta Inverted Index Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/inverted-index.md)
- [Clickzetta SQL Functions](../../../../../../../yunqidoc/cn_markdown_20250526/sql_functions/) - [Clickzetta SQL Functions](../../../../../../../yunqidoc/cn_markdown_20250526/sql_functions/)

@ -22,4 +22,4 @@ pytest api/tests/integration_tests/vdb/clickzetta/
## Security Note ## Security Note
Never commit credentials to the repository. Always use environment variables or secure credential management systems. Never commit credentials to the repository. Always use environment variables or secure credential management systems.

@ -150,7 +150,7 @@ class TestClickzettaVector(AbstractVectorTest):
batch_size = 25 batch_size = 25
documents = [] documents = []
embeddings = [] embeddings = []
for i in range(batch_size): for i in range(batch_size):
doc = Document( doc = Document(
page_content=f"Batch document {i}: This is a test document for batch processing.", page_content=f"Batch document {i}: This is a test document for batch processing.",
@ -182,7 +182,7 @@ class TestClickzettaVector(AbstractVectorTest):
metadata={"doc_id": "special_doc", "test": "edge_case"} metadata={"doc_id": "special_doc", "test": "edge_case"}
) )
embeddings = [[0.1, 0.2, 0.3, 0.4]] embeddings = [[0.1, 0.2, 0.3, 0.4]]
vector_store.add_texts(documents=[special_doc], embeddings=embeddings) vector_store.add_texts(documents=[special_doc], embeddings=embeddings)
assert vector_store.text_exists("special_doc") assert vector_store.text_exists("special_doc")
@ -215,9 +215,9 @@ class TestClickzettaVector(AbstractVectorTest):
metadata={"doc_id": "en_doc_2", "lang": "english"} metadata={"doc_id": "en_doc_2", "lang": "english"}
), ),
] ]
embeddings = [[0.1, 0.2, 0.3, 0.4] for _ in documents] embeddings = [[0.1, 0.2, 0.3, 0.4] for _ in documents]
vector_store.create(texts=documents, embeddings=embeddings) vector_store.create(texts=documents, embeddings=embeddings)
# Test Chinese full-text search # Test Chinese full-text search

@ -22,18 +22,18 @@ def test_clickzetta_connection():
vcluster=os.getenv("CLICKZETTA_VCLUSTER", "default"), vcluster=os.getenv("CLICKZETTA_VCLUSTER", "default"),
database=os.getenv("CLICKZETTA_SCHEMA", "dify") database=os.getenv("CLICKZETTA_SCHEMA", "dify")
) )
with conn.cursor() as cursor: with conn.cursor() as cursor:
# Test basic connectivity # Test basic connectivity
cursor.execute("SELECT 1 as test") cursor.execute("SELECT 1 as test")
result = cursor.fetchone() result = cursor.fetchone()
print(f"✓ Connection test: {result}") print(f"✓ Connection test: {result}")
# Check if our test table exists # Check if our test table exists
cursor.execute("SHOW TABLES IN dify") cursor.execute("SHOW TABLES IN dify")
tables = cursor.fetchall() tables = cursor.fetchall()
print(f"✓ Existing tables: {[t[1] for t in tables if t[0] == 'dify']}") print(f"✓ Existing tables: {[t[1] for t in tables if t[0] == 'dify']}")
# Check if test collection exists # Check if test collection exists
test_collection = "collection_test_dataset" test_collection = "collection_test_dataset"
if test_collection in [t[1] for t in tables if t[0] == 'dify']: if test_collection in [t[1] for t in tables if t[0] == 'dify']:
@ -42,14 +42,14 @@ def test_clickzetta_connection():
print(f"✓ Table structure for {test_collection}:") print(f"✓ Table structure for {test_collection}:")
for col in columns: for col in columns:
print(f" - {col[0]}: {col[1]}") print(f" - {col[0]}: {col[1]}")
# Check for indexes # Check for indexes
cursor.execute(f"SHOW INDEXES IN dify.{test_collection}") cursor.execute(f"SHOW INDEXES IN dify.{test_collection}")
indexes = cursor.fetchall() indexes = cursor.fetchall()
print(f"✓ Indexes on {test_collection}:") print(f"✓ Indexes on {test_collection}:")
for idx in indexes: for idx in indexes:
print(f" - {idx}") print(f" - {idx}")
return True return True
except Exception as e: except Exception as e:
print(f"✗ Connection test failed: {e}") print(f"✗ Connection test failed: {e}")
@ -59,7 +59,7 @@ def test_dify_api():
"""Test Dify API with Clickzetta backend""" """Test Dify API with Clickzetta backend"""
print("\n=== Testing Dify API ===") print("\n=== Testing Dify API ===")
base_url = "http://localhost:5001" base_url = "http://localhost:5001"
# Wait for API to be ready # Wait for API to be ready
max_retries = 30 max_retries = 30
for i in range(max_retries): for i in range(max_retries):
@ -73,7 +73,7 @@ def test_dify_api():
print("✗ Dify API is not responding") print("✗ Dify API is not responding")
return False return False
time.sleep(2) time.sleep(2)
# Check vector store configuration # Check vector store configuration
try: try:
# This is a simplified check - in production, you'd use proper auth # This is a simplified check - in production, you'd use proper auth
@ -86,47 +86,47 @@ def test_dify_api():
def verify_table_structure(): def verify_table_structure():
"""Verify the table structure meets Dify requirements""" """Verify the table structure meets Dify requirements"""
print("\n=== Verifying Table Structure ===") print("\n=== Verifying Table Structure ===")
expected_columns = { expected_columns = {
"id": "VARCHAR", "id": "VARCHAR",
"page_content": "VARCHAR", "page_content": "VARCHAR",
"metadata": "VARCHAR", # JSON stored as VARCHAR in Clickzetta "metadata": "VARCHAR", # JSON stored as VARCHAR in Clickzetta
"vector": "ARRAY<FLOAT>" "vector": "ARRAY<FLOAT>"
} }
expected_metadata_fields = [ expected_metadata_fields = [
"doc_id", "doc_id",
"doc_hash", "doc_hash",
"document_id", "document_id",
"dataset_id" "dataset_id"
] ]
print("✓ Expected table structure:") print("✓ Expected table structure:")
for col, dtype in expected_columns.items(): for col, dtype in expected_columns.items():
print(f" - {col}: {dtype}") print(f" - {col}: {dtype}")
print("\n✓ Required metadata fields:") print("\n✓ Required metadata fields:")
for field in expected_metadata_fields: for field in expected_metadata_fields:
print(f" - {field}") print(f" - {field}")
print("\n✓ Index requirements:") print("\n✓ Index requirements:")
print(" - Vector index (HNSW) on 'vector' column") print(" - Vector index (HNSW) on 'vector' column")
print(" - Full-text index on 'page_content' (optional)") print(" - Full-text index on 'page_content' (optional)")
print(" - Functional index on metadata->>'$.doc_id' (recommended)") print(" - Functional index on metadata->>'$.doc_id' (recommended)")
print(" - Functional index on metadata->>'$.document_id' (recommended)") print(" - Functional index on metadata->>'$.document_id' (recommended)")
return True return True
def main(): def main():
"""Run all tests""" """Run all tests"""
print("Starting Clickzetta integration tests for Dify Docker\n") print("Starting Clickzetta integration tests for Dify Docker\n")
tests = [ tests = [
("Direct Clickzetta Connection", test_clickzetta_connection), ("Direct Clickzetta Connection", test_clickzetta_connection),
("Dify API Status", test_dify_api), ("Dify API Status", test_dify_api),
("Table Structure Verification", verify_table_structure), ("Table Structure Verification", verify_table_structure),
] ]
results = [] results = []
for test_name, test_func in tests: for test_name, test_func in tests:
try: try:
@ -135,21 +135,21 @@ def main():
except Exception as e: except Exception as e:
print(f"\n{test_name} crashed: {e}") print(f"\n{test_name} crashed: {e}")
results.append((test_name, False)) results.append((test_name, False))
# Summary # Summary
print("\n" + "="*50) print("\n" + "="*50)
print("Test Summary:") print("Test Summary:")
print("="*50) print("="*50)
passed = sum(1 for _, success in results if success) passed = sum(1 for _, success in results if success)
total = len(results) total = len(results)
for test_name, success in results: for test_name, success in results:
status = "✅ PASSED" if success else "❌ FAILED" status = "✅ PASSED" if success else "❌ FAILED"
print(f"{test_name}: {status}") print(f"{test_name}: {status}")
print(f"\nTotal: {passed}/{total} tests passed") print(f"\nTotal: {passed}/{total} tests passed")
if passed == total: if passed == total:
print("\n🎉 All tests passed! Clickzetta is ready for Dify Docker deployment.") print("\n🎉 All tests passed! Clickzetta is ready for Dify Docker deployment.")
print("\nNext steps:") print("\nNext steps:")

Loading…
Cancel
Save