sap-ai-sdk-core 2.9.9__py3-none-any.whl → 3.0.8__py3-none-any.whl
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.
- ai_core_sdk/ai_core_v2_client.py +157 -0
- ai_core_sdk/cli.py +172 -0
- ai_core_sdk/credentials.py +196 -0
- ai_core_sdk/exception.py +11 -0
- ai_core_sdk/helpers/__init__.py +39 -0
- ai_core_sdk/helpers/constants.py +18 -0
- ai_core_sdk/helpers/logging.py +23 -0
- ai_core_sdk/models/__init__.py +33 -0
- ai_core_sdk/models/application.py +37 -0
- ai_core_sdk/models/application_query_response.py +30 -0
- ai_core_sdk/models/application_resource_sync_status.py +34 -0
- ai_core_sdk/models/application_source.py +34 -0
- ai_core_sdk/models/application_status.py +66 -0
- ai_core_sdk/models/base_models.py +62 -0
- ai_core_sdk/models/docker_registry_secret.py +23 -0
- ai_core_sdk/models/docker_registry_secret_query_response.py +30 -0
- ai_core_sdk/models/kpi.py +25 -0
- ai_core_sdk/models/object_store_secret.py +32 -0
- ai_core_sdk/models/object_store_secret_query_response.py +30 -0
- ai_core_sdk/models/repository.py +36 -0
- ai_core_sdk/models/repository_query_response.py +30 -0
- ai_core_sdk/models/repository_status.py +9 -0
- ai_core_sdk/models/resource_group.py +50 -0
- ai_core_sdk/models/resource_group_query_response.py +31 -0
- ai_core_sdk/models/resource_group_status.py +9 -0
- ai_core_sdk/models/secret.py +30 -0
- ai_core_sdk/models/secret_query_response.py +30 -0
- ai_core_sdk/resource_clients/__init__.py +13 -0
- ai_core_sdk/resource_clients/applications_client.py +173 -0
- ai_core_sdk/resource_clients/docker_registry_secrets_client.py +117 -0
- ai_core_sdk/resource_clients/internal_rest_client.py +52 -0
- ai_core_sdk/resource_clients/kpi_client.py +26 -0
- ai_core_sdk/resource_clients/metrics_client.py +131 -0
- ai_core_sdk/resource_clients/object_store_secrets_client.py +215 -0
- ai_core_sdk/resource_clients/repositories_client.py +116 -0
- ai_core_sdk/resource_clients/secrets_client.py +148 -0
- ai_core_sdk/tracking/__init__.py +2 -0
- ai_core_sdk/tracking/tracking.py +215 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.ai_core_v2_client.html +127 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.cli.html +59 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.credentials.html +209 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.exception.html +161 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.helpers.constants.html +90 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.helpers.html +52 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.helpers.logging.html +41 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.html +29 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.application.html +79 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.application_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.application_resource_sync_status.html +77 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.application_source.html +77 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.application_status.html +90 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.base_models.html +120 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.docker_registry_secret.html +85 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.docker_registry_secret_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.html +40 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.kpi.html +73 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.object_store_secret.html +71 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.object_store_secret_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.repository.html +77 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.repository_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.repository_status.html +69 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.resource_group.html +85 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.resource_group_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.resource_group_status.html +69 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.secret.html +76 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.models.secret_query_response.html +86 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.applications_client.html +186 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.docker_registry_secrets_client.html +147 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.html +29 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.internal_rest_client.html +181 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.kpi_client.html +87 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.metrics_client.html +189 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.object_store_secrets_client.html +205 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.repositories_client.html +148 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.resource_groups_client.html +156 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.resource_clients.secrets_client.html +165 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.tracking.html +22 -0
- sap_ai_sdk_core-3.0.8.data/data/docs/ai_core_sdk.tracking.tracking.html +224 -0
- sap_ai_sdk_core-3.0.8.dist-info/METADATA +253 -0
- sap_ai_sdk_core-3.0.8.dist-info/RECORD +84 -0
- {sap_ai_sdk_core-2.9.9.dist-info → sap_ai_sdk_core-3.0.8.dist-info}/WHEEL +1 -1
- sap_ai_sdk_core-3.0.8.dist-info/top_level.txt +1 -0
- sap_ai_sdk_core-2.9.9.dist-info/METADATA +0 -43
- sap_ai_sdk_core-2.9.9.dist-info/RECORD +0 -6
- sap_ai_sdk_core-2.9.9.dist-info/top_level.txt +0 -1
- {sap-ai-sdk-core → ai_core_sdk}/__init__.py +0 -0
- {sap_ai_sdk_core-2.9.9.dist-info/licenses → sap_ai_sdk_core-3.0.8.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# pylint: disable=C0114
|
|
2
|
+
import os
|
|
3
|
+
from typing import Callable, List
|
|
4
|
+
|
|
5
|
+
from ai_api_client_sdk.helpers.authenticator import Authenticator
|
|
6
|
+
from ai_core_sdk.exception import AIAPIAuthenticatorException
|
|
7
|
+
from ai_core_sdk.helpers import is_within_aicore
|
|
8
|
+
from ai_core_sdk.models import Metric, MetricCustomInfo, MetricsQueryResponse, MetricTag
|
|
9
|
+
from ai_core_sdk.resource_clients import AIAPIV2Client
|
|
10
|
+
from ai_core_sdk.resource_clients.internal_rest_client import InternalRestClient
|
|
11
|
+
from ai_core_sdk.resource_clients.metrics_client import MetricsCoreClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Tracking(MetricsCoreClient): # pylint: disable=W0223
|
|
15
|
+
"""Tracking is a class implemented for interacting with the metrics related
|
|
16
|
+
endpoints of the server. It is a wrapper around the base class
|
|
17
|
+
:class:`ai_core_sdk.resource_clients.metrics_client.MetricsCoreClient`
|
|
18
|
+
|
|
19
|
+
:param base_url: Base URL of the AI Core. Should include the base path as well. (i.e., "<base_url>/lm/scenarios"
|
|
20
|
+
should work)
|
|
21
|
+
:type base_url: str
|
|
22
|
+
:param auth_url: URL of the authorization endpoint. Should be the full URL (including /oauth/token), defaults to
|
|
23
|
+
None
|
|
24
|
+
:type auth_url: str, optional
|
|
25
|
+
:param client_id: client id to be used for authorization, defaults to None
|
|
26
|
+
:type client_id: str, optional
|
|
27
|
+
:param client_secret: client secret to be used for authorization, defaults to None
|
|
28
|
+
:type client_secret: str, optional
|
|
29
|
+
:param cert_str: certificate file content, needs to be provided alongside the key_str parameter, defaults to None
|
|
30
|
+
:type cert_str: str, optional
|
|
31
|
+
:param key_str: key file content, needs to be provided alongside the cert_str parameter, defaults to None
|
|
32
|
+
:type key_str: str, optional
|
|
33
|
+
:param cert_file_path: path to the certificate file, needs to be provided alongside the key_file_path parameter,
|
|
34
|
+
defaults to None
|
|
35
|
+
:type cert_file_path: str, optional
|
|
36
|
+
:param key_file_path: path to the key file, needs to be provided alongside the cert_file_path parameter,
|
|
37
|
+
defaults to None
|
|
38
|
+
:type key_file_path: str, optional
|
|
39
|
+
:param token_creator: the function which returns the Bearer token, when called. Either this, or
|
|
40
|
+
auth_url & client_id & client_secret should be specified, defaults to None
|
|
41
|
+
:type token_creator: Callable[[], str], optional
|
|
42
|
+
:param resource_group: The default resource group which will be used while sending the requests to the server. If
|
|
43
|
+
not set, the resource_group should be specified with every request to the server, defaults to None
|
|
44
|
+
:type resource_group: str, optional
|
|
45
|
+
"""
|
|
46
|
+
def __init__(self, base_url: str = None, auth_url: str = None, client_id: str = None, client_secret: str = None, # pylint: disable=W0231,R0913
|
|
47
|
+
cert_str: str = None, key_str: str = None, cert_file_path: str = None, key_file_path: str = None,
|
|
48
|
+
token_creator: Callable[[], str] = None, resource_group: str = None):
|
|
49
|
+
self.base_url: str = base_url
|
|
50
|
+
self.metrics_path = '/metrics'
|
|
51
|
+
self.local_experimentation = False
|
|
52
|
+
ai_api_base_url = f'{base_url}/lm'
|
|
53
|
+
|
|
54
|
+
if base_url:
|
|
55
|
+
token_creator = AIAPIV2Client._create_token_creator_if_does_not_exist(
|
|
56
|
+
token_creator=token_creator, auth_url=auth_url, client_id=client_id, client_secret=client_secret,
|
|
57
|
+
cert_str=cert_str, key_str=key_str, cert_file_path=cert_file_path, key_file_path=key_file_path)
|
|
58
|
+
ai_api_v2_client = AIAPIV2Client(base_url=ai_api_base_url, token_creator=token_creator,
|
|
59
|
+
resource_group=resource_group)
|
|
60
|
+
self.metrics_core_client = MetricsCoreClient(rest_client = ai_api_v2_client.rest_client)
|
|
61
|
+
elif is_within_aicore():
|
|
62
|
+
self.metrics_core_client = MetricsCoreClient(
|
|
63
|
+
rest_client=InternalRestClient(),
|
|
64
|
+
execution_id=os.getenv("AICORE_EXECUTION_ID"),
|
|
65
|
+
)
|
|
66
|
+
else:
|
|
67
|
+
print('Warning: Enabling local experimentation. Metrics logged will not be persisted anywhere.')
|
|
68
|
+
self.local_experimentation = True
|
|
69
|
+
|
|
70
|
+
def modify(self, execution_id: str = '', metrics: List[Metric] = None, tags: List[MetricTag] = None, # pylint: disable=R0913
|
|
71
|
+
custom_info: List[MetricCustomInfo] = None, resource_group: str = None) -> None:
|
|
72
|
+
"""Creates or updates the metrics for an execution.
|
|
73
|
+
|
|
74
|
+
:param execution_id: ID of the execution, of which the metrics should be modified.
|
|
75
|
+
:type execution_id: str
|
|
76
|
+
:param metrics: List of the metrics related to the execution, defaults to None
|
|
77
|
+
:type metrics: List[class:`ai_api_client_sdk.metric.Metric`], optional
|
|
78
|
+
:param tags: List of the tags related to the execution, defaults to None
|
|
79
|
+
:type tags: List[class:'ai_api_client_sdk.models.metric_tag.MetricTag'], optional
|
|
80
|
+
:param custom_info: List of custom info related to the execution, defaults to None
|
|
81
|
+
:type custom_info: List[class:`ai_api_client_sdk.models.metric_custom_info.MetricCustomInfo`], optional
|
|
82
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
83
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
84
|
+
defaults to None
|
|
85
|
+
:type resource_group: str
|
|
86
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
87
|
+
server
|
|
88
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
89
|
+
server
|
|
90
|
+
"""
|
|
91
|
+
if not self.local_experimentation:
|
|
92
|
+
self.metrics_core_client.modify(execution_id=execution_id, metrics=metrics, tags=tags,
|
|
93
|
+
custom_info=custom_info, resource_group=resource_group)
|
|
94
|
+
|
|
95
|
+
def log_metrics(self, metrics: List[Metric], execution_id: str = '', artifact_name: str = None,
|
|
96
|
+
resource_group: str = None) -> None:
|
|
97
|
+
"""Creates or updates the metrics for an execution.
|
|
98
|
+
|
|
99
|
+
:param metrics: List of the metrics related to the execution,
|
|
100
|
+
:type metrics: List[class:`ai_api_client_sdk.metric.Metric`]
|
|
101
|
+
:param execution_id: ID of the execution, of which the metrics should be modified.
|
|
102
|
+
:type execution_id: str
|
|
103
|
+
:param artifact_name: Name of the artifact to associate with a metric, defaults to None
|
|
104
|
+
:type artifact_name: str
|
|
105
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
106
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
107
|
+
defaults to None
|
|
108
|
+
:type resource_group: str
|
|
109
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
110
|
+
server
|
|
111
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
112
|
+
server
|
|
113
|
+
"""
|
|
114
|
+
if not self.local_experimentation:
|
|
115
|
+
self.metrics_core_client.log_metrics(metrics=metrics,
|
|
116
|
+
execution_id=execution_id,
|
|
117
|
+
artifact_name=artifact_name,
|
|
118
|
+
resource_group=resource_group)
|
|
119
|
+
|
|
120
|
+
def set_custom_info(self, custom_info: List[MetricCustomInfo], execution_id: str = '',
|
|
121
|
+
resource_group: str = None) -> None:
|
|
122
|
+
"""log custom info against the given execution
|
|
123
|
+
captures consumption semantics for the metrics or complex metric in JSON format.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
:param custom_info: List of custom info related to the execution
|
|
127
|
+
:type custom_info: List[class:`ai_api_client_sdk.models.metric_custom_info.MetricCustomInfo`], optional
|
|
128
|
+
:param execution_id: ID of the execution, of which the metrics should be modified.
|
|
129
|
+
:type execution_id: str
|
|
130
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
131
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
132
|
+
defaults to None
|
|
133
|
+
:type resource_group: str
|
|
134
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
135
|
+
server
|
|
136
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
137
|
+
server
|
|
138
|
+
"""
|
|
139
|
+
if not self.local_experimentation:
|
|
140
|
+
self.metrics_core_client.set_custom_info(custom_info=custom_info, execution_id=execution_id,
|
|
141
|
+
resource_group=resource_group)
|
|
142
|
+
|
|
143
|
+
def set_tags(self, tags: List[MetricTag], execution_id: str = '', resource_group: str = None) -> None:
|
|
144
|
+
"""log tags against the given execution
|
|
145
|
+
|
|
146
|
+
:param tags: List of the tags related to the execution, defaults to None
|
|
147
|
+
:type tags: List[class:'ai_api_client_sdk.models.metric_tag.MetricTag']
|
|
148
|
+
:param execution_id: ID of the execution, of which the metrics should be modified.
|
|
149
|
+
:type execution_id: str
|
|
150
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
151
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
152
|
+
defaults to None
|
|
153
|
+
:type resource_group: str
|
|
154
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
155
|
+
server
|
|
156
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
157
|
+
server
|
|
158
|
+
"""
|
|
159
|
+
if not self.local_experimentation:
|
|
160
|
+
self.metrics_core_client.set_tags(tags=tags, execution_id=execution_id, resource_group=resource_group)
|
|
161
|
+
|
|
162
|
+
def query(self, filter: str = None, execution_ids: List[str] = None, # pylint: disable=W0622
|
|
163
|
+
select: List[str] = None, resource_group: str = None) -> \
|
|
164
|
+
MetricsQueryResponse:
|
|
165
|
+
"""Creates or updates the metrics for an execution.
|
|
166
|
+
|
|
167
|
+
:param filter: Deprecated. Use parameter execution_ids instead. A filter expression that filters the metric
|
|
168
|
+
resources using execution IDs. User can only use in, eq operators in filter expression, defaults to None
|
|
169
|
+
:type filter: str, optional
|
|
170
|
+
:param execution_ids: IDs of the executions, of which the metrics should be retrieved, defaults to None
|
|
171
|
+
:type execution_ids: List[str], optional
|
|
172
|
+
:param select: Values of select can be metrics,tags,customInfo or any of the combinations of these or *.
|
|
173
|
+
Can be used to select(project) only the resources specified
|
|
174
|
+
:type select: List[str], optional
|
|
175
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
176
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
177
|
+
defaults to None
|
|
178
|
+
:type resource_group: str
|
|
179
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
180
|
+
server
|
|
181
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
|
|
182
|
+
server
|
|
183
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
184
|
+
server
|
|
185
|
+
:return: An object representing the response from the server
|
|
186
|
+
:rtype: class:`ai_api_client_sdk.models.metrics_query_response.MetricsQueryResponse`
|
|
187
|
+
"""
|
|
188
|
+
if self.local_experimentation:
|
|
189
|
+
print('Warning: Response will be always empty')
|
|
190
|
+
return MetricsQueryResponse.from_dict({"count":0,"resources":[]})
|
|
191
|
+
return self.metrics_core_client.query(filter=filter,
|
|
192
|
+
execution_ids=execution_ids,
|
|
193
|
+
select=select,
|
|
194
|
+
resource_group=resource_group)
|
|
195
|
+
|
|
196
|
+
def delete(self, execution_id: str, resource_group: str = None) -> None:
|
|
197
|
+
"""Deletes the metrics.
|
|
198
|
+
|
|
199
|
+
:param execution_id: ID of the execution, of which the metrics should be deleted.
|
|
200
|
+
:type execution_id: str
|
|
201
|
+
:param resource_group: Resource Group which the request should be sent on behalf. Either this or a default
|
|
202
|
+
resource group in the :class:`ai_api_client_sdk.ai_api_v2_client.AIAPIV2Client` should be specified,
|
|
203
|
+
defaults to None
|
|
204
|
+
:type resource_group: str
|
|
205
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIInvalidRequestException` if a 400 response is received from the
|
|
206
|
+
server
|
|
207
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIAuthorizationException` if a 401 response is received from the
|
|
208
|
+
server
|
|
209
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPINotFoundException` if a 404 response is received from the
|
|
210
|
+
server
|
|
211
|
+
:raises: class:`ai_api_client_sdk.exception.AIAPIServerException` if a non-2XX response is received from the
|
|
212
|
+
server
|
|
213
|
+
"""
|
|
214
|
+
if not self.local_experimentation:
|
|
215
|
+
self.metrics_core_client.delete(execution_id=execution_id, resource_group=resource_group)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
2
|
+
<html><head><title>Python: module ai_core_sdk.ai_core_v2_client</title>
|
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
4
|
+
</head><body bgcolor="#f0f0f8">
|
|
5
|
+
|
|
6
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
7
|
+
<tr bgcolor="#7799ee">
|
|
8
|
+
<td valign=bottom> <br>
|
|
9
|
+
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="ai_core_sdk.html"><font color="#ffffff">ai_core_sdk</font></a>.ai_core_v2_client</strong></big></big></font></td
|
|
10
|
+
><td align=right valign=bottom
|
|
11
|
+
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jenkins/agent/workspace/AI-Foundation_ai-core-sdk_master/ai_core_sdk/ai_core_v2_client.py">/home/jenkins/agent/workspace/AI-Foundation_ai-core-sdk_master/ai_core_sdk/ai_core_v2_client.py</a></font></td></tr></table>
|
|
12
|
+
<p></p>
|
|
13
|
+
<p>
|
|
14
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
15
|
+
<tr bgcolor="#aa55cc">
|
|
16
|
+
<td colspan=3 valign=bottom> <br>
|
|
17
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
18
|
+
|
|
19
|
+
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
20
|
+
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
|
|
21
|
+
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
|
22
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
23
|
+
<tr bgcolor="#ee77aa">
|
|
24
|
+
<td colspan=3 valign=bottom> <br>
|
|
25
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
26
|
+
|
|
27
|
+
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
28
|
+
<td width="100%"><dl>
|
|
29
|
+
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
|
|
30
|
+
</font></dt><dd>
|
|
31
|
+
<dl>
|
|
32
|
+
<dt><font face="helvetica, arial"><a href="ai_core_sdk.ai_core_v2_client.html#AICoreV2Client">AICoreV2Client</a>
|
|
33
|
+
</font></dt></dl>
|
|
34
|
+
</dd>
|
|
35
|
+
</dl>
|
|
36
|
+
<p>
|
|
37
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
38
|
+
<tr bgcolor="#ffc8d8">
|
|
39
|
+
<td colspan=3 valign=bottom> <br>
|
|
40
|
+
<font color="#000000" face="helvetica, arial"><a name="AICoreV2Client">class <strong>AICoreV2Client</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
41
|
+
|
|
42
|
+
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
43
|
+
<td colspan=2><tt><a href="#AICoreV2Client">AICoreV2Client</a>(base_url: str, auth_url: str = None, client_id: str = None, client_secret: str = None, cert_str: str = None, key_str: str = None, cert_file_path: str = None, key_file_path: str = None, token_creator: Callable[[], str] = None, resource_group: str = None, read_timeout=60, connect_timeout=60, num_request_retries=3)<br>
|
|
44
|
+
<br>
|
|
45
|
+
The <a href="#AICoreV2Client">AICoreV2Client</a> is the class implemented to interact with the AI Core endpoints. The user can use its<br>
|
|
46
|
+
attributes corresponding to the resources, for interacting with endpoints related to that resource. (i.e.,<br>
|
|
47
|
+
aicoreclient.scenario)<br>
|
|
48
|
+
<br>
|
|
49
|
+
:param base_url: Base URL of the AI Core. Should include the base path as well. (i.e., "<base_url>/lm/scenarios"<br>
|
|
50
|
+
should work)<br>
|
|
51
|
+
:type base_url: str<br>
|
|
52
|
+
:param auth_url: URL of the authorization endpoint. Should be the full URL (including /oauth/token), defaults to<br>
|
|
53
|
+
None<br>
|
|
54
|
+
:type auth_url: str, optional<br>
|
|
55
|
+
:param client_id: client id to be used for authorization, defaults to None<br>
|
|
56
|
+
:type client_id: str, optional<br>
|
|
57
|
+
:param client_secret: client secret to be used for authorization, defaults to None<br>
|
|
58
|
+
:type client_secret: str, optional<br>
|
|
59
|
+
:param cert_str: certificate file content, needs to be provided alongside the key_str parameter, defaults to None<br>
|
|
60
|
+
:type cert_str: str, optional<br>
|
|
61
|
+
:param key_str: key file content, needs to be provided alongside the cert_str parameter, defaults to None<br>
|
|
62
|
+
:type key_str: str, optional<br>
|
|
63
|
+
:param cert_file_path: path to the certificate file, needs to be provided alongside the key_file_path parameter,<br>
|
|
64
|
+
defaults to None<br>
|
|
65
|
+
:type cert_file_path: str, optional<br>
|
|
66
|
+
:param key_file_path: path to the key file, needs to be provided alongside the cert_file_path parameter,<br>
|
|
67
|
+
defaults to None<br>
|
|
68
|
+
:type key_file_path: str, optional<br>
|
|
69
|
+
:param token_creator: the function which returns the Bearer token, when called. Either this, or<br>
|
|
70
|
+
auth_url & client_id & client_secret should be specified, defaults to None<br>
|
|
71
|
+
:type token_creator: Callable[[], str], optional<br>
|
|
72
|
+
:param resource_group: The default resource group which will be used while sending the requests to the server. If<br>
|
|
73
|
+
not set, the resource_group should be specified with every request to the server, defaults to None<br>
|
|
74
|
+
:type resource_group: str, optional<br>
|
|
75
|
+
:param read_timeout: Read timeout for requests in seconds, defaults to 60s<br>
|
|
76
|
+
:type read_timeout: int<br>
|
|
77
|
+
:param connect_timeout: Connect timeout for requests in seconds, defaults to 60s<br>
|
|
78
|
+
:type connect_timeout: int<br>
|
|
79
|
+
:param num_request_retries: Number of retries for failing requests with http status code 429, 500, 502, 503 or 504,<br>
|
|
80
|
+
defaults to 60s<br>
|
|
81
|
+
:type num_request_retries: int<br> </tt></td></tr>
|
|
82
|
+
<tr><td> </td>
|
|
83
|
+
<td width="100%">Methods defined here:<br>
|
|
84
|
+
<dl><dt><a name="AICoreV2Client-__init__"><strong>__init__</strong></a>(self, base_url: str, auth_url: str = None, client_id: str = None, client_secret: str = None, cert_str: str = None, key_str: str = None, cert_file_path: str = None, key_file_path: str = None, token_creator: Callable[[], str] = None, resource_group: str = None, read_timeout=60, connect_timeout=60, num_request_retries=3)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
85
|
+
|
|
86
|
+
<hr>
|
|
87
|
+
Static methods defined here:<br>
|
|
88
|
+
<dl><dt><a name="AICoreV2Client-from_env"><strong>from_env</strong></a>(profile_name: str = None, **kwargs)</dt><dd><tt>Alternative way to create an <a href="#AICoreV2Client">AICoreV2Client</a> <a href="builtins.html#object">object</a>.<br>
|
|
89
|
+
Parameters for base_url, auth_url, client_id, client_secret, x.509 credentials (either as file path or string)<br>
|
|
90
|
+
and resource_group can be passed as keyword or are pulled from environment variables.<br>
|
|
91
|
+
It is also possible to use a profile, which is a json file in the config directory. The profile name can be<br>
|
|
92
|
+
passed as keyword or is pulled from the environment variable AICORE_PROFILE. If no profile is specified,<br>
|
|
93
|
+
the default profile is used.<br>
|
|
94
|
+
A specific path to a config, that should be used, can be set via the environment variable AICORE_CONFIG.<br>
|
|
95
|
+
The hierarchy of precedence is:<br>
|
|
96
|
+
1. keyword argument<br>
|
|
97
|
+
2. environment variable<br>
|
|
98
|
+
3. configuration file<br>
|
|
99
|
+
4. value from VCAP_SERVICES environment variable, if exists<br>
|
|
100
|
+
<br>
|
|
101
|
+
:param profile_name: name of the profile to use, defaults to None. If None is passed, the profile is read from<br>
|
|
102
|
+
the environment variable AICORE_PROFILE. If this is not set, the default profile is used.<br>
|
|
103
|
+
The default profile is read from $AICORE_HOME/config.json.<br>
|
|
104
|
+
:type profile_name: optional, str<br>
|
|
105
|
+
**kwargs: check the parameters of the class constructor</tt></dd></dl>
|
|
106
|
+
|
|
107
|
+
<hr>
|
|
108
|
+
Data descriptors defined here:<br>
|
|
109
|
+
<dl><dt><strong>__dict__</strong></dt>
|
|
110
|
+
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
111
|
+
</dl>
|
|
112
|
+
<dl><dt><strong>__weakref__</strong></dt>
|
|
113
|
+
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
114
|
+
</dl>
|
|
115
|
+
<hr>
|
|
116
|
+
Data and other attributes defined here:<br>
|
|
117
|
+
<dl><dt><strong>logger</strong> = <Logger ai_core_sdk (INFO)></dl>
|
|
118
|
+
|
|
119
|
+
</td></tr></table></td></tr></table><p>
|
|
120
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
121
|
+
<tr bgcolor="#55aa55">
|
|
122
|
+
<td colspan=3 valign=bottom> <br>
|
|
123
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
124
|
+
|
|
125
|
+
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
126
|
+
<td width="100%"><strong>Callable</strong> = typing.Callable</td></tr></table>
|
|
127
|
+
</body></html>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
2
|
+
<html><head><title>Python: module ai_core_sdk.cli</title>
|
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
4
|
+
</head><body bgcolor="#f0f0f8">
|
|
5
|
+
|
|
6
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
7
|
+
<tr bgcolor="#7799ee">
|
|
8
|
+
<td valign=bottom> <br>
|
|
9
|
+
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="ai_core_sdk.html"><font color="#ffffff">ai_core_sdk</font></a>.cli</strong></big></big></font></td
|
|
10
|
+
><td align=right valign=bottom
|
|
11
|
+
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jenkins/agent/workspace/AI-Foundation_ai-core-sdk_master/ai_core_sdk/cli.py">/home/jenkins/agent/workspace/AI-Foundation_ai-core-sdk_master/ai_core_sdk/cli.py</a></font></td></tr></table>
|
|
12
|
+
<p></p>
|
|
13
|
+
<p>
|
|
14
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
15
|
+
<tr bgcolor="#aa55cc">
|
|
16
|
+
<td colspan=3 valign=bottom> <br>
|
|
17
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
18
|
+
|
|
19
|
+
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
20
|
+
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="click.html">click</a><br>
|
|
21
|
+
</td><td width="25%" valign=top><a href="json.html">json</a><br>
|
|
22
|
+
</td><td width="25%" valign=top><a href="pathlib.html">pathlib</a><br>
|
|
23
|
+
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
|
24
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
25
|
+
<tr bgcolor="#eeaa77">
|
|
26
|
+
<td colspan=3 valign=bottom> <br>
|
|
27
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
28
|
+
|
|
29
|
+
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
30
|
+
<td width="100%"><dl><dt><a name="-confirm_resource_group"><strong>confirm_resource_group</strong></a>(resource_group: 'Optional[str]' = None)</dt></dl>
|
|
31
|
+
<dl><dt><a name="-create_config"><strong>create_config</strong></a>(**kwargs)</dt><dd><tt># Utility Functions</tt></dd></dl>
|
|
32
|
+
<dl><dt><a name="-create_config_file"><strong>create_config_file</strong></a>(config_path: 'pathlib.Path', auth_url: 'str', client_id: 'str', client_secret: 'str', cert_file_path: 'pathlib.Path', key_file_path: 'pathlib.Path', base_url: 'str', resource_group: 'str')</dt></dl>
|
|
33
|
+
<dl><dt><a name="-get_auth_url"><strong>get_auth_url</strong></a>(auth_url: 'Optional[str]' = None)</dt></dl>
|
|
34
|
+
<dl><dt><a name="-get_base_url"><strong>get_base_url</strong></a>(base_url: 'Optional[str]' = None)</dt></dl>
|
|
35
|
+
<dl><dt><a name="-get_profile_config_path"><strong>get_profile_config_path</strong></a>(profile: 'str')</dt></dl>
|
|
36
|
+
<dl><dt><a name="-get_str_value"><strong>get_str_value</strong></a>(msg: 'str', value: 'Optional[str]' = None)</dt></dl>
|
|
37
|
+
<dl><dt><a name="-is_valid_url"><strong>is_valid_url</strong></a>(url, path_forbidden=True)</dt></dl>
|
|
38
|
+
<dl><dt><a name="-load_service_key"><strong>load_service_key</strong></a>(service_key_json: 'str')</dt></dl>
|
|
39
|
+
<dl><dt><a name="-prompt_for_input"><strong>prompt_for_input</strong></a>(prompt_text, is_url=False, path_forbidden=True)</dt></dl>
|
|
40
|
+
</td></tr></table><p>
|
|
41
|
+
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
42
|
+
<tr bgcolor="#55aa55">
|
|
43
|
+
<td colspan=3 valign=bottom> <br>
|
|
44
|
+
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
45
|
+
|
|
46
|
+
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
47
|
+
<td width="100%"><strong>AI_CORE_PREFIX</strong> = 'AICORE'<br>
|
|
48
|
+
<strong>API_V2_SUFFIX</strong> = '/v2'<br>
|
|
49
|
+
<strong>CREDENTIAL_VALUES</strong> = [CredentialsValue(name='client_id', vcap_key=('cr...s', 'clientid'), default=None, transform_fn=None), CredentialsValue(name='client_secret', vcap_key=...'clientsecret'), default=None, transform_fn=None), CredentialsValue(name='auth_url', vcap_key=('cre...ansform_fn=<function <lambda> at 0x7f6e21cb12d0>), CredentialsValue(name='base_url', vcap_key=('cre...ansform_fn=<function <lambda> at 0x7f6e21cb1e10>), CredentialsValue(name='resource_group', vcap_key=None, default=None, transform_fn=None), CredentialsValue(name='cert_url', vcap_key=('cre...ansform_fn=<function <lambda> at 0x7f6e21cb1f30>), CredentialsValue(name='cert_file_path', vcap_key=None, default=None, transform_fn=None), CredentialsValue(name='key_file_path', vcap_key=None, default=None, transform_fn=None), CredentialsValue(name='cert_str', vcap_key=('cre...ansform_fn=<function <lambda> at 0x7f6e21cb1fc0>), CredentialsValue(name='key_str', vcap_key=('cred...ansform_fn=<function <lambda> at 0x7f6e21cb2050>)]<br>
|
|
50
|
+
<strong>DEFAULT_CONFIG</strong> = 'config.json'<br>
|
|
51
|
+
<strong>DEFAULT_PROFILE</strong> = 'default'<br>
|
|
52
|
+
<strong>DEFAULT_RESOURCE_GROUP</strong> = 'default'<br>
|
|
53
|
+
<strong>MAX_TRIES</strong> = 5<br>
|
|
54
|
+
<strong>OAUTH_TOKEN_SUFFIX</strong> = '/oauth/token'<br>
|
|
55
|
+
<strong>Optional</strong> = typing.Optional<br>
|
|
56
|
+
<strong>annotations</strong> = _Feature((3, 7, 0, 'beta', 1), (3, 11, 0, 'alpha', 0), 16777216)<br>
|
|
57
|
+
<strong>cli</strong> = <Group cli><br>
|
|
58
|
+
<strong>configure</strong> = <Command configure></td></tr></table>
|
|
59
|
+
</body></html>
|