chromadol


Namechromadol JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryData Object Layer for ChromaDB
upload_time2024-01-03 19:49:45
maintainer
docs_urlNone
authorOtoSense
requires_python
licensemit
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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'}],
    ... }

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,
    ... }

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chromadol",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "OtoSense",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/25/34/8a8a899de3e15439af66bad12abffbc48e013a766761eea3659c477756bd/chromadol-0.1.2.tar.gz",
    "platform": null,
    "description": "# chromadol\nData Object Layer for ChromaDB\n\n\nTo install:\t```pip install chromadol```\n\n\n# Example usage\n\nTo make a `ChromaClient` DOL, you can specify a `chromadb` `Client`, `PersistentClient` (etc.) \ninstance, or specify a string (which will be interpreted as a path to a directory to\nsave the data to in a `PersistentClient` instance).\n\n    >>> from chromadol import ChromaClient\n    >>> import tempfile, os \n    >>> with tempfile.TemporaryDirectory() as temp_dir:\n    ...     tempdir = os.path.join(temp_dir, \"chromadol_test\")\n    ...     os.makedirs(tempdir)\n    >>> client = ChromaClient(tempdir)\n\nRemoving all contents of client to be able to run a test on a clean slate\n\n    >>> for k in client:\n    ...     del client[k]\n\n\nThere's nothing yet:\n\n    >>> list(client)\n    []\n\nNow let's \"get\" a collection. \n\n    >>> collection = client['chromadol_test']\n\nNote that just accessing the collection creates it (by default)\n\n\n    >>> list(client)\n    ['chromadol_test']\n\nHere's nothing in the collection yet:\n\n    >>> list(collection)\n    []\n\nSo let's write something.\nNote that `chromadb` is designed to operate on multiple documents at once, \nso the \"chromadb-natural\" way of specifying it's keys and contents (and any extras) \nwould be like this:\n\n    >>> collection[['piece', 'of']] = {\n    ...     'documents': ['contents for piece', 'contents for of'],\n    ...     'metadatas': [{'author': 'me'}, {'author': 'you'}],\n    ... }\n\nNow we have two documents in the collection:\n\n    >>> len(collection)\n    2\n\nNote, though, that the order of the documents is not guaranteed.\n\n    >>> sorted(collection)\n    ['of', 'piece']\n\n    >>> assert collection['piece'] == {\n    ...     'ids': ['piece'],\n    ...     'embeddings': None,\n    ...     'metadatas': [{'author': 'me'}],\n    ...     'documents': ['contents for piece'],\n    ...     'uris': None,\n    ...     'data': None\n    ... }\n\n    >>> assert collection['of'] == {\n    ...     'ids': ['of'],\n    ...     'embeddings': None,\n    ...     'metadatas': [{'author': 'you'}],\n    ...     'documents': ['contents for of'],\n    ...     'uris': None,\n    ...     'data': None\n    ... }\n\nYou can also read multiple documents at once.\nBut note that the order of the documents is not guaranteed.\n\n    >>> collection[['piece', 'of']] == collection[['of', 'piece']]\n    True\n\nYou can read or write one document at a time too.\n\n    >>> collection['cake'] = {\n    ...     \"documents\": \"contents for cake\",\n    ... }\n    >>> sorted(collection)  # sorting because order is not guaranteed\n    ['cake', 'of', 'piece']\n    >>> assert collection['cake'] == {\n    ...     'ids': ['cake'],\n    ...     'embeddings': None,\n    ...     'metadatas': [None],\n    ...     'documents': ['contents for cake'],\n    ...     'uris': None,\n    ...     'data': None,\n    ... }\n\nIn fact, see that if you only want to specify the \"documents\" part of the information,\nyou can just write a string instead of a dictionary:\n\n    >>> collection['cake'] = 'a different cake'\n    >>> assert collection['cake'] == {\n    ...     'ids': ['cake'],\n    ...     'embeddings': None,\n    ...     'metadatas': [None],\n    ...     'documents': ['a different cake'],\n    ...     'uris': None,\n    ...     'data': None,\n    ... }\n",
    "bugtrack_url": null,
    "license": "mit",
    "summary": "Data Object Layer for ChromaDB",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "253d9e55f2ae6d20dd3562cb082431217df83557373c48dd54d17924490c9ab5",
                "md5": "6d0d9f3f8435d99f30a29ae5710359e6",
                "sha256": "79360c6555e84ea70ad628f013375958435a440b6c9b30f5a6307bae416cb11b"
            },
            "downloads": -1,
            "filename": "chromadol-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6d0d9f3f8435d99f30a29ae5710359e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9531,
            "upload_time": "2024-01-03T19:49:44",
            "upload_time_iso_8601": "2024-01-03T19:49:44.097925Z",
            "url": "https://files.pythonhosted.org/packages/25/3d/9e55f2ae6d20dd3562cb082431217df83557373c48dd54d17924490c9ab5/chromadol-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25348a8a899de3e15439af66bad12abffbc48e013a766761eea3659c477756bd",
                "md5": "059f2f7ec66572f44befb76883ac1801",
                "sha256": "f18752ec7b6361f3d4c60a36c59b3c3d2ab9d252a7bfdc30697aaadb8e8fc7d6"
            },
            "downloads": -1,
            "filename": "chromadol-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "059f2f7ec66572f44befb76883ac1801",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7381,
            "upload_time": "2024-01-03T19:49:45",
            "upload_time_iso_8601": "2024-01-03T19:49:45.051151Z",
            "url": "https://files.pythonhosted.org/packages/25/34/8a8a899de3e15439af66bad12abffbc48e013a766761eea3659c477756bd/chromadol-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 19:49:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "chromadol"
}
        
Elapsed time: 0.14983s