craft-ai-sdk 0.68.2rc1__py3-none-any.whl → 0.68.3rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of craft-ai-sdk might be problematic. Click here for more details.

craft_ai_sdk/__init__.py CHANGED
@@ -13,4 +13,4 @@ from .io import ( # noqa: F401
13
13
  )
14
14
  from .sdk import CraftAiSdk # noqa: F401
15
15
 
16
- __version__ = "0.68.2rc1"
16
+ __version__ = "0.68.3rc1"
@@ -1,10 +1,16 @@
1
- from typing import TypedDict
1
+ from typing import TYPE_CHECKING, TypedDict
2
2
 
3
3
  from craft_ai_sdk.shared.environments import get_environment_id
4
4
 
5
5
  from ..sdk import BaseCraftAiSdk
6
6
  from ..shared.logger import log_action, log_func_result
7
7
 
8
+ if TYPE_CHECKING:
9
+ try:
10
+ import weaviate as weaviate_type
11
+ except ModuleNotFoundError:
12
+ pass
13
+
8
14
 
9
15
  class VectorDatabaseCredentials(TypedDict):
10
16
  vector_database_url: str
@@ -29,8 +35,32 @@ def get_vector_database_credentials(sdk: BaseCraftAiSdk) -> VectorDatabaseCreden
29
35
  return sdk._get(vector_database_url)
30
36
 
31
37
 
38
+ class WeaviateParameters(VectorDatabaseCredentials):
39
+ is_secure: bool
40
+ vector_database_host: str
41
+
42
+
43
+ def _get_weaviate_parameters(sdk: BaseCraftAiSdk):
44
+ credentials = get_vector_database_credentials(sdk)
45
+
46
+ is_secure = credentials["vector_database_url"].startswith("https://")
47
+
48
+ vector_database_host = (
49
+ credentials["vector_database_url"]
50
+ .replace("http://", "")
51
+ .replace("https://", "")
52
+ ).rstrip("/")
53
+
54
+ return WeaviateParameters(
55
+ vector_database_url=credentials["vector_database_url"],
56
+ vector_database_token=credentials["vector_database_token"],
57
+ is_secure=is_secure,
58
+ vector_database_host=vector_database_host,
59
+ )
60
+
61
+
32
62
  @log_func_result("Connecting to Weaviate")
33
- def get_weaviate_client(sdk: BaseCraftAiSdk):
63
+ def get_weaviate_client(sdk: BaseCraftAiSdk) -> "weaviate_type.WeaviateClient":
34
64
  """Initializes and returns a Weaviate client for interacting with the vector
35
65
  database.
36
66
 
@@ -44,28 +74,65 @@ def get_weaviate_client(sdk: BaseCraftAiSdk):
44
74
  "The 'weaviate' package is required to use the vector database. "
45
75
  "You can install it with 'pip install weaviate-client'."
46
76
  ) from None
47
- credentials = get_vector_database_credentials(sdk)
48
77
 
49
- is_secure = credentials["vector_database_url"].startswith("https://")
50
-
51
- vector_database_url = (
52
- credentials["vector_database_url"]
53
- .replace("http://", "")
54
- .replace("https://", "")
55
- ).rstrip("/")
78
+ weaviate_parameters = _get_weaviate_parameters(sdk)
56
79
 
57
80
  log_action(sdk, "Connecting to Weaviate")
58
81
 
59
82
  weaviate_client = weaviate.connect_to_custom(
60
- http_host=vector_database_url,
83
+ http_host=weaviate_parameters["vector_database_host"],
84
+ http_port=8080,
85
+ grpc_host=weaviate_parameters["vector_database_host"],
86
+ grpc_port=8082,
87
+ http_secure=weaviate_parameters["is_secure"],
88
+ grpc_secure=weaviate_parameters["is_secure"],
89
+ headers={
90
+ "craft-vector-database-token": weaviate_parameters["vector_database_token"],
91
+ "craft-vector-database-url": weaviate_parameters["vector_database_url"],
92
+ },
93
+ auth_credentials=None,
94
+ )
95
+
96
+ log_action(
97
+ sdk,
98
+ f"Connected to Weaviate, using version {weaviate.__version__}",
99
+ )
100
+
101
+ return weaviate_client
102
+
103
+
104
+ @log_func_result("Connecting to Weaviate")
105
+ def get_async_weaviate_client(
106
+ sdk: BaseCraftAiSdk,
107
+ ) -> "weaviate_type.WeaviateAsyncClient":
108
+ """Initializes and returns an async Weaviate client for interacting with the vector
109
+ database.
110
+
111
+ Returns:
112
+ :obj:`weaviate.WeaviateAsyncClient`: The Weaviate client.
113
+ """
114
+ try:
115
+ import weaviate
116
+ except ModuleNotFoundError:
117
+ raise ModuleNotFoundError(
118
+ "The 'weaviate' package is required to use the vector database. "
119
+ "You can install it with 'pip install weaviate-client'."
120
+ ) from None
121
+
122
+ weaviate_parameters = _get_weaviate_parameters(sdk)
123
+
124
+ log_action(sdk, "Connecting to Weaviate")
125
+
126
+ weaviate_client = weaviate.use_async_with_custom(
127
+ http_host=weaviate_parameters["vector_database_host"],
61
128
  http_port=8080,
62
- grpc_host=vector_database_url,
129
+ grpc_host=weaviate_parameters["vector_database_host"],
63
130
  grpc_port=8082,
64
- http_secure=is_secure,
65
- grpc_secure=is_secure,
131
+ http_secure=weaviate_parameters["is_secure"],
132
+ grpc_secure=weaviate_parameters["is_secure"],
66
133
  headers={
67
- "craft-vector-database-token": credentials["vector_database_token"],
68
- "craft-vector-database-url": credentials["vector_database_url"],
134
+ "craft-vector-database-token": weaviate_parameters["vector_database_token"],
135
+ "craft-vector-database-url": weaviate_parameters["vector_database_url"],
69
136
  },
70
137
  auth_credentials=None,
71
138
  )
craft_ai_sdk/sdk.py CHANGED
@@ -123,6 +123,7 @@ class CraftAiSdk(BaseCraftAiSdk):
123
123
  )
124
124
  from .core.users import get_user
125
125
  from .core.vector_database import (
126
+ get_async_weaviate_client,
126
127
  get_vector_database_credentials,
127
128
  get_weaviate_client,
128
129
  )
@@ -142,7 +143,7 @@ class CraftAiSdk(BaseCraftAiSdk):
142
143
  )
143
144
  # Default timeout of proxy network components
144
145
  _access_token_margin = timedelta(seconds=120)
145
- _version = "0.68.2rc1" # Would be better to share it somewhere
146
+ _version = "0.68.3rc1" # Would be better to share it somewhere
146
147
 
147
148
  def __init__(
148
149
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: craft-ai-sdk
3
- Version: 0.68.2rc1
3
+ Version: 0.68.3rc1
4
4
  Summary: Craft AI MLOps platform SDK
5
5
  License: Apache-2.0
6
6
  Author: Craft AI
@@ -1,4 +1,4 @@
1
- craft_ai_sdk/__init__.py,sha256=eFFCciMenzXHcefjgWH5c0zm394Bnnv3KxLYwpt0VwQ,366
1
+ craft_ai_sdk/__init__.py,sha256=H3m8hXsrWJjz_Qt2Z1bxkMPfM3jN0HuTf91pDMhlsOQ,366
2
2
  craft_ai_sdk/constants.py,sha256=rH4JrGlTpbjjjNRrKhk5oScbj5G5INrcVza6Bb6kIzY,980
3
3
  craft_ai_sdk/core/data_store.py,sha256=BPQalGcm6bujgkgu-MtNWWhKiJEg4MiVuCtByNbTbK8,9956
4
4
  craft_ai_sdk/core/deployments.py,sha256=Hig0Z6tZXbaLxms9ENtKI4OG3ki7G4Iz3wGk2V2Gmfg,37731
@@ -11,10 +11,10 @@ craft_ai_sdk/core/pipelines.py,sha256=FD6ai2_YhE1tz6QO57bj_lA-i93TXZzm0Y9PA0mpoc
11
11
  craft_ai_sdk/core/resource_metrics.py,sha256=ubCe6QOhud3f-EQr_TXKBsrFFaxZubqTS3fZqfV7kgg,3457
12
12
  craft_ai_sdk/core/steps.py,sha256=TwOWXAAVpLPuSZ_gvf-3E5uKEvfGIzR52Y58bqKn_Ds,23487
13
13
  craft_ai_sdk/core/users.py,sha256=q5et87q0SOMpRTBOiLX026oaEOTaY1aGqKdbUC51zbA,618
14
- craft_ai_sdk/core/vector_database.py,sha256=cidA9R-KL9nYR7d7VqBx8o8pIu1Rdp3XYLZn6pnwmok,2397
14
+ craft_ai_sdk/core/vector_database.py,sha256=NzlYeEvq4eH75Y47Z0Gam7BWJIJ0E2IPXajmPipHUAU,4553
15
15
  craft_ai_sdk/exceptions.py,sha256=IC-JfZmmmaTsbMCgirOEByRmWnatQLjKe8BErRkuwM0,1075
16
16
  craft_ai_sdk/io.py,sha256=x1G7ga10W_SeTDLHe-FrhU26_WNwWW32-yprMmCZ5Ck,11836
17
- craft_ai_sdk/sdk.py,sha256=-BuLBOOlzg7CFHimo26cMnz5Ax_eZbfZOaxKWdjOT_0,11717
17
+ craft_ai_sdk/sdk.py,sha256=CXQ0pV4J-EZenJz23LntmYxhGPybTWCJWtmltV7yLew,11752
18
18
  craft_ai_sdk/shared/authentication.py,sha256=mnsEhG0mWwG9ZY-GToHDNnYERoou_cjt4k8l_87QW6s,1024
19
19
  craft_ai_sdk/shared/environments.py,sha256=JOV3s0KIFVl_zskJb--bybzIXEGQJjrf_T4dL-szSlQ,500
20
20
  craft_ai_sdk/shared/execution_context.py,sha256=B2Ghq-wiUvq81q5mhsm79Oc59c8c00uQxMIpApFD03o,585
@@ -27,8 +27,8 @@ craft_ai_sdk/utils/__init__.py,sha256=A0sLCXSPD1Z3q2GP1uLDjvif4ivOr__Hzg9RQysEuq
27
27
  craft_ai_sdk/utils/datetime_utils.py,sha256=yYP5HVdI879WXxQCajPTnas1pWrwInOxMux-mxqQNQM,734
28
28
  craft_ai_sdk/utils/dict_utils.py,sha256=1HQ3A14SN48XPFDmQleujGAgksmkjIs3hyPLpwhwh24,748
29
29
  craft_ai_sdk/utils/file_utils.py,sha256=o10-CDt4qzgCJNPykvlNrL6WTouhVLY8C8BVpHJYt18,2795
30
- craft_ai_sdk-0.68.2rc1.dist-info/LICENSE,sha256=_2oYRJic9lZK05LceuJ9aZZw5mPHYc1WQhJiVS-oGFU,10754
31
- craft_ai_sdk-0.68.2rc1.dist-info/METADATA,sha256=DbN2rnk6mZMqGMKju5vc0tPeAW6yQ51OX63LxQOleEg,1679
32
- craft_ai_sdk-0.68.2rc1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
33
- craft_ai_sdk-0.68.2rc1.dist-info/entry_points.txt,sha256=QC96WcXvvUfLMRgFD-l_y7_TgC9SqZybLs9EQ8dsGiQ,417
34
- craft_ai_sdk-0.68.2rc1.dist-info/RECORD,,
30
+ craft_ai_sdk-0.68.3rc1.dist-info/LICENSE,sha256=_2oYRJic9lZK05LceuJ9aZZw5mPHYc1WQhJiVS-oGFU,10754
31
+ craft_ai_sdk-0.68.3rc1.dist-info/METADATA,sha256=jTCVA73g52xzvzwGOCjM9dg71A9nUHMJP_uUt130WUc,1679
32
+ craft_ai_sdk-0.68.3rc1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
33
+ craft_ai_sdk-0.68.3rc1.dist-info/entry_points.txt,sha256=QC96WcXvvUfLMRgFD-l_y7_TgC9SqZybLs9EQ8dsGiQ,417
34
+ craft_ai_sdk-0.68.3rc1.dist-info/RECORD,,