craft-ai-sdk 0.68.2__tar.gz → 0.70.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 (35) hide show
  1. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/PKG-INFO +11 -12
  2. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/README.md +1 -1
  3. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/__init__.py +1 -1
  4. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/pipelines.py +2 -0
  5. craft_ai_sdk-0.70.0/craft_ai_sdk/core/vector_database.py +145 -0
  6. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/sdk.py +2 -1
  7. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/helpers.py +8 -0
  8. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/documentation.pdf +0 -0
  9. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/pyproject.toml +41 -31
  10. craft_ai_sdk-0.68.2/craft_ai_sdk/core/vector_database.py +0 -78
  11. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/LICENSE +0 -0
  12. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/constants.py +0 -0
  13. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/data_store.py +0 -0
  14. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/deployments.py +0 -0
  15. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/endpoints.py +0 -0
  16. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/environment_variables.py +0 -0
  17. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/pipeline_executions.py +0 -0
  18. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/pipeline_metrics.py +0 -0
  19. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/pipeline_templates.py +0 -0
  20. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/resource_metrics.py +0 -0
  21. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/steps.py +0 -0
  22. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/core/users.py +0 -0
  23. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/exceptions.py +0 -0
  24. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/io.py +0 -0
  25. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/authentication.py +0 -0
  26. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/environments.py +0 -0
  27. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/execution_context.py +0 -0
  28. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/logger.py +0 -0
  29. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/request_response_handler.py +0 -0
  30. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/types.py +0 -0
  31. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/shared/warnings.py +0 -0
  32. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/utils/__init__.py +0 -0
  33. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/utils/datetime_utils.py +0 -0
  34. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/utils/dict_utils.py +0 -0
  35. {craft_ai_sdk-0.68.2 → craft_ai_sdk-0.70.0}/craft_ai_sdk/utils/file_utils.py +0 -0
@@ -1,23 +1,22 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: craft-ai-sdk
3
- Version: 0.68.2
3
+ Version: 0.70.0
4
4
  Summary: Craft AI MLOps platform SDK
5
- License: Apache-2.0
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
6
7
  Author: Craft AI
7
8
  Author-email: contact@craft.ai
8
- Requires-Python: >=3.9,<4.0
9
- Classifier: License :: OSI Approved :: Apache Software License
9
+ Requires-Python: >=3.10
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
11
  Classifier: Programming Language :: Python :: 3.10
13
12
  Classifier: Programming Language :: Python :: 3.11
14
13
  Classifier: Programming Language :: Python :: 3.12
15
14
  Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: PyJWT (>=2.3.0,<3.0.0)
17
- Requires-Dist: StrEnum (>=0.4.9,<0.5.0)
18
- Requires-Dist: requests (>=2.27.1,<3.0.0)
19
- Requires-Dist: weaviate-client (>=4.10.4,<5.0.0)
20
- Project-URL: Homepage, https://www.craft.ai/
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Dist: StrEnum (>=0.4.9)
17
+ Requires-Dist: pyjwt (>=2.4.0)
18
+ Requires-Dist: requests (>=2.32.4)
19
+ Requires-Dist: weaviate-client (>=4.15.3)
21
20
  Description-Content-Type: text/markdown
22
21
 
23
22
  # Craft AI Python SDK
@@ -25,7 +24,7 @@ Description-Content-Type: text/markdown
25
24
  This Python SDK lets you interact with Craft AI MLOps Platform.
26
25
 
27
26
  ## Installation
28
- This project relies on **Python 3.9+**. Once a supported version of Python is installed, you can install `craft-ai-sdk` from PyPI with:
27
+ This project relies on **Python 3.10+**. Once a supported version of Python is installed, you can install `craft-ai-sdk` from PyPI with:
29
28
 
30
29
  ```console
31
30
  pip install craft-ai-sdk
@@ -3,7 +3,7 @@
3
3
  This Python SDK lets you interact with Craft AI MLOps Platform.
4
4
 
5
5
  ## Installation
6
- This project relies on **Python 3.9+**. Once a supported version of Python is installed, you can install `craft-ai-sdk` from PyPI with:
6
+ This project relies on **Python 3.10+**. Once a supported version of Python is installed, you can install `craft-ai-sdk` from PyPI with:
7
7
 
8
8
  ```console
9
9
  pip install craft-ai-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.68.2"
16
+ __version__ = "0.70.0"
@@ -474,6 +474,7 @@ def get_pipeline(
474
474
  the pipeline.
475
475
  """
476
476
  base_url = f"{sdk.base_environment_api_url}/pipelines/{pipeline_name}"
477
+ log_action(sdk, f'Get pipeline: "{pipeline_name}", "{wait_for_completion}".')
477
478
  if wait_for_completion:
478
479
  pipeline = wait_create_until_ready(
479
480
  sdk,
@@ -487,6 +488,7 @@ def get_pipeline(
487
488
  )
488
489
  else:
489
490
  pipeline = sdk._get(base_url)
491
+ log_action(sdk, "Get pipeline done.")
490
492
 
491
493
  latest_execution = sdk._get(
492
494
  f"{sdk.base_environment_api_url}/pipelines/{pipeline_name}/executions/latest"
@@ -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.2" # Would be better to share it somewhere
146
+ _version = "0.70.0" # Would be better to share it somewhere
146
147
 
147
148
  def __init__(
148
149
  self,
@@ -1,15 +1,23 @@
1
1
  from craft_ai_sdk.exceptions import SdkException
2
+ from craft_ai_sdk.shared.logger import log_action
2
3
 
3
4
 
4
5
  def wait_create_until_ready(sdk, name, get_func, timeout_s, start_time, get_log_func):
5
6
  elapsed_time = sdk._get_time() - start_time
6
7
  status = "creation_pending"
8
+ log_action(sdk, f'Start waiting for "{name}" to be created.')
7
9
  while status == "creation_pending" and (
8
10
  timeout_s is None or elapsed_time < timeout_s
9
11
  ):
10
12
  created_obj = get_func(sdk, name)
11
13
  status = created_obj.get("creation_info", {}).get("status", None)
12
14
  elapsed_time = sdk._get_time() - start_time
15
+ log_action(
16
+ sdk,
17
+ f'Still waiting for "{name}" to be created, \
18
+ status="{status}", elapsed time={elapsed_time}s.',
19
+ )
20
+ log_action(sdk, f'End waiting for "{name}" to be created, status="{status}".')
13
21
 
14
22
  if status == "creation_failed":
15
23
  raise SdkException(
@@ -1,15 +1,20 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "craft-ai-sdk"
3
- version = "0.68.2"
4
3
  description = "Craft AI MLOps platform SDK"
5
- license = "Apache-2.0"
6
- authors = ["Craft AI <contact@craft.ai>"]
4
+ authors = [{name = "Craft AI", email = "contact@craft.ai"}]
7
5
  readme = "README.md"
8
6
  homepage = "https://www.craft.ai/"
9
- packages = [{ include = "craft_ai_sdk" }]
10
- include = ["documentation.pdf"]
7
+ license = "Apache-2.0"
8
+ version = "0.70.0"
9
+ requires-python = ">=3.10"
10
+ dependencies = [
11
+ "requests >= 2.32.4",
12
+ "pyjwt >= 2.4.0",
13
+ "StrEnum >= 0.4.9",
14
+ "weaviate-client >= 4.15.3",
15
+ ]
11
16
 
12
- [tool.poetry.scripts]
17
+ [project.scripts]
13
18
  lint = "scripts.scripts:lint"
14
19
  lintfix = "scripts.scripts:lintfix"
15
20
  format = "scripts.scripts:format"
@@ -22,33 +27,38 @@ set-version = "scripts.scripts:set_version"
22
27
  pdfdoc = "scripts.scripts:generate_docs_in_pdf"
23
28
  rstdoc = "scripts.scripts:generate_docs_in_rst"
24
29
 
30
+ [dependency-groups]
31
+ dev = [
32
+ "ipython < 8.31", # >= 8.31.0 dropped support for python 3.10
33
+ "ipykernel >= 7.1.0",
34
+ "pylint >= 4.0.3",
35
+ "python-dotenv >= 1.2.1",
36
+ "pytest >= 9.0.1",
37
+ "pytest-asyncio >= 1.3.0",
38
+ "requests-mock[fixture] >= 1.12.1",
39
+ "pytest-watch >= 4.2.0",
40
+ "pyarrow >= 22.0.0",
41
+ "pandas >= 2.3.3",
42
+ "ruff >= 0.14.6",
43
+ ]
44
+ docs = [
45
+ "doc8 >= 2.0.0",
46
+ "Sphinx < 8.2.0", # >= 8.2.0 dropped support for python 3.10
47
+ "sphinxcontrib-restbuilder >= 0.3",
48
+ ]
49
+
50
+ [tool.poetry]
51
+ version = "0.70.0"
52
+ packages = [{ include = "craft_ai_sdk" }]
53
+ include = ["documentation.pdf"]
54
+ requires-poetry = ">=2.2.1"
55
+
56
+ [tool.poetry.group.docs]
57
+ optional = true
58
+
25
59
  [tool.pytest.ini_options]
26
60
  filterwarnings = ["ignore::UserWarning"]
27
61
 
28
- [tool.poetry.dependencies]
29
- python = "^3.9"
30
- requests = "^2.27.1"
31
- PyJWT = "^2.3.0"
32
- StrEnum = "^0.4.9"
33
- weaviate-client = "^4.10.4"
34
-
35
- [tool.poetry.group.dev.dependencies]
36
- ipython = "^8.18.1"
37
- ipykernel = "^6.29.5"
38
- pylint = "^3.3.7"
39
- python-dotenv = "^1.0.1"
40
- pytest = "^8.3.4"
41
- requests-mock = { extras = ["fixture"], version = "^1.9.3" }
42
- pytest-watch = "^4.2.0"
43
- pyarrow = "^19.0.1"
44
- pandas = "^2.2.3"
45
- ruff = "^0.12.2"
46
-
47
- [tool.poetry.group.docs.dependencies]
48
- doc8 = "^0.10.1"
49
- Sphinx = "^5.0.1"
50
- sphinxcontrib-restbuilder = "^0.3"
51
-
52
62
  [tool.ruff.lint]
53
63
  extend-select = ["B", "C", "E", "F", "I", "T", "W"]
54
64
  extend-ignore = ["C401", "C901"]
@@ -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