weaviate.wcs
Module used to automatically submit batches to Weaviate.
- class weaviate.wcs.WCS(auth_client_secret: AuthClientPassword, timeout_config: Tuple[Real, Real] | Real = (2, 20), proxies: dict | str | None = None, trust_env: bool = False, dev: bool = False)
Bases:
BaseConnection
WCS class used to create/delete WCS cluster instances.
- dev
True if the WCS instance is for the development console, False if it is for the production environment.
- Type:
bool
Initialize a WCS class instance.
- Parameters:
auth_client_secret (AuthClientPassword) – Authentication credentials for the WCS.
dev (bool, optional) – Whether to use the development environment, i.e. https://dev.console.semi.technology/. If False uses the production environment, i.e. https://console.semi.technology/. By default False.
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).
- add_user_to_cluster(cluster_name: str, user: str) None
Add user to the WCS Weaviate cluster instance.
- Parameters:
cluster_name (str) – The name of the Weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
user – The user to be added to WCS Weaviate cluster instance.
- Raises:
requests.ConnectionError – If the network connection to Weaviate fails.
weaviate.UnsuccessfulStatusCodeError – If deleting the Weaviate cluster failed for a different reason, more information is given in the exception.
- create(cluster_name: str | None = None, cluster_type: str = 'sandbox', with_auth: bool = False, modules: str | dict | list | None = None, config: dict | None = None, wait_for_completion: bool = True) str
Create the cluster and return The Weaviate server URL.
- Parameters:
cluster_name (str, optional) – The name of the weaviate cluster to be created, if None a random one is going to be generated, by default None. NOTE: Case insensitive. The created cluster’s name is always lowercased.
cluster_type (str, optional) – the cluster type/tier, by default ‘sandbox’.
with_auth (bool, optional) – Enable the authentication to the cluster about to be created, by default False.
modules (str or dict or list, optional) – The modules to use, can have multiple modules. One module should look like this: >>> { … “name”: “string”, # required … “repo”: “string”, # optional … “tag”: “string”, # optional … “inferenceUrl”: “string” # optional … } See the Examples for additional information.
config (dict, optional) – the cluster configuration. If NOT None then cluster_name, cluster_type, module are ignored and the whole cluster configuration should be in this argument, by default None. See the Examples below for the complete configuration schema.
wait_for_completion (bool, optional) – Whether to wait until the cluster is built, by default True
Examples
If the modules is string then it is going to be used as the MODULE_NAME with a default tag for that given MODULE_NAME. If module is a dict then it should have the below structure.
Contextionary:
>>> { ... "name": "text2vec-contextionary", ... "tag": "en0.16.0-v1.0.0" # this is the default tag ... }
Transformers:
>>> { ... "name": "text2vec-transformers", ... "tag": "sentence-transformers-paraphrase-MiniLM-L6-v2" ... }
Both the examples above use the ‘semitechnologies’ repo (which is the default one). The modules also can be a list of individual module configuration that conforms to the above description.
The COMPLETE config argument looks like this:
>>> { ... "email": "user@example.com", ... "configuration": { ... "requiresAuthentication": true, ... "c11yTag": "string", ... "tier": "string", ... "supportLevel": "string", ... "region": "string", ... "release": { ... "chart": "latest", ... "weaviate": "latest" ... }, ... "modules": [ ... { ... "name": "string", ... "repo": "string", ... "tag": "string", ... "inferenceUrl": "string" ... } ... ], ... "backup": { ... "activated": false ... }, ... "restore": { ... "name": "string" ... } ... }, ... "id": "string" ... }
- Returns:
The URL of the create Weaviate server cluster.
- Return type:
str
- Raises:
requests.ConnectionError – If the network connection to weaviate fails.
weaviate.UnexpectedStatusCodeException – If creating the weaviate cluster failed for a different reason, more information is given in the exception.
TypeError – If config is neither None nor of type ‘dict’.
TypeError – If modules argument is of a wrong type.
KeyError – If one of the modules does not conform to the module schema.
TypeError – In case modules is a list and one module has a wrong type.
TypeError – In case one of the modules is of type dict and the values are not of type ‘str’.
- delete_cluster(cluster_name: str) None
Delete the WCS Weaviate cluster instance.
- Parameters:
cluster_name (str) – The name of the weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
- Raises:
requests.ConnectionError – If the network connection to weaviate fails.
weaviate.UnexpectedStatusCodeException – If deleting the weaviate cluster failed for a different reason, more information is given in the exception.
- get_cluster_config(cluster_name: str) dict
Get details of a cluster.
- Parameters:
cluster_name (str) – The name of the weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
- Returns:
Details in a JSON format. If no cluster with such name was found then an empty dictionary is returned.
- Return type:
dict
- Raises:
requests.ConnectionError – If the network connection to weaviate fails.
weaviate.UnexpectedStatusCodeException – If getting the weaviate cluster failed for a different reason, more information is given in the exception.
- get_clusters() List[str] | None
Lists all weaviate clusters registered with the this account.
- Returns:
A list of cluster names or None if no clusters.
- Return type:
Optional[List[str]]
- Raises:
requests.ConnectionError – If the network connection to weaviate fails.
weaviate.UnexpectedStatusCodeException – If getting the weaviate clusters failed for a different reason, more information is given in the exception.
- get_users_of_cluster(cluster_name: str) list
Get users of the WCS Weaviate cluster instance.
- Parameters:
cluster_name (str) – The name of the Weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
- Raises:
requests.ConnectionError – If the network connection to Weaviate fails.
weaviate.UnsuccessfulStatusCodeError – If deleting the Weaviate cluster failed for a different reason, more information is given in the exception.
- Returns:
The list of users.
- Return type:
list
- is_ready(cluster_name: str) bool
Check if the cluster is created.
- Parameters:
cluster_name (str) – The name of the weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
- Returns:
True if cluster is created and ready to use, False otherwise.
- Return type:
bool
- remove_user_from_cluster(cluster_name: str, user: str) None
Remove user from the WCS Weaviate cluster instance.
- Parameters:
cluster_name (str) – The name of the Weaviate server cluster. NOTE: Case insensitive. The WCS cluster’s name is always lowercased.
user – The user to be removed from WCS Weaviate cluster instance.
- Raises:
requests.ConnectionError – If the network connection to Weaviate fails.
weaviate.UnsuccessfulStatusCodeError – If deleting the Weaviate cluster failed for a different reason, more information is given in the exception.