Skip to content

Commit

Permalink
adding new management command for creating collections and fixing ini…
Browse files Browse the repository at this point in the history
…t script (#1911)
  • Loading branch information
shanbady authored Dec 19, 2024
1 parent cbad97b commit b37acc1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docker-compose.apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
condition: service_healthy
redis:
condition: service_healthy
qdrant:
condition: service_healthy
volumes:
- .:/src
- django_media:/var/media
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ services:
- "6333:6333"
volumes:
- qdrant-data:/qdrant/storage
healthcheck:
test: ["CMD", "cat", ".qdrant-initialized"]
interval: 1s
timeout: 3s
retries: 10
nginx:
profiles:
- backend
Expand Down
5 changes: 4 additions & 1 deletion scripts/run-django-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ RUN_DATA_MIGRATIONS=true python3 manage.py migrate --noinput
echo "Loading fixtures!"
python3 manage.py loaddata platforms schools departments offered_by

# create initial qdrant collections
python manage.py create_qdrant_collections

# consolidate user subscriptions and remove duplicate percolate instances
python $MANAGE_FILE prune_subscription_queries 2>&1 | indent
python manage.py prune_subscription_queries 2>&1

uwsgi uwsgi.ini --honour-stdin
33 changes: 33 additions & 0 deletions vector_search/management/commands/create_qdrant_collections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Management command to create Qdrant collections"""

from django.core.management.base import BaseCommand

from vector_search.utils import (
create_qdrand_collections,
)


class Command(BaseCommand):
"""Creates Qdrant collections"""

help = "Create Qdrant collections"

def add_arguments(self, parser):
parser.add_argument(
"--force",
dest="force",
action="store_true",
help="delete existing collections and force recreate",
)

super().add_arguments(parser)

def handle(self, *args, **options): # noqa: ARG002
"""Create Qdrant collections"""

if options["force"]:
create_qdrand_collections(force_recreate=True)
else:
create_qdrand_collections(force_recreate=False)

self.stdout.write("Created Qdrant collections")

0 comments on commit b37acc1

Please sign in to comment.