weaviate.wcs¶
Module used to automatically submit batches to Weaviate.
-
class
weaviate.wcs.
WCS
(auth_client_secret: weaviate.auth.AuthCredentials, 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 (AuthCredentials) – 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.
-
create
(cluster_name: Optional[str] = None, cluster_type: str = 'sandbox', with_auth: bool = False, module: Optional[Union[dict, str]] = None, config: Optional[dict] = None, wait_for_completion: bool = True) → str¶ Create the cluster and return a Weaviate Client instance that is connected to that cluster.
- Parameters
cluster_name (str, optional) – Name of the weaviate cluster, if None a random one is going to be generated, by default None
cluster_type (str, optional) – Cluster type, by default ‘sandbox’.
with_auth (bool, optional) – Enable the authentication to the cluster about to be created, by default False.
module (str or dict, optional) – The vectorizer module to use. Supported only on DEV environment WCS. The module configuration looks like this: {“name”: MODULE_NAME, “tag”: MODULE_TAG} See examples below.
config (dict, optional) – Cluster configuration. If it is NOT None then cluster_name, cluster_type, module are ignored and the whole cluster configuration should be in this argument, by default None
wait_for_completion (bool, optional) – Whether to wait until the cluster is built, by default True
Examples
If the module is str 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 above structure.
Contextionary:
>>> { ... "name": "text2vec-contextionary", ... "tag": "en0.16.0-v1.0.0" # this is the default tag ... }
Transformers:
>>> { ... "name": "text2vec-transformers", ... "tag": "distilbert-base-uncased" # or another transformer model from ... # https://huggingface.co/models ... }
- Returns
The URL of the create 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.
-
delete
(cluster_name: str) → None¶ Delete the WCS instance.
- Parameters
cluster_name (str) – Name of the weaviate cluster.
- 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) – Name of the weaviate cluster.
- Returns
Details in a JSON format.
- 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
(email: str) → Optional[List[str]]¶ Lists all weaviate clusters registered with the ‘email’.
- Parameters
email (str) – The email for which to get cluster names.
- 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_authentication_required
= True¶
-
is_ready
(cluster_name: str) → bool¶ Check if the cluster is created.
- Parameters
cluster_name (str) – Name of the weaviate cluster.
- Returns
True if cluster is created and ready to use, False otherwise.
- Return type
bool
-