Skip to content

Commit e4e4f6d

Browse files
authored
Made sdist/wheel 99.7% smaller (#39)
* Made sdist/wheel 99.7% smaller * Linter * Removed `lite` tests * Removed pq-dim test * Updated test workflow * Updated test workflow
1 parent 93e00b1 commit e4e4f6d

File tree

8 files changed

+63
-190
lines changed

8 files changed

+63
-190
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -82,49 +82,6 @@ jobs:
8282
# Install optional test dependencies
8383
pip install langchain langchain-community langchain-core sentence-transformers requests
8484
85-
- name: Test with Lite version
86-
run: |
87-
echo "=== Testing with Lite version ==="
88-
# Set up environment for Lite
89-
export CYBORGDB_API_KEY="${{ secrets.CYBORGDB_FREE_API_KEY }}"
90-
export CYBORGDB_DB_TYPE=postgres
91-
export CYBORGDB_CONNECTION_STRING="host=localhost port=5432 dbname=cyborgdb user=postgres password=postgres"
92-
export CYBORGDB_SERVICE_LOG_LEVEL=DEBUG
93-
94-
# Start the service with Lite API key
95-
nohup cyborgdb-service > server-lite.log 2>&1 &
96-
echo $! > server-lite.pid
97-
98-
# Wait for service to be ready
99-
for i in {1..30}; do
100-
if curl -fs http://localhost:8000/v1/health > /dev/null; then
101-
echo "Lite service is up!"
102-
break
103-
fi
104-
sleep 1
105-
done
106-
107-
if ! curl -fs http://localhost:8000/v1/health > /dev/null; then
108-
echo "Lite service failed to start"
109-
cat server-lite.log
110-
exit 1
111-
fi
112-
113-
# Run lite-compatible tests
114-
# pytest tests/test_client_lite.py tests/test_langchain_integration.py -v --cov=cyborgdb --cov-report=term-missing --cov-append
115-
pytest tests/test_client_lite.py -v --cov=cyborgdb --cov-report=term-missing --cov-append
116-
117-
# Stop lite server
118-
kill $(cat server-lite.pid) || true
119-
120-
# Remove cyborgdb-lite
121-
pip uninstall -y cyborgdb-lite
122-
123-
# Clean up PostgreSQL database to avoid conflicts between lite and standard
124-
PGPASSWORD=postgres psql -h localhost -U postgres -d cyborgdb -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
125-
126-
sleep 2
127-
12885
- name: Test with Standard version
12986
run: |
13087
echo "=== Testing with Standard version ==="
@@ -153,8 +110,12 @@ jobs:
153110
exit 1
154111
fi
155112
156-
# Run all tests (full version tests will run, lite tests will also work)
113+
# Run all tests
114+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
115+
pytest tests/quick_flow_test.py -v --cov=cyborgdb --cov-report=term-missing --cov-append
116+
else
157117
pytest tests/ -v --cov=cyborgdb --cov-report=term-missing --cov-append --ignore=tests/test_api_contract.py
118+
fi
158119
159120
# Store the server pid for later cleanup
160121
echo "Standard server PID: $(cat server-standard.pid)"
@@ -167,9 +128,6 @@ jobs:
167128
168129
- name: Kill Server
169130
run: |
170-
if [ -f server-lite.pid ]; then
171-
kill $(cat server-lite.pid) || true
172-
fi
173131
if [ -f server-standard.pid ]; then
174132
kill $(cat server-standard.pid) || true
175133
fi

MANIFEST.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include README.md LICENSE pyproject.toml
2+
recursive-include cyborgdb *.py py.typed
3+
4+
# Exclude everything else
5+
prune tests
6+
prune .github
7+
prune .openapi-generator
8+
global-exclude .gitignore
9+
global-exclude CODEOWNERS
10+
global-exclude *.json
11+
global-exclude *.sh
12+
exclude .openapi-generator-ignore
13+
exclude openapi.json
14+
exclude update-openapi-client.sh
15+
exclude CODEOWNERS

pyproject.toml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "Python Client SDK for CyborgDB: The Confidential Vector Database"
99
readme = "README.md"
1010
requires-python = ">= 3.10"
11-
license = {text = "MIT"}
11+
license = "MIT"
1212
authors = [
1313
{name = "Cyborg Inc."}
1414
]
@@ -53,6 +53,25 @@ langchain = [
5353
[tool.setuptools.packages.find]
5454
where = ["."]
5555
include = ["cyborgdb*"]
56+
exclude = ["tests*", "*.tests*", "*.tests"]
57+
58+
[tool.setuptools]
59+
# Exclude files from source distribution
60+
include-package-data = false
61+
62+
[tool.setuptools.package-data]
63+
cyborgdb = ["py.typed"]
64+
65+
[tool.setuptools.exclude-package-data]
66+
"*" = [
67+
"tests/*",
68+
".github/*",
69+
".openapi-generator/*",
70+
"*.json",
71+
"*.sh",
72+
".gitignore",
73+
"CODEOWNERS",
74+
]
5675

5776
[tool.setuptools_scm]
5877
version_scheme = "guess-next-dev"

tests/comprehensive_test.py

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,29 +205,27 @@ def test_ivfpq_index_creation_and_operations(self):
205205
query_vector = self.test_vectors[0]
206206
results = self.index.query(query_vectors=[query_vector], top_k=5)
207207

208-
209-
210208
self.assertGreater(len(results[0]), 0)
211209
self.assertTrue("id" in results[0])
212210

213-
def test_ivfpq_parameter_validation(self):
214-
"""Test IVFPQ parameter validation"""
215-
# Test invalid pq_dim = 0
216-
invalid_config = cyborgdb.IndexIVFPQ(
217-
dimension=self.dimension, pq_dim=0, pq_bits=8
218-
)
211+
# def test_ivfpq_parameter_validation(self):
212+
# """Test IVFPQ parameter validation"""
213+
# # Test invalid pq_dim = 0
214+
# invalid_config = cyborgdb.IndexIVFPQ(
215+
# dimension=self.dimension, pq_dim=0, pq_bits=8
216+
# )
219217

220-
with self.assertRaises(Exception) as context:
221-
invalid_index = self.client.create_index(
222-
generate_unique_name(),
223-
self.client.generate_key(),
224-
invalid_config,
225-
metric="euclidean",
226-
)
227-
invalid_index.delete_index()
218+
# with self.assertRaises(Exception) as context:
219+
# invalid_index = self.client.create_index(
220+
# generate_unique_name(),
221+
# self.client.generate_key(),
222+
# invalid_config,
223+
# metric="euclidean",
224+
# )
225+
# invalid_index.delete_index()
228226

229-
# Verify the error is about pq_dim
230-
self.assertIn("pq_dim", str(context.exception).lower())
227+
# # Verify the error is about pq_dim
228+
# self.assertIn("pq_dim", str(context.exception).lower())
231229

232230

233231
class TestErrorHandling(unittest.TestCase):
@@ -394,7 +392,7 @@ def test_mismatched_parameter_lengths(self):
394392

395393
# Test with empty items list
396394
with self.assertRaises(Exception):
397-
result = self.index.upsert([])
395+
self.index.upsert([])
398396

399397
def test_content_preservation_through_operations(self):
400398
"""Test that content is preserved through various operations"""
@@ -468,7 +466,7 @@ async def concurrent_upsert():
468466

469467

470468
class TestBackendCompatibility(unittest.TestCase):
471-
"""Test backend compatibility (Lite vs Full)"""
469+
"""Test backend compatibility"""
472470

473471
def setUp(self):
474472
self.client = create_client()
@@ -490,12 +488,6 @@ def tearDown(self):
490488
except Exception:
491489
pass
492490

493-
def test_lite_backend_compatibility(self):
494-
"""Test operations with lite backend"""
495-
client = create_client()
496-
health = client.get_health()
497-
self.assertIsInstance(health, (dict, bool, str, type(None)))
498-
499491
def test_feature_availability_differences(self):
500492
"""Test feature availability between backend variants"""
501493
client = create_client()

tests/test_api_contract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,7 @@ def test_15_encrypted_index_query(self):
708708

709709
self.assertIsInstance(results, list)
710710
# Single query returns flat list of results
711-
self.assertGreater(
712-
len(results), 0, "Query should return at least one result"
713-
)
711+
self.assertGreater(len(results), 0, "Query should return at least one result")
714712

715713
# Check exact structure with default include - id is always included, plus distance and metadata by default
716714
for result in results:
@@ -823,7 +821,9 @@ def test_16_encrypted_index_query_patterns(self):
823821
self.assertIsInstance(results, list)
824822
self.assertGreater(len(results), 0, "Should have results for single query")
825823
if len(results) > 0:
826-
self.assertIsInstance(results[0], dict, "Single query should return flat list of dicts")
824+
self.assertIsInstance(
825+
results[0], dict, "Single query should return flat list of dicts"
826+
)
827827
self.assertIn("id", results[0])
828828
self.assertIn("distance", results[0])
829829

tests/test_client.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ def setUp(self):
3333
self.index = self.client.create_index(
3434
self.index_name, self.test_key, self.index_config, metric="euclidean"
3535
)
36-
# except Exception as e:
37-
# # If IndexIVF fails (likely using lite backend), skip these tests
38-
# if "cyborgdb_lite" in str(e) or "IndexIVF" in str(e):
39-
# self.skipTest(
40-
# "Server is using lite backend, skipping full version tests"
41-
# )
42-
# raise
4336

4437
def tearDown(self):
4538
"""Clean up after tests."""

tests/test_client_lite.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

tests/test_demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ def test_get_demo_api_key_connection_error(self, mock_post):
159159
# Mock connection error
160160
import requests
161161

162-
mock_post.side_effect = requests.exceptions.ConnectionError(
163-
"Failed to connect"
164-
)
162+
mock_post.side_effect = requests.exceptions.ConnectionError("Failed to connect")
165163

166164
# Call the function and expect ValueError
167165
with self.assertRaises(ValueError) as context:

0 commit comments

Comments
 (0)