craft-ai-sdk 0.68.2rc1__tar.gz → 0.68.3__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.
Potentially problematic release.
This version of craft-ai-sdk might be problematic. Click here for more details.
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/PKG-INFO +1 -1
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/__init__.py +1 -1
- craft_ai_sdk-0.68.3/craft_ai_sdk/core/vector_database.py +145 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/sdk.py +2 -1
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/documentation.pdf +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/pyproject.toml +2 -1
- craft_ai_sdk-0.68.2rc1/craft_ai_sdk/core/vector_database.py +0 -78
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/LICENSE +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/README.md +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/constants.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/data_store.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/deployments.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/endpoints.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/environment_variables.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/pipeline_executions.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/pipeline_metrics.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/pipeline_templates.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/pipelines.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/resource_metrics.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/steps.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/core/users.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/exceptions.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/io.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/authentication.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/environments.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/execution_context.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/helpers.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/logger.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/request_response_handler.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/types.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/warnings.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/utils/__init__.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/utils/datetime_utils.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/utils/dict_utils.py +0 -0
- {craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/utils/file_utils.py +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, TypedDict
|
|
2
|
+
|
|
3
|
+
from craft_ai_sdk.shared.environments import get_environment_id
|
|
4
|
+
|
|
5
|
+
from ..sdk import BaseCraftAiSdk
|
|
6
|
+
from ..shared.logger import log_action, log_func_result
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
try:
|
|
10
|
+
import weaviate as weaviate_type
|
|
11
|
+
except ModuleNotFoundError:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class VectorDatabaseCredentials(TypedDict):
|
|
16
|
+
vector_database_url: str
|
|
17
|
+
vector_database_token: str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_vector_database_credentials(sdk: BaseCraftAiSdk) -> VectorDatabaseCredentials:
|
|
21
|
+
"""Get the credentials of the vector database.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
:obj:`dict`: The vector database credentials, with the following keys:
|
|
25
|
+
* ``"vector_database_url"`` (:obj:`str`): URL of the vector database.
|
|
26
|
+
* ``"vector_database_token"`` (:obj:`str`): Token to connect to the vector
|
|
27
|
+
database.
|
|
28
|
+
"""
|
|
29
|
+
environment_id = get_environment_id(sdk)
|
|
30
|
+
|
|
31
|
+
vector_database_url = (
|
|
32
|
+
f"{sdk.base_control_api_url}/environments/{environment_id}/vector-database"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return sdk._get(vector_database_url)
|
|
36
|
+
|
|
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
|
+
|
|
62
|
+
@log_func_result("Connecting to Weaviate")
|
|
63
|
+
def get_weaviate_client(sdk: BaseCraftAiSdk) -> "weaviate_type.WeaviateClient":
|
|
64
|
+
"""Initializes and returns a Weaviate client for interacting with the vector
|
|
65
|
+
database.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
:obj:`weaviate.WeaviateClient`: The Weaviate client.
|
|
69
|
+
"""
|
|
70
|
+
try:
|
|
71
|
+
import weaviate
|
|
72
|
+
except ModuleNotFoundError:
|
|
73
|
+
raise ModuleNotFoundError(
|
|
74
|
+
"The 'weaviate' package is required to use the vector database. "
|
|
75
|
+
"You can install it with 'pip install weaviate-client'."
|
|
76
|
+
) from None
|
|
77
|
+
|
|
78
|
+
weaviate_parameters = _get_weaviate_parameters(sdk)
|
|
79
|
+
|
|
80
|
+
log_action(sdk, "Connecting to Weaviate")
|
|
81
|
+
|
|
82
|
+
weaviate_client = weaviate.connect_to_custom(
|
|
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"],
|
|
128
|
+
http_port=8080,
|
|
129
|
+
grpc_host=weaviate_parameters["vector_database_host"],
|
|
130
|
+
grpc_port=8082,
|
|
131
|
+
http_secure=weaviate_parameters["is_secure"],
|
|
132
|
+
grpc_secure=weaviate_parameters["is_secure"],
|
|
133
|
+
headers={
|
|
134
|
+
"craft-vector-database-token": weaviate_parameters["vector_database_token"],
|
|
135
|
+
"craft-vector-database-url": weaviate_parameters["vector_database_url"],
|
|
136
|
+
},
|
|
137
|
+
auth_credentials=None,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
log_action(
|
|
141
|
+
sdk,
|
|
142
|
+
f"Connected to Weaviate, using version {weaviate.__version__}",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return weaviate_client
|
|
@@ -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.
|
|
146
|
+
_version = "0.68.3" # Would be better to share it somewhere
|
|
146
147
|
|
|
147
148
|
def __init__(
|
|
148
149
|
self,
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "craft-ai-sdk"
|
|
3
|
-
version = "0.68.
|
|
3
|
+
version = "0.68.3"
|
|
4
4
|
description = "Craft AI MLOps platform SDK"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
authors = ["Craft AI <contact@craft.ai>"]
|
|
@@ -38,6 +38,7 @@ ipykernel = "^6.29.5"
|
|
|
38
38
|
pylint = "^3.3.7"
|
|
39
39
|
python-dotenv = "^1.0.1"
|
|
40
40
|
pytest = "^8.3.4"
|
|
41
|
+
pytest-asyncio = "^1.2.0"
|
|
41
42
|
requests-mock = { extras = ["fixture"], version = "^1.9.3" }
|
|
42
43
|
pytest-watch = "^4.2.0"
|
|
43
44
|
pyarrow = "^19.0.1"
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
from typing import TypedDict
|
|
2
|
-
|
|
3
|
-
from craft_ai_sdk.shared.environments import get_environment_id
|
|
4
|
-
|
|
5
|
-
from ..sdk import BaseCraftAiSdk
|
|
6
|
-
from ..shared.logger import log_action, log_func_result
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class VectorDatabaseCredentials(TypedDict):
|
|
10
|
-
vector_database_url: str
|
|
11
|
-
vector_database_token: str
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def get_vector_database_credentials(sdk: BaseCraftAiSdk) -> VectorDatabaseCredentials:
|
|
15
|
-
"""Get the credentials of the vector database.
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
:obj:`dict`: The vector database credentials, with the following keys:
|
|
19
|
-
* ``"vector_database_url"`` (:obj:`str`): URL of the vector database.
|
|
20
|
-
* ``"vector_database_token"`` (:obj:`str`): Token to connect to the vector
|
|
21
|
-
database.
|
|
22
|
-
"""
|
|
23
|
-
environment_id = get_environment_id(sdk)
|
|
24
|
-
|
|
25
|
-
vector_database_url = (
|
|
26
|
-
f"{sdk.base_control_api_url}/environments/{environment_id}/vector-database"
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return sdk._get(vector_database_url)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@log_func_result("Connecting to Weaviate")
|
|
33
|
-
def get_weaviate_client(sdk: BaseCraftAiSdk):
|
|
34
|
-
"""Initializes and returns a Weaviate client for interacting with the vector
|
|
35
|
-
database.
|
|
36
|
-
|
|
37
|
-
Returns:
|
|
38
|
-
:obj:`weaviate.WeaviateClient`: The Weaviate client.
|
|
39
|
-
"""
|
|
40
|
-
try:
|
|
41
|
-
import weaviate
|
|
42
|
-
except ModuleNotFoundError:
|
|
43
|
-
raise ModuleNotFoundError(
|
|
44
|
-
"The 'weaviate' package is required to use the vector database. "
|
|
45
|
-
"You can install it with 'pip install weaviate-client'."
|
|
46
|
-
) from None
|
|
47
|
-
credentials = get_vector_database_credentials(sdk)
|
|
48
|
-
|
|
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("/")
|
|
56
|
-
|
|
57
|
-
log_action(sdk, "Connecting to Weaviate")
|
|
58
|
-
|
|
59
|
-
weaviate_client = weaviate.connect_to_custom(
|
|
60
|
-
http_host=vector_database_url,
|
|
61
|
-
http_port=8080,
|
|
62
|
-
grpc_host=vector_database_url,
|
|
63
|
-
grpc_port=8082,
|
|
64
|
-
http_secure=is_secure,
|
|
65
|
-
grpc_secure=is_secure,
|
|
66
|
-
headers={
|
|
67
|
-
"craft-vector-database-token": credentials["vector_database_token"],
|
|
68
|
-
"craft-vector-database-url": credentials["vector_database_url"],
|
|
69
|
-
},
|
|
70
|
-
auth_credentials=None,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
log_action(
|
|
74
|
-
sdk,
|
|
75
|
-
f"Connected to Weaviate, using version {weaviate.__version__}",
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
return weaviate_client
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{craft_ai_sdk-0.68.2rc1 → craft_ai_sdk-0.68.3}/craft_ai_sdk/shared/request_response_handler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|