craft-ai-sdk 0.67.0rc1__tar.gz → 0.67.1__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.67.0rc1 → craft_ai_sdk-0.67.1}/PKG-INFO +1 -1
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/__init__.py +1 -1
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/data_store.py +35 -14
- craft_ai_sdk-0.67.1/craft_ai_sdk/core/pipeline_templates.py +126 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/pipelines.py +122 -21
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/sdk.py +3 -1
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/environments.py +2 -2
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/documentation.pdf +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/pyproject.toml +1 -1
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/LICENSE +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/README.md +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/constants.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/deployments.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/endpoints.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/environment_variables.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/pipeline_executions.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/pipeline_metrics.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/resource_metrics.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/steps.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/users.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/core/vector_database.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/exceptions.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/io.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/authentication.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/execution_context.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/helpers.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/logger.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/request_response_handler.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/types.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/shared/warnings.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/utils/__init__.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/utils/datetime_utils.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/utils/dict_utils.py +0 -0
- {craft_ai_sdk-0.67.0rc1 → craft_ai_sdk-0.67.1}/craft_ai_sdk/utils/file_utils.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import io
|
|
2
|
-
from typing import TypedDict, Union
|
|
2
|
+
from typing import IO, Iterable, TypedDict, Union
|
|
3
3
|
|
|
4
4
|
import requests
|
|
5
5
|
|
|
@@ -46,17 +46,17 @@ def get_data_store_object_information(
|
|
|
46
46
|
return result
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def
|
|
49
|
+
def iter_data_store_objects(
|
|
50
50
|
sdk: BaseCraftAiSdk, folder_path: Union[str, None] = None
|
|
51
|
-
) ->
|
|
52
|
-
"""Get
|
|
51
|
+
) -> Iterable[DataStoreObjectInformation]:
|
|
52
|
+
"""Get an iterable returning every objects stored in the data store.
|
|
53
53
|
|
|
54
54
|
Args:
|
|
55
55
|
folder_path (:obj:`str`, optional): Location of the requested folder in the data
|
|
56
56
|
store.
|
|
57
57
|
|
|
58
58
|
Returns:
|
|
59
|
-
:obj:`
|
|
59
|
+
:obj:`Iterable` of :obj:`dict`: List of objects in the data store represented
|
|
60
60
|
as :obj:`dict` with the following keys:
|
|
61
61
|
|
|
62
62
|
* ``"path"`` (:obj:`str`): Location of the object in the data store.
|
|
@@ -66,16 +66,37 @@ def list_data_store_objects(
|
|
|
66
66
|
"""
|
|
67
67
|
url = f"{sdk.base_environment_api_url}/data-store/list"
|
|
68
68
|
params = {"folder_path": folder_path} if folder_path else {}
|
|
69
|
-
|
|
70
|
-
all_items = result["items"]
|
|
71
|
-
while result.get("continuation_token", None):
|
|
72
|
-
params = {"continuation_token": result["continuation_token"], **params}
|
|
69
|
+
while True:
|
|
73
70
|
result = sdk._get(url, params=params)
|
|
74
|
-
|
|
71
|
+
for object in result["items"]:
|
|
72
|
+
object["size"] = convert_size(object["size"])
|
|
73
|
+
yield object
|
|
74
|
+
continuation_token = result.get("continuation_token", None)
|
|
75
|
+
if continuation_token is None:
|
|
76
|
+
return
|
|
77
|
+
else:
|
|
78
|
+
params = {"continuation_token": continuation_token, **params}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def list_data_store_objects(
|
|
82
|
+
sdk: BaseCraftAiSdk, folder_path: Union[str, None] = None
|
|
83
|
+
) -> list[DataStoreObjectInformation]:
|
|
84
|
+
"""Get the list of the objects stored in the data store.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
folder_path (:obj:`str`, optional): Location of the requested folder in the data
|
|
88
|
+
store.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
:obj:`list` of :obj:`dict`: List of objects in the data store represented
|
|
92
|
+
as :obj:`dict` with the following keys:
|
|
75
93
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
* ``"path"`` (:obj:`str`): Location of the object in the data store.
|
|
95
|
+
* ``"last_modified"`` (:obj:`str`): The creation date or last
|
|
96
|
+
modification date in ISO format.
|
|
97
|
+
* ``"size"`` (:obj:`int`): The size of the object in bytes.
|
|
98
|
+
"""
|
|
99
|
+
return list(iter_data_store_objects(sdk, folder_path))
|
|
79
100
|
|
|
80
101
|
|
|
81
102
|
def _get_upload_presigned_url(sdk: BaseCraftAiSdk, object_path_in_datastore: str):
|
|
@@ -205,7 +226,7 @@ def _get_download_presigned_url(
|
|
|
205
226
|
def download_data_store_object(
|
|
206
227
|
sdk: BaseCraftAiSdk,
|
|
207
228
|
object_path_in_datastore: str,
|
|
208
|
-
filepath_or_buffer: Union[str, io.IOBase],
|
|
229
|
+
filepath_or_buffer: Union[str, IO, io.IOBase],
|
|
209
230
|
):
|
|
210
231
|
"""Download an object in the data store and save it into a file.
|
|
211
232
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from typing import TypedDict
|
|
2
|
+
|
|
3
|
+
from craft_ai_sdk.sdk import BaseCraftAiSdk
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PipelineTemplateReference(TypedDict):
|
|
7
|
+
name: str
|
|
8
|
+
version: str
|
|
9
|
+
display_name: str
|
|
10
|
+
description: str
|
|
11
|
+
hosting_type: str
|
|
12
|
+
model_family: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PipelineTemplate(PipelineTemplateReference):
|
|
16
|
+
enabled: bool
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PipelineTemplateDetails(PipelineTemplate):
|
|
20
|
+
inputs: list[dict]
|
|
21
|
+
outputs: list[dict]
|
|
22
|
+
recommended_inputs_mapping: list[dict]
|
|
23
|
+
recommended_outputs_mapping: list[dict]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def list_pipeline_templates(sdk: BaseCraftAiSdk) -> list[PipelineTemplate]:
|
|
27
|
+
"""List all the available pipeline templates.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
:obj:`list` of :obj:`dict`: List of available pipeline templates represented
|
|
31
|
+
as a dict with the following keys:
|
|
32
|
+
|
|
33
|
+
* ``"name"`` (:obj:`str`): Name of the pipeline template used as an
|
|
34
|
+
identifier to create the pipeline.
|
|
35
|
+
* ``"version"`` (:obj:`str`): Version of the pipeline template.
|
|
36
|
+
* ``"enabled"`` (:obj:`bool`): Whether the pipeline template can be used to
|
|
37
|
+
create pipelines or not.
|
|
38
|
+
* ``"display_name"`` (:obj:`str`): Display name of the pipeline
|
|
39
|
+
template.
|
|
40
|
+
* ``"description"`` (:obj:`str`): Description of the pipeline template.
|
|
41
|
+
* ``"hosting_type"`` (:obj:`str`): Either ``"self-hosted"`` if the model
|
|
42
|
+
runs on the environment's infrastructure, or ``"private-api"`` if the
|
|
43
|
+
model inference is done through an external API.
|
|
44
|
+
* ``"model_family"`` (:obj:`str`): Model family of the pipeline
|
|
45
|
+
template.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
url = f"{sdk.base_environment_api_url}/pipeline-templates"
|
|
49
|
+
response = sdk._get(url)
|
|
50
|
+
return response["pipeline_templates"]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_pipeline_template(sdk: BaseCraftAiSdk, pipeline_template_name: str):
|
|
54
|
+
"""Get information about a specific pipeline template. A pipeline template
|
|
55
|
+
could be used to create a pipeline.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
pipeline_template_name (str): Name of the pipeline template to retrieve.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
:obj:`dict`: Information on the pipeline template represented as dict
|
|
62
|
+
with the following keys:
|
|
63
|
+
|
|
64
|
+
* ``"name"`` (:obj:`str`): Name of the pipeline template used as an
|
|
65
|
+
identifier to create the pipeline.
|
|
66
|
+
* ``"version"`` (:obj:`str`): Version of the pipeline template.
|
|
67
|
+
* ``"enabled"`` (:obj:`bool`): Whether the pipeline template can be used to
|
|
68
|
+
create pipelines or not.
|
|
69
|
+
* ``"display_name"`` (:obj:`str`): Display name of the pipeline
|
|
70
|
+
template.
|
|
71
|
+
* ``"description"`` (:obj:`str`): Description of the pipeline template.
|
|
72
|
+
* ``"hosting_type"`` (:obj:`str`): Either ``"self-hosted"`` if the model
|
|
73
|
+
runs on the environment's infrastructure, or ``"private-api"`` if the
|
|
74
|
+
model inference is done through an external API.
|
|
75
|
+
* ``"model_family"`` (:obj:`str`): Model family of the pipeline
|
|
76
|
+
template.
|
|
77
|
+
* ``"inputs"`` (:obj:`list` of :obj:`dict`): List of inputs of the pipeline
|
|
78
|
+
once created represented as a dict with the following keys:
|
|
79
|
+
|
|
80
|
+
* ``"name"`` (:obj:`str`): Input name.
|
|
81
|
+
* ``"data_type"`` (:obj:`str`): Input data type.
|
|
82
|
+
* ``"is_required"`` (:obj:`bool`): Whether the input is required.
|
|
83
|
+
* ``"default_value"`` (:obj:`str`): Input default value.
|
|
84
|
+
* ``"description"`` (:obj:`str`): Output description.
|
|
85
|
+
|
|
86
|
+
* ``"outputs"`` (:obj:`list` of :obj:`dict`): List of outputs of the pipeline
|
|
87
|
+
once created represented as a dict with the following keys:
|
|
88
|
+
|
|
89
|
+
* ``"name"`` (:obj:`str`): Output name.
|
|
90
|
+
* ``"data_type"`` (:obj:`str`): Output data type.
|
|
91
|
+
* ``"description"`` (:obj:`str`): Output description.
|
|
92
|
+
|
|
93
|
+
* ``"recommended_inputs_mapping"`` (:obj:`list` of :obj:`dict`):
|
|
94
|
+
List of recommended inputs mapping for creating a deployment represented
|
|
95
|
+
as a dict with the following keys:
|
|
96
|
+
|
|
97
|
+
* ``"pipeline_input_name"`` (:obj:`str`): Name of the input.
|
|
98
|
+
* ``"data_type`` (:obj:`str`): Data type of the input.
|
|
99
|
+
* ``"source`` (:obj:`str`): Source of type of the input. Can be
|
|
100
|
+
"environment_variable", "datastore", "constant", "is_null" "endpoint"
|
|
101
|
+
or "run".
|
|
102
|
+
* ``"endpoint_input_name"`` (:obj:`str`): Name of the input in the
|
|
103
|
+
endpoint execution if source is "endpoint".
|
|
104
|
+
* ``"constant_value"`` (:obj:`str`): Value of the constant if source is
|
|
105
|
+
"constant".
|
|
106
|
+
* ``"environment_variable_name"`` (:obj:`str`): Name of the environment
|
|
107
|
+
variable if source is "environment_variable".
|
|
108
|
+
* ``"is_null"`` (:obj:`bool`): True if source is "is_null".
|
|
109
|
+
* ``"value"``: Value of the input.
|
|
110
|
+
|
|
111
|
+
* ``"recommended_outputs_mapping"`` (:obj:`list` of :obj:`dict`):
|
|
112
|
+
List of recommended outputs mapping for creating a deployment represented
|
|
113
|
+
as a dict with the following keys:
|
|
114
|
+
|
|
115
|
+
* ``"pipeline_output_name"`` (:obj:`str`): Name of the output.
|
|
116
|
+
* ``"data_type`` (:obj:`str`): Data type of the output.
|
|
117
|
+
* ``"destination`` (:obj:`str`): Destination of type of the output. Can be
|
|
118
|
+
"datastore", "is_null" "endpoint" or "run".
|
|
119
|
+
* ``"endpoint_output_name"`` (:obj:`str`): Name of the output in the
|
|
120
|
+
endpoint execution if destination is "endpoint".
|
|
121
|
+
* ``"is_null"`` (:obj:`bool`): True if destination is "is_null".
|
|
122
|
+
* ``"value"``: Value of the output.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
url = f"{sdk.base_environment_api_url}/pipeline-templates/{pipeline_template_name}"
|
|
126
|
+
return sdk._get(url)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import warnings
|
|
3
|
-
from typing import TypedDict, Union, cast
|
|
3
|
+
from typing import TypedDict, Union, cast, overload
|
|
4
4
|
|
|
5
5
|
import requests
|
|
6
6
|
from typing_extensions import NotRequired
|
|
7
7
|
|
|
8
|
+
from craft_ai_sdk.core.pipeline_templates import PipelineTemplateReference
|
|
8
9
|
from craft_ai_sdk.io import Input, Output
|
|
9
10
|
from craft_ai_sdk.shared.types import Log
|
|
10
11
|
|
|
@@ -33,16 +34,6 @@ class PipelineParameter(TypedDict):
|
|
|
33
34
|
container_config: ContainerConfig
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
class PipelineTemplateReference(TypedDict):
|
|
37
|
-
id: str
|
|
38
|
-
name: str
|
|
39
|
-
version: str
|
|
40
|
-
display_name: str
|
|
41
|
-
description: str
|
|
42
|
-
hosting_type: str
|
|
43
|
-
model_family: str
|
|
44
|
-
|
|
45
|
-
|
|
46
37
|
class PipelineCreationInfo(StepCreationInfo):
|
|
47
38
|
last_execution_id: str
|
|
48
39
|
pipeline_template: Union[PipelineTemplateReference, None]
|
|
@@ -73,6 +64,24 @@ class PipelineDeleted(TypedDict):
|
|
|
73
64
|
deployments: list[PipelineDeletedDeployment]
|
|
74
65
|
|
|
75
66
|
|
|
67
|
+
def _create_pipeline_from_template(
|
|
68
|
+
sdk: BaseCraftAiSdk, pipeline_name: str, pipeline_template_name: str
|
|
69
|
+
) -> None:
|
|
70
|
+
url = f"{sdk.base_environment_api_url}/pipelines"
|
|
71
|
+
body = {
|
|
72
|
+
"pipeline_name": pipeline_name,
|
|
73
|
+
"pipeline_template_name": pipeline_template_name,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
log_action(
|
|
77
|
+
sdk,
|
|
78
|
+
f'Please wait while pipeline "{pipeline_name}" is being created. '
|
|
79
|
+
"This may take a while...",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
sdk._post(url, json=body, allow_redirects=False)
|
|
83
|
+
|
|
84
|
+
|
|
76
85
|
def _create_pipeline_with_step(
|
|
77
86
|
sdk: BaseCraftAiSdk, pipeline_name: str, step_name: str
|
|
78
87
|
) -> Pipeline:
|
|
@@ -87,6 +96,28 @@ def _create_pipeline_with_step(
|
|
|
87
96
|
)
|
|
88
97
|
|
|
89
98
|
|
|
99
|
+
@overload
|
|
100
|
+
def create_pipeline(
|
|
101
|
+
sdk: BaseCraftAiSdk,
|
|
102
|
+
pipeline_name: str,
|
|
103
|
+
function_path: Union[str, None] = None,
|
|
104
|
+
function_name: Union[str, None] = None,
|
|
105
|
+
description: Union[str, None] = None,
|
|
106
|
+
container_config: Union[ContainerConfig, None] = None,
|
|
107
|
+
inputs: Union[list[Input], None] = None,
|
|
108
|
+
outputs: Union[list[Output], None] = None,
|
|
109
|
+
wait_for_completion: bool = True,
|
|
110
|
+
timeout_s: Union[int, None] = None,
|
|
111
|
+
) -> Pipeline: ...
|
|
112
|
+
@overload
|
|
113
|
+
def create_pipeline(
|
|
114
|
+
sdk: BaseCraftAiSdk,
|
|
115
|
+
pipeline_name: str,
|
|
116
|
+
*,
|
|
117
|
+
pipeline_template_name: str,
|
|
118
|
+
wait_for_completion: bool = True,
|
|
119
|
+
timeout_s: Union[int, None] = None,
|
|
120
|
+
) -> Pipeline: ...
|
|
90
121
|
@log_func_result("Pipeline creation")
|
|
91
122
|
def create_pipeline(
|
|
92
123
|
sdk: BaseCraftAiSdk,
|
|
@@ -97,19 +128,35 @@ def create_pipeline(
|
|
|
97
128
|
container_config: Union[ContainerConfig, None] = None,
|
|
98
129
|
inputs: Union[list[Input], None] = None,
|
|
99
130
|
outputs: Union[list[Output], None] = None,
|
|
100
|
-
wait_for_completion=True,
|
|
131
|
+
wait_for_completion: bool = True,
|
|
101
132
|
timeout_s: Union[int, None] = None,
|
|
133
|
+
*,
|
|
134
|
+
pipeline_template_name: Union[str, None] = None,
|
|
102
135
|
**kwargs,
|
|
103
|
-
):
|
|
104
|
-
"""Create a pipeline
|
|
136
|
+
) -> Pipeline:
|
|
137
|
+
"""Create a pipeline via two main creation modes:
|
|
138
|
+
|
|
139
|
+
**Function-based pipeline creation**
|
|
140
|
+
Create a pipeline from a function located on a remote repository or locally.
|
|
141
|
+
It requires :obj:`function_path` and :obj:`function_name` parameters
|
|
142
|
+
to be specified.
|
|
143
|
+
|
|
144
|
+
Use :obj:`CREATION_PARAMETER_VALUE` to explicitly set a value to null or fall back
|
|
145
|
+
on project information.
|
|
146
|
+
You can also use :obj:`container_config.included_folders` to specify the files and
|
|
147
|
+
folders required for the pipeline execution. This is useful if your repository
|
|
148
|
+
contains large files that are not required for the pipeline execution, such as
|
|
149
|
+
documentation or test files. Indeed there is a maximum limit of 5MB for the
|
|
150
|
+
total size of the content specified with :obj:`included_folders`.
|
|
151
|
+
|
|
152
|
+
**Template-based pipeline creation**
|
|
153
|
+
Create a pipeline from a predefined pipeline template by specifying the
|
|
154
|
+
:obj:`pipeline_template_name`. Function parameters should not be specified in
|
|
155
|
+
this case, as the template defines them.
|
|
156
|
+
|
|
157
|
+
In both cases, there are two optional parameters to control the pipeline creation
|
|
158
|
+
process: :obj:`wait_for_completion` and :obj:`timeout_s`.
|
|
105
159
|
|
|
106
|
-
Use :obj:`CREATION_PARAMETER_VALUE` to explicitly set a value to null or fall back
|
|
107
|
-
on project information.
|
|
108
|
-
You can also use :obj:`container_config.included_folders` to specify the files and
|
|
109
|
-
folders required for the pipeline execution. This is useful if your repository
|
|
110
|
-
contains large files that are not required for the pipeline execution, such as
|
|
111
|
-
documentation or test files. Indeed there is a maximum limit of 5MB for the
|
|
112
|
-
total size of the content specified with :obj:`included_folders`.
|
|
113
160
|
|
|
114
161
|
Args:
|
|
115
162
|
pipeline_name (:obj:`str`): Name of the pipeline to be created.
|
|
@@ -169,6 +216,9 @@ def create_pipeline(
|
|
|
169
216
|
:obj:`dict` with the name of the output as keys and the value of the
|
|
170
217
|
output as values. Each output should be specified as an instance
|
|
171
218
|
of :class:`Output` via this parameter `outputs`.
|
|
219
|
+
|
|
220
|
+
pipeline_template_name (:obj:`str`, keyword-only): Name of the pipeline template
|
|
221
|
+
to use.
|
|
172
222
|
wait_for_completion (:obj:`bool`, optional): Whether to wait for the pipeline
|
|
173
223
|
to be created. Defaults to ``True``.
|
|
174
224
|
timeout_s (:obj:`int`): Maximum time (in seconds) to wait for the pipeline to
|
|
@@ -229,9 +279,44 @@ def create_pipeline(
|
|
|
229
279
|
* ``"status"`` (:obj:`str`): either ``"creation_pending"`` or ``"ready"``.
|
|
230
280
|
* ``"origin"`` (:obj:`str`): The origin of the pipeline, can be
|
|
231
281
|
``"git_repository"`` or ``"local"``.
|
|
282
|
+
* ``"pipeline_template"`` (:obj:`dict` or :obj:`None`): The pipeline template
|
|
283
|
+
used to create the pipeline, :obj:`None` if the pipeline was not created
|
|
284
|
+
from a template. If not :obj:`None`, the dictionary has the following keys:
|
|
285
|
+
|
|
286
|
+
* ``"name"`` (:obj:`str`): Name of the pipeline template used as an
|
|
287
|
+
identifier to create the pipeline.
|
|
288
|
+
* ``"version"`` (:obj:`str`): Version of the pipeline template.
|
|
289
|
+
* ``"display_name"`` (:obj:`str`): Display name of the pipeline
|
|
290
|
+
template.
|
|
291
|
+
* ``"description"`` (:obj:`str`): Description of the pipeline template.
|
|
292
|
+
* ``"hosting_type"`` (:obj:`str`): Either ``"self-hosted"`` if the model
|
|
293
|
+
runs on the environment's infrastructure, or ``"private-api"`` if the
|
|
294
|
+
model inference is done through an external API.
|
|
295
|
+
* ``"model_family"`` (:obj:`str`): Model family of the pipeline
|
|
296
|
+
template.
|
|
232
297
|
* ``"last_execution_id"`` (:obj:`str`): The id of the last execution of
|
|
233
298
|
the pipeline.
|
|
234
299
|
"""
|
|
300
|
+
# Pipeline creation from a template
|
|
301
|
+
if pipeline_template_name is not None:
|
|
302
|
+
if (
|
|
303
|
+
function_path is not None
|
|
304
|
+
or function_name is not None
|
|
305
|
+
or description is not None
|
|
306
|
+
or container_config is not None
|
|
307
|
+
or inputs is not None
|
|
308
|
+
or outputs is not None
|
|
309
|
+
or len(kwargs) != 0
|
|
310
|
+
):
|
|
311
|
+
raise ValueError(
|
|
312
|
+
"create_pipeline() got unexpected arguments. When specifying the "
|
|
313
|
+
"'pipeline_template_name' keyword argument, no other argument than "
|
|
314
|
+
"'pipeline_name' should be provided."
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
_create_pipeline_from_template(sdk, pipeline_name, pipeline_template_name)
|
|
318
|
+
return get_pipeline(sdk, pipeline_name, wait_for_completion, timeout_s)
|
|
319
|
+
|
|
235
320
|
# For backward compatibility, a pipeline can be created with a single step:
|
|
236
321
|
args_are_none = all(
|
|
237
322
|
arg is None
|
|
@@ -333,6 +418,7 @@ def get_pipeline(
|
|
|
333
418
|
* ``"data_type"`` (:obj:`str`): Input data type.
|
|
334
419
|
* ``"is_required"`` (:obj:`bool`): Whether the input is required.
|
|
335
420
|
* ``"default_value"`` (:obj:`str`): Input default value.
|
|
421
|
+
* ``"description"`` (:obj:`str`): Output description.
|
|
336
422
|
|
|
337
423
|
* ``"outputs"`` (:obj:`list` of :obj:`dict`): List of outputs
|
|
338
424
|
represented as a :obj:`dict` with the following keys:
|
|
@@ -369,6 +455,21 @@ def get_pipeline(
|
|
|
369
455
|
* ``"status"`` (:obj:`str`): either ``"creation_pending"`` or ``"ready"``.
|
|
370
456
|
* ``"origin"`` (:obj:`str`): The origin of the pipeline, can be
|
|
371
457
|
``"git_repository"`` or ``"local"``.
|
|
458
|
+
* ``"pipeline_template"`` (:obj:`dict` or :obj:`None`): The pipeline template
|
|
459
|
+
used to create the pipeline, :obj:`None` if the pipeline was not created
|
|
460
|
+
from a template. If not :obj:`None`, the dictionary has the following keys:
|
|
461
|
+
|
|
462
|
+
* ``"name"`` (:obj:`str`): Name of the pipeline template used as an
|
|
463
|
+
identifier to create the pipeline.
|
|
464
|
+
* ``"version"`` (:obj:`str`): Version of the pipeline template.
|
|
465
|
+
* ``"display_name"`` (:obj:`str`): Display name of the pipeline
|
|
466
|
+
template.
|
|
467
|
+
* ``"description"`` (:obj:`str`): Description of the pipeline template.
|
|
468
|
+
* ``"hosting_type"`` (:obj:`str`): Either ``"self-hosted"`` if the model
|
|
469
|
+
runs on the environment's infrastructure, or ``"private-api"`` if the
|
|
470
|
+
model inference is done through an external API.
|
|
471
|
+
* ``"model_family"`` (:obj:`str`): Model family of the pipeline
|
|
472
|
+
template.
|
|
372
473
|
* ``"last_execution_id"`` (:obj:`str`): The id of the last execution of
|
|
373
474
|
the pipeline.
|
|
374
475
|
"""
|
|
@@ -65,6 +65,7 @@ class CraftAiSdk(BaseCraftAiSdk):
|
|
|
65
65
|
delete_data_store_object,
|
|
66
66
|
download_data_store_object,
|
|
67
67
|
get_data_store_object_information,
|
|
68
|
+
iter_data_store_objects,
|
|
68
69
|
list_data_store_objects,
|
|
69
70
|
upload_data_store_object,
|
|
70
71
|
)
|
|
@@ -102,6 +103,7 @@ class CraftAiSdk(BaseCraftAiSdk):
|
|
|
102
103
|
record_list_metric_values,
|
|
103
104
|
record_metric_value,
|
|
104
105
|
)
|
|
106
|
+
from .core.pipeline_templates import get_pipeline_template, list_pipeline_templates
|
|
105
107
|
from .core.pipelines import (
|
|
106
108
|
create_pipeline,
|
|
107
109
|
delete_pipeline,
|
|
@@ -139,7 +141,7 @@ class CraftAiSdk(BaseCraftAiSdk):
|
|
|
139
141
|
os.environ.get("CRAFT_AI__MULTIPART_PART_SIZE__B", str(38 * 256 * 1024))
|
|
140
142
|
)
|
|
141
143
|
_access_token_margin = timedelta(seconds=30)
|
|
142
|
-
_version = "0.67.
|
|
144
|
+
_version = "0.67.1" # Would be better to share it somewhere
|
|
143
145
|
|
|
144
146
|
def __init__(
|
|
145
147
|
self,
|
|
@@ -5,7 +5,7 @@ from craft_ai_sdk.shared.request_response_handler import handle_http_response
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def get_environment_id(sdk: BaseCraftAiSdk):
|
|
8
|
-
health_url = f"{sdk.base_environment_api_url}/
|
|
8
|
+
health_url = f"{sdk.base_environment_api_url}/environment-info"
|
|
9
9
|
health_result = requests.get(
|
|
10
10
|
health_url,
|
|
11
11
|
headers={
|
|
@@ -13,4 +13,4 @@ def get_environment_id(sdk: BaseCraftAiSdk):
|
|
|
13
13
|
},
|
|
14
14
|
)
|
|
15
15
|
handle_http_response(health_result)
|
|
16
|
-
return health_result.json().get("environment_id"
|
|
16
|
+
return health_result.json().get("environment_id")
|
|
Binary file
|
|
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.67.0rc1 → craft_ai_sdk-0.67.1}/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
|