chromadol
Data Object Layer for ChromaDB
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'}],
... }
Now we have two documents in the collection:
>>> len(collection)
2
Note, though, that the order of the documents is not guaranteed.
>>> sorted(collection)
['of', 'piece']
>>> assert collection['piece'] == {
... 'ids': ['piece'],
... 'embeddings': None,
... 'metadatas': [{'author': 'me'}],
... 'documents': ['contents for piece'],
... 'uris': None,
... 'data': None
... }
>>> assert collection['of'] == {
... 'ids': ['of'],
... 'embeddings': None,
... 'metadatas': [{'author': 'you'}],
... 'documents': ['contents for of'],
... 'uris': None,
... 'data': None
... }
You can also read multiple documents at once. But note that the order of the documents is not guaranteed.
>>> collection[['piece', 'of']] == collection[['of', 'piece']]
True
You can read or write one document at a time too.
>>> collection['cake'] = {
... "documents": "contents for cake",
... }
>>> sorted(collection) # sorting because order is not guaranteed
['cake', 'of', 'piece']
>>> 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,
... }
Metadata
Release files for chromadol 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chromadol-0.1.8.tar.gz | 19.4 kB | Without provenance | Details for chromadol-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chromadol-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for chromadol-0.1.8-py3-none-any.whl |
Total release size: 36.7 kB
Release files / chromadol-0.1.8.tar.gz
| Download URL | chromadol-0.1.8.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e88b15e6b17a0558da4d4be85b8bc8c6e63e8eee8a0265b8b50b569fde7493e
|
|
BLAKE2b-256 checksum How to use checksums |
73c21d06777e5cb1f7b5889824247a5243270daf1f38c9cff4e66a3499b18cde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / chromadol-0.1.8-py3-none-any.whl
| Download URL | chromadol-0.1.8-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a58b13934d2e4f482823c79e4a681003983d09a964bb477c115556f014b2b650
|
|
BLAKE2b-256 checksum How to use checksums |
fc7fdf65a8980e3e2c34928a59bb1c23251ad812e5638cb0f12b2d836bd577a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for chromadol 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.