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
- class jina.clients.mixin.AsyncHealthCheckMixin[source]#
Bases:
object
The Health check Mixin for Client and Flow to expose dry_run API
- 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, **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 callback error will be logged only without blocking the further requests.7return_responses (
bool
) – if set to True, the result will come as Response and not as a DocumentArraykwargs – 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: 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_responses: 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_responses: 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_responses: 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_responses: 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, return_responses=False, **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 callback 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 DocumentArraykwargs – 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: 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_responses: bool = False, **kwargs) AsyncGenerator[None, Union[DocumentArray, 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_responses: bool = False, **kwargs) AsyncGenerator[None, Union[DocumentArray, 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_responses: bool = False, **kwargs) AsyncGenerator[None, Union[DocumentArray, 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_responses: bool = False, **kwargs) AsyncGenerator[None, Union[DocumentArray, Response]] #