jina.flow.mixin.async_crud

class jina.flow.mixin.async_crud.AsyncCRUDFlowMixin[source]

Bases: object

The asynchronous version of the Mixin for CRUD in Flow

train(inputs, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Do training on the current Flow

Parameters
  • inputs (Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], Callable[…, Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]]]]]) – An iterator of bytes. If not given, then you have to specify it in kwargs.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index_ndarray(array, axis=0, size=None, shuffle=False, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Using numpy ndarray as the index source for the current Flow

Parameters
  • array (ndarray) – the numpy ndarray data source

  • axis (int) – iterate over that axis

  • size (Optional[int]) – the maximum number of the sub arrays

  • shuffle (bool) – shuffle the the numpy data source beforehand

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search_ndarray(array, axis=0, size=None, shuffle=False, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a numpy ndarray as the query source for searching on the current Flow

Parameters
  • array (ndarray) – the numpy ndarray data source

  • axis (int) – iterate over that axis

  • size (Optional[int]) – the maximum number of the sub arrays

  • shuffle (bool) – shuffle the the numpy data source beforehand

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index_lines(lines=None, filepath=None, size=None, sampling_rate=None, read_mode='r', line_format='json', field_resolver=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of lines as the index source for indexing on the current Flow

Parameters
  • lines (Union[Iterable[str], TextIO, None]) – a list of strings, each is considered as d document

  • filepath (Optional[str]) – a text file that each line contains a document

  • size (Optional[int]) – the maximum number of the documents

  • sampling_rate (Optional[float]) – the sampling rate between [0, 1]

  • read_mode (str) – specifies the mode in which the file is opened. ‘r’ for reading in text mode, ‘rb’ for reading in binary

  • line_format (str) – the format of each line: json or csv

  • field_resolver (Optional[Dict[str, str]]) – a map from field names defined in document (JSON, dict) to the field names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index_csv(lines, field_resolver=None, size=None, sampling_rate=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of lines as the index source for indexing on the current Flow :type lines: Union[Iterable[str], TextIO] :param lines: a list of strings, each is considered as d document :type size: Optional[int] :param size: the maximum number of the documents :type sampling_rate: Optional[float] :param sampling_rate: the sampling rate between [0, 1] :type field_resolver: Optional[Dict[str, str]] :param field_resolver: a map from field names defined in document (JSON, dict) to the field

names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

Parameters
  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index_ndjson(lines, field_resolver=None, size=None, sampling_rate=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of lines as the index source for indexing on the current Flow :type lines: Union[Iterable[str], TextIO] :param lines: a list of strings, each is considered as d document :type size: Optional[int] :param size: the maximum number of the documents :type sampling_rate: Optional[float] :param sampling_rate: the sampling rate between [0, 1] :type field_resolver: Optional[Dict[str, str]] :param field_resolver: a map from field names defined in document (JSON, dict) to the field

names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

Parameters
  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index_files(patterns, recursive=True, size=None, sampling_rate=None, read_mode=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a set of files as the index source for indexing on the current Flow

Parameters
  • patterns (Union[str, Iterable[str]]) – The pattern may contain simple shell-style wildcards, e.g. ‘*.py’, ‘[*.zip, *.gz]’

  • recursive (bool) – If recursive is true, the pattern ‘**’ will match any files and zero or more directories and subdirectories.

  • size (Optional[int]) – the maximum number of the files

  • sampling_rate (Optional[float]) – the sampling rate between [0, 1]

  • read_mode (Optional[str]) – specifies the mode in which the file is opened. ‘r’ for reading in text mode, ‘rb’ for reading in binary mode

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search_files(patterns, recursive=True, size=None, sampling_rate=None, read_mode=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a set of files as the query source for searching on the current Flow

Parameters
  • patterns (Union[str, Iterable[str]]) – The pattern may contain simple shell-style wildcards, e.g. ‘*.py’, ‘[*.zip, *.gz]’

  • recursive (bool) – If recursive is true, the pattern ‘**’ will match any files and zero or more directories and subdirectories.

  • size (Optional[int]) – the maximum number of the files

  • sampling_rate (Optional[float]) – the sampling rate between [0, 1]

  • read_mode (Optional[str]) – specifies the mode in which the file is opened. ‘r’ for reading in text mode, ‘rb’ for reading in

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search_ndjson(lines, field_resolver=None, size=None, sampling_rate=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of files as the query source for searching on the current Flow :type lines: Union[Iterable[str], TextIO] :param lines: a list of strings, each is considered as d document :type size: Optional[int] :param size: the maximum number of the documents :type sampling_rate: Optional[float] :param sampling_rate: the sampling rate between [0, 1] :type field_resolver: Optional[Dict[str, str]] :param field_resolver: a map from field names defined in document (JSON, dict) to the field

names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

Parameters
  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search_csv(lines, field_resolver=None, size=None, sampling_rate=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of lines as the index source for indexing on the current Flow :type lines: Union[Iterable[str], TextIO] :param lines: a list of strings, each is considered as d document :type size: Optional[int] :param size: the maximum number of the documents :type sampling_rate: Optional[float] :param sampling_rate: the sampling rate between [0, 1] :type field_resolver: Optional[Dict[str, str]] :param field_resolver: a map from field names defined in document (JSON, dict) to the field

names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

Parameters
  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search_lines(lines=None, filepath=None, size=None, sampling_rate=None, read_mode='r', line_format='json', field_resolver=None, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Use a list of files as the query source for searching on the current Flow

Parameters
  • filepath (Optional[str]) – a text file that each line contains a document

  • lines (Union[Iterable[str], TextIO, None]) – a list of strings, each is considered as d document

  • size (Optional[int]) – the maximum number of the documents

  • sampling_rate (Optional[float]) – the sampling rate between [0, 1]

  • read_mode (str) – specifies the mode in which the file is opened. ‘r’ for reading in text mode, ‘rb’ for reading in binary

  • line_format (str) – the format of each line: json or csv

  • field_resolver (Optional[Dict[str, str]]) – a map from field names defined in document (JSON, dict) to the field names defined in Protobuf. This is only used when the given document is a JSON string or a Python dict.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

index(inputs, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Do indexing on the current Flow

It will start a CLIClient and call index().

Parameters
  • inputs (Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], Callable[…, Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]]]]]) – An iterator of bytes. If not given, then you have to specify it in kwargs.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

update(inputs, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Do updates on the current Flow

It will start a CLIClient and call index().

Parameters
  • inputs (Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], Callable[…, Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]]]]]) – An iterator of bytes. If not given, then you have to specify it in kwargs.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

delete(ids, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Do deletion on the current Flow

Parameters
  • ids (Iterable[str]) – An iterable of ids

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results

search(inputs, on_done=None, on_error=None, on_always=None, **kwargs)[source]

Do searching on the current Flow

It will start a CLIClient and call search().

Parameters
  • inputs (Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], Callable[…, Union[Document, Iterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]], AsyncIterable[Union[~DocumentContentType, ~DocumentSourceType, Document, Tuple[~DocumentContentType, ~DocumentContentType], Tuple[~DocumentSourceType, ~DocumentSourceType]]]]]]) – An iterator of bytes. If not given, then you have to specify it in kwargs.

  • on_done (Optional[Callable[…, None]]) – the function to be called when the Request object is resolved.

  • on_error (Optional[Callable[…, None]]) – the function to be called when the Request object is rejected.

  • on_always (Optional[Callable[…, None]]) – the function to be called when the Request object is is either resolved or rejected.

  • kwargs – accepts all keyword arguments of jina client CLI

Yields

results