jina.clients.mixin module

class jina.clients.mixin.PostMixin[source]

Bases: object

The Post Mixin class for Client and Flow

post(on, inputs=None, on_done=None, on_error=None, on_always=None, parameters=None, target_peapod=None, request_size=100, show_progress=False, continue_on_error=False, return_results=False, **kwargs)[source]

Post a general data request to the 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]]]]], None]) – input data which can be an Iterable, a function which returns an Iterable, or a single Document id.

  • on (str) – the endpoint is used for identifying the user-defined request_type, labeled by @requests(on='/abc')

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

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

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

  • parameters (Optional[Dict]) – the kwargs that will be sent to the executor

  • target_peapod (Optional[str]) – a regex string represent the certain peas/pods request targeted

  • request_size (int) – the number of Documents per request. <=0 means all inputs in one request.

  • show_progress (bool) – if set, client will show a progress bar on receiving every request.

  • continue_on_error (bool) – if set, a Request that causes callback error will be logged only without blocking the further requests.

  • return_results (bool) – if set, the results of all Requests will be returned as a list. This is useful when one wants process Responses in bulk instead of using callback.

  • kwargs – additional parameters

Return type

Optional[List[Response]]

Returns

None or list of Response

Warning

target_peapod uses re.match for checking if the pattern is matched.

target_peapod=='foo' will match both pods with the name foo and foo_what_ever_suffix.

index(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, **kwargs)Optional[List[jina.types.request.Response]]
search(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, **kwargs)Optional[List[jina.types.request.Response]]
update(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, **kwargs)Optional[List[jina.types.request.Response]]
delete(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, **kwargs)Optional[List[jina.types.request.Response]]
class jina.clients.mixin.AsyncPostMixin[source]

Bases: object

The Async Post Mixin class for AsyncClient and AsyncFlow

post(on, inputs=None, on_done=None, on_error=None, on_always=None, parameters=None, target_peapod=None, request_size=100, show_progress=False, continue_on_error=False, **kwargs)[source]

Post a general data request to the 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]]]]], None]) – input data which can be an Iterable, a function which returns an Iterable, or a single Document id.

  • on (str) – the endpoint is used for identifying the user-defined request_type, labeled by @requests(on='/abc')

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

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

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

  • parameters (Optional[Dict]) – the kwargs that will be sent to the executor

  • target_peapod (Optional[str]) – a regex string represent the certain peas/pods request targeted

  • request_size (int) – the number of Documents per request. <=0 means all inputs in one request.

  • show_progress (bool) – if set, client will show a progress bar on receiving every request.

  • continue_on_error (bool) – if set, a Request that causes callback error will be logged only without blocking the further requests.

  • kwargs – additional parameters

Yield

Response object

Return type

AsyncGenerator[None, Response]

index(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, **kwargs)AsyncGenerator[None, jina.types.request.Response]
search(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, **kwargs)AsyncGenerator[None, jina.types.request.Response]
update(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, **kwargs)AsyncGenerator[None, jina.types.request.Response]
delete(inputs: Optional[Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], Callable[[], Union[jina.types.document.Document, Iterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]], AsyncIterable[Union[DocumentContentType, DocumentSourceType, jina.types.document.Document, Tuple[DocumentContentType, DocumentContentType], Tuple[DocumentSourceType, DocumentSourceType]]]]]]] = None, on_done: Optional[Callable[[jina.types.request.Response], None]] = None, on_error: Optional[Callable[[jina.types.request.Response], None]] = None, on_always: Optional[Callable[[jina.types.request.Response], None]] = None, parameters: Optional[Dict] = None, target_peapod: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, **kwargs)AsyncGenerator[None, jina.types.request.Response]