Cloud Function for Image Processing
This directory contains the source code for the Cloud Function that processes image embeddings.
Deployment
Note: This Cloud Function is now deployed via Terraform, not the previous bash script.
The Cloud Function is automatically deployed when you run:
cd deployment/terraform
terraform apply
What the Cloud Function Does
- Triggered by Pub/Sub: Listens to the
image-processing-topicfor new image processing tasks - Downloads Images: Retrieves images from Google Cloud Storage
- Generates Embeddings: Uses Google Cloud Vision API to create image embeddings
- Stores Vectors: Saves embeddings to the Qdrant vector database
- Updates Status: Updates Firestore with processing status and embedding metadata
Environment Variables
The following environment variables are automatically configured by Terraform:
QDRANT_HOST: IP address of the vector database VMQDRANT_PORT: Port for Qdrant (default: 6333)QDRANT_API_KEY: API key for Qdrant authenticationQDRANT_COLLECTION: Collection name for storing vectors (default: image_vectors)
Function Configuration
- Runtime: Python 3.11
- Memory: 512MB
- Timeout: 540 seconds (9 minutes)
- Max Instances: 10
- Min Instances: 0 (scales to zero when not in use)
- Retry Policy: Automatic retries on failure
Dependencies
See requirements.txt for the complete list of Python dependencies.
Monitoring
The function automatically logs to Google Cloud Logging. You can monitor:
- Function executions
- Error rates
- Processing times
- Pub/Sub message handling
Manual Testing
To manually trigger the function, publish a message to the Pub/Sub topic:
{
"image_id": "test-image-123",
"storage_path": "your-bucket/path/to/image.jpg",
"team_id": "team-456",
"retry_count": 0
}