teradataml 20.0.0.5__py3-none-any.whl → 20.0.0.7__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.
Potentially problematic release.
This version of teradataml might be problematic. Click here for more details.
- teradataml/LICENSE-3RD-PARTY.pdf +0 -0
- teradataml/README.md +306 -0
- teradataml/__init__.py +1 -1
- teradataml/_version.py +1 -1
- teradataml/analytics/analytic_function_executor.py +162 -76
- teradataml/analytics/byom/__init__.py +1 -1
- teradataml/analytics/json_parser/__init__.py +2 -0
- teradataml/analytics/json_parser/analytic_functions_argument.py +95 -2
- teradataml/analytics/json_parser/metadata.py +22 -4
- teradataml/analytics/sqle/DecisionTreePredict.py +3 -2
- teradataml/analytics/sqle/NaiveBayesPredict.py +3 -2
- teradataml/analytics/sqle/__init__.py +3 -0
- teradataml/analytics/utils.py +59 -11
- teradataml/automl/__init__.py +2369 -464
- teradataml/automl/autodataprep/__init__.py +15 -0
- teradataml/automl/custom_json_utils.py +184 -112
- teradataml/automl/data_preparation.py +113 -58
- teradataml/automl/data_transformation.py +154 -53
- teradataml/automl/feature_engineering.py +113 -53
- teradataml/automl/feature_exploration.py +548 -25
- teradataml/automl/model_evaluation.py +260 -32
- teradataml/automl/model_training.py +399 -206
- teradataml/clients/auth_client.py +10 -6
- teradataml/clients/keycloak_client.py +165 -0
- teradataml/common/aed_utils.py +11 -2
- teradataml/common/bulk_exposed_utils.py +4 -2
- teradataml/common/constants.py +72 -2
- teradataml/common/exceptions.py +32 -0
- teradataml/common/garbagecollector.py +50 -21
- teradataml/common/messagecodes.py +73 -1
- teradataml/common/messages.py +27 -1
- teradataml/common/sqlbundle.py +25 -7
- teradataml/common/utils.py +210 -22
- teradataml/context/aed_context.py +16 -10
- teradataml/context/context.py +37 -9
- teradataml/data/Employee.csv +5 -0
- teradataml/data/Employee_Address.csv +4 -0
- teradataml/data/Employee_roles.csv +5 -0
- teradataml/data/JulesBelvezeDummyData.csv +100 -0
- teradataml/data/byom_example.json +5 -0
- teradataml/data/creditcard_data.csv +284618 -0
- teradataml/data/docs/byom/docs/ONNXSeq2Seq.py +255 -0
- teradataml/data/docs/sqle/docs_17_10/NGramSplitter.py +1 -1
- teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +1 -1
- teradataml/data/docs/sqle/docs_17_20/TextParser.py +1 -1
- teradataml/data/jsons/byom/ONNXSeq2Seq.json +287 -0
- teradataml/data/jsons/byom/onnxembeddings.json +1 -0
- teradataml/data/jsons/sqle/20.00/AI_AnalyzeSentiment.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_AskLLM.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_DetectLanguage.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_ExtractKeyPhrases.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_MaskPII.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_RecognizeEntities.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_RecognizePIIEntities.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_TextClassifier.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_TextEmbeddings.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_TextSummarize.json +3 -7
- teradataml/data/jsons/sqle/20.00/AI_TextTranslate.json +3 -7
- teradataml/data/jsons/sqle/20.00/TD_API_AzureML.json +151 -0
- teradataml/data/jsons/sqle/20.00/TD_API_Sagemaker.json +182 -0
- teradataml/data/jsons/sqle/20.00/TD_API_VertexAI.json +183 -0
- teradataml/data/load_example_data.py +29 -11
- teradataml/data/pattern_matching_data.csv +11 -0
- teradataml/data/payment_fraud_dataset.csv +10001 -0
- teradataml/data/sdk/modelops/modelops_spec.json +101737 -0
- teradataml/data/teradataml_example.json +75 -1
- teradataml/data/url_data.csv +10 -9
- teradataml/dataframe/copy_to.py +715 -55
- teradataml/dataframe/dataframe.py +2115 -97
- teradataml/dataframe/dataframe_utils.py +66 -28
- teradataml/dataframe/functions.py +1130 -2
- teradataml/dataframe/setop.py +4 -1
- teradataml/dataframe/sql.py +710 -1039
- teradataml/dbutils/dbutils.py +470 -35
- teradataml/dbutils/filemgr.py +1 -1
- teradataml/hyperparameter_tuner/optimizer.py +456 -142
- teradataml/hyperparameter_tuner/utils.py +4 -2
- teradataml/lib/aed_0_1.dll +0 -0
- teradataml/lib/libaed_0_1.dylib +0 -0
- teradataml/lib/libaed_0_1.so +0 -0
- teradataml/lib/libaed_0_1_aarch64.so +0 -0
- teradataml/opensource/_base.py +7 -1
- teradataml/options/configure.py +20 -4
- teradataml/scriptmgmt/UserEnv.py +247 -36
- teradataml/scriptmgmt/lls_utils.py +140 -39
- teradataml/sdk/README.md +79 -0
- teradataml/sdk/__init__.py +4 -0
- teradataml/sdk/_auth_modes.py +422 -0
- teradataml/sdk/_func_params.py +487 -0
- teradataml/sdk/_json_parser.py +453 -0
- teradataml/sdk/_openapi_spec_constants.py +249 -0
- teradataml/sdk/_utils.py +236 -0
- teradataml/sdk/api_client.py +900 -0
- teradataml/sdk/constants.py +62 -0
- teradataml/sdk/modelops/__init__.py +98 -0
- teradataml/sdk/modelops/_client.py +409 -0
- teradataml/sdk/modelops/_constants.py +304 -0
- teradataml/sdk/modelops/models.py +2308 -0
- teradataml/sdk/spinner.py +107 -0
- teradataml/series/series.py +12 -7
- teradataml/store/feature_store/constants.py +601 -234
- teradataml/store/feature_store/feature_store.py +2886 -616
- teradataml/store/feature_store/mind_map.py +639 -0
- teradataml/store/feature_store/models.py +5831 -214
- teradataml/store/feature_store/utils.py +390 -0
- teradataml/table_operators/query_generator.py +4 -21
- teradataml/table_operators/table_operator_util.py +1 -1
- teradataml/table_operators/templates/dataframe_register.template +6 -2
- teradataml/table_operators/templates/dataframe_udf.template +6 -2
- teradataml/utils/docstring.py +527 -0
- teradataml/utils/dtypes.py +95 -1
- teradataml/utils/internal_buffer.py +2 -2
- teradataml/utils/utils.py +41 -3
- teradataml/utils/validators.py +699 -18
- {teradataml-20.0.0.5.dist-info → teradataml-20.0.0.7.dist-info}/METADATA +312 -2
- {teradataml-20.0.0.5.dist-info → teradataml-20.0.0.7.dist-info}/RECORD +119 -87
- {teradataml-20.0.0.5.dist-info → teradataml-20.0.0.7.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.5.dist-info → teradataml-20.0.0.7.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.5.dist-info → teradataml-20.0.0.7.dist-info}/zip-safe +0 -0
|
@@ -33,6 +33,8 @@ class _AuthWorkflow:
|
|
|
33
33
|
5. "username" which is the DB user.
|
|
34
34
|
5. "expiration_time" which is the expiration time for the token and has a default value of
|
|
35
35
|
31536000 seconds.
|
|
36
|
+
6. "valid_from" which states epoch seconds representing time from which JWT token will be valid
|
|
37
|
+
and same is used as iat claim in payload.
|
|
36
38
|
Types: dict
|
|
37
39
|
|
|
38
40
|
RETURNS:
|
|
@@ -52,7 +54,7 @@ class _AuthWorkflow:
|
|
|
52
54
|
Generate expiry epoch time.
|
|
53
55
|
|
|
54
56
|
RETURNS:
|
|
55
|
-
|
|
57
|
+
tuple
|
|
56
58
|
"""
|
|
57
59
|
current_epoch_time = int(time.time())
|
|
58
60
|
expiry_epoch_time = current_epoch_time + self.state.get('expiration_time')
|
|
@@ -83,12 +85,11 @@ class _AuthWorkflow:
|
|
|
83
85
|
RETURNS:
|
|
84
86
|
A dictionary with the JWT payload.
|
|
85
87
|
"""
|
|
86
|
-
|
|
88
|
+
_, exp = self._get_epoch_time()
|
|
87
89
|
payload = {
|
|
88
90
|
"aud": [
|
|
89
91
|
"td:service:authentication"
|
|
90
92
|
],
|
|
91
|
-
"iat": iat,
|
|
92
93
|
"exp": exp,
|
|
93
94
|
"iss": "teradataml",
|
|
94
95
|
"multi-use": True,
|
|
@@ -96,6 +97,9 @@ class _AuthWorkflow:
|
|
|
96
97
|
"pat": self.state['pat_token'],
|
|
97
98
|
"sub": self.state['username']
|
|
98
99
|
}
|
|
100
|
+
# Add iat if applicable.
|
|
101
|
+
if self.state['valid_from'] is not None:
|
|
102
|
+
payload.update({"iat": self.state['valid_from']})
|
|
99
103
|
return payload
|
|
100
104
|
|
|
101
105
|
def _sign_jwt(self, payload, header):
|
|
@@ -128,6 +132,6 @@ class _AuthWorkflow:
|
|
|
128
132
|
RETURNS:
|
|
129
133
|
str
|
|
130
134
|
"""
|
|
131
|
-
|
|
132
|
-
self.state['jwt'] =
|
|
133
|
-
return
|
|
135
|
+
jwt_token = self._sign_jwt(self._generate_payload(), self._generate_header())
|
|
136
|
+
self.state['jwt'] = jwt_token
|
|
137
|
+
return jwt_token
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unpublished work.
|
|
3
|
+
Copyright (c) 2025 by Teradata Corporation. All rights reserved.
|
|
4
|
+
TERADATA CORPORATION CONFIDENTIAL AND TRADE SECRET
|
|
5
|
+
Primary Owner: shivani.kondewar@teradata.com
|
|
6
|
+
Secondary Owner: aanchal.kavedia@teradata.com
|
|
7
|
+
This file implements _KeycloakManager class used to store data for keycloak token generation.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import time
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
from teradataml import TeradataMlException, MessageCodes
|
|
14
|
+
from teradataml.common.constants import HTTPRequest
|
|
15
|
+
from teradataml.context.context import _get_user
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class GrantType(Enum):
|
|
19
|
+
PASS = "password"
|
|
20
|
+
REFRESH = "refresh_token"
|
|
21
|
+
CLIENT = "client_credentials"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _KeycloakManager():
|
|
25
|
+
|
|
26
|
+
def __init__(self, auth_url, client_id):
|
|
27
|
+
"""
|
|
28
|
+
DESCRIPTION:
|
|
29
|
+
Constructor to initiate keycloak manager.
|
|
30
|
+
|
|
31
|
+
PARAMETERS:
|
|
32
|
+
auth_url:
|
|
33
|
+
Required Argument.
|
|
34
|
+
Specifies the endpoint URL for a keycloak server.
|
|
35
|
+
Types: str
|
|
36
|
+
|
|
37
|
+
client_id:
|
|
38
|
+
Required Argument.
|
|
39
|
+
Specifies the client/service for which keycloak server avails a token.
|
|
40
|
+
Types: str
|
|
41
|
+
|
|
42
|
+
RETURNS:
|
|
43
|
+
Instance of _KeycloakManager.
|
|
44
|
+
|
|
45
|
+
RAISES:
|
|
46
|
+
None
|
|
47
|
+
|
|
48
|
+
EXAMPLES:
|
|
49
|
+
>>> token_generator = _KeycloakManager(auth_url=auth_url,
|
|
50
|
+
... username=username,
|
|
51
|
+
... client_id=client_id)
|
|
52
|
+
"""
|
|
53
|
+
self._auth_url = auth_url
|
|
54
|
+
self._client_id = client_id
|
|
55
|
+
self._header = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
56
|
+
self._expires_at = None
|
|
57
|
+
self._refresh_expires_at = None
|
|
58
|
+
|
|
59
|
+
def generate_token(self, username=None, password=None, refresh=False):
|
|
60
|
+
"""
|
|
61
|
+
DESCRIPTION:
|
|
62
|
+
Method generates keycloak token.
|
|
63
|
+
Token can be generated using any one of the following information:
|
|
64
|
+
* Username and password
|
|
65
|
+
* Refresh token
|
|
66
|
+
|
|
67
|
+
PARAMETERS:
|
|
68
|
+
username:
|
|
69
|
+
Optional Argument.
|
|
70
|
+
Specifies the username for database user for which keycloak token is
|
|
71
|
+
to be generated. If not specified, then user associated with current
|
|
72
|
+
connection is used.
|
|
73
|
+
Types: str
|
|
74
|
+
|
|
75
|
+
password:
|
|
76
|
+
Optional Argument.
|
|
77
|
+
Specifies the password for database user.
|
|
78
|
+
Types: str
|
|
79
|
+
|
|
80
|
+
refresh:
|
|
81
|
+
Optional Argument.
|
|
82
|
+
Specifies the boolean flag to indicate if token needs to be generated
|
|
83
|
+
using existing refresh token or not.
|
|
84
|
+
Default value: False
|
|
85
|
+
Types: Boolean
|
|
86
|
+
|
|
87
|
+
RETURNS:
|
|
88
|
+
Keycloak token
|
|
89
|
+
|
|
90
|
+
RAISES:
|
|
91
|
+
RuntimeError.
|
|
92
|
+
|
|
93
|
+
EXAMPLES:
|
|
94
|
+
# Example 1: Generate the authentication token using username and password.
|
|
95
|
+
>>> keycloak_obj.generate_token(username="username", password="password")
|
|
96
|
+
|
|
97
|
+
# Example 2: Generate the authentication token using default username for
|
|
98
|
+
# current session and provided password.
|
|
99
|
+
>>> keycloak_obj.generate_token(password="password")
|
|
100
|
+
|
|
101
|
+
# Example 3: Generate the authentication token using refresh token which is
|
|
102
|
+
# already available.
|
|
103
|
+
>>> keycloak_obj.generate_token(refresh=True)
|
|
104
|
+
"""
|
|
105
|
+
# Define the payload.
|
|
106
|
+
if password:
|
|
107
|
+
payload = {
|
|
108
|
+
"grant_type": GrantType.PASS.value,
|
|
109
|
+
"client_id": self._client_id,
|
|
110
|
+
"username": username if username else _get_user(),
|
|
111
|
+
"password": password
|
|
112
|
+
}
|
|
113
|
+
if refresh:
|
|
114
|
+
payload = {
|
|
115
|
+
"grant_type": GrantType.REFRESH.value,
|
|
116
|
+
"client_id": self._client_id,
|
|
117
|
+
"refresh_token": self._refresh_token
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Make the POST request.
|
|
121
|
+
# Importing locally to avoid circular import.
|
|
122
|
+
from teradataml import UtilFuncs
|
|
123
|
+
response = UtilFuncs._http_request(self._auth_url, HTTPRequest.POST,
|
|
124
|
+
headers=self._header, data=payload)
|
|
125
|
+
|
|
126
|
+
# Check the response.
|
|
127
|
+
if 200 <= response.status_code < 300:
|
|
128
|
+
response_data = response.json()
|
|
129
|
+
self._auth_token = response_data['access_token']
|
|
130
|
+
self._refresh_token = response_data['refresh_token']
|
|
131
|
+
# 30 is buffer time to assume delay in processing of response_data.
|
|
132
|
+
self._expires_at = time.time() + response_data['expires_in'] - 30
|
|
133
|
+
self._refresh_expires_at = time.time() + response_data['refresh_expires_in'] - 30
|
|
134
|
+
else:
|
|
135
|
+
raise
|
|
136
|
+
|
|
137
|
+
return self._auth_token
|
|
138
|
+
|
|
139
|
+
def get_token(self):
|
|
140
|
+
"""
|
|
141
|
+
DESCRIPTION:
|
|
142
|
+
Function to get keycloak token.
|
|
143
|
+
If access token is not expired, existing token is returned.
|
|
144
|
+
If access token is expired, and refresh token is alive, new access token is generated.
|
|
145
|
+
If both access token and refresh token are expired, TeradataMlException is raised
|
|
146
|
+
|
|
147
|
+
RETURNS:
|
|
148
|
+
Keycloak token
|
|
149
|
+
|
|
150
|
+
RAISES:
|
|
151
|
+
TeradataMlException.
|
|
152
|
+
|
|
153
|
+
"""
|
|
154
|
+
# If existing auth_token is expired, regenerate using refresh token.
|
|
155
|
+
if self._expires_at and time.time() > self._expires_at:
|
|
156
|
+
# If refresh token is expired, raise error.
|
|
157
|
+
if self._refresh_expires_at and time.time() > self._refresh_expires_at:
|
|
158
|
+
raise TeradataMlException("Refresh token for keycloak is expired."
|
|
159
|
+
" Execute set_auth_token() to set fresh authentication token.",
|
|
160
|
+
MessageCodes.FUNC_EXECUTION_FAILED)
|
|
161
|
+
else:
|
|
162
|
+
# Regenerate fresh access token using refresh token.
|
|
163
|
+
self.generate_token(refresh=True)
|
|
164
|
+
|
|
165
|
+
return self._auth_token
|
teradataml/common/aed_utils.py
CHANGED
|
@@ -150,7 +150,7 @@ class AedUtils:
|
|
|
150
150
|
|
|
151
151
|
return self.aed_context._validate_aed_return_code(ret_code[0], nodeid_out[0].decode("utf-8"))
|
|
152
152
|
|
|
153
|
-
def _aed_select(self, nodeid, select_expr, distinct=False):
|
|
153
|
+
def _aed_select(self, nodeid, select_expr, distinct=False, timestamp_expr=None):
|
|
154
154
|
"""
|
|
155
155
|
This wrapper function facilitates a integration with 'aed_select',
|
|
156
156
|
a C++ function, in AED library, with Python tdml library.
|
|
@@ -162,6 +162,7 @@ class AedUtils:
|
|
|
162
162
|
nodeid - A DAG node, a input to the select API.
|
|
163
163
|
select_expr - Columns, to be selected from the data frame.
|
|
164
164
|
distinct - Boolean, to decide addition of Distinct clause.
|
|
165
|
+
timestamp_expr - A string, to specify the temporal table clause.
|
|
165
166
|
|
|
166
167
|
EXAMPLES:
|
|
167
168
|
aed_table_nodeid = AedObj._aed_table("dbname.tablename")
|
|
@@ -181,11 +182,16 @@ class AedUtils:
|
|
|
181
182
|
POINTER(c_char_p),
|
|
182
183
|
POINTER(c_char_p),
|
|
183
184
|
POINTER(c_char_p),
|
|
185
|
+
POINTER(c_int),
|
|
184
186
|
POINTER(c_int)
|
|
185
187
|
]
|
|
186
188
|
|
|
187
189
|
arg_name = ["projection"]
|
|
188
190
|
arg_value = ["DISTINCT " + select_expr if distinct else select_expr]
|
|
191
|
+
if timestamp_expr:
|
|
192
|
+
arg_name.append("timestamp_expr")
|
|
193
|
+
arg_value.append(timestamp_expr)
|
|
194
|
+
|
|
189
195
|
temp_table_name = UtilFuncs._generate_temp_table_name(prefix="select_", use_default_database=True, quote=False)
|
|
190
196
|
output_table = [UtilFuncs._extract_table_name(temp_table_name)]
|
|
191
197
|
output_schema = [UtilFuncs._extract_db_name(temp_table_name)]
|
|
@@ -195,6 +201,8 @@ class AedUtils:
|
|
|
195
201
|
|
|
196
202
|
# return code
|
|
197
203
|
ret_code = self.aed_context._int_array1(0)
|
|
204
|
+
|
|
205
|
+
length = self.aed_context._int_array1(len(arg_value))
|
|
198
206
|
try:
|
|
199
207
|
# *** AED request to select columns
|
|
200
208
|
self.aed_context.ele_common_lib.aed_select(self.aed_context._arr_c([nodeid]),
|
|
@@ -203,6 +211,7 @@ class AedUtils:
|
|
|
203
211
|
self.aed_context._arr_c(output_table),
|
|
204
212
|
self.aed_context._arr_c(output_schema),
|
|
205
213
|
nodeid_out,
|
|
214
|
+
length,
|
|
206
215
|
ret_code)
|
|
207
216
|
except Exception as emsg:
|
|
208
217
|
raise TeradataMlException(Messages.get_message(MessageCodes.AED_EXEC_FAILED, "(aed_select)" + str(emsg)),
|
|
@@ -2050,7 +2059,7 @@ class AedUtils:
|
|
|
2050
2059
|
POINTER(c_int)
|
|
2051
2060
|
]
|
|
2052
2061
|
# Get number of parent nodes present to allocate enough memory
|
|
2053
|
-
number_of_parent_nodes = self._aed_get_parent_node_count(nodeid)
|
|
2062
|
+
number_of_parent_nodes = self._aed_get_parent_node_count(nodeid)
|
|
2054
2063
|
parent_nodeids = self.aed_context._arr_c(["00000000000000000000"] * number_of_parent_nodes)
|
|
2055
2064
|
ret_code = self.aed_context._int_array1(0)
|
|
2056
2065
|
|
|
@@ -98,7 +98,9 @@ def _validate_unimplemented_function(func_name, func_params, *args, **kwargs):
|
|
|
98
98
|
function_signature,
|
|
99
99
|
return_statement)
|
|
100
100
|
# Creating function object from the string in locals.
|
|
101
|
-
|
|
101
|
+
global_scope = {}
|
|
102
|
+
namespace = {}
|
|
103
|
+
exec(function_expression, global_scope, namespace)
|
|
102
104
|
|
|
103
105
|
# kwargs may contain other properties too. So, before we call the function,
|
|
104
106
|
# copying kwargs to another variable and remove additional properties.
|
|
@@ -107,5 +109,5 @@ def _validate_unimplemented_function(func_name, func_params, *args, **kwargs):
|
|
|
107
109
|
if not param in TDMLFrameworkKeywords.AGGREGATE_FUNCTION_DEFAULT_ARGUMENTS.value:
|
|
108
110
|
kw[param] = kwargs[param]
|
|
109
111
|
|
|
110
|
-
return
|
|
112
|
+
return namespace[func_name](*args, **kw)
|
|
111
113
|
|
teradataml/common/constants.py
CHANGED
|
@@ -63,8 +63,14 @@ class SQLConstants(Enum):
|
|
|
63
63
|
SQL_SELECT_COLUMNNAMES_WITH_WHERE = 32
|
|
64
64
|
SQL_HELP_DATABASE = 33
|
|
65
65
|
SQL_HELP_DATALAKE = 34
|
|
66
|
+
SQL_INSERT_INTO_TABLE_VALUES_WITH_COLUMN_NAMES = 35
|
|
66
67
|
CONSTRAINT = ["check_constraint", "primary_key_constraint",
|
|
67
68
|
"foreign_key_constraint", "unique_key_constraint"]
|
|
69
|
+
SQL_TD_OTF_METADATA = 35
|
|
70
|
+
SQL_TD_OTF_SNAPSHOT = 36
|
|
71
|
+
SQL_LIST_TRIGGERS = 37
|
|
72
|
+
SQL_SHOW_TABLE = 38
|
|
73
|
+
SQL_SHOW_VIEW = 39
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
class TeradataConstants(Enum):
|
|
@@ -141,6 +147,9 @@ class TeradataTypes(Enum):
|
|
|
141
147
|
INTERVAL_DAY_TO_SECOND, INTERVAL_HOUR,
|
|
142
148
|
INTERVAL_HOUR_TO_MINUTE, INTERVAL_HOUR_TO_SECOND,
|
|
143
149
|
INTERVAL_MINUTE, INTERVAL_MINUTE_TO_SECOND, INTERVAL_SECOND)
|
|
150
|
+
TD_RANGE_N_CLAUSE_TYPES = (INTERVAL_YEAR, INTERVAL_DAY, INTERVAL_MONTH,
|
|
151
|
+
INTERVAL_MINUTE, INTERVAL_SECOND, INTERVAL_HOUR)
|
|
152
|
+
|
|
144
153
|
|
|
145
154
|
|
|
146
155
|
class TeradataTableKindConstants(Enum):
|
|
@@ -153,6 +162,21 @@ class TeradataTableKindConstants(Enum):
|
|
|
153
162
|
VOLATILE_TABLE_NAME = 'Table Name'
|
|
154
163
|
REGULAR_TABLE_NAME = 'TableName'
|
|
155
164
|
|
|
165
|
+
class DataFrameTypes(Enum):
|
|
166
|
+
VIEW = "VIEW"
|
|
167
|
+
VALID_TIME_VIEW = "VALID_TIME_VIEW"
|
|
168
|
+
TRANSACTION_TIME_VIEW = "TRANSACTION_TIME_VIEW"
|
|
169
|
+
BI_TEMPORAL_VIEW = "BI_TEMPORAL_VIEW"
|
|
170
|
+
REGULAR_TABLE = "TABLE"
|
|
171
|
+
OTF_TABLE = "OTF"
|
|
172
|
+
BI_TEMPORAL = "BI_TEMPORAL"
|
|
173
|
+
TRANSACTION_TIME= "TRANSACTION_TIME"
|
|
174
|
+
VALID_TIME = "VALID_TIME"
|
|
175
|
+
ART_TABLE = "ART"
|
|
176
|
+
VOLATILE_TABLE = "VOLATILE_TABLE"
|
|
177
|
+
VALID_TIME_VOLATILE_TABLE = "VALID_TIME_VOLATILE_TABLE"
|
|
178
|
+
TRANSACTION_TIME_VOLATILE_TABLE = "TRANSACTION_TIME_VOLATILE_TABLE"
|
|
179
|
+
BI_TEMPORAL_VOLATILE_TABLE = "BI_TEMPORAL_VOLATILE_TABLE"
|
|
156
180
|
|
|
157
181
|
class SQLPattern(Enum):
|
|
158
182
|
SQLMR = re.compile(r"SELECT \* FROM .*\((\s*.*)*\) as .*", re.IGNORECASE)
|
|
@@ -1432,7 +1456,8 @@ class TeradataReservedKeywords(Enum):
|
|
|
1432
1456
|
"SUMMARY",
|
|
1433
1457
|
"HASH",
|
|
1434
1458
|
"METHOD",
|
|
1435
|
-
"TYPE"
|
|
1459
|
+
"TYPE",
|
|
1460
|
+
"CATALOG"
|
|
1436
1461
|
]
|
|
1437
1462
|
|
|
1438
1463
|
|
|
@@ -1507,10 +1532,21 @@ class AsyncStatusColumns(Enum):
|
|
|
1507
1532
|
|
|
1508
1533
|
|
|
1509
1534
|
class AsyncOpStatus(Enum):
|
|
1510
|
-
# Holds valid status for asynchronous
|
|
1535
|
+
# Holds valid status for asynchronous operations in UES.
|
|
1511
1536
|
FILE_INSTALLED = "File Installed"
|
|
1512
1537
|
ERRED = "Errored"
|
|
1513
1538
|
FINISHED = "Finished"
|
|
1539
|
+
MODEL_INSTALLED = "ModelInstalled"
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
class AsyncOpStatusOAFColumns(Enum):
|
|
1543
|
+
# Holds column names of dataframe representing status of given claim-id.
|
|
1544
|
+
CLAIM_ID = "Claim Id"
|
|
1545
|
+
FILE_LIB_MODEL_NAME = "File/Libs/Model"
|
|
1546
|
+
METHOD_NAME = "Method Name"
|
|
1547
|
+
STAGE = "Stage"
|
|
1548
|
+
TIMESTAMP = "Timestamp"
|
|
1549
|
+
ADDITIONAL_DETAILS = "Additional Details"
|
|
1514
1550
|
|
|
1515
1551
|
|
|
1516
1552
|
class CloudProvider(Enum):
|
|
@@ -1557,6 +1593,23 @@ class SessionParamsPythonNames(Enum):
|
|
|
1557
1593
|
class AutoMLConstants(Enum):
|
|
1558
1594
|
# List stores feature selection methods
|
|
1559
1595
|
FEATURE_SELECTION_MTDS = ["lasso", "rfe", "pca"]
|
|
1596
|
+
# Model lists
|
|
1597
|
+
SUPERVISED_MODELS = ["glm", "svm", "knn", "decision_forest", "xgboost"]
|
|
1598
|
+
CLUSTERING_MODELS = ["KMeans", "GaussianMixture"]
|
|
1599
|
+
ALL_MODELS = SUPERVISED_MODELS + CLUSTERING_MODELS
|
|
1600
|
+
|
|
1601
|
+
# Metric lists
|
|
1602
|
+
CLASSIFICATION_METRICS = ["MICRO-F1", "MACRO-F1", "MICRO-RECALL", "MACRO-RECALL",
|
|
1603
|
+
"MICRO-PRECISION", "MACRO-PRECISION", "WEIGHTED-PRECISION",
|
|
1604
|
+
"WEIGHTED-RECALL", "WEIGHTED-F1", "ACCURACY"]
|
|
1605
|
+
|
|
1606
|
+
REGRESSION_METRICS = ["R2", "MAE", "MSE", "MSLE", "MAPE", "MPE",
|
|
1607
|
+
"RMSE", "RMSLE", "ME", "EV", "MPD", "MGD"]
|
|
1608
|
+
|
|
1609
|
+
CLUSTERING_METRICS = ["SILHOUETTE", "CALINSKI", "DAVIES"]
|
|
1610
|
+
|
|
1611
|
+
# Combined for default case
|
|
1612
|
+
ALL_METRICS = REGRESSION_METRICS + CLASSIFICATION_METRICS + CLUSTERING_METRICS
|
|
1560
1613
|
|
|
1561
1614
|
|
|
1562
1615
|
class AuthMechs(Enum):
|
|
@@ -1567,3 +1620,20 @@ class AuthMechs(Enum):
|
|
|
1567
1620
|
JWT = "JWT"
|
|
1568
1621
|
PAT = "PAT"
|
|
1569
1622
|
BASIC = "BASIC"
|
|
1623
|
+
KEYCLOAK = "KEYCLOAK"
|
|
1624
|
+
|
|
1625
|
+
class TDServices(Enum):
|
|
1626
|
+
"""
|
|
1627
|
+
Enum to hold permitted values for types for services availed on Teradata vantage.
|
|
1628
|
+
"""
|
|
1629
|
+
VECTORSTORE = "vectorstore"
|
|
1630
|
+
MOPS = "MODELOPS" # For future reference
|
|
1631
|
+
|
|
1632
|
+
class AccessQueries(Enum):
|
|
1633
|
+
"""
|
|
1634
|
+
Enum to hold permitted access queries.
|
|
1635
|
+
"""
|
|
1636
|
+
read = ["{grant_revoke_} SELECT ON {database_} {to_from_} {user_}"]
|
|
1637
|
+
write= ["{grant_revoke_} CREATE TABLE ON {database_} {to_from_} {user_}",
|
|
1638
|
+
"{grant_revoke_} CREATE VIEW ON {database_} {to_from_} {user_}",
|
|
1639
|
+
"{grant_revoke_} DELETE, UPDATE, INSERT ON {database_} {to_from_} {user_}"]
|
teradataml/common/exceptions.py
CHANGED
|
@@ -12,6 +12,12 @@ teradataml.common.exceptions
|
|
|
12
12
|
An Error class for the teradataml python module
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
import warnings
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
class TeradataMlException(Exception):
|
|
16
22
|
"""
|
|
17
23
|
Teradata Ml Exception class.
|
|
@@ -71,3 +77,29 @@ class TeradataMlException(Exception):
|
|
|
71
77
|
"""
|
|
72
78
|
super(TeradataMlException, self).__init__(msg)
|
|
73
79
|
self.code = code
|
|
80
|
+
|
|
81
|
+
class TeradatamlRestException(TeradataMlException):
|
|
82
|
+
def __init__(self, msg, code, raw_message=None):
|
|
83
|
+
super().__init__(msg, code)
|
|
84
|
+
|
|
85
|
+
self._msg = msg
|
|
86
|
+
self._raw_message = raw_message
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def json_response(self):
|
|
90
|
+
"""
|
|
91
|
+
Returns the JSON response from the server.
|
|
92
|
+
"""
|
|
93
|
+
if self._raw_message is not None and self._raw_message.startswith("Error message: "):
|
|
94
|
+
failure_msg = f"Could not convert msg to json. Message is \n{self._raw_message}"
|
|
95
|
+
try:
|
|
96
|
+
json_resp = self._msg.split("Error message: ")[1]
|
|
97
|
+
json_resp = json.loads(json_resp)
|
|
98
|
+
return pprint.pformat(json_resp)
|
|
99
|
+
except json.JSONDecodeError as _:
|
|
100
|
+
warnings.warn(failure_msg)
|
|
101
|
+
elif self._raw_message is None:
|
|
102
|
+
return None
|
|
103
|
+
else:
|
|
104
|
+
warnings.warn(failure_msg)
|
|
105
|
+
|
|
@@ -325,23 +325,26 @@ class GarbageCollector():
|
|
|
325
325
|
raise
|
|
326
326
|
|
|
327
327
|
@staticmethod
|
|
328
|
-
def _delete_object_entry(
|
|
328
|
+
def _delete_object_entry(objects_to_delete,
|
|
329
329
|
object_type=TeradataConstants.TERADATA_TABLE,
|
|
330
330
|
remove_entry_from_gc_list=False):
|
|
331
331
|
"""
|
|
332
332
|
DESCRIPTION:
|
|
333
333
|
Deletes an entry of table/view/script from persisted file.
|
|
334
|
-
This makes sure that the object is not garbage collected.
|
|
334
|
+
This makes sure that the object(s) is/are not garbage collected.
|
|
335
335
|
|
|
336
336
|
PARAMETERS:
|
|
337
|
-
|
|
337
|
+
objects_to_delete:
|
|
338
338
|
Required Argument.
|
|
339
|
-
Specifies the
|
|
340
|
-
Types: str
|
|
339
|
+
Specifies the names of the table/view/script to be deleted.
|
|
340
|
+
Types: str or list of str
|
|
341
341
|
|
|
342
342
|
object_type:
|
|
343
343
|
Optional Argument.
|
|
344
344
|
Specifies the type of the object (table/view/script) to be deleted.
|
|
345
|
+
Note:
|
|
346
|
+
Pass None, when object type is not available. In this case, the given object will be
|
|
347
|
+
removed from GC file based on just object name and current process id.
|
|
345
348
|
Default Value: TeradataConstants.TERADATA_TABLE
|
|
346
349
|
Types: TeradataConstants
|
|
347
350
|
|
|
@@ -365,8 +368,11 @@ class GarbageCollector():
|
|
|
365
368
|
None.
|
|
366
369
|
|
|
367
370
|
EXAMPLES:
|
|
368
|
-
GarbageCollector._delete_table_view_entry(
|
|
371
|
+
GarbageCollector._delete_table_view_entry(objects_to_delete = 'temp.temp_table1')
|
|
369
372
|
"""
|
|
373
|
+
from teradataml.common.utils import UtilFuncs
|
|
374
|
+
objects_to_delete = UtilFuncs._as_list(objects_to_delete)
|
|
375
|
+
|
|
370
376
|
try:
|
|
371
377
|
tempfilename = GarbageCollector.__make_temp_file_name()
|
|
372
378
|
if not os.path.isfile(tempfilename):
|
|
@@ -383,25 +389,37 @@ class GarbageCollector():
|
|
|
383
389
|
db_object_type = int(record_parts[2].strip())
|
|
384
390
|
db_object = record_parts[3].strip()
|
|
385
391
|
|
|
392
|
+
_added_in_gc_file = False # Set to True if the entry is added to GC file.
|
|
393
|
+
|
|
386
394
|
# Avoid substring matches by comparing object names in full.
|
|
387
395
|
# Also make sure to check for the pid.
|
|
388
|
-
if not (
|
|
396
|
+
if object_type and not (db_object in objects_to_delete
|
|
389
397
|
and object_type.value == db_object_type
|
|
390
398
|
and int(os.getpid()) == contentpid):
|
|
391
399
|
fgc.write(db_object_entry)
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
_added_in_gc_file = True
|
|
401
|
+
|
|
402
|
+
elif object_type is None:
|
|
403
|
+
if db_object in objects_to_delete and int(os.getpid()) == contentpid:
|
|
404
|
+
# Skip adding to GC file if the object is being deleted but object_type is passed as None.
|
|
405
|
+
pass
|
|
406
|
+
else:
|
|
407
|
+
fgc.write(db_object_entry)
|
|
408
|
+
_added_in_gc_file = True
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
if not _added_in_gc_file and remove_entry_from_gc_list and configure._validate_gc:
|
|
412
|
+
# Delete the entry from gc lists if required.
|
|
413
|
+
GarbageCollector.__delete_object_from_gc_list(db_object, object_type)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
# If object is a script, also delete the local copy of the file.
|
|
417
|
+
if not _added_in_gc_file and object_type in \
|
|
418
|
+
[TeradataConstants.TERADATA_SCRIPT,
|
|
419
|
+
TeradataConstants.TERADATA_APPLY,
|
|
420
|
+
TeradataConstants.TERADATA_TEXT_FILE,
|
|
421
|
+
TeradataConstants.TERADATA_LOCAL_SCRIPT]:
|
|
422
|
+
GarbageCollector.__delete_gc_tempdir_local_file(db_object, object_type)
|
|
405
423
|
fgc.truncate()
|
|
406
424
|
except Exception as e:
|
|
407
425
|
raise
|
|
@@ -456,8 +474,19 @@ class GarbageCollector():
|
|
|
456
474
|
GarbageCollector.__gc_container.remove(object_name)
|
|
457
475
|
elif TeradataConstants.TERADATA_APPLY == object_type:
|
|
458
476
|
GarbageCollector.__gc_apply.remove(object_name)
|
|
459
|
-
|
|
477
|
+
elif TeradataConstants.TERADATA_SCRIPT == object_type:
|
|
460
478
|
GarbageCollector.__gc_scripts.remove(object_name)
|
|
479
|
+
else:
|
|
480
|
+
# If none of the conditions met, then try removing from all.
|
|
481
|
+
_all_gc_lists = [GarbageCollector.__gc_tables, GarbageCollector.__gc_views,
|
|
482
|
+
GarbageCollector.__gc_scripts, GarbageCollector.__gc_container,
|
|
483
|
+
GarbageCollector.__gc_apply]
|
|
484
|
+
for _list in _all_gc_lists:
|
|
485
|
+
try:
|
|
486
|
+
_list.remove(object_name)
|
|
487
|
+
except ValueError:
|
|
488
|
+
# If the object is not found in the list, just ignore.
|
|
489
|
+
pass
|
|
461
490
|
|
|
462
491
|
@staticmethod
|
|
463
492
|
def _delete_local_file(file_path):
|