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_executor=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 (Optional[ForwardRef]) – 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[ForwardRef]) – the function to be called when the Request object is resolved.

      • on_error (Optional[ForwardRef]) – the function to be called when the Request object is rejected.

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

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

      • target_executor (Optional[str]) – a regex string. Only matching Executors will process the request.

      • 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 Documents resulting from all Requests will be returned as a DocumentArray. This is useful when one wants process Responses in bulk instead of using callback.

      • kwargs – additional parameters

      Return type

      Union[ForwardRef, List[ForwardRef], None]

      Returns

      None or DocumentArray containing all response Documents

    Warning

    • target_executor uses re.match for checking if the pattern is matched.

      target_executor=='foo' will match both deployments with the name foo and foo_what_ever_suffix.

  • index(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, \*kwargs*) → Optional[Union[DocumentArray, List[Response]]]

  • search(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, \*kwargs*) → Optional[Union[DocumentArray, List[Response]]]

  • update(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, \*kwargs*) → Optional[Union[DocumentArray, List[Response]]]

  • delete(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_results: bool = False, \*kwargs*) → Optional[Union[DocumentArray, List[Response]]]

class jina.clients.mixin.AsyncPostMixin[source]

Bases: object

The Async Post Mixin class for AsyncClient and AsyncFlow

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

    Post a general data request to the Flow.

    • Parameters

      • inputs (Optional[ForwardRef]) – 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[ForwardRef]) – the function to be called when the Request object is resolved.

      • on_error (Optional[ForwardRef]) – the function to be called when the Request object is rejected.

      • on_always (Optional[ForwardRef]) – 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_executor (Optional[str]) – a regex string. Only matching Executors will process the request.

      • 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, ForwardRef]

  • index(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, \*kwargs*) → AsyncGenerator[None, Response]

  • search(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, \*kwargs*) → AsyncGenerator[None, Response]

  • update(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, \*kwargs*) → AsyncGenerator[None, Response]

  • delete(inputs: Optional[InputType] = None, on_done: Optional[CallbackFnType] = None, on_error: Optional[CallbackFnType] = None, on_always: Optional[CallbackFnType] = None, parameters: Optional[Dict] = None, target_executor: Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, \*kwargs*) → AsyncGenerator[None, Response]