weaviate.client¶
Client class definition.
- class weaviate.client.Client(url: str, auth_client_secret: Optional[weaviate.auth.AuthCredentials] = None, timeout_config: Union[Tuple[numbers.Real, numbers.Real], numbers.Real] = (2, 20), proxies: Optional[Union[dict, str]] = None, trust_env: bool = False, additional_headers: Optional[dict] = None)¶
Bases:
object
A python native weaviate Client class that encapsulates Weaviate functionalities in one object. A Client instance creates all the needed objects to interact with Weaviate, and connects all of them to the same Weaviate instance. See below the Attributes of the Client instance. For the per attribute functionality see that attribute’s documentation.
- classification¶
A Classification object instance connected to the same Weaviate instance as the Client.
- schema¶
A Schema object instance connected to the same Weaviate instance as the Client.
- contextionary¶
A Contextionary object instance connected to the same Weaviate instance as the Client.
- batch¶
A Batch object instance connected to the same Weaviate instance as the Client.
- Type
- data_object¶
A DataObject object instance connected to the same Weaviate instance as the Client.
- Type
weaviate.date.DataObject
- query¶
A Query object instance connected to the same Weaviate instance as the Client.
- Type
Initialize a Client class instance.
- Parameters
url (str) – The URL to the weaviate instance.
auth_client_secret (weaviate.AuthCredentials or None, optional) – Authentication client secret, by default None.
timeout_config (tuple(Real, Real) or Real, optional) – Set the timeout configuration for all requests to the Weaviate server. It can be a real number or, a tuple of two real numbers: (connect timeout, read timeout). If only one real number is passed then both connect and read timeout will be set to that value, by default (2, 20).
proxies (dict, str or None, optional) – Proxies to be used for requests. Are used by both ‘requests’ and ‘aiohttp’. Can be passed as a dict (‘requests’ format: https://docs.python-requests.org/en/stable/user/advanced/#proxies), str (HTTP/HTTPS protocols are going to use this proxy) or None. By default None.
trust_env (bool, optional) – Whether to read proxies from the ENV variables: (HTTP_PROXY or http_proxy, HTTPS_PROXY or https_proxy). By default False. NOTE: ‘proxies’ has priority over ‘trust_env’, i.e. if ‘proxies’ is NOT None, ‘trust_env’ is ignored.
additional_headers (dict or None) – Additional headers to include in the requests, used to set OpenAI key. OpenAI key looks like this: {‘X-OpenAI-Api-Key’: ‘KEY’}, by default None
Examples
Without Auth.
>>> client = Client( ... url = 'http://localhost:8080' ... ) >>> client = Client( ... url = 'http://localhost:8080', ... timeout_config = (5, 15) ... )
With Auth.
>>> my_credentials = weaviate.auth.AuthClientPassword(USER_NAME, MY_PASSWORD) >>> client = Client( ... url = 'http://localhost:8080', ... auth_client_secret = my_credentials ... )
- Raises
TypeError – If arguments are of a wrong data type.
- get_meta() dict ¶
Get the meta endpoint description of weaviate.
- Returns
The dict describing the weaviate configuration.
- Return type
dict
- Raises
weaviate.UnexpectedStatusCodeException – If weaviate reports a none OK status.
- get_open_id_configuration() Optional[dict] ¶
Get the openid-configuration.
- Returns
The configuration or None if not configured.
- Return type
dict
- Raises
weaviate.UnexpectedStatusCodeException – If weaviate reports a none OK status.
- is_live() bool ¶
Ping Weaviate’s live state.
- Returns
True if weaviate is live and should not be killed, False otherwise.
- Return type
bool
- is_ready() bool ¶
Ping Weaviate’s ready state
- Returns
True if Weaviate is ready to accept requests, False otherwise.
- Return type
bool
- property timeout_config: Tuple[numbers.Real, numbers.Real]¶
Getter/setter for timeout_config.
- Parameters
timeout_config (tuple(Real, Real) or Real, optional) –
For Getter only: Set the timeout configuration for all requests to the Weaviate server. It can be a real number or, a tuple of two real numbers:
(connect timeout, read timeout).
If only one real number is passed then both connect and read timeout will be set to that value.
- Returns
For Getter only: Requests Timeout configuration.
- Return type
Tuple[Real, Real]