Skip to content

Commit b2cbae6

Browse files
Fix api contract workflow (#40)
* add optional dependencies and update api key * add 1password * add manual triggering for lint/test workflow * update some references to lite/standard * remove reference to unused variable `result` * remove 1password and generate demo api key * reformatted with ruff * make MockEmbeddings conditionally set * comment out failing ivfpq parameter validation test * linting * Updated workflow --------- Co-authored-by: Nico D. <44616242+dupontcyborg@users.noreply.github.com> Co-authored-by: nicolas <ndupont@cyborg.co>
1 parent e4e4f6d commit b2cbae6

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ permissions:
33
contents: read
44

55
on:
6+
workflow_dispatch:
67
pull_request:
78
types: [opened, synchronize]
89
push:
@@ -68,30 +69,43 @@ jobs:
6869
fetch-depth: 0 # Get full history for version detection
6970
fetch-tags: true # Fetch all tags
7071

72+
- name: Install service dependencies
73+
run: |
74+
# Install CPU-only torch
75+
pip install torch --index-url https://download.pytorch.org/whl/cpu
76+
# Install optional test dependencies
77+
pip install sentence-transformers
78+
7179
- name: Install cyborgdb-service from source
7280
run: |
7381
# Install the server from the cloned repository
7482
pip install ./cyborgdb-service
7583
76-
- name: Install SDK dependencies
84+
- name: Install SDK and test dependencies
7785
run: |
78-
pip install -e .
86+
pip install '.[langchain]'
7987
pip install pytest pytest-cov pytest-asyncio
80-
# Install CPU-only torch
81-
pip install torch --index-url https://download.pytorch.org/whl/cpu
82-
# Install optional test dependencies
83-
pip install langchain langchain-community langchain-core sentence-transformers requests
8488
85-
- name: Test with Standard version
89+
- name: Load Demo API Key
90+
run: |
91+
echo "=== Loading Demo API Key ==="
92+
CYBORGDB_API_KEY=$(python -c "from cyborgdb import get_demo_api_key; print(get_demo_api_key())")
93+
if [ -z "$CYBORGDB_API_KEY" ]; then
94+
echo "Failed to generate demo API key"
95+
exit 1
96+
fi
97+
echo "CYBORGDB_API_KEY=${CYBORGDB_API_KEY}" >> $GITHUB_ENV
98+
echo "Demo API key loaded successfully"
99+
100+
- name: Test
86101
run: |
87-
echo "=== Testing with Standard version ==="
102+
echo "=== Running Tests with local CyborgDB Service ==="
88103
# Set up environment for Standard
89-
export CYBORGDB_API_KEY="${{ secrets.CYBORGDB_STANDARD_API_KEY }}"
90104
export CYBORGDB_DB_TYPE=postgres
91105
export CYBORGDB_CONNECTION_STRING="host=localhost port=5432 dbname=cyborgdb user=postgres password=postgres"
92106
export CYBORGDB_SERVICE_LOG_LEVEL=DEBUG
93107
94-
# Start the service with Standard API key
108+
# Start the service
95109
nohup cyborgdb-service > server-standard.log 2>&1 &
96110
echo $! > server-standard.pid
97111

tests/test_langchain_integration.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@
2323
from langchain_core.embeddings import Embeddings
2424

2525
LANGCHAIN_AVAILABLE = True
26-
except ImportError:
27-
LANGCHAIN_AVAILABLE = False
28-
29-
# Define a dummy Embeddings class if langchain is not available
30-
class Embeddings:
31-
pass
32-
33-
34-
# Mock embedding class for testing
35-
if LANGCHAIN_AVAILABLE:
3626

27+
# Define MockEmbeddings inside the try block where Embeddings is available
3728
class MockEmbeddings(Embeddings):
3829
"""Mock embeddings for testing that generates semantically meaningful vectors."""
3930

@@ -95,6 +86,17 @@ def embed_query(self, text: str) -> List[float]:
9586
"""Generate embedding for a single query."""
9687
return self._text_to_vector(text)
9788

89+
except ImportError:
90+
LANGCHAIN_AVAILABLE = False
91+
92+
# Define a dummy Embeddings class if langchain is not available
93+
class Embeddings:
94+
pass
95+
96+
# Define a dummy MockEmbeddings that won't be used
97+
class MockEmbeddings:
98+
pass
99+
98100

99101
@unittest.skipUnless(LANGCHAIN_AVAILABLE, "LangChain dependencies not available")
100102
class TestLangChainIntegration(unittest.TestCase):

0 commit comments

Comments
 (0)