weaviate.connect¶
Module communication to a Weaviate instance. Used to connect to Weaviate and run REST requests.
-
class
weaviate.connect.
Connection
(url: str, auth_client_secret: Optional[weaviate.auth.AuthCredentials] = None, timeout_config: Union[Tuple[numbers.Real, numbers.Real], numbers.Real] = (2, 20))¶ Bases:
object
Connection class used to communicate to a weaviate instance.
Initialize a Connection class instance.
- Parameters
url (str) – URL to a running weaviate instance.
auth_client_secret (weaviate.auth.AuthCredentials, optional) – User login credentials to a weaviate instance, 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).
-
run_rest
(path: str, rest_method: int, weaviate_object: Optional[dict] = None, params: Optional[dict] = None) → requests.models.Response¶ Make a request to the weaviate instance.
- Parameters
path (str) – Sub-path to the weaviate resources. Must be a valid weaviate sub-path. e.g. /meta or /objects, without version.
rest_method (int) – Type of the rest API request. Is defined through a constant given in the package e.g. REST_METHOD_GET.
weaviate_object (dict, optional) – Object is used as payload, by default None
params (dict, optional) – Additional request parameters, by default None
- Returns
The response if request was successful.
- Return type
requests.Response
- Raises
requests.ConnectionError – If the request could not be made. (from requests.’method’ calls)
-
property
timeout_config
¶ 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]