weaviate.wcs¶
Module used to automatically submit batches to Weaviate.
- class weaviate.wcs.WCS(auth_client_secret: weaviate.auth.AuthClientPassword, timeout_config: Union[Tuple[numbers.Real, numbers.Real], numbers.Real] = (2, 20), dev: bool = False)¶
Bases:
weaviate.connect.connection.Connection
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).
- create(cluster_name: Optional[str] = None, cluster_type: str = 'sandbox', with_auth: bool = False, modules: Optional[Union[str, dict, list]] = None, config: Optional[dict] = 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 modlues 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() Optional[List[str]] ¶
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.
- 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