craft-ai-sdk 0.61.1__tar.gz → 0.62.0__tar.gz

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.
Files changed (33) hide show
  1. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/PKG-INFO +2 -1
  2. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/__init__.py +1 -1
  3. craft_ai_sdk-0.62.0/craft_ai_sdk/core/vector_database.py +67 -0
  4. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/sdk.py +6 -2
  5. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/documentation.pdf +0 -0
  6. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/pyproject.toml +2 -1
  7. craft_ai_sdk-0.61.1/craft_ai_sdk/core/vector_database.py +0 -21
  8. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/LICENSE +0 -0
  9. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/README.md +0 -0
  10. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/constants.py +0 -0
  11. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/data_store.py +0 -0
  12. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/deployments.py +0 -0
  13. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/endpoints.py +0 -0
  14. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/environment_variables.py +0 -0
  15. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/pipeline_executions.py +0 -0
  16. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/pipeline_metrics.py +0 -0
  17. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/pipelines.py +0 -0
  18. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/resource_metrics.py +0 -0
  19. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/steps.py +0 -0
  20. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/core/users.py +0 -0
  21. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/exceptions.py +0 -0
  22. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/io.py +0 -0
  23. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/authentication.py +0 -0
  24. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/environments.py +0 -0
  25. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/execution_context.py +0 -0
  26. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/helpers.py +0 -0
  27. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/logger.py +0 -0
  28. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/request_response_handler.py +0 -0
  29. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/shared/warnings.py +0 -0
  30. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/utils/__init__.py +0 -0
  31. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/utils/datetime_utils.py +0 -0
  32. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/utils/dict_utils.py +0 -0
  33. {craft_ai_sdk-0.61.1 → craft_ai_sdk-0.62.0}/craft_ai_sdk/utils/file_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: craft-ai-sdk
3
- Version: 0.61.1
3
+ Version: 0.62.0
4
4
  Summary: Craft AI MLOps platform SDK
5
5
  Home-page: https://www.craft.ai/
6
6
  License: Apache-2.0
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
16
16
  Requires-Dist: PyJWT (>=2.3.0,<3.0.0)
17
17
  Requires-Dist: StrEnum (>=0.4.9,<0.5.0)
18
18
  Requires-Dist: requests (>=2.27.1,<3.0.0)
19
+ Requires-Dist: weaviate-client (>=4.10.4,<5.0.0)
19
20
  Description-Content-Type: text/markdown
20
21
 
21
22
  # Craft AI Python SDK
@@ -13,4 +13,4 @@ from .io import ( # noqa: F401
13
13
  )
14
14
  from .sdk import CraftAiSdk # noqa: F401
15
15
 
16
- __version__ = "0.61.1"
16
+ __version__ = "0.62.0"
@@ -0,0 +1,67 @@
1
+ from craft_ai_sdk.shared.environments import get_environment_id
2
+
3
+ from ..sdk import BaseCraftAiSdk
4
+ from ..shared.logger import log_action, log_func_result
5
+
6
+
7
+ def get_vector_database_credentials(sdk: BaseCraftAiSdk):
8
+ """Get the credentials of the vector database.
9
+
10
+ Returns:
11
+ :obj:`dict`: The vector database credentials, with the following keys:
12
+ * ``"vector_database_url"`` (:obj:`str`): URL of the vector database.
13
+ * ``"vector_database_token"`` (:obj:`str`): Token to connect to the vector
14
+ database.
15
+ """
16
+ environment_id = get_environment_id(sdk)
17
+
18
+ vector_database_url = (
19
+ f"{sdk.base_control_api_url}/environments/{environment_id}/vector-database"
20
+ )
21
+
22
+ return sdk._get(vector_database_url)
23
+
24
+
25
+ @log_func_result("Connecting to Weaviate")
26
+ def get_weaviate_client(sdk: BaseCraftAiSdk):
27
+ """Get the Weaviate client.
28
+
29
+ Returns:
30
+ :obj:`weaviate.WeaviateClient`: The Weaviate client.
31
+ """
32
+ try:
33
+ import weaviate
34
+ except ModuleNotFoundError:
35
+ raise ModuleNotFoundError(
36
+ "The 'weaviate' package is required to use the vector database. "
37
+ "You can install it with 'pip install weaviate-client'."
38
+ )
39
+ credentials = get_vector_database_credentials(sdk)
40
+
41
+ is_secure = credentials["vector_database_url"].startswith("https://")
42
+
43
+ vector_database_url = (
44
+ credentials["vector_database_url"]
45
+ .replace("http://", "")
46
+ .replace("https://", "")
47
+ ).rstrip("/")
48
+
49
+ log_action(sdk, "Connecting to Weaviate")
50
+
51
+ weaviate_client = weaviate.connect_to_custom(
52
+ http_host=vector_database_url,
53
+ http_port=8080,
54
+ grpc_host=vector_database_url,
55
+ grpc_port=8082,
56
+ http_secure=is_secure,
57
+ grpc_secure=is_secure,
58
+ headers={
59
+ "craft-vector-database-token": credentials["vector_database_token"],
60
+ "craft-vector-database-url": credentials["vector_database_url"],
61
+ },
62
+ auth_credentials=None,
63
+ )
64
+
65
+ log_action(sdk, "Connected to Weaviate, using version", weaviate.__version__)
66
+
67
+ return weaviate_client
@@ -116,7 +116,11 @@ class CraftAiSdk(BaseCraftAiSdk):
116
116
  list_steps,
117
117
  )
118
118
  from .core.users import get_user
119
- from .core.vector_database import get_vector_database_credentials
119
+
120
+ from .core.vector_database import (
121
+ get_vector_database_credentials,
122
+ get_weaviate_client,
123
+ )
120
124
 
121
125
  # Size (in bytes) from which datastore upload will switch to multipart
122
126
  # AWS: minimum part size is 5MiB
@@ -132,7 +136,7 @@ class CraftAiSdk(BaseCraftAiSdk):
132
136
  os.environ.get("CRAFT_AI__MULTIPART_PART_SIZE__B", str(38 * 256 * 1024))
133
137
  )
134
138
  _access_token_margin = timedelta(seconds=30)
135
- _version = "0.61.1" # Would be better to share it somewhere
139
+ _version = "0.62.0" # Would be better to share it somewhere
136
140
 
137
141
  def __init__(
138
142
  self,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "craft-ai-sdk"
3
- version = "0.61.1"
3
+ version = "0.62.0"
4
4
  description = "Craft AI MLOps platform SDK"
5
5
  license = "Apache-2.0"
6
6
  authors = ["Craft AI <contact@craft.ai>"]
@@ -29,6 +29,7 @@ python = "^3.9"
29
29
  requests = "^2.27.1"
30
30
  PyJWT = "^2.3.0"
31
31
  StrEnum = "^0.4.9"
32
+ weaviate-client = "^4.10.4"
32
33
 
33
34
  [tool.poetry.group.dev.dependencies]
34
35
  ipython = "^8.18.1"
@@ -1,21 +0,0 @@
1
- from craft_ai_sdk.shared.environments import get_environment_id
2
-
3
- from ..sdk import BaseCraftAiSdk
4
-
5
-
6
- def get_vector_database_credentials(sdk: BaseCraftAiSdk):
7
- """Get the credentials of the vector database.
8
-
9
- Returns:
10
- :obj:`dict`: The vector database credentials, with the following keys:
11
- * ``"vector_database_url"`` (:obj:`str`): URL of the vector database.
12
- * ``"vector_database_token"`` (:obj:`str`): Token to connect to the vector
13
- database.
14
- """
15
- environment_id = get_environment_id(sdk)
16
-
17
- vector_database_url = (
18
- f"{sdk.base_control_api_url}/environments/{environment_id}/vector-database"
19
- )
20
-
21
- return sdk._get(vector_database_url)
File without changes
File without changes