Skip to main content
Glama
AWS_IRIS_VECTORDB_CLIENT_GUIDE.md8.89 kB
# Quick Start: IRISVectorDBClient with AWS IRIS **Last Updated**: December 12, 2025 **Status**: ✅ Production Ready ## TL;DR Use the existing `IRISVectorDBClient` abstraction with AWS IRIS - it handles all vector SQL syntax automatically. ```python from src.vectorization.vector_db_client import IRISVectorDBClient # Connect to AWS IRIS client = IRISVectorDBClient( host="3.84.250.46", port=1972, namespace="%SYS", # Use %SYS (DEMO has access restrictions) username="_SYSTEM", password="SYS", vector_dimension=1024 ) with client: # Insert - no manual TO_VECTOR() needed client.insert_vector( resource_id="doc-001", embedding=embedding_list, table_name="SQLUser.ClinicalNoteVectors" # Fully qualified ) # Search - no manual VECTOR_COSINE() needed results = client.search_similar( query_vector=query_list, table_name="SQLUser.ClinicalNoteVectors" ) ``` ## Why This Approach? ### ✅ Benefits - **No Manual SQL**: Client handles `TO_VECTOR()` and `VECTOR_COSINE()` syntax - **Dimension Validation**: Automatic checking and clear error messages - **Clean Python API**: Pass Python lists, not SQL strings - **Works Everywhere**: Same code for local and AWS - **Type Safety**: Proper error handling and validation ### ❌ Don't Do This ```python # Manual SQL approach (error-prone) vector_str = ','.join(map(str, embedding)) sql = f"INSERT ... VALUES (TO_VECTOR('{vector_str}', DOUBLE, 1024), ...)" cursor.execute(sql) # SQL injection risk, no validation ``` ## Critical Detail: Namespace Access ### Problem AWS IRIS Community Edition has different namespace permissions: - `%SYS` namespace: ✅ Full access for _SYSTEM user - `DEMO` namespace: ❌ Access denied (requires additional setup) ### Solution Connect to `%SYS`, use fully qualified table names: ```python namespace="%SYS" # Not "DEMO" table_name="SQLUser.ClinicalNoteVectors" # Fully qualified ``` ### How It Works IRISVectorDBClient builds: `%SYS.SQLUser.ClinicalNoteVectors` IRIS interprets as: `SQLUser.ClinicalNoteVectors` ✓ ## Complete Working Example ### Full Integration Test **Script**: `scripts/aws/test-iris-vector-client-aws.py` ```python #!/usr/bin/env python3 import os import requests from src.vectorization.vector_db_client import IRISVectorDBClient def get_nvidia_embedding(text, api_key): """Get 1024-dim embedding from NVIDIA NIM API""" response = requests.post( "https://integrate.api.nvidia.com/v1/embeddings", headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" }, json={ "input": [text], "model": "nvidia/nv-embedqa-e5-v5", "input_type": "query" } ) return response.json()['data'][0]['embedding'] def main(): api_key = os.getenv('NVIDIA_API_KEY') # Test data notes = [ {"id": "001", "text": "Patient with acute chest pain..."}, {"id": "002", "text": "Cardiac catheterization performed..."} ] # Generate embeddings for note in notes: note['embedding'] = get_nvidia_embedding(note['text'], api_key) # Connect to AWS IRIS client = IRISVectorDBClient( host="3.84.250.46", port=1972, namespace="%SYS", username="_SYSTEM", password="SYS", vector_dimension=1024 ) with client: # Insert vectors for note in notes: client.insert_vector( resource_id=note['id'], patient_id=f"PATIENT_{note['id']}", document_type="Clinical Note", text_content=note['text'], embedding=note['embedding'], embedding_model="nvidia/nv-embedqa-e5-v5", table_name="SQLUser.ClinicalNoteVectors" ) # Search query = "chest pain" query_embedding = get_nvidia_embedding(query, api_key) results = client.search_similar( query_vector=query_embedding, top_k=2, table_name="SQLUser.ClinicalNoteVectors" ) # Display results for i, result in enumerate(results, 1): print(f"{i}. {result['resource_id']}: {result['similarity']:.3f}") if __name__ == '__main__': main() ``` ### Run The Test ```bash export NVIDIA_API_KEY="your-key-here" python3 scripts/aws/test-iris-vector-client-aws.py ``` ### Expected Output ``` ✅ Step 1: NVIDIA NIM embeddings generated (1024-dim) ✅ Step 2: Connected to AWS IRIS via %SYS namespace ✅ Step 3: Vectors inserted (no manual TO_VECTOR SQL) ✅ Step 4: Similarity search results: 1. 001: 0.662 similarity 2. 002: 0.483 similarity ✅ Step 5: Cleanup complete ``` ## Troubleshooting ### Connection Failed: "Access Denied" **Problem**: Trying to connect to DEMO namespace ```python namespace="DEMO" # ❌ This fails on AWS ``` **Solution**: Connect to %SYS ```python namespace="%SYS" # ✅ This works ``` ### Table Not Found **Problem**: Not using fully qualified table name ```python table_name="ClinicalNoteVectors" # ❌ May not be found ``` **Solution**: Use fully qualified name ```python table_name="SQLUser.ClinicalNoteVectors" # ✅ Always works ``` ### Dimension Mismatch **Problem**: Vector dimension doesn't match configured dimension ```python client = IRISVectorDBClient(..., vector_dimension=1024) client.insert_vector(embedding=[0.1, 0.2]) # ❌ Only 2 dims ``` **Error Message**: `ValueError: Vector dimension mismatch: expected 1024, got 2` **Solution**: Ensure embeddings match configured dimension ## Diagnostic Tool If you encounter connection issues, run the diagnostic script: ```bash ./scripts/aws/diagnose-iris-connection.sh ``` This will test: 1. Network connectivity (ports 1972 and 52773) 2. Container status (if you have SSH access) 3. Multiple connection formats 4. Namespace access permissions ## AWS IRIS Connection Details ### Instance Information - **Public IP**: 3.84.250.46 - **Instance Type**: g5.xlarge (NVIDIA A10G GPU) - **Region**: us-east-1 - **Instance ID**: i-0432eba10b98c4949 ### IRIS Ports - **SQL Port**: 1972 (for connections) - **Management Portal**: 52773 (web interface) - URL: http://3.84.250.46:52773/csp/sys/UtilHome.csp - Username: _SYSTEM - Password: SYS ### Tables Created - `SQLUser.ClinicalNoteVectors` - Text embeddings (VECTOR DOUBLE 1024) - `SQLUser.MedicalImageVectors` - Image embeddings (VECTOR DOUBLE 1024) ## Performance Expectations ### Typical Latency (MacBook → AWS us-east-1) - **NVIDIA NIM embedding**: ~500ms per text - **IRIS vector insertion**: <50ms per vector - **IRIS similarity search**: <10ms for 2 results - **Network latency**: ~100ms round-trip - **Total end-to-end**: 2-3 seconds for full pipeline ## GraphRAG Migration Now that IRISVectorDBClient works with AWS, you can migrate GraphRAG: ### 1. Update Configuration Edit `config/fhir_graphrag_config.aws.yaml`: ```yaml database: iris: host: "3.84.250.46" port: 1972 namespace: "%SYS" # Use %SYS username: "_SYSTEM" password: "SYS" table_prefix: "SQLUser." # For fully qualified names vector_storage: table_name: "SQLUser.ClinicalNoteVectors" dimension: 1024 ``` ### 2. Run GraphRAG Setup ```bash # Create knowledge graph tables python3 src/setup/fhir_graphrag_setup.py --config aws --mode=init # Extract entities python3 src/setup/fhir_graphrag_setup.py --config aws --mode=build # Query python3 src/query/fhir_graphrag_query.py "chest pain" --config aws ``` ## Related Documentation ### AWS Deployment - **Complete Deployment**: `AWS_DEPLOYMENT_COMPLETE.md` - **Integration Success**: `AWS_IRIS_CLIENT_SUCCESS.md` - **Deployment Status**: `AWS_DEPLOYMENT_STATUS.md` ### IRIS Resources - **iris-devtester Guide**: `docs/iris-devtester-for-aws.md` - **Constitution Memory**: `.specify/memory/constitution.md` (Section III, VI) ### Scripts - **Test Script**: `scripts/aws/test-iris-vector-client-aws.py` - **Diagnostic Tool**: `scripts/aws/diagnose-iris-connection.sh` - **Setup Script**: `scripts/aws/setup-iris-schema.py` ## Key Takeaways 1. ✅ **Always use IRISVectorDBClient** - Don't write manual TO_VECTOR SQL 2. ✅ **Connect to %SYS namespace** - DEMO has access restrictions on AWS 3. ✅ **Use fully qualified table names** - `SQLUser.TableName` 4. ✅ **Let the client handle vector syntax** - It's tested and validated 5. ✅ **Same code works everywhere** - Local and AWS use identical API ## Next Steps 1. **Test with Your Data**: Run the test script with your clinical notes 2. **Migrate GraphRAG**: Point to AWS configuration 3. **Production Readiness**: Add connection pooling, monitoring, backup --- **Questions?** Check the diagnostic script or AWS deployment docs. **Issues?** Verify namespace (%SYS) and table names (SQLUser.TableName).

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/isc-tdyar/medical-graphrag-assistant'

If you have feedback or need assistance with the MCP directory API, please join our Discord server