Skip to content

DocStore

docarray.store.abstract_doc_store.AbstractDocStore

Bases: ABC

Source code in docarray/store/abstract_doc_store.py
class AbstractDocStore(ABC):
    @staticmethod
    @abstractmethod
    def list(namespace: str, show_table: bool) -> List[str]:
        """List all DocLists in the specified backend at the namespace.

        :param namespace: The namespace to list
        :param show_table: If true, a table is printed to the console
        :return: A list of DocList names
        """
        ...

    @staticmethod
    @abstractmethod
    def delete(name: str, missing_ok: bool) -> bool:
        """Delete the DocList object at the specified name

        :param name: The name of the DocList to delete
        :param missing_ok: If true, no error will be raised if the DocList does not exist.
        :return: True if the DocList was deleted, False if it did not exist.
        """
        ...

    @staticmethod
    @abstractmethod
    def push(
        docs: 'DocList',
        name: str,
        show_progress: bool,
    ) -> Dict:
        """Push this DocList to the specified name.

        :param docs: The DocList to push
        :param name: The name to push to
        :param show_progress: If true, a progress bar will be displayed.
        """
        ...

    @staticmethod
    @abstractmethod
    def push_stream(
        docs: Iterator['BaseDoc'],
        url: str,
        show_progress: bool = False,
    ) -> Dict:
        """Push a stream of documents to the specified name.

        :param docs: a stream of documents
        :param url: The name to push to
        :param show_progress: If true, a progress bar will be displayed.
        """
        ...

    @staticmethod
    @abstractmethod
    def pull(
        docs_cls: Type['DocList'],
        name: str,
        show_progress: bool,
        local_cache: bool,
    ) -> 'DocList':
        """Pull a DocList from the specified name.

        :param docs_cls: The DocList class to instantiate
        :param name: The name to pull from
        :param show_progress: If true, a progress bar will be displayed.
        :param local_cache: If true, the DocList will be cached locally
        :return: A DocList
        """
        ...

    @staticmethod
    @abstractmethod
    def pull_stream(
        docs_cls: Type['DocList'],
        name: str,
        show_progress: bool,
        local_cache: bool,
    ) -> Iterator['BaseDoc']:
        """Pull a stream of documents from the specified name.

        :param docs_cls: The DocList class to instantiate
        :param name: The name to pull from
        :param show_progress: If true, a progress bar will be displayed.
        :param local_cache: If true, the DocList will be cached locally
        :return: An iterator of documents"""
        ...

delete(name, missing_ok) abstractmethod staticmethod

Delete the DocList object at the specified name

Parameters:

Name Type Description Default
name str

The name of the DocList to delete

required
missing_ok bool

If true, no error will be raised if the DocList does not exist.

required

Returns:

Type Description
bool

True if the DocList was deleted, False if it did not exist.

Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def delete(name: str, missing_ok: bool) -> bool:
    """Delete the DocList object at the specified name

    :param name: The name of the DocList to delete
    :param missing_ok: If true, no error will be raised if the DocList does not exist.
    :return: True if the DocList was deleted, False if it did not exist.
    """
    ...

list(namespace, show_table) abstractmethod staticmethod

List all DocLists in the specified backend at the namespace.

Parameters:

Name Type Description Default
namespace str

The namespace to list

required
show_table bool

If true, a table is printed to the console

required

Returns:

Type Description
List[str]

A list of DocList names

Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def list(namespace: str, show_table: bool) -> List[str]:
    """List all DocLists in the specified backend at the namespace.

    :param namespace: The namespace to list
    :param show_table: If true, a table is printed to the console
    :return: A list of DocList names
    """
    ...

pull(docs_cls, name, show_progress, local_cache) abstractmethod staticmethod

Pull a DocList from the specified name.

Parameters:

Name Type Description Default
docs_cls Type[DocList]

The DocList class to instantiate

required
name str

The name to pull from

required
show_progress bool

If true, a progress bar will be displayed.

required
local_cache bool

If true, the DocList will be cached locally

required

Returns:

Type Description
DocList

A DocList

Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def pull(
    docs_cls: Type['DocList'],
    name: str,
    show_progress: bool,
    local_cache: bool,
) -> 'DocList':
    """Pull a DocList from the specified name.

    :param docs_cls: The DocList class to instantiate
    :param name: The name to pull from
    :param show_progress: If true, a progress bar will be displayed.
    :param local_cache: If true, the DocList will be cached locally
    :return: A DocList
    """
    ...

pull_stream(docs_cls, name, show_progress, local_cache) abstractmethod staticmethod

Pull a stream of documents from the specified name.

Parameters:

Name Type Description Default
docs_cls Type[DocList]

The DocList class to instantiate

required
name str

The name to pull from

required
show_progress bool

If true, a progress bar will be displayed.

required
local_cache bool

If true, the DocList will be cached locally

required

Returns:

Type Description
Iterator[BaseDoc]

An iterator of documents

Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def pull_stream(
    docs_cls: Type['DocList'],
    name: str,
    show_progress: bool,
    local_cache: bool,
) -> Iterator['BaseDoc']:
    """Pull a stream of documents from the specified name.

    :param docs_cls: The DocList class to instantiate
    :param name: The name to pull from
    :param show_progress: If true, a progress bar will be displayed.
    :param local_cache: If true, the DocList will be cached locally
    :return: An iterator of documents"""
    ...

push(docs, name, show_progress) abstractmethod staticmethod

Push this DocList to the specified name.

Parameters:

Name Type Description Default
docs DocList

The DocList to push

required
name str

The name to push to

required
show_progress bool

If true, a progress bar will be displayed.

required
Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def push(
    docs: 'DocList',
    name: str,
    show_progress: bool,
) -> Dict:
    """Push this DocList to the specified name.

    :param docs: The DocList to push
    :param name: The name to push to
    :param show_progress: If true, a progress bar will be displayed.
    """
    ...

push_stream(docs, url, show_progress=False) abstractmethod staticmethod

Push a stream of documents to the specified name.

Parameters:

Name Type Description Default
docs Iterator[BaseDoc]

a stream of documents

required
url str

The name to push to

required
show_progress bool

If true, a progress bar will be displayed.

False
Source code in docarray/store/abstract_doc_store.py
@staticmethod
@abstractmethod
def push_stream(
    docs: Iterator['BaseDoc'],
    url: str,
    show_progress: bool = False,
) -> Dict:
    """Push a stream of documents to the specified name.

    :param docs: a stream of documents
    :param url: The name to push to
    :param show_progress: If true, a progress bar will be displayed.
    """
    ...