Compare commits

..

63 Commits

Author SHA1 Message Date
Jina Dev Bot ad2b64a468 chore(version): the next version will be 0.0.22
build(JoanFM): release 0.0.21
2024-03-04 17:10:05 +00:00
Gabe Goodhart f0200e5872
fix: handle missing __validators__ (#68)
https://github.com/jina-ai/vectordb/issues/67

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
2024-03-04 18:06:34 +01:00
Jina Dev Bot 53cd4a54d8 chore(version): the next version will be 0.0.21
build(JoanFM): release 0.20.0
2023-10-23 10:26:51 +00:00
0x376h 5f8fc998c8
feat: dd method queryid to check id exists (#63)
* add num_docs

add num_docs

* Update test_inmemory_vectordb.py

* Update test_hnswlib_vectordb.py

* add

* add

* Update test_inmemory_vectordb.py

* change method name

* commit some miss files

* blank spaces change

* Update test_inmemory_vectordb.py

* Update test_inmemory_vectordb.py
2023-10-17 19:09:57 +02:00
Jina Dev Bot a43080813c chore(version): the next version will be 0.0.20
build(JoanFM): release 0.0.19
2023-10-08 03:17:48 +00:00
0x376h 059dc489b4
add num_docs (#62)
* add num_docs

add num_docs

* Update test_inmemory_vectordb.py

* Update test_hnswlib_vectordb.py
2023-10-08 05:16:26 +02:00
Naymul Islam a8531f61d6
improve the get_uri function with better error handling and code organization (#58)
error handling in the get_uri function is improved and hardcoded constants is refactored
2023-09-18 18:06:35 +02:00
Naymul Islam 21163e3a95
refactor the hardcoded constant and close opened file (#57)
there are some constant that are hardcoded into the code before in this commit those are at the top of the file for better code readability and there is a opened file that didn't close before in this commit that is closed
2023-09-18 14:31:45 +02:00
Jina Dev Bot 35cbf73a35 chore(version): the next version will be 0.0.19
build(JoanFM): release 0.0.18
2023-08-23 07:50:45 +00:00
Joan Fontanals a8e48b23aa
fix: fix incompatibility with Jina version (#55) 2023-08-23 09:49:30 +02:00
Jina Dev Bot 4c5f5ebc90 chore(version): the next version will be 0.0.18
build(JoanFM): release 0.0.17
2023-07-25 02:37:17 +00:00
Joan Fontanals a48f341c8f
fix: fix applying serve and deploy on instance (#53)
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-07-25 04:36:17 +02:00
Joan Fontanals e0c9921c3b
test: optout telemetry in test (#50) 2023-07-20 10:58:08 +02:00
Jina Dev Bot be1f72da50 chore(version): the next version will be 0.0.17
build(JoanFM): release 0.0.16
2023-07-19 16:34:03 +00:00
Joan Fontanals 0357cfead5
chore: fix docarray version in deploy (#49) 2023-07-19 18:33:16 +02:00
Jina Dev Bot 44856718e7 chore(version): the next version will be 0.0.16
build(JoanFM): release 0.0.15
2023-07-19 15:17:55 +00:00
Joan Fontanals 497d1ef608
fix: fix db port for deployment (#48) 2023-07-19 17:17:05 +02:00
Jina Dev Bot d3d4a43ce3 chore(version): the next version will be 0.0.15
build(JoanFM): release 0.0.14
2023-07-14 10:30:54 +00:00
Joan Fontanals 5ef1c96495
fix: fix single quotes (#47)
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-07-14 12:30:04 +02:00
Joan Fontanals Martinez 14bc575ba9 chore: upgrade version 2023-07-14 12:22:35 +02:00
Han Xiao daef4aac87
chore: fix readme 2023-07-14 12:14:13 +02:00
Han Xiao c24b8d95da chore: update readme 2023-07-14 12:05:04 +02:00
Han Xiao 6d2aa133c7 chore: update readme 2023-07-14 12:00:44 +02:00
Han Xiao 133f088fc7 chore: update readme 2023-07-14 11:58:15 +02:00
Han Xiao a3a4a720b5 chore: update readme 2023-07-14 11:50:51 +02:00
Han Xiao b3f7a04be5 chore: update readme 2023-07-14 11:48:23 +02:00
Han Xiao b2625b5632 Merge remote-tracking branch 'origin/main' 2023-07-14 11:43:21 +02:00
Han Xiao 96071d1650 chore: update readme 2023-07-14 11:43:15 +02:00
Han Xiao 9f19eb4a85
Merge pull request #46 from jina-ai/fix-readme-small
chore: fix message in readme
2023-07-14 11:38:36 +02:00
Joan Fontanals Martinez 1df0dcc090 chore: fix message in readme 2023-07-14 11:21:31 +02:00
Han Xiao d8f9ae69bf chore: update readme 2023-07-14 11:17:08 +02:00
Han Xiao 62b5d5c542
chore: update readme 2023-07-14 11:14:41 +02:00
Han Xiao 73ee9c8156 chore: update readme 2023-07-14 11:10:10 +02:00
Han Xiao 6f514b3276 chore: update readme 2023-07-14 11:05:24 +02:00
Han Xiao 85e890d46b chore: update readme 2023-07-14 11:02:47 +02:00
Han Xiao 124743f99a chore: update readme 2023-07-14 11:01:51 +02:00
Joan Fontanals ced2914085
chore: fix help message serve (#45) 2023-07-14 09:10:20 +02:00
Deepankar Mahapatro 7efdc669ac
chore: ignore warnings (#44) 2023-07-14 09:07:57 +02:00
Jina Dev Bot 8e1ab38b50 chore(version): the next version will be 0.0.12
build(JoanFM): release 0.0.11
2023-07-14 06:51:57 +00:00
Joan Fontanals e298e6ef50
chore: add MANIFEST.in (#43)
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-07-14 08:49:53 +02:00
Jina Dev Bot 790f634100 chore(version): the next version will be 0.0.11
build(JoanFM): release 0.0.10
2023-07-13 20:19:13 +00:00
Joan Fontanals d63c295930
fix: fix setup reqs (#42) 2023-07-13 22:18:16 +02:00
Jina Dev Bot 574a8968b5 chore(version): the next version will be 0.0.10
build(JoanFM): release 0.0.9
2023-07-11 15:58:32 +00:00
Deepankar Mahapatro d1d24d9bc6
ci: add tag.yml (#41) 2023-07-11 17:57:41 +02:00
Jina Dev Bot 9dc3c63e6e chore(version): the next version will be 0.0.9
build(JoanFM): release 0.0.8
2023-07-11 15:24:27 +00:00
Deepankar Mahapatro 6ca5760034
ci: revert force-release step (#40) 2023-07-11 17:23:35 +02:00
Joan Fontanals 942f1f5d43
chore: add badges to README (#39) 2023-07-11 16:41:39 +02:00
Jina Dev Bot d012a48cfe chore(version): the next version will be 0.0.8
build(JoanFM): release 0.0.6
2023-07-10 14:00:17 +00:00
Joan Fontanals 69492e0663
docs: fix README (#38) 2023-07-10 15:58:57 +02:00
Jina Dev Bot 07a8480a29 chore(version): the next version will be 0.0.7
build(JoanFM): release 0.0.6
2023-07-10 13:22:11 +00:00
Joan Fontanals cf1b6b29d5
docs: fix README (#37) 2023-07-10 15:21:18 +02:00
Jina Dev Bot ca47a292f2 chore(version): the next version will be 0.0.6
build(JoanFM): release 0.0.5
2023-07-10 10:27:06 +00:00
Joan Fontanals 16ceb6d722
chore: add long description (#36) 2023-07-10 12:26:15 +02:00
Jina Dev Bot 28ea29485d chore(version): the next version will be 0.0.5
build(JoanFM): release 0.0.4 with latest jina version
2023-07-10 09:54:55 +00:00
Joan Fontanals 39dc5f9e26
chore: update vectordb version and requirements (#35) 2023-07-10 11:53:46 +02:00
Joan Fontanals ad507a6d68
Update README.md (#34) 2023-07-05 14:41:30 +02:00
Joan Fontanals 626b534ce3
fix: do not override dry run endpoints schemas (#33) 2023-07-05 14:41:18 +02:00
Joan Fontanals 0c0627eed9
chore: some changes (#32)
* fix: fix some stuff for deployment

* docs: change README show deploy output

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>

* docs: change readme

---------

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-06-27 16:33:26 +02:00
Joan Fontanals d66ef1bd1f
fix: fix some stuff for deployment (#31)
* fix: fix some stuff for deployment

* docs: change README show deploy output

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>

---------

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-06-27 16:29:04 +02:00
Jina Dev Bot 73236ff9cf chore(version): the next version will be 0.0.3
build(JoanFM): release 0.0.2
2023-06-22 13:43:20 +00:00
Joan Fontanals 0e5fd82589
chore: update versions of Jina and DocArray (#30)
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-06-22 15:42:05 +02:00
Joan Fontanals 13f79de3cd
chore: debug test (#29)
* chore: debug test

* test: help investigate

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>

* test: add timeout

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>

* test: run integration tests split

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>

---------

Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
2023-06-22 09:29:06 +02:00
Jina Dev Bot 41b6ac954c chore(version): the next version will be 0.0.2
build(JoanFM): try release 0.0.1 for test
2023-06-19 11:06:17 +00:00
32 changed files with 843 additions and 305 deletions

BIN
.github/images/guide-1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

BIN
.github/images/guide-2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
.github/images/guide-3.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

BIN
.github/images/vectordb-logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
.github/images/vectordb_deploy_list.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -92,9 +92,7 @@ jobs:
pip install pytest-timeout
pip install flaky
pip install .
#pip install -U docarray[hnswlib]>=0.33.0
pip install git+https://github.com/jina-ai/jina.git@help-investigate
pip install git+https://github.com/docarray/docarray.git@main
pip install -U docarray[hnswlib]>=0.34.0
- name: Test
id: test
run: |
@ -126,9 +124,7 @@ jobs:
pip install pytest-timeout
pip install flaky
pip install .
#pip install -U docarray[hnswlib]>=0.33.0
pip install git+https://github.com/jina-ai/jina.git@help-investigate
pip install git+https://github.com/docarray/docarray.git@main
pip install -U docarray[hnswlib]>=0.34.0
- name: Test
id: test
run: |

View File

@ -47,7 +47,7 @@ jobs:
with:
python-version: 3.7
- run: |
git fetch --depth=200
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
npm install git-release-notes
pip install twine wheel
./scripts/release.sh final "${{ github.event.inputs.release_reason }}" "${{github.actor}}"

37
.github/workflows/tag.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Release CD
on:
push:
tags:
- "v*" # push to version tags trigger the build
#on:
# push:
# branches-ignore:
# - '**' # temporally disable this action
jobs:
create-release:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: 'main'
- uses: actions/setup-python@v2
with:
python-version: 3.7
- run: |
python scripts/get-last-release-note.py
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: 💫 Patch ${{ github.ref }}
body_path: 'tmp.md'
draft: false
prerelease: false

359
CHANGELOG.md Normal file
View File

@ -0,0 +1,359 @@
<a name=release-note-0-0-1></a>
## Release Note (`0.0.1`)
> Release time: 2023-06-19 11:05:34
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals Martinez, 🙇
### 🏁 Unit Test and CICD
- [[```a271d1a8```](https://github.com/jina-ai/jina/commit/a271d1a84b189174610183b6a49a9fe32b1e2aa5)] __-__ fix release yaml (*Joan Fontanals Martinez*)
<a name=release-note-0-0-2></a>
## Release Note (`0.0.2`)
> Release time: 2023-06-22 13:43:16
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🍹 Other Improvements
- [[```0e5fd825```](https://github.com/jina-ai/jina/commit/0e5fd82589fd8dc9f6256d9b710ad03854353096)] __-__ update versions of Jina and DocArray (#30) (*Joan Fontanals*)
- [[```13f79de3```](https://github.com/jina-ai/jina/commit/13f79de3cd384771ac886d31a7f5737fc2470f11)] __-__ debug test (#29) (*Joan Fontanals*)
- [[```41b6ac95```](https://github.com/jina-ai/jina/commit/41b6ac954c2a1965f90829ff8a3114df94884e5c)] __-__ __version__: the next version will be 0.0.2 (*Jina Dev Bot*)
<a name=release-note-0-0-4></a>
## Release Note (`0.0.4`)
> Release time: 2023-07-10 09:54:52
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```626b534c```](https://github.com/jina-ai/jina/commit/626b534ce363890b0d79fed9ec8ccd233e79112b)] __-__ do not override dry run endpoints schemas (#33) (*Joan Fontanals*)
- [[```d66ef1bd```](https://github.com/jina-ai/jina/commit/d66ef1bd1fbeb33c7fb76a306ec9b6ac81ac6673)] __-__ fix some stuff for deployment (#31) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```39dc5f9e```](https://github.com/jina-ai/jina/commit/39dc5f9e26f1028220e3f5b2d7a87cbfe2674563)] __-__ update vectordb version and requirements (#35) (*Joan Fontanals*)
- [[```ad507a6d```](https://github.com/jina-ai/jina/commit/ad507a6d685dcf7326b425edda5e456aa20097cd)] __-__ Update README.md (#34) (*Joan Fontanals*)
- [[```0c0627ee```](https://github.com/jina-ai/jina/commit/0c0627eed984a39c48fb939fb805928fff58570c)] __-__ some changes (#32) (*Joan Fontanals*)
- [[```73236ff9```](https://github.com/jina-ai/jina/commit/73236ff9cf2fe811f830955a81ab320288962b29)] __-__ __version__: the next version will be 0.0.3 (*Jina Dev Bot*)
<a name=release-note-0-0-5></a>
## Release Note (`0.0.5`)
> Release time: 2023-07-10 10:27:03
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🍹 Other Improvements
- [[```16ceb6d7```](https://github.com/jina-ai/jina/commit/16ceb6d72227aefae47b62e1ef234e6ad98b6483)] __-__ add long description (#36) (*Joan Fontanals*)
- [[```28ea2948```](https://github.com/jina-ai/jina/commit/28ea29485dcc516ed829a251388612cc664bb96a)] __-__ __version__: the next version will be 0.0.5 (*Jina Dev Bot*)
<a name=release-note-0-0-6></a>
## Release Note (`0.0.6`)
> Release time: 2023-07-10 13:22:08
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 📗 Documentation
- [[```cf1b6b29```](https://github.com/jina-ai/jina/commit/cf1b6b29d543af91cd20bf800043eee6ebf4fe53)] __-__ fix README (#37) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```ca47a292```](https://github.com/jina-ai/jina/commit/ca47a292f26a758a181a36a75e3c33a9a578ed5f)] __-__ __version__: the next version will be 0.0.6 (*Jina Dev Bot*)
<a name=release-note-0-0-7></a>
## Release Note (`0.0.7`)
> Release time: 2023-07-10 14:00:14
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 📗 Documentation
- [[```69492e06```](https://github.com/jina-ai/jina/commit/69492e0663a2d79c9500beea77c564050064ce8d)] __-__ fix README (#38) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```07a8480a```](https://github.com/jina-ai/jina/commit/07a8480a2905a8d7293f79c0668818f684bbd65d)] __-__ __version__: the next version will be 0.0.7 (*Jina Dev Bot*)
<a name=release-note-0-0-8></a>
## Release Note (`0.0.8`)
> Release time: 2023-07-11 15:24:25
🙇 We'd like to thank all contributors for this new release! In particular,
Deepankar Mahapatro, Joan Fontanals, Jina Dev Bot, 🙇
### 🏁 Unit Test and CICD
- [[```6ca57600```](https://github.com/jina-ai/jina/commit/6ca576003403bfab6d0222adbb8be7edfe812337)] __-__ revert force-release step (#40) (*Deepankar Mahapatro*)
### 🍹 Other Improvements
- [[```942f1f5d```](https://github.com/jina-ai/jina/commit/942f1f5d43c2433ecfbaa0f3ae66c90d6caa896d)] __-__ add badges to README (#39) (*Joan Fontanals*)
- [[```d012a48c```](https://github.com/jina-ai/jina/commit/d012a48cfeb79f2ffe52bf24f5a8e9f11b637f92)] __-__ __version__: the next version will be 0.0.8 (*Jina Dev Bot*)
<a name=release-note-0-0-9></a>
## Release Note (`0.0.9`)
> Release time: 2023-07-11 15:58:29
🙇 We'd like to thank all contributors for this new release! In particular,
Deepankar Mahapatro, Jina Dev Bot, 🙇
### 🏁 Unit Test and CICD
- [[```d1d24d9b```](https://github.com/jina-ai/jina/commit/d1d24d9bc6596bca2cdd055885829e345318820c)] __-__ add tag.yml (#41) (*Deepankar Mahapatro*)
### 🍹 Other Improvements
- [[```9dc3c63e```](https://github.com/jina-ai/jina/commit/9dc3c63e6e9eb8b79336194f9a52e66a77c0faef)] __-__ __version__: the next version will be 0.0.9 (*Jina Dev Bot*)
<a name=release-note-0-0-10></a>
## Release Note (`0.0.10`)
> Release time: 2023-07-13 20:19:10
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```d63c2959```](https://github.com/jina-ai/jina/commit/d63c295930d16ebfd83acafa65f4eac68cb5ad80)] __-__ fix setup reqs (#42) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```574a8968```](https://github.com/jina-ai/jina/commit/574a8968b5f11f5a2aba88c0bd4cd7bfd45b0427)] __-__ __version__: the next version will be 0.0.10 (*Jina Dev Bot*)
<a name=release-note-0-0-11></a>
## Release Note (`0.0.11`)
> Release time: 2023-07-14 06:51:55
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🍹 Other Improvements
- [[```e298e6ef```](https://github.com/jina-ai/jina/commit/e298e6ef500193d6a4e98760b2137c071514a704)] __-__ add MANIFEST.in (#43) (*Joan Fontanals*)
- [[```790f6341```](https://github.com/jina-ai/jina/commit/790f6341007a744976cbd0bc431ba2d3bb5327e8)] __-__ __version__: the next version will be 0.0.11 (*Jina Dev Bot*)
<a name=release-note-0-0-14></a>
## Release Note (`0.0.14`)
> Release time: 2023-07-14 10:30:51
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Joan Fontanals Martinez, Han Xiao, Deepankar Mahapatro, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```5ef1c964```](https://github.com/jina-ai/jina/commit/5ef1c964953e7aac9f0336317de29fb83b408938)] __-__ fix single quotes (#47) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```14bc575b```](https://github.com/jina-ai/jina/commit/14bc575ba99387b5239e4b607741eb151da16182)] __-__ upgrade version (*Joan Fontanals Martinez*)
- [[```daef4aac```](https://github.com/jina-ai/jina/commit/daef4aac87751ecf191da1ab75dd9938865a5dc5)] __-__ fix readme (*Han Xiao*)
- [[```c24b8d95```](https://github.com/jina-ai/jina/commit/c24b8d95dae0cd43d4b0e61dd0c587d85b2950d8)] __-__ update readme (*Han Xiao*)
- [[```1df0dcc0```](https://github.com/jina-ai/jina/commit/1df0dcc0901480deccf3b580c1e00b1f4bc0dfb6)] __-__ fix message in readme (*Joan Fontanals Martinez*)
- [[```ced29140```](https://github.com/jina-ai/jina/commit/ced291408538c21e5d310cc643c080789b382b4d)] __-__ fix help message serve (#45) (*Joan Fontanals*)
- [[```7efdc669```](https://github.com/jina-ai/jina/commit/7efdc669ac0cef150e6972f757b9525f66aed52e)] __-__ ignore warnings (#44) (*Deepankar Mahapatro*)
- [[```8e1ab38b```](https://github.com/jina-ai/jina/commit/8e1ab38b5017feacac1caa64da5a3fc039eb872a)] __-__ __version__: the next version will be 0.0.12 (*Jina Dev Bot*)
<a name=release-note-0-0-15></a>
## Release Note (`0.0.15`)
> Release time: 2023-07-19 15:17:53
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```497d1ef6```](https://github.com/jina-ai/jina/commit/497d1ef608dba6db73ce96fe1f5f5849a0cb4e0e)] __-__ fix db port for deployment (#48) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```d3d4a43c```](https://github.com/jina-ai/jina/commit/d3d4a43ce382c2526946818ce7f907f8b997bc9d)] __-__ __version__: the next version will be 0.0.15 (*Jina Dev Bot*)
<a name=release-note-0-0-16></a>
## Release Note (`0.0.16`)
> Release time: 2023-07-19 16:33:59
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🍹 Other Improvements
- [[```0357cfea```](https://github.com/jina-ai/jina/commit/0357cfead576b237675f1d1f38360a391deb9a3a)] __-__ fix docarray version in deploy (#49) (*Joan Fontanals*)
- [[```44856718```](https://github.com/jina-ai/jina/commit/44856718e7ce838cfd7e02f15f82c0d90b815694)] __-__ __version__: the next version will be 0.0.16 (*Jina Dev Bot*)
<a name=release-note-0-0-17></a>
## Release Note (`0.0.17`)
> Release time: 2023-07-25 02:37:14
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```a48f341c```](https://github.com/jina-ai/jina/commit/a48f341c8f5fc13ae70144fca9f73ec6de1764d0)] __-__ fix applying serve and deploy on instance (#53) (*Joan Fontanals*)
### 🏁 Unit Test and CICD
- [[```e0c9921c```](https://github.com/jina-ai/jina/commit/e0c9921c3b720d799bf6f99582a6d2eeb5c1ffee)] __-__ optout telemetry in test (#50) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```be1f72da```](https://github.com/jina-ai/jina/commit/be1f72da50c06982ed9abcedcb5db75dc9faf32f)] __-__ __version__: the next version will be 0.0.17 (*Jina Dev Bot*)
<a name=release-note-0-0-18></a>
## Release Note (`0.0.18`)
> Release time: 2023-08-23 07:50:40
🙇 We'd like to thank all contributors for this new release! In particular,
Joan Fontanals, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```a8e48b23```](https://github.com/jina-ai/jina/commit/a8e48b23aa4bb7a000f9099f24711473b31cf24a)] __-__ fix incompatibility with Jina version (#55) (*Joan Fontanals*)
### 🍹 Other Improvements
- [[```4c5f5ebc```](https://github.com/jina-ai/jina/commit/4c5f5ebc909d7308daf9c1813fc8e022f93ad1d6)] __-__ __version__: the next version will be 0.0.18 (*Jina Dev Bot*)
<a name=release-note-0-0-19></a>
## Release Note (`0.0.19`)
> Release time: 2023-10-08 03:17:44
🙇 We'd like to thank all contributors for this new release! In particular,
0x376h, Naymul Islam, Jina Dev Bot, 🙇
### 🍹 Other Improvements
- [[```059dc489```](https://github.com/jina-ai/jina/commit/059dc489b4e2c698ef8e71811eafee2c7a0ae500)] __-__ add num_docs (#62) (*0x376h*)
- [[```35cbf73a```](https://github.com/jina-ai/jina/commit/35cbf73a355e33667e66d9949c8ef58e28a10bd1)] __-__ __version__: the next version will be 0.0.19 (*Jina Dev Bot*)
<a name=release-note-0-0-20></a>
## Release Note (`0.0.20`)
> Release time: 2023-10-23 10:26:48
🙇 We'd like to thank all contributors for this new release! In particular,
0x376h, Jina Dev Bot, 🙇
### 🆕 New Features
- [[```5f8fc998```](https://github.com/jina-ai/jina/commit/5f8fc998c8c6b29553bff2146bc64166072f8b6a)] __-__ dd method queryid to check id exists (#63) (*0x376h*)
### 🍹 Other Improvements
- [[```a4308081```](https://github.com/jina-ai/jina/commit/a43080813c53c62f86f29083fab5f1a104c27388)] __-__ __version__: the next version will be 0.0.20 (*Jina Dev Bot*)
<a name=release-note-0-0-21></a>
## Release Note (`0.0.21`)
> Release time: 2024-03-04 17:10:02
🙇 We'd like to thank all contributors for this new release! In particular,
Gabe Goodhart, Jina Dev Bot, 🙇
### 🐞 Bug fixes
- [[```f0200e58```](https://github.com/jina-ai/jina/commit/f0200e58721549e009dd872c21642d44c7082177)] __-__ handle missing __validators__ (#68) (*Gabe Goodhart*)
### 🍹 Other Improvements
- [[```53cd4a54```](https://github.com/jina-ai/jina/commit/53cd4a54d8d8411170e9b384feed8ede2f75b423)] __-__ __version__: the next version will be 0.0.21 (*Jina Dev Bot*)

View File

@ -8,6 +8,4 @@ COPY . /vectordb/
RUN cd /vectordb && pip install -U pip && pip install .
RUN pip install -U docarray[hnswlib]>=0.33
ENTRYPOINT ["vectordb"]

6
MANIFEST.in Normal file
View File

@ -0,0 +1,6 @@
recursive-include vectordb/ *
global-exclude __pycache__/*
include LICENSE
include requirements.txt
prune test/
prune **/tests/

371
README.md
View File

@ -1,10 +1,25 @@
# Vector Database for Python Developers
<p align="center">
<a href="https://docs.jina.ai"><img src="https://github.com/jina-ai/vectordb/blob/main/.github%2Fimages%2Fvectordb-logo.png?raw=true" alt="VectorDB from Jina AI logo" width="300px"></a>
</p>
Vector databases store embeddings for semantic similarity between objects, enabling similarity searches across multimodal data types. They enhance LLM applications by providing context and improving generation results.
<p align="center">
<b>A Python vector database you just need - no more, no less.</b>
</p>
<p align=center>
<a href="https://pypi.org/project/vectordb/"><img alt="PyPI" src="https://img.shields.io/pypi/v/vectordb?label=Release&style=flat-square"></a>
<a href="https://discord.jina.ai"><img src="https://img.shields.io/discord/1106542220112302130?logo=discord&logoColor=white&style=flat-square"></a>
<a href="https://pypistats.org/packages/vectordb"><img alt="PyPI - Downloads from official pypistats" src="https://img.shields.io/pypi/dm/vectordb?style=flat-square"></a>
<a href="https://github.com/jina-ai/vectordb/actions/workflows/cd.yml"><img alt="Github CD status" src="https://github.com/jina-ai/vectordb/actions/workflows/cd.yml/badge.svg"></a>
</p>
`vectordb` is a Pythonic vector database offers a comprehensive suite of [CRUD](#crud-support) (Create, Read, Update, Delete) operations and robust [scalability options, including sharding and replication](#scaling-your-db). It's readily deployable in a variety of environments, from [local](#getting-started-with-vectordb-locally) to [on-premise](#getting-started-with-vectordb-as-a-service) and [cloud](#hosting-vectordb-on-jina-ai-cloud). `vectordb` delivers exactly what you need - no more, no less. It's a testament to effective Pythonic design without over-engineering, making it a lean yet powerful solution for all your needs.
`vectordb` capitalizes on the powerful retrieval prowess of [DocArray](https://github.com/docarray/docarray) and the scalability, reliability, and serving capabilities of [Jina](https://github.com/jina-ai/jina). Here's the magic: DocArray serves as the engine driving vector search logic, while Jina guarantees efficient and scalable index serving. This synergy culminates in a robust, yet user-friendly vector database experience - that's `vectordb` for you.
Meet vectordb: a user-friendly Python solution for creating vector databases with CRUD support. Unlike complex alternatives, vectordb allows easy local deployment while offering scalability features like sharding and replication. Seamlessly transition from a local library to a served database without unnecessary complexity.
vectordb leverages [DocArray](https://github.com/docarray/docarray) retrieval capabilities and [Jina](https://github.com/jina-ai/jina) scalability, reliability, and serving capabilities. In essence, DocArray powers the Vector Search logic while Jina ensures scalable index serving, creating a powerful and user-friendly vector database experience.
<!--In simple terms, one can think as [DocArray](https://github.com/docarray/docarray) being a the `Lucene` algorithmic logic for Vector Search powering the retrieval capabilities and [Jina](https://github.com/jina-ai/jina), the ElasticSearch making sure that the indexes are served and scaled for the clients, `vectordb` wraps these technologies to give a powerful and easy to use experience to
use and develop vector databases.-->
@ -13,243 +28,279 @@ use and develop vector databases.-->
<!--(THIS CAN BE SHOWN WHEN CUSTOMIZATION IS ENABLED) Stop wondering what exact algorithms do existing solutions apply, how do they apply filtering or how to map your schema to their solutions, with `vectordb` you as a Python developer can easily understand and control what is the vector search algorithm doing, giving you the full control if needed while supporting you for local setting and in more advanced and demanding scenarios in the cloud. -->
## :muscle: Features
## Install
- User-friendly interface: `vectordb` offers a simple and intuitive interface, catering to users of all levels of expertise.
```bash
pip install vectordb
```
- Tailored to your needs: `vectordb` provides the necessary features without unnecessary complexity, ensuring a smooth transition from local to server and cloud deployment.
<table>
<tr>
<td>
<a href="#getting-started-with-vectordb-locally">
<img src="https://github.com/jina-ai/vectordb/blob/main/.github%2Fimages%2Fguide-1.png?raw=true" alt="Use vectordb from Jina AI locally" width="100%">
</a>
</td>
<td>
<a href="#getting-started-with-vectordb-as-a-service">
<img src="https://github.com/jina-ai/vectordb/blob/main/.github%2Fimages%2Fguide-2.png?raw=true" alt="Use vectordb from Jina AI as a service" width="100%">
</a>
</td>
<td>
<a href="#hosting-vectordb-on-jina-ai-cloud">
<img src="https://github.com/jina-ai/vectordb/blob/main/.github%2Fimages%2Fguide-3.png?raw=true" alt="Use vectordb from Jina AI on Jina AI Cloud" width="100%">
</a>
</td>
</tr>
</table>
- CRUD support: `vectordb` supports essential CRUD operations, including indexing, searching, updating, and deleting.
- Serve as a service: `vectordb` allows you to serve your databases and perform insertion or searching operations through gRPC, HTTP or Websocket protocols.
- Scalability: Take advantage of `vectordb's` deployment capabilities to benefit from powerful scalability features such as sharding and replication. Sharding improves service latency, while replication enhances availability and throughput.
## Getting started with `vectordb` locally
- DCloud deployment: Easily deploy your service in the cloud using [Jina AI Cloud](https://cloud.jina.ai/). Stay tuned for upcoming deployment options.
- Serverless capacity: `vectordb` can be deployed in the cloud in serverless mode, allowing you to save resources and have the data available only when needed.
- Multiple ANN algorithms: `vectordb` contains different implementations of ANN algorithms. These are the ones offered so far, we plan to integrate more:
- InMemoryExactNNVectorDB (Exact NN Search): Implements Simple Nearest Neighbour Algorithm.
- HNSWVectorDB (based on HNSW): Based on [HNSWLib](https://github.com/nmslib/hnswlib)
<!--(THIS CAN BE SHOWN WHEN FILTER IS ENABLED)- Filter capacity: `vectordb` allows you to have filters on top of the ANN search. -->
<!--(THIS CAN BE SHOWN WHEN FILTER IS ENABLED)- Customizable: `vectordb` can be easily extended to suit your specific needs or schemas, so you can build the database you want and for any input and output schema you want with the help of [DocArray](https://github.com/docarray/docarray).-->
## 🏁 Getting Started
To get started with Vector Database, simply follow these easy steps, in this example we are going to use `InMemoryExactNNVectorDB` as example:
1. Install `vectordb`:
```pip install vectordb```
2. Define your Index Document schema using [DocArray](https://docs.docarray.org/user_guide/representing/first_step/):
1. Kick things off by defining a Document schema with the [DocArray](https://docs.docarray.org/user_guide/representing/first_step/) dataclass syntax:
```python
from docarray import BaseDoc
from docarray.typing import NdArray
class MyTextDoc(TextDoc):
text: str = ''
embedding: NdArray[768]
class ToyDoc(BaseDoc):
text: str = ''
embedding: NdArray[128]
```
Make sure that the schema has a field `schema` as a `tensor` type with shape annotation as in the example.
3. Use any of the pre-built databases with the document schema (InMemoryExactNNVectorDB or HNSWVectorDB):
2. Opt for a pre-built database (like `InMemoryExactNNVectorDB` or `HNSWVectorDB`), and apply the schema:
```python
from docarray import DocList
import numpy as np
from vectordb import InMemoryExactNNVectorDB, HNSWVectorDB
db = InMemoryExactNNVectorDB[MyTextDoc](workspace='./workspace_path')
db.index(inputs=DocList[MyTextDoc]([MyTextDoc(text=f'index {i}', embedding=np.random.rand(128)) for i in range(1000)]))
results = db.search(inputs=DocList[MyTextDoc]([MyTextDoc(text='query', embedding=np.random.rand(128)]), limit=10)
# Specify your workspace path
db = InMemoryExactNNVectorDB[ToyDoc](workspace='./workspace_path')
# Index a list of documents with random embeddings
doc_list = [ToyDoc(text=f'toy doc {i}', embedding=np.random.rand(128)) for i in range(1000)]
db.index(inputs=DocList[ToyDoc](doc_list))
# Perform a search query
query = ToyDoc(text='query', embedding=np.random.rand(128))
results = db.search(inputs=DocList[ToyDoc]([query]), limit=10)
# Print out the matches
for m in results[0].matches:
print(m)
```
Each result will contain the matches under the `.matches` attribute as a `DocList[MyTextDoc]`
Since we issued a single query, `results` contains only one element. The nearest neighbour search results are conveniently stored in the `.matches` attribute.
4. Serve the database as a service with any of these protocols: `gRPC`, `HTTP` and `Webscoket`.
## Getting started with `vectordb` as a service
`vectordb` is designed to be easily served as a service, supporting `gRPC`, `HTTP`, and `Websocket` communication protocols.
### Server Side
On the server side, you would start the service as follows:
```python
with InMemoryExactNNVectorDB[MyTextDoc].serve(workspace='./hnwslib_path', protocol='grpc', port=12345, replicas=1, shards=1) as service:
service.index(inputs=DocList[TextDoc]([TextDoc(text=f'index {i}', embedding=np.random.rand(128)) for i in range(1000)]))
with db.serve(protocol='grpc', port=12345, replicas=1, shards=1) as service:
service.block()
```
5. Interact with the database through a client in a similar way as previously:
This command starts `vectordb` as a service on port `12345`, using the `gRPC` protocol with `1` replica and `1` shard.
### Client Side
On the client side, you can access the service with the following commands:
```python
from vectordb import Client
c = Client[MyTextDoc](address='grpc://0.0.0.0:12345')
results = c.search(inputs=DocList[TextDoc]([TextDoc(text='query', embedding=np.random.rand(128)]), limit=10)
# Instantiate a client connected to the server. In practice, replace 0.0.0.0 to the server IP address.
client = Client[ToyDoc](address='grpc://0.0.0.0:12345')
# Perform a search query
results = client.search(inputs=DocList[ToyDoc]([query]), limit=10)
```
## CRUD API:
When using `vectordb` as a library or accesing it from a client to a served instance, the Python objects share the exact same API
to provide `index`, `search`, `update` and `delete` capability:
- `index`: Index gets as input the `DocList` to index.
- `search`: Search gets as input the `DocList` of batched queries or a single `BaseDoc` as single query. It returns a single or multiple results where each query has `matches` and `scores` attributes sorted by `relevance`.
- `delete`: Delete gets as input the `DocList` of documents to delete from the index. The `delete` operation will only care for the `id` attribute, so you need to keep track of the `indexed` `IDs` if you want to delete documents.
- `update`: Delete gets as input the `DocList` of documents to update in the index. The `update` operation will update the `indexed` document with the same Index with the attributes and payload from the input documents.
## :rocket: Serve and scale your own Database, add replication and sharding
### Serving:
In order to enable your `vectordb` served so that it can be accessed from a Client, you can give the following parameters:
- protocol: The protocol to be used for serving, it can be `gRPC`, `HTTP`, `websocket` or any combination of them provided as a list. Defaults to `gRPC`
- port: The port where the service will be accessible, it can be a list of one port for each protocol provided. Default to 8081
- workspace: The workspace is the path used by the VectorDB to hold and persist required data. Defaults to '.' (current directory)
This allows you to perform a search query, receiving the results directly from the remote `vectordb` service.
### Scalability
## Hosting `vectordb` on Jina AI Cloud
When serving or deploying your Vector Databases you can set 2 scaling parameters and `vectordb`:
You can seamlessly deploy your `vectordb` instance to Jina AI Cloud, which ensures access to your database from any location.
- Shards: The number of shards in which the data will be split. This will allow for better latency. `vectordb` will make sure that Documents are indexed in only one of the shards, while search request will be sent to all the shards and `vectordb` will make sure to merge the results from all shards.
- Replicas: The number of replicas of the same DB that must exist. The given replication factor will be shared by all the `shards`. `vectordb` uses [RAFT](https://raft.github.io/) algorithm to ensure that the index is in sync between all the replicas of each shard. With this, `vectordb` increases the availability of the service and allows for better search throughput as multiple replicas can respond in parallel to more search requests while allowing CRUD operations.
** When deployed to JCloud, the number of replicas will be set to 1. We are working to enable replication in the cloud
## 💻 `vectordb` CLI
`vectordb` is a simple CLI that helps you to serve and deploy your `vectordb` db.
First, you need to embed your database instance or class in a python file.
Start by embedding your database instance or class into a Python file:
```python
# example.py
from docarray import DocList, BaseDoc
from docarray.typing import NdArray
from docarray import BaseDoc
from vectordb import InMemoryExactNNVectorDB
class MyDoc(BaseDoc):
text: str
embedding: NdArray[128]
db = InMemoryExactNNVectorDB[MyDoc](workspace='./vectordb') # notice how `db` is the instance that we want to serve
db = InMemoryExactNNVectorDB[ToyDoc](workspace='./vectordb') # notice how `db` is the instance that we want to serve
if __name__ == '__main__':
# make sure to protect this part of the code
with app.serve() as service:
# IMPORTANT: make sure to protect this part of the code using __main__ guard
with db.serve() as service:
service.block()
```
Next, follow these steps to deploy your instance:
| Description | Command |
| --- | ---: |
| Serve your app locally | `vectordb serve --db example:db` |
| Deploy your app on JCloud |`vectordb deploy --db example:db` |
1. If you haven't already, sign up for a [Jina AI Cloud](https://cloud.jina.ai/) account.
2. Use the `jc` command line to login to your Jina AI Cloud account:
## :cloud: Deploy it to the cloud
```bash
jc login
```
`vectordb` allows you to deploy your solution to the cloud easily.
3. Deploy your instance:
1. First, you need to get a [Jina AI Cloud](https://cloud.jina.ai/) account
```bash
vectordb deploy --db example:db
```
2. Login to your Jina AI Cloud account using the `jc` command line:
![](./.github/images/vectordb_deploy_screenshot.png)
```jc login```
### Connect from the client
3. Deploy:
```bash
vectordb deploy --db example:db
```
After deployment, use the `vectordb` Client to access the assigned endpoint:
<details>
<summary>Show command output</summary>
```text
╭──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ App ID │ <id>
├──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Phase │ Serving │
├──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Endpoint │ grpc://<id>.wolf.jina.ai │
├──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ App logs │ dashboards.wolf.jina.ai │
╰──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
</details>
4. Connect from Client
Once deployed, you can use `vectordb` Client to access the given endpoint.
```python
from vectordb import Client
c = Client(address=' grpc://<id>.wolf.jina.ai')
# replace the ID with the ID of your deployed DB as shown in the screenshot above
c = Client(address='grpcs://ID.wolf.jina.ai')
```
5. Manage your deployed instances using [jcloud](https://github.com/jina-ai/jcloud):
You can then list and delete your deployed DBs with `jc` command:
### Manage your deployed instances using [jcloud](https://github.com/jina-ai/jcloud)
```jc list <>```
You can then list, pause, resume or delete your deployed DBs with `jc` command:
```jc delete <>```
```jcloud list ID```
![](./.github/images/vectordb_deploy_list.png)
```jcloud pause ID``` or ```jcloud resume ID```
![](./.github/images/vectordb_deploy_paused.png)
```jcloud remove ID```
## ⚙️ Configure
Here you can find the list of parameters you can use to configure the behavior for each of the `VectorDB` types.
## Advanced Topics
### InMemoryExactNNVectorDB
### What is a vector database?
This database type does an exhaustive search on the embeddings and therefore has a very limited configuration setting:
Vector databases serve as sophisticated repositories for embeddings, capturing the essence of semantic similarity among disparate objects. These databases facilitate similarity searches across a myriad of multimodal data types, paving the way for a new era of information retrieval. By providing contextual understanding and enriching generation results, vector databases greatly enhance the performance and utility of Language Learning Models (LLM). This underscores their pivotal role in the evolution of data science and machine learning applications.
- workspace: The folder where the required data will be persisted.
### CRUD support
Both the local library usage and the client-server interactions in `vectordb` share the same API. This provides `index`, `search`, `update`, and `delete` functionalities:
- `index`: Accepts a `DocList` to index.
- `search`: Takes a `DocList` of batched queries or a single `BaseDoc` as a single query. It returns either single or multiple results, each with `matches` and `scores` attributes sorted by `relevance`.
- `delete`: Accepts a `DocList` of documents to remove from the index. Only the `id` attribute is necessary, so make sure to track the `indexed` `IDs` if you need to delete documents.
- `update`: Accepts a `DocList` of documents to update in the index. The `update` operation will replace the `indexed` document with the same index with the attributes and payload from the input documents.
### Service endpoint configuration
You can serve `vectordb` and access it from a client with the following parameters:
- protocol: The serving protocol. It can be `gRPC`, `HTTP`, `websocket` or a combination of them, provided as a list. Default is `gRPC`.
- port: The service access port. Can be a list of ports for each provided protocol. Default is 8081.
- workspace: The path where the VectorDB persists required data. Default is '.' (current directory).
### Scaling your DB
You can set two scaling parameters when serving or deploying your Vector Databases with `vectordb`:
- Shards: The number of data shards. This improves latency, as `vectordb` ensures Documents are indexed in only one of the shards. Search requests are sent to all shards and results are merged.
- Replicas: The number of DB replicas. `vectordb` uses the [RAFT](https://raft.github.io/) algorithm to sync the index between replicas of each shard. This increases service availability and search throughput, as multiple replicas can respond in parallel to more search requests while allowing CRUD operations. Note: In JCloud deployments, the number of replicas is set to 1. We're working on enabling replication in the cloud.
### Vector search configuration
Here are the parameters for each `VectorDB` type:
#### InMemoryExactNNVectorDB
This database performs exhaustive search on embeddings and has limited configuration settings:
- `workspace`: The folder where required data is persisted.
```python
InMemoryExactNNVectorDB[MyDoc](workspace='./vectordb')
InMemoryExactNNVectorDB[MyDoc].serve(workspace='./vectordb')
```
### HNSWVectorDB
#### HNSWVectorDB
This database implements Approximate Nearest Neighbour based on HNSW algorithm using [HNSWLib](https://github.com/nmslib/hnswlib).
This database employs the HNSW (Hierarchical Navigable Small World) algorithm from [HNSWLib](https://github.com/nmslib/hnswlib) for Approximate Nearest Neighbor search. It provides several configuration options:
It containes more configuration options:
- `workspace`: Specifies the directory where required data is stored and persisted.
- workspace: The folder where the required data will be persisted.
Then a set of configurations that tweak the performance and accuracy of the NN search algorithm. You can find more details in [HNSWLib README](https://github.com/nmslib/hnswlib)
Additionally, HNSWVectorDB offers a set of configurations that allow tuning the performance and accuracy of the Nearest Neighbor search algorithm. Detailed descriptions of these configurations can be found in the [HNSWLib README](https://github.com/nmslib/hnswlib):
- space: name of the space, related to the similarity metric used (can be one of "l2", "ip", or "cosine"), default: "l2"
- max_elements: Initial capacity of the index, which is increased dynamically, default: 1024,
- ef_construction: parameter that controls speed/accuracy trade-off during the index construction, default: 200,
- ef: parameter controlling query time/accuracy trade-off, default: 10,
- M: parameter that defines the maximum number of outgoing connections in the graph, default: 16.
- allow_replace_deleted: enables replacing of deleted elements with new added ones, default: False
- num_threads: default number of threads to use while `index` and `search` are used, default: 1
- `space`: Specifies the similarity metric used for the space (options are "l2", "ip", or "cosine"). The default is "l2".
- `max_elements`: Sets the initial capacity of the index, which can be increased dynamically. The default is 1024.
- `ef_construction`: This parameter controls the speed/accuracy trade-off during index construction. The default is 200.
- `ef`: This parameter controls the query time/accuracy trade-off. The default is 10.
- `M`: This parameter defines the maximum number of outgoing connections in the graph. The default is 16.
- `allow_replace_deleted`: If set to `True`, this allows replacement of deleted elements with newly added ones. The default is `False`.
- `num_threads`: This sets the default number of threads to be used during `index` and `search` operations. The default is 1.
## 🛣️ Roadmap
We have big plans for the future of Vector Database! Here are some of the features we have in the works:
- More ANN search algorithms: We want to support more ANN search algorithms.
- Filter capacity: We want to support filtering for our offered ANN Search solutions.
- Customizable: We want to make it easy for users to customize the behavior for their specific needs in an easy way for Python developers.
- Serverless capacity: We're working on adding serverless capacity to `vectordb` in the cloud. We currenly allow to scale between 0 and 1 replica, we aim to offer from 0 to N.
- More deploying options: We want to enable deploying `vectordb` on different clouds with more options
### Command line interface
If you need any help with `vectordb`, or you are interested on using it and have some requests to make it fit your own need. don't hesitate to reach out to us. You can join our [Slack community](https://jina.ai/slack) and chat with us and other community members.
`vectordb` includes a simple CLI for serving and deploying your database:
| Description | Command |
|---------------------------------| ---: |
| Serve your DB locally | `vectordb serve --db example:db` |
| Deploy your DB on Jina AI Cloud |`vectordb deploy --db example:db` |
## Features
- **User-friendly Interface:** With `vectordb`, simplicity is key. Its intuitive interface is designed to accommodate users across varying levels of expertise.
- **Minimalistic Design:** `vectordb` packs all the essentials, with no unnecessary complexity. It ensures a seamless transition from local to server and cloud deployment.
- **Full CRUD Support:** From indexing and searching to updating and deleting, `vectordb` covers the entire spectrum of CRUD operations.
- **DB as a Service:** Harness the power of gRPC, HTTP, and Websocket protocols with `vectordb`. It enables you to serve your databases and conduct insertion or searching operations efficiently.
- **Scalability:** Experience the raw power of `vectordb`'s deployment capabilities, including robust scalability features like sharding and replication. Improve your service latency with sharding, while replication enhances availability and throughput.
- **Cloud Deployment:** Deploying your service in the cloud is a breeze with [Jina AI Cloud](https://cloud.jina.ai/). More deployment options are coming soon!
- **Serverless Capability:** `vectordb` can be deployed in a serverless mode in the cloud, ensuring optimal resource utilization and data availability as per your needs.
- **Multiple ANN Algorithms:** `vectordb` offers diverse implementations of Approximate Nearest Neighbors (ANN) algorithms. Here are the current offerings, with more integrations on the horizon:
- InMemoryExactNNVectorDB (Exact NN Search): Implements Simple Nearest Neighbor Algorithm.
- HNSWVectorDB (based on HNSW): Utilizes [HNSWLib](https://github.com/nmslib/hnswlib)
<!--(THIS CAN BE SHOWN WHEN FILTER IS ENABLED)- Filter capacity: `vectordb` allows you to have filters on top of the ANN search. -->
<!--(THIS CAN BE SHOWN WHEN FILTER IS ENABLED)- Customizable: `vectordb` can be easily extended to suit your specific needs or schemas, so you can build the database you want and for any input and output schema you want with the help of [DocArray](https://github.com/docarray/docarray).-->
## Roadmap
The future of Vector Database looks bright, and we have ambitious plans! Here's a sneak peek into the features we're currently developing:
- More ANN Search Algorithms: Our goal is to support an even wider range of ANN search algorithms.
- Enhanced Filtering Capabilities: We're working on enhancing our ANN Search solutions to support advanced filtering.
- Customizability: We aim to make `vectordb` highly customizable, allowing Python developers to tailor its behavior to their specific needs with ease.
- Expanding Serverless Capacity: We're striving to enhance the serverless capacity of `vectordb` in the cloud. While we currently support scaling between 0 and 1 replica, our goal is to extend this to 0 to N replicas.
- Expanded Deployment Options: We're actively working on facilitating the deployment of `vectordb` across various cloud platforms, with a broad range of options.
Need help with `vectordb`? Interested in using it but require certain features to meet your unique needs? Don't hesitate to reach out to us. Join our [Discord community](https://discord.jina.ai) to chat with us and other community members.
## Contributing
We welcome contributions from the community! If you have an idea for a new feature or improvement, please let us know. We're always looking for ways to make `vectordb` better for our users.
The VectorDB project is backed by [Jina AI](https://jina.ai) and licensed under Apache-2.0. Contributions from the community are greatly appreciated! If you have an idea for a new feature or an improvement, we would love to hear from you. We're always looking for ways to make `vectordb` more user-friendly and effective.

52
aux.py
View File

@ -1,52 +0,0 @@
from docarray import DocList, BaseDoc
from docarray.documents import TextDoc
from docarray.typing import NdArray
from vectordb import HNSWVectorDB
from vectordb import InMemoryExactNNVectorDB
import numpy as np
class MyDoc(BaseDoc):
text: str
embedding: NdArray[128]
docs = [MyDoc(text='hey', embedding=np.random.rand(128)) for i in range(200)]
indexer = InMemoryExactNNVectorDB[MyDoc]()
indexer.index(docs=DocList[MyDoc](docs))
resp = indexer.search(docs=DocList[MyDoc](docs[0:3]))
print(f' resp {resp}')
for query in resp:
print(f' query matches {query.matches}')
print(f' query matches scores {query.scores}')
service = InMemoryExactNNVectorDB[MyDoc].serve()
with service:
service.index(inputs=DocList[MyDoc](docs))
resp = service.search(inputs=DocList[MyDoc](docs[0:3]))
print(f' resp {resp}')
for query in resp:
print(f' query matches {query.matches}')
print(f' query matches scores {query.scores}')
# indexer = HNSWVectorDB[MyDoc]()
indexer.index(docs=DocList[MyDoc](docs))
resp = indexer.search(docs=DocList[MyDoc](docs[0:3]))
print(f' resp {resp}')
for query in resp:
print(f' query matches {query.matches}')
print(f' query matches scores {query.scores}')
service = HNSWVectorDB[MyDoc].serve()
with service:
service.index(inputs=DocList[MyDoc](docs))
resp = service.search(inputs=DocList[MyDoc](docs[0:3]))
print(f' resp {resp}')
for query in resp:
print(f' query matches {query.matches}')
print(f' query matches scores {query.scores}')
from vectordb.utils.create_doc_type import create_output_doc_type
o = create_output_doc_type(MyDoc)
print(f' {o}')

23
example.py Normal file
View File

@ -0,0 +1,23 @@
from docarray import DocList, BaseDoc
from docarray.typing import NdArray
from vectordb import InMemoryExactNNVectorDB, HNSWVectorDB
import random
import string
import numpy as np
class MyDoc(BaseDoc):
text: str
embedding: NdArray[128]
db = InMemoryExactNNVectorDB[MyDoc](workspace='./workspace')
if __name__ == '__main__':
docs_to_index = DocList[MyDoc](
[MyDoc(text="".join(random.choice(string.ascii_lowercase) for _ in range(5)), embedding=np.random.rand(128))
for _ in range(2000)])
query = docs_to_index[100:200]
with HNSWVectorDB[MyDoc].serve(workspace='./workspace', replicas=1, shards=1,
protocol='grpc') as service:
service.index(inputs=docs_to_index)
resp = service.search(inputs=query, limit=3)

View File

@ -1,3 +1,2 @@
jina>=3.17.0
click
#docarray[hnswlib]>=0.33.0
jina>=3.20.0
docarray[hnswlib]>=0.34.0

View File

@ -1,10 +1,15 @@
from setuptools import setup, find_packages
from os import path
AUTHOR = 'Jina AI'
AUTHOR_EMAIL = 'hello@jina.ai'
LICENSE = 'Apache 2.0'
GITHUB_URL = 'https://github.com/jina-ai/vectordb/'
DOWNLOAD_URL = 'https://github.com/jina-ai/vectordb/tags'
try:
pkg_name = 'vectordb'
libinfo_py = path.join(pkg_name, '__init__.py')
libinfo_content = open(libinfo_py, 'r', encoding='utf-8').readlines()
with open(libinfo_py, 'r', encoding='utf-8') as f:
libinfo_content = f.readlines()
version_line = [l.strip() for l in libinfo_content if l.startswith('__version__')][
0
]
@ -12,19 +17,28 @@ try:
except FileNotFoundError:
__version__ = '0.0.0'
try:
with open('README.md', encoding='utf-8') as fp:
_long_description = fp.read()
except FileNotFoundError:
_long_description = ''
# Read the contents of requirements.txt
with open('requirements.txt', 'r') as f:
with open(path.join(path.dirname(__file__), 'requirements.txt'), 'r') as f:
requirements = f.read().splitlines()
setup(
name='vectordb',
version=__version__,
description='The Python VectorDB. Build your vector database from working as a library to scaling as a database in the cloud',
author='Jina AI',
author_email='hello@jina.ai',
license='Apache 2.0',
url='https://github.com/jina-ai/vectordb/',
download_url='https://github.com/jina-ai/vectordb/tags',
long_description=_long_description,
long_description_content_type='text/markdown',
author= AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=GITHUB_URL,
download_url=DOWNLOAD_URL,
packages=find_packages(),
classifiers=[
'Development Status :: 5 - Production/Stable',
@ -54,6 +68,3 @@ setup(
},
install_requires=requirements,
)
import subprocess
subprocess.run(['pip', 'install', 'docarray[hnswlib]>=0.33.0'])

View File

@ -1,5 +1,11 @@
import pytest
@pytest.fixture(autouse=True)
def test_log_level(monkeypatch):
monkeypatch.setenv('JINA_LOG_LEVEL', 'DEBUG')
@pytest.fixture(autouse=True)
def test_disable_telemetry(monkeypatch):
monkeypatch.setenv('JINA_OPTOUT_TELEMETRY', 'True')

View File

@ -30,8 +30,8 @@ def docs_to_index():
def test_hnswlib_vectordb_batch(docs_to_index, replicas, shards, protocol, tmpdir):
query = docs_to_index[:10]
port = random_port()
with HNSWVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}) as db:
with HNSWVectorDB[MyDoc](workspace=str(tmpdir)).serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -53,7 +53,7 @@ def test_hnswlib_vectordb_single_query(docs_to_index, limit, replicas, shards, p
query = docs_to_index[100]
port = random_port()
with HNSWVectorDB[MyDoc](ef=5000).serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
protocol=protocol, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -72,8 +72,8 @@ def test_hnswlib_vectordb_delete(docs_to_index, replicas, shards, protocol, tmpd
query = docs_to_index[0]
port = random_port()
delete = MyDoc(id=query.id, text='', embedding=np.random.rand(128))
with HNSWVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}) as db:
with HNSWVectorDB[MyDoc](workspace=str(tmpdir)).serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -102,8 +102,8 @@ def test_hnswlib_vectordb_udpate_text(docs_to_index, replicas, shards, protocol,
query = docs_to_index[0]
port = random_port()
update = MyDoc(id=query.id, text=query.text + '_changed', embedding=query.embedding)
with HNSWVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}) as db:
with HNSWVectorDB[MyDoc]().serve(workspace=str(tmpdir), replicas=replicas, shards=shards, protocol=protocol, port=port,
uses_with={'ef': 5000}, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -132,7 +132,7 @@ def test_hnswlib_vectordb_restore(docs_to_index, replicas, shards, protocol, tmp
port = random_port()
with HNSWVectorDB[MyDoc](ef=5000).serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
protocol=protocol, timeout_ready=10000) as db:
db.index(docs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -144,8 +144,8 @@ def test_hnswlib_vectordb_restore(docs_to_index, replicas, shards, protocol, tmp
assert res.text == res.matches[0].text
assert res.scores[0] < 0.001 # some precision issues, should be 0.0
with HNSWVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol, uses_with={'ef': 5000}) as new_db:
with HNSWVectorDB[MyDoc]().serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol, uses_with={'ef': 5000}, timeout_ready=10000) as new_db:
time.sleep(2)
resp = new_db.search(docs=query)
assert len(resp) == len(query)

View File

@ -30,8 +30,8 @@ def docs_to_index():
def test_inmemory_vectordb_batch(docs_to_index, replicas, shards, protocol, tmpdir):
query = docs_to_index[:10]
port = random_port()
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
with InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir)).serve(replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -52,8 +52,8 @@ def test_inmemory_vectordb_batch(docs_to_index, replicas, shards, protocol, tmpd
def test_inmemory_vectordb_single_query(docs_to_index, limit, replicas, shards, protocol, tmpdir):
query = docs_to_index[100]
port = random_port()
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
with InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir)).serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -72,8 +72,8 @@ def test_inmemory_vectordb_delete(docs_to_index, replicas, shards, protocol, tmp
query = docs_to_index[0]
port = random_port()
delete = MyDoc(id=query.id, text='', embedding=np.random.rand(128))
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
with InMemoryExactNNVectorDB[MyDoc]().serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -102,8 +102,8 @@ def test_inmemory_vectordb_udpate_text(docs_to_index, replicas, shards, protocol
query = docs_to_index[0]
port = random_port()
update = MyDoc(id=query.id, text=query.text + '_changed', embedding=query.embedding)
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
with InMemoryExactNNVectorDB[MyDoc]().serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as db:
db.index(inputs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -131,8 +131,8 @@ def test_inmemory_vectordb_restore(docs_to_index, replicas, shards, protocol, tm
query = docs_to_index[:100]
port = random_port()
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as db:
with InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir)).serve(replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as db:
db.index(docs=docs_to_index)
if replicas > 1:
time.sleep(2)
@ -144,8 +144,8 @@ def test_inmemory_vectordb_restore(docs_to_index, replicas, shards, protocol, tm
assert res.text == res.matches[0].text
assert res.scores[0] > 0.99 # some precision issues, should be 1
with InMemoryExactNNVectorDB[MyDoc].serve(workspace=str(tmpdir), replicas=replicas, shards=shards, port=port,
protocol=protocol) as new_db:
with InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir)).serve(replicas=replicas, shards=shards, port=port,
protocol=protocol, timeout_ready=10000) as new_db:
time.sleep(2)
resp = new_db.search(docs=query)
assert len(resp) == len(query)

View File

@ -169,4 +169,20 @@ def test_hnswlib_vectordb_restore(docs_to_index, tmpdir):
assert len(res.matches) == 10
# assert res.id == res.matches[0].id
# assert res.text == res.matches[0].text
# assert res.scores[0] < 0.001 # some precision issues, should be 0
# assert res.scores[0] < 0.001 # some precision issues, should be 0
def test_hnswlib_num_dos(tmpdir):
db = HNSWVectorDB[MyDoc](workspace=str(tmpdir))
doc_list = [MyDoc(text=f'toy doc {i}', embedding=np.random.rand(128)) for i in range(1000)]
db.index(inputs=DocList[MyDoc](doc_list))
x = db.num_docs()
assert x['num_docs'] == 1000
def test_hnswlib_query_id(tmpdir):
db = HNSWVectorDB[MyDoc](workspace=str(tmpdir))
doc_list = [MyDoc(id='test_1',text=f'test', embedding=np.random.rand(128)) ]
db.index(inputs=DocList[MyDoc](doc_list))
queryobjtest1 = db.get_by_id('test_1')
queryobjtest2 = db.get_by_id('test_2')
assert queryobjtest2 is None
assert queryobjtest1.id == 'test_1'

View File

@ -172,3 +172,19 @@ def test_inmemory_vectordb_restore(docs_to_index, tmpdir):
assert res.id == res.matches[0].id
assert res.text == res.matches[0].text
assert res.scores[0] > 0.99 # some precision issues, should be 1
def test_inmemory_num_dos(tmpdir):
db = InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir))
doc_list = [MyDoc(text=f'toy doc {i}', embedding=np.random.rand(128)) for i in range(1000)]
db.index(inputs=DocList[MyDoc](doc_list))
x = db.num_docs()
assert x['num_docs'] == 1000
def test_inmemory_query_id(tmpdir):
db = InMemoryExactNNVectorDB[MyDoc](workspace=str(tmpdir))
doc_list = [MyDoc(id='test_1',text=f'test', embedding=np.random.rand(128)) ]
db.index(inputs=DocList[MyDoc](doc_list))
queryobjtest1 = db.get_by_id('test_1')
queryobjtest2 = db.get_by_id('test_2')
assert queryobjtest2 is None
assert queryobjtest1.id == 'test_1'

View File

@ -1,4 +1,19 @@
__version__ = '0.0.1'
def _ignore_warnings():
import logging
import warnings
logging.captureWarnings(True)
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message="Deprecated call to `pkg_resources.declare_namespace('google')`.",
)
_ignore_warnings()
__version__ = '0.0.22'
from vectordb.client import Client
from vectordb.db.hnsw_vectordb import HNSWVectorDB
from vectordb.db.inmemory_exact_vectordb import InMemoryExactNNVectorDB
from vectordb.db.hnsw_vectordb import HNSWVectorDB

View File

@ -11,7 +11,7 @@ def vectordb():
pass
@vectordb.command(help='Deploy a vectorDB app to Jina AI Cloud')
@vectordb.command(help='Deploy a vectorDB db to Jina AI Cloud')
@click.option(
'--db',
'--app',
@ -39,14 +39,16 @@ def vectordb():
)
def deploy(db, protocol, shards):
definition_file, _, obj_name = db.partition(":")
if not definition_file.endswith('.py'):
definition_file = f'{definition_file}.py'
protocol = protocol.split(',')
VectorDB.deploy(protoocl=protocol,
VectorDB.deploy(protocol=protocol,
shards=shards,
definition_file=definition_file,
obj_name=obj_name)
@vectordb.command(help='Deploy a vectorDB app to Jina AI Cloud')
@vectordb.command(help='Locally serve a vectorDB db')
@click.option(
'--db',
'--app',

View File

@ -0,0 +1 @@
from vectordb.client.client import Client

View File

@ -52,7 +52,10 @@ class VectorDB(Generic[TSchema]):
self._workspace = kwargs['work_dir']
if 'workspace' in kwargs:
self._workspace = kwargs['workspace']
self._uses_with = kwargs
self._uses_with = {}
self._uses_with.update(**kwargs)
if 'workspace' in self._uses_with:
self._uses_with.pop('workspace')
kwargs['requests'] = REQUESTS_MAP
kwargs['runtime_args'] = {'workspace': self._workspace}
self._executor = self._executor_cls(*args, **kwargs)
@ -72,14 +75,6 @@ class VectorDB(Generic[TSchema]):
obj_name: Optional[str] = None,
**kwargs):
from jina import Deployment, Flow
is_instance = False
uses_with = uses_with or {}
if isinstance(cls, VectorDB):
is_instance = True
uses_with = uses_with.update(**cls._uses_with)
if is_instance:
workspace = workspace or cls._workspace
replicas = replicas or 1
shards = shards or 1
protocol = protocol or 'grpc'
@ -126,8 +121,9 @@ class VectorDB(Generic[TSchema]):
# here we would need to push the EXECUTOR TO HUBBLE AND CHANGE THE USES
assert definition_file is not None, 'Trying to create a Jina Object for Deployment without the file where the vectordb object/class is defined'
assert obj_name is not None, 'Trying to create a Jina Object for Deployment without the name of the vectordb object/class to deploy'
uses = f'jinaai+docker://{push_vectordb_to_hubble(vectordb_name=obj_name, definition_file_path=definition_file)}'
uses = f'{push_vectordb_to_hubble(vectordb_name=obj_name, definition_file_path=definition_file)}'
use_deployment = False
port = 8080
if 'websocket' in protocol_list: # websocket not supported for Deployment
use_deployment = False
@ -148,39 +144,43 @@ class VectorDB(Generic[TSchema]):
workspace=workspace,
polling=polling, **kwargs)
else:
jina_object = Flow(port=port, protocol=protocol, **kwargs).add(name='indexer',
uses=uses,
uses_with=uses_with,
shards=shards,
replicas=replicas,
stateful=stateful,
peer_ports=peer_ports,
polling=polling,
workspace=workspace)
jina_object = Flow(port=port, protocol=protocol, env=['JINA_LOG_LEVEL=DEBUG'], **kwargs).add(name='indexer',
uses=uses,
uses_with=uses_with,
shards=shards,
replicas=replicas,
stateful=stateful,
peer_ports=peer_ports,
polling=polling,
workspace=workspace)
return jina_object
@classmethod
def serve(cls,
def serve(self,
*,
port: Optional[Union[str, List[str]]] = 8081,
protocol: Optional[Union[str, List[str]]] = None,
**kwargs):
protocol = protocol or 'grpc'
protocol_list = [p.lower() for p in protocol] if isinstance(protocol, list) else [protocol.lower()]
ctxt_manager = cls._get_jina_object(to_deploy=False, port=port, protocol=protocol, **kwargs)
uses_with = kwargs.pop('uses_with', {})
uses_with.update(self._uses_with)
workspace = kwargs.pop('workspace', self._workspace)
ctxt_manager = self._get_jina_object(to_deploy=False, port=port, protocol=protocol, workspace=workspace,
uses_with=uses_with, **kwargs)
port = port[0] if isinstance(port, list) else port
return Service(ctxt_manager, address=f'{protocol_list[0]}://0.0.0.0:{port}', schema=cls._input_schema,
reverse_order=cls.reverse_score_order)
return Service(ctxt_manager, address=f'{protocol_list[0]}://0.0.0.0:{port}', schema=self._input_schema,
reverse_order=self.reverse_score_order)
@classmethod
def deploy(cls,
def deploy(self,
**kwargs):
from tempfile import mkdtemp
import os
import yaml
from yaml.loader import SafeLoader
jina_obj = cls._get_jina_object(to_deploy=True, **kwargs)
uses_with = kwargs.pop('uses_with', {})
uses_with.update(self._uses_with)
jina_obj = self._get_jina_object(to_deploy=True, uses_with=uses_with, **kwargs)
tmpdir = mkdtemp()
jina_obj.save_config(os.path.join(tmpdir, 'flow.yml'))
@ -192,7 +192,10 @@ class VectorDB(Generic[TSchema]):
for executor in flow_dict['executors']:
executor['jcloud'] = executor_jcloud_config
import docarray
global_jcloud_config = {
'docarray': docarray.__version__,
'labels': {
'app': 'vectordb',
},
@ -215,7 +218,6 @@ class VectorDB(Generic[TSchema]):
flow_path = os.path.join(tmpdir, 'flow.yml')
with open(flow_path, 'w') as f:
yaml.safe_dump(flow_dict, f, sort_keys=False)
cloud_flow = CloudFlow(path=flow_path)
async def _deploy():
@ -225,6 +227,17 @@ class VectorDB(Generic[TSchema]):
ret = asyncio.run(_deploy())
return ret
def num_docs(self, **kwargs):
return self._executor.num_docs()
def get_by_id(self,info_id, **kwargs):
ret = None
try:
ret = self._executor.get_by_id(info_id)
except KeyError:
pass
return ret
@pass_kwargs_as_params
@unify_input_output
def index(self, docs: 'DocList[TSchema]', parameters: Optional[Dict] = None, **kwargs):

View File

@ -105,8 +105,11 @@ class HNSWLibIndexer(TypedExecutor):
return self.update(docs, *args, **kwargs)
def num_docs(self, **kwargs):
return {'num_docs': self._index.num_docs()}
return {'num_docs': self._indexer.num_docs()}
def get_by_id(self,info_id,**kwargs):
return self._indexer[info_id]
def snapshot(self, snapshot_dir):
# TODO: Maybe copy the work_dir to workspace if `handle` is False
raise NotImplementedError('Act as not implemented')

View File

@ -71,8 +71,11 @@ class InMemoryExactNNIndexer(TypedExecutor):
return self._index(docs)
def num_docs(self, *args, **kwargs):
return {'num_docs': self._index.num_docs()}
return {'num_docs': self._indexer.num_docs()}
def get_by_id(self,info_id,**kwargs):
return self._indexer[info_id]
def snapshot(self, snapshot_dir):
snapshot_file = f'{snapshot_dir}/index.bin'
self._indexer.persist(snapshot_file)

View File

@ -1,5 +1,6 @@
from jina import Executor
from jina.serve.executors import _FunctionWithSchema
from jina.serve.executors import __dry_run_endpoint__
from typing import TypeVar, Generic, Type, Optional, TYPE_CHECKING
from vectordb.utils.create_doc_type import create_output_doc_type
@ -15,7 +16,6 @@ OutputSchema = TypeVar('OutputSchema', bound='BaseDoc')
methods = ['/index', '/update', '/delete', '/search']
class TypedExecutor(Executor, Generic[InputSchema, OutputSchema]):
# the BaseDoc that defines the schema of the store
# for subclasses this is filled automatically
@ -27,12 +27,25 @@ class TypedExecutor(Executor, Generic[InputSchema, OutputSchema]):
from docarray import DocList
self._num_replicas = getattr(self.runtime_args, 'replicas', 1)
for k, v in self._requests.items():
if k != '/search':
self._requests[k] = _FunctionWithSchema(self._requests[k].fn, DocList[self._input_schema],
DocList[self._input_schema])
else:
self._requests[k] = _FunctionWithSchema(self._requests[k].fn, DocList[self._input_schema],
DocList[self._output_schema])
if k != __dry_run_endpoint__:
if k != '/search':
self._requests[k] = _FunctionWithSchema(fn=self._requests[k].fn,
is_generator=self._requests[k].is_generator,
is_batch_docs=self._requests[k].is_batch_docs,
is_singleton_doc=self._requests[k].is_singleton_doc,
parameters_is_pydantic_model=self._requests[k].parameters_is_pydantic_model,
parameters_model=self._requests[k].parameters_model,
request_schema=DocList[self._input_schema],
response_schema=DocList[self._input_schema])
else:
self._requests[k] = _FunctionWithSchema(fn=self._requests[k].fn,
is_generator=self._requests[k].is_generator,
is_batch_docs=self._requests[k].is_batch_docs,
is_singleton_doc=self._requests[k].is_singleton_doc,
parameters_is_pydantic_model=self._requests[k].parameters_is_pydantic_model,
parameters_model=self._requests[k].parameters_model,
request_schema=DocList[self._input_schema],
response_schema=DocList[self._output_schema])
@property
def handle_persistence(self):

View File

@ -15,7 +15,8 @@ def create_output_doc_type(input_doc_type: Type['BaseDoc']):
return create_model(
input_doc_type.__name__ + 'WithMatchesAndScores',
__base__=input_doc_type,
__validators__=input_doc_type.__validators__,
# NOTE: With pydantic>=2, __validators__ does not exist
__validators__=getattr(input_doc_type, "__validators__", None),
matches=(DocList[input_doc_type], []),
scores=(List[float], [])
)

View File

@ -11,7 +11,7 @@ from pathlib import Path
__resources_path__ = os.path.join(
Path(os.path.dirname(sys.modules['vectordb'].__file__)).parent.absolute(), 'resources'
)
API_URL = "https://apihubble.jina.ai/v2/executor/getMeta?id={id}&tag={tag}"
class EnvironmentVarCtxtManager:
"""a class to wrap env vars"""
@ -40,6 +40,25 @@ class EnvironmentVarCtxtManager:
os.unsetenv(key)
def get_uri(id: str, tag: str):
import requests
from hubble import Auth
headers = {"Authorization": f"token {Auth.get_auth_token()}"}
response = requests.get(API_URL.format(id=id, tag=tag), headers=headers)
if response.status_code != 200:
raise Exception(f"Request failed with status code {response.status_code}")
response_json = response.json()
if response_json is None:
raise Exception(f'Could not find image with id {id} and tag {tag}')
image_name = response_json['data']['name']
user_name = response_json['meta']['owner']['name']
return f'jinaai+docker://{user_name}/{image_name}:{tag}'
def get_random_tag():
return 't-' + uuid.uuid4().hex[:5]
@ -110,4 +129,6 @@ def push_vectordb_to_hubble(
with open(os.path.join(tmpdir, 'config.yml'), mode='w', encoding='utf-8') as f:
f.write(content)
return _push_to_hubble(tmpdir, image_name, tag, True, False)
executor_id = _push_to_hubble(tmpdir, image_name, tag, True, False)
id, tag = executor_id.split(':')
return get_uri(id, tag)