-
Notifications
You must be signed in to change notification settings - Fork 22
Add SearchIndex and VectorSearchIndex #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
echo "Starting the container" | ||
|
||
IMAGE=${1:-mongodb/mongodb-atlas-local:latest} | ||
DOCKER=$(which docker || which podman) | ||
|
||
$DOCKER pull $IMAGE | ||
|
||
$DOCKER kill mongodb_atlas_local || true | ||
|
||
CONTAINER_ID=$($DOCKER run --rm -d --name mongodb_atlas_local -p 27017:27017 $IMAGE) | ||
|
||
function wait() { | ||
CONTAINER_ID=$1 | ||
echo "waiting for container to become healthy..." | ||
$DOCKER logs mongodb_atlas_local | ||
} | ||
|
||
wait "$CONTAINER_ID" | ||
|
||
# Sleep for a bit to let all services start. | ||
sleep 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Python Tests on Atlas | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**.py' | ||
- '!setup.py' | ||
- '.github/workflows/test-python-atlas.yml' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -eux {0} | ||
|
||
jobs: | ||
build: | ||
name: Django Test Suite | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout django-mongodb-backend | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: install django-mongodb-backend | ||
run: | | ||
pip3 install --upgrade pip | ||
pip3 install -e . | ||
- name: Checkout Django | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'mongodb-forks/django' | ||
ref: 'mongodb-5.2.x' | ||
path: 'django_repo' | ||
persist-credentials: false | ||
- name: Install system packages for Django's Python test dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libmemcached-dev | ||
- name: Install Django and its Python test dependencies | ||
run: | | ||
cd django_repo/tests/ | ||
pip3 install -e .. | ||
pip3 install -r requirements/py3.txt | ||
- name: Copy the test settings file | ||
run: cp .github/workflows/mongodb_settings.py django_repo/tests/ | ||
- name: Copy the test runner file | ||
run: cp .github/workflows/runtests.py django_repo/tests/runtests_.py | ||
- name: Start local Atlas | ||
working-directory: . | ||
run: bash .github/workflows/start_local_atlas.sh mongodb/mongodb-atlas-local:7 | ||
- name: Run tests | ||
run: python3 django_repo/tests/runtests_.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from itertools import chain | ||
|
||
from django.apps import apps | ||
from django.core.checks import Tags, register | ||
from django.db import connections, router | ||
|
||
|
||
def check_indexes(app_configs, databases=None, **kwargs): # noqa: ARG001 | ||
""" | ||
Call Index.check() on all model indexes. | ||
|
||
This function will be obsolete when Django calls Index.check() after | ||
https://code.djangoproject.com/ticket/36273. | ||
""" | ||
errors = [] | ||
if app_configs is None: | ||
models = apps.get_models() | ||
else: | ||
models = chain.from_iterable(app_config.get_models() for app_config in app_configs) | ||
for model in models: | ||
for db in databases or (): | ||
if not router.allow_migrate_model(db, model): | ||
continue | ||
connection = connections[db] | ||
for model_index in model._meta.indexes: | ||
if hasattr(model_index, "check"): | ||
errors.extend(model_index.check(model, connection)) | ||
return errors | ||
|
||
|
||
def register_checks(): | ||
register(check_indexes, Tags.models) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.