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.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, **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.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
[ForwardRef
]) – the function to be called when theRequest
object is resolved.on_error (
Optional
[ForwardRef
]) – the function to be called when theRequest
object is rejected.on_always (
Optional
[ForwardRef
]) – 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.kwargs – additional parameters
- Return type
Union
[ForwardRef
,List
[ForwardRef
],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, **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, **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, **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, **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]#
Async 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.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
[ForwardRef
]) – the function to be called when theRequest
object is resolved.on_error (
Optional
[ForwardRef
]) – the function to be called when theRequest
object is rejected.on_always (
Optional
[ForwardRef
]) – 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.kwargs – additional parameters
- 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
,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] #