jina.clients.mixin module#
- class jina.clients.mixin.MutateMixin[source]#
Bases:
object
The GraphQL Mutation Mixin for Client and Flow
- mutate(mutation, variables=None, timeout=None, headers=None)[source]#
Perform a GraphQL mutation
- Parameters:
mutation (
str
) – the GraphQL mutation as a single string.variables (
Optional
[dict
]) – variables to be substituted in the mutation. Not needed if no variables are present in the mutation string.timeout (
Optional
[float
]) – HTTP request timeoutheaders (
Optional
[dict
]) – HTTP headers
- Returns:
dict containing the optional keys
data
anderrors
, for response data and errors.
- class jina.clients.mixin.AsyncMutateMixin[source]#
Bases:
MutateMixin
The async GraphQL Mutation Mixin for Client and Flow
- async mutate(mutation, variables=None, timeout=None, headers=None)[source]#
Perform a GraphQL mutation, asynchronously
- Parameters:
mutation (
str
) – the GraphQL mutation as a single string.variables (
Optional
[dict
]) – variables to be substituted in the mutation. Not needed if no variables are present in the mutation string.timeout (
Optional
[float
]) – HTTP request timeoutheaders (
Optional
[dict
]) – HTTP headers
- Returns:
dict containing the optional keys
data
anderrors
, for response data and errors.
- class jina.clients.mixin.HealthCheckMixin[source]#
Bases:
object
The Health check Mixin for Client and Flow to expose dry_run API
- is_flow_ready(**kwargs)[source]#
Check if the Flow is ready to receive requests
- Parameters:
kwargs – potential kwargs received passed from the public interface
- Return type:
bool
- Returns:
boolean indicating the health/readiness of the Flow
- dry_run(**kwargs)#
- class jina.clients.mixin.AsyncHealthCheckMixin[source]#
Bases:
object
The Health check Mixin for Client and Flow to expose dry_run API
- async is_flow_ready(**kwargs)[source]#
Check if the Flow is ready to receive requests
- Parameters:
kwargs – potential kwargs received passed from the public interface
- Return type:
bool
- Returns:
boolean indicating the health/readiness of the Flow
- dry_run(**kwargs)#
- class jina.clients.mixin.ProfileMixin[source]#
Bases:
object
The Profile Mixin for Client and Flow to expose profile API
- class jina.clients.mixin.AsyncProfileMixin[source]#
Bases:
object
The Profile Mixin for Client and Flow to expose profile API
- 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_responses=False, max_attempts=1, initial_backoff=0.5, max_backoff=2, backoff_multiplier=1.5, results_in_order=False, stream=True, prefetch=None, return_type=<class 'docarray.array.document.DocumentArray'>, **kwargs)[source]#
Post a general data request to the Flow.
- Parameters:
inputs (
Optional
[InputType]) – input data which can be an Iterable, a function which returns an Iterable, or a single Document.on (
str
) – the endpoint which is invoked. All the functions in the executors decorated by @requests(on=…) with the same endpoint are invoked.on_done (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is resolved.on_error (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is rejected.on_always (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is either resolved or rejected.parameters (
Optional
[Dict
]) – the kwargs that will be sent to the executortarget_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 an error will be logged only without blocking the further requests.return_responses (
bool
) – if set to True, the result will come as Response and not as a DocumentArraymax_attempts (
int
) – Number of sending attempts, including the original request.initial_backoff (
float
) – The first retry will happen with a delay of random(0, initial_backoff)max_backoff (
float
) – The maximum accepted backoff after the exponential incremental delaybackoff_multiplier (
float
) – The n-th attempt will occur at random(0, min(initialBackoff*backoffMultiplier**(n-1), maxBackoff))results_in_order (
bool
) – return the results in the same order as the inputsstream (
bool
) – Applicable only to grpc client. If True, the requests are sent to the target using the gRPC streaming interface otherwise the gRPC unary interface will be used. The value is True by default.prefetch (
Optional
[int
]) – How many Requests are processed from the Client at the same time. If not provided then Gateway prefetch value will be used.return_type (
Type
[DocumentArray
]) – the DocumentArray type to be returned. By default, it is DocumentArray.kwargs – additional parameters
- Return type:
Union
[DocumentArray
,List
[Response],None
]- Returns:
None or DocumentArray containing all response Documents
Warning
target_executor
usesre.match
for checking if the pattern is matched.target_executor=='foo'
will match both deployments with the namefoo
andfoo_what_ever_suffix
.
- index(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) Optional[Union[DocumentArray, List[Response]]] #
- search(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) Optional[Union[DocumentArray, List[Response]]] #
- update(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) Optional[Union[DocumentArray, List[Response]]] #
- delete(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **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, return_responses=False, max_attempts=1, initial_backoff=0.5, max_backoff=2, backoff_multiplier=1.5, results_in_order=False, stream=True, prefetch=None, return_type=<class 'docarray.array.document.DocumentArray'>, **kwargs)[source]#
Async Post a general data request to the Flow.
- Parameters:
inputs (
Optional
[InputType]) – input data which can be an Iterable, a function which returns an Iterable, or a single Document.on (
str
) – the endpoint which is invoked. All the functions in the executors decorated by @requests(on=…) with the same endpoint are invoked.on_done (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is resolved.on_error (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is rejected.on_always (
Optional
[CallbackFnType]) – the function to be called when theRequest
object is either resolved or rejected.parameters (
Optional
[Dict
]) – the kwargs that will be sent to the executortarget_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 an error will be logged only without blocking the further requests.return_responses (
bool
) – if set to True, the result will come as Response and not as a DocumentArraymax_attempts (
int
) – Number of sending attempts, including the original request.initial_backoff (
float
) – The first retry will happen with a delay of random(0, initial_backoff)max_backoff (
float
) – The maximum accepted backoff after the exponential incremental delaybackoff_multiplier (
float
) – The n-th attempt will occur at random(0, min(initialBackoff*backoffMultiplier**(n-1), maxBackoff))results_in_order (
bool
) – return the results in the same order as the inputsstream (
bool
) – Applicable only to grpc client. If True, the requests are sent to the target using the gRPC streaming interface otherwise the gRPC unary interface will be used. The value is True by default.prefetch (
Optional
[int
]) – How many Requests are processed from the Client at the same time. If not provided then Gateway prefetch value will be used.return_type (
Type
[DocumentArray
]) – the DocumentArray type to be returned. By default, it is DocumentArray.kwargs – additional parameters, can be used to pass metadata or authentication information in the server call
- Yield:
Response object
Warning
target_executor
usesre.match
for checking if the pattern is matched.target_executor=='foo'
will match both deployments with the namefoo
andfoo_what_ever_suffix
.- Return type:
AsyncGenerator
[None
,Union
[DocumentArray
, Response]]
- index(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) AsyncGenerator[None, Union[DocumentArray, Response]] #
- search(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) AsyncGenerator[None, Union[DocumentArray, Response]] #
- update(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) AsyncGenerator[None, Union[DocumentArray, Response]] #
- delete(inputs: ~typing.Optional[InputType] = None, on_done: ~typing.Optional[CallbackFnType] = None, on_error: ~typing.Optional[CallbackFnType] = None, on_always: ~typing.Optional[CallbackFnType] = None, parameters: ~typing.Optional[~typing.Dict] = None, target_executor: ~typing.Optional[str] = None, request_size: int = 100, show_progress: bool = False, continue_on_error: bool = False, return_responses: bool = False, max_attempts: int = 1, initial_backoff: float = 0.5, max_backoff: float = 2, backoff_multiplier: float = 1.5, results_in_order: bool = False, stream: bool = True, prefetch: ~typing.Optional[int] = None, return_type: ~typing.Type[~docarray.array.document.DocumentArray] = <class 'docarray.array.document.DocumentArray'>, **kwargs) AsyncGenerator[None, Union[DocumentArray, Response]] #