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).

Raises

ValueError – If no authentication credentials provided but the Weaviate server has an OpenID configured.

delete(path: str, weaviate_object: Optional[dict] = None)requests.models.Response

Make a DELETE request to the Weaviate server instance.

Parameters
  • path (str) – Sub-path to the Weaviate resources. Must be a valid Weaviate sub-path. e.g. ‘/meta’ or ‘/objects’, without version.

  • weaviate_object (dict, optional) – Object is used as payload for DELETE request. By default None.

Returns

The response, if request was successful.

Return type

requests.Response

Raises

requests.ConnectionError – If the DELETE request could not be made.

get(path: str, params: Optional[dict] = None)requests.models.Response

Make a GET request to the Weaviate server instance.

Parameters
  • path (str) – Sub-path to the Weaviate resources. Must be a valid Weaviate sub-path. e.g. ‘/meta’ or ‘/objects’, without version.

  • 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 GET request could not be made.

patch(path: str, weaviate_object: dict)requests.models.Response

Make a PATCH request to the Weaviate server instance.

Parameters
  • path (str) – Sub-path to the Weaviate resources. Must be a valid Weaviate sub-path. e.g. ‘/meta’ or ‘/objects’, without version.

  • weaviate_object (dict) – Object is used as payload for PATCH request.

Returns

The response, if request was successful.

Return type

requests.Response

Raises

requests.ConnectionError – If the PATCH request could not be made.

post(path: str, weaviate_object: dict)requests.models.Response

Make a POST request to the Weaviate server instance.

Parameters
  • path (str) – Sub-path to the Weaviate resources. Must be a valid Weaviate sub-path. e.g. ‘/meta’ or ‘/objects’, without version.

  • weaviate_object (dict) – Object is used as payload for POST request.

Returns

The response, if request was successful.

Return type

requests.Response

Raises

requests.ConnectionError – If the POST request could not be made.

put(path: str, weaviate_object: dict)requests.models.Response

Make a PUT request to the Weaviate server instance.

Parameters
  • path (str) – Sub-path to the Weaviate resources. Must be a valid Weaviate sub-path. e.g. ‘/meta’ or ‘/objects’, without version.

  • weaviate_object (dict) – Object is used as payload for PUT request.

Returns

The response, if request was successful.

Return type

requests.Response

Raises

requests.ConnectionError – If the PUT request could not be made.

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]