craft-ai-sdk 0.50.0rc1__tar.gz → 0.50.1rc2__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.50.0rc1 → craft_ai_sdk-0.50.1rc2}/PKG-INFO +1 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/__init__.py +1 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/pipeline_metrics.py +1 -22
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/sdk.py +1 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/utils.py +33 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/documentation.pdf +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/pyproject.toml +1 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/setup.py +1 -1
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/LICENSE +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/README.md +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/constants.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/data_store.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/deployments.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/endpoints.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/environment_variables.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/pipeline_executions.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/pipelines.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/resource_metrics.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/steps.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/users.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/exceptions.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/io.py +0 -0
- {craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/warnings.py +0 -0
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import warnings
|
|
3
2
|
|
|
4
|
-
from ..utils import log_func_result, remove_none_values
|
|
3
|
+
from ..utils import log_func_result, remove_none_values, get_execution_id
|
|
5
4
|
from ..sdk import BaseCraftAiSdk
|
|
6
5
|
|
|
7
|
-
_execution_context = None
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def get_execution_id():
|
|
11
|
-
global _execution_context
|
|
12
|
-
if _execution_context is None:
|
|
13
|
-
try:
|
|
14
|
-
# File injected in steps
|
|
15
|
-
import __craft_internal_execution_context # type: ignore
|
|
16
|
-
|
|
17
|
-
_execution_context = __craft_internal_execution_context
|
|
18
|
-
except ImportError:
|
|
19
|
-
_execution_context = False
|
|
20
|
-
if _execution_context:
|
|
21
|
-
try:
|
|
22
|
-
return _execution_context.current_execution_id.get()
|
|
23
|
-
except LookupError:
|
|
24
|
-
pass
|
|
25
|
-
return os.environ.get("CRAFT_AI_EXECUTION_ID")
|
|
26
|
-
|
|
27
6
|
|
|
28
7
|
@log_func_result("Pipeline metrics definition", get_execution_id)
|
|
29
8
|
def record_metric_value(sdk: BaseCraftAiSdk, name, value):
|
|
@@ -128,7 +128,7 @@ class CraftAiSdk(BaseCraftAiSdk):
|
|
|
128
128
|
os.environ.get("CRAFT_AI__MULTIPART_PART_SIZE__B", str(38 * 256 * 1024))
|
|
129
129
|
)
|
|
130
130
|
_access_token_margin = timedelta(seconds=30)
|
|
131
|
-
_version = "0.50.
|
|
131
|
+
_version = "0.50.1rc2" # Would be better to share it somewhere
|
|
132
132
|
|
|
133
133
|
def __init__(
|
|
134
134
|
self,
|
|
@@ -8,9 +8,30 @@ from typing import Callable, Iterable, Union
|
|
|
8
8
|
import xml.etree.ElementTree as ET
|
|
9
9
|
from requests import RequestException, Response
|
|
10
10
|
from json import JSONDecodeError
|
|
11
|
+
import os
|
|
11
12
|
|
|
12
13
|
from .exceptions import SdkException
|
|
13
14
|
|
|
15
|
+
_execution_context = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_execution_id():
|
|
19
|
+
global _execution_context
|
|
20
|
+
if _execution_context is None:
|
|
21
|
+
try:
|
|
22
|
+
# File injected in steps
|
|
23
|
+
import __craft_internal_execution_context # type: ignore
|
|
24
|
+
|
|
25
|
+
_execution_context = __craft_internal_execution_context
|
|
26
|
+
except ImportError:
|
|
27
|
+
_execution_context = False
|
|
28
|
+
if _execution_context:
|
|
29
|
+
try:
|
|
30
|
+
return _execution_context.current_execution_id.get()
|
|
31
|
+
except LookupError:
|
|
32
|
+
pass
|
|
33
|
+
return os.environ.get("CRAFT_AI_EXECUTION_ID")
|
|
34
|
+
|
|
14
35
|
|
|
15
36
|
def handle_data_store_response(response):
|
|
16
37
|
"""Return the content of a response received from the datastore
|
|
@@ -64,8 +85,19 @@ def _parse_json_response(response):
|
|
|
64
85
|
def _raise_craft_ai_error_from_response(response: Response):
|
|
65
86
|
try:
|
|
66
87
|
error_content = response.json()
|
|
88
|
+
error_message = error_content.get("message", "The server returned an error")
|
|
89
|
+
|
|
90
|
+
# Permission denied inside a running execution
|
|
91
|
+
if response.status_code == 403 and get_execution_id() is not None:
|
|
92
|
+
error_message = (
|
|
93
|
+
"Insufficient permissions. This is probably because "
|
|
94
|
+
"you called an SDK function that is not permitted from "
|
|
95
|
+
"inside a running deployment or execution, even if it "
|
|
96
|
+
"works from your computer. Original error: " + error_message
|
|
97
|
+
)
|
|
98
|
+
|
|
67
99
|
raise SdkException(
|
|
68
|
-
message=
|
|
100
|
+
message=error_message,
|
|
69
101
|
status_code=response.status_code,
|
|
70
102
|
name=error_content.get("name"),
|
|
71
103
|
request_id=error_content.get("request_id"),
|
|
Binary file
|
|
@@ -24,7 +24,7 @@ entry_points = \
|
|
|
24
24
|
|
|
25
25
|
setup_kwargs = {
|
|
26
26
|
'name': 'craft-ai-sdk',
|
|
27
|
-
'version': '0.50.
|
|
27
|
+
'version': '0.50.1rc2',
|
|
28
28
|
'description': 'Craft AI MLOps platform SDK',
|
|
29
29
|
'long_description': '# Craft AI Python SDK\n\nThis Python SDK lets you interact with Craft AI MLOps Platform.\n\n## Installation\nThis project relies on **Python 3.8+**. Once a supported version of Python is installed, you can install `craft-ai-sdk` from PyPI with:\n\n```console\npip install craft-ai-sdk\n```\n\n## Basic usage\nYou can configure the SDK by instantiating the `CraftAiSdk` class in this way:\n\n```python\nfrom craft_ai_sdk import CraftAiSdk\n\nCRAFT_AI_SDK_TOKEN = # your access key obtained from your settings page\nCRAFT_AI_ENVIRONMENT_URL = # url to your environment\n\nsdk = CraftAiSdk(sdk_token=CRAFT_AI_SDK_TOKEN, environment_url=CRAFT_AI_ENVIRONMENT_URL)\n```\n\nIf using the SDK in interactive mode, some additional feedbacks will be printed. You can force disable or enable those logs by either\n* Setting the `verbose_log` SDK parameter\n* Or setting the `SDK_VERBOSE_LOG` env var\n',
|
|
30
30
|
'author': 'Craft AI',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{craft_ai_sdk-0.50.0rc1 → craft_ai_sdk-0.50.1rc2}/craft_ai_sdk/core/environment_variables.py
RENAMED
|
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
|