-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0435a41
commit 9fb5019
Showing
14 changed files
with
734 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,115 @@ | ||
wads_configs.json | ||
data/wads_configs.json | ||
wads/data/wads_configs.json | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
|
||
.DS_Store | ||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
_build | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
docs/* | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# PyCharm | ||
.idea |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [year] [fullname] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,96 @@ | ||
# chromadol | ||
Data Object Layer for ChromaDB | ||
|
||
|
||
To install: ```pip install chromadol``` | ||
|
||
|
||
# Example usage | ||
|
||
To make a `ChromaClient` DOL, you can specify a `chromadb` `Client`, `PersistentClient` (etc.) | ||
instance, or specify a string (which will be interpreted as a path to a directory to | ||
save the data to in a `PersistentClient` instance). | ||
|
||
>>> from chromadol import ChromaClient | ||
>>> import tempfile, os | ||
>>> with tempfile.TemporaryDirectory() as temp_dir: | ||
... tempdir = os.path.join(temp_dir, "chromadol_test") | ||
... os.makedirs(tempdir) | ||
>>> client = ChromaClient(tempdir) | ||
|
||
Removing all contents of client to be able to run a test on a clean slate | ||
|
||
>>> for k in client: | ||
... del client[k] | ||
|
||
|
||
There's nothing yet: | ||
|
||
>>> list(client) | ||
[] | ||
|
||
Now let's "get" a collection. | ||
|
||
>>> collection = client['chromadol_test'] | ||
|
||
Note that just accessing the collection creates it (by default) | ||
|
||
|
||
>>> list(client) | ||
['chromadol_test'] | ||
|
||
Here's nothing in the collection yet: | ||
|
||
>>> list(collection) | ||
[] | ||
|
||
So let's write something. | ||
Note that `chromadb` is designed to operate on multiple documents at once, | ||
so the "chromadb-natural" way of specifying it's keys and contents (and any extras) | ||
would be like this: | ||
|
||
>>> collection[['piece', 'of']] = { | ||
... 'documents': ['contents for piece', 'contents for of'], | ||
... 'metadatas': [{'author': 'me'}, {'author': 'you'}], | ||
... } | ||
>>> list(collection) | ||
['piece', 'of'] | ||
>>> | ||
>>> assert collection[['piece', 'of']] == { | ||
... 'ids': ['piece', 'of'], | ||
... 'embeddings': None, | ||
... 'metadatas': [{'author': 'me'}, {'author': 'you'}], | ||
... 'documents': ['contents for piece', 'contents for of'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } | ||
|
||
|
||
But you can read or write one document at a time too. | ||
|
||
>>> collection['cake'] = { | ||
... "documents": "contents for cake", | ||
... } | ||
>>> list(collection) | ||
['piece', 'of', 'cake'] | ||
>>> assert collection['cake'] == { | ||
... 'ids': ['cake'], | ||
... 'embeddings': None, | ||
... 'metadatas': [None], | ||
... 'documents': ['contents for cake'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } | ||
|
||
In fact, see that if you only want to specify the "documents" part of the information, | ||
you can just write a string instead of a dictionary: | ||
|
||
>>> collection['cake'] = 'a different cake' | ||
>>> assert collection['cake'] == { | ||
... 'ids': ['cake'], | ||
... 'embeddings': None, | ||
... 'metadatas': [None], | ||
... 'documents': ['a different cake'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } |
This file contains 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,96 @@ | ||
"""Data Object Layer (DOL) for ChromaDB | ||
Example usage: | ||
To make a `ChromaClient` DOL, you can specify a `chromadb` `Client`, `PersistentClient` (etc.) | ||
instance, or specify a string (which will be interpreted as a path to a directory to | ||
save the data to in a `PersistentClient` instance). | ||
>>> from chromadol import ChromaClient | ||
>>> import tempfile, os | ||
>>> with tempfile.TemporaryDirectory() as temp_dir: | ||
... tempdir = os.path.join(temp_dir, "chromadol_test") | ||
... os.makedirs(tempdir) | ||
>>> client = ChromaClient(tempdir) | ||
Removing all contents of client to be able to run a test on a clean slate | ||
>>> for k in client: | ||
... del client[k] | ||
... | ||
There's nothing yet: | ||
>>> list(client) | ||
[] | ||
Now let's "get" a collection. | ||
>>> collection = client['chromadol_test'] | ||
Note that just accessing the collection creates it (by default) | ||
>>> list(client) | ||
['chromadol_test'] | ||
Here's nothing in the collection yet: | ||
>>> list(collection) | ||
[] | ||
So let's write something. | ||
Note that `chromadb` is designed to operate on multiple documents at once, | ||
so the "chromadb-natural" way of specifying it's keys and contents (and any extras) | ||
would be like this: | ||
>>> collection[['piece', 'of']] = { | ||
... 'documents': ['contents for piece', 'contents for of'], | ||
... 'metadatas': [{'author': 'me'}, {'author': 'you'}], | ||
... } | ||
>>> list(collection) | ||
['piece', 'of'] | ||
>>> | ||
>>> assert collection[['piece', 'of']] == { | ||
... 'ids': ['piece', 'of'], | ||
... 'embeddings': None, | ||
... 'metadatas': [{'author': 'me'}, {'author': 'you'}], | ||
... 'documents': ['contents for piece', 'contents for of'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } | ||
But you can read or write one document at a time too. | ||
>>> collection['cake'] = { | ||
... "documents": "contents for cake", | ||
... } | ||
>>> list(collection) | ||
['piece', 'of', 'cake'] | ||
>>> assert collection['cake'] == { | ||
... 'ids': ['cake'], | ||
... 'embeddings': None, | ||
... 'metadatas': [None], | ||
... 'documents': ['contents for cake'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } | ||
In fact, see that if you only want to specify the "documents" part of the information, | ||
you can just write a string instead of a dictionary: | ||
>>> collection['cake'] = 'a different cake' | ||
>>> assert collection['cake'] == { | ||
... 'ids': ['cake'], | ||
... 'embeddings': None, | ||
... 'metadatas': [None], | ||
... 'documents': ['a different cake'], | ||
... 'uris': None, | ||
... 'data': None, | ||
... } | ||
""" | ||
|
||
from chromadol.base import ChromaCollection, ChromaClient |
Oops, something went wrong.