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
|
@@ -276,6 +276,8 @@ class _ProgressBar:
|
|
|
276
276
|
progress_precent=_progress_percent,
|
|
277
277
|
completed_jobs=self.completed_jobs,
|
|
278
278
|
total_jobs=self.total_jobs)
|
|
279
|
+
# Add padding to clear any leftover characters from the previous message.
|
|
280
|
+
padded_msg = _msg.ljust(self.blank_space_len)
|
|
279
281
|
# Display the formatted bar.
|
|
280
|
-
print(
|
|
281
|
-
self.blank_space_len = len(
|
|
282
|
+
print(padded_msg, end='\r', file=self.STDOUT, flush=True)
|
|
283
|
+
self.blank_space_len = len(padded_msg)
|
teradataml/lib/aed_0_1.dll
CHANGED
|
Binary file
|
teradataml/lib/libaed_0_1.dylib
CHANGED
|
Binary file
|
teradataml/lib/libaed_0_1.so
CHANGED
|
Binary file
|
|
Binary file
|
teradataml/opensource/_base.py
CHANGED
|
@@ -51,6 +51,7 @@ from teradataml.opensource._wrapper_utils import (_generate_new_name,
|
|
|
51
51
|
_validate_df_query_type)
|
|
52
52
|
from teradataml.options.configure import configure
|
|
53
53
|
from teradataml.utils.validators import _Validators
|
|
54
|
+
from teradataml.utils.internal_buffer import _InternalBuffer
|
|
54
55
|
|
|
55
56
|
logger = pylogger.getLogger()
|
|
56
57
|
|
|
@@ -88,9 +89,13 @@ class _GenericObjectWrapper:
|
|
|
88
89
|
self._env = configure.openml_user_env
|
|
89
90
|
else:
|
|
90
91
|
self._env = UtilFuncs._create_or_get_env("open_source_ml.json")
|
|
92
|
+
else:
|
|
93
|
+
set_session_param("searchuifdbpath", self._db_name)
|
|
91
94
|
|
|
92
95
|
# Check if the Python interpreter major versions are consistent between Vantage and local.
|
|
93
|
-
|
|
96
|
+
_check_py_version = _InternalBuffer.get('_check_py_version')
|
|
97
|
+
if _check_py_version:
|
|
98
|
+
UtilFuncs._check_python_version_diff(self._env)
|
|
94
99
|
|
|
95
100
|
# Raise warning when python package versions don't match between Vantage and local.
|
|
96
101
|
# OPENSOURCE_PACKAGE_NAME is set for each opensource package, but not for the base class.
|
|
@@ -1257,6 +1262,7 @@ class _OpenSourceObjectWrapper(_GenericObjectWrapper):
|
|
|
1257
1262
|
|
|
1258
1263
|
class _FunctionWrapper(_GenericObjectWrapper):
|
|
1259
1264
|
def __init__(self, module_name, func_name, file_type, template_file):
|
|
1265
|
+
|
|
1260
1266
|
super().__init__()
|
|
1261
1267
|
self._module_name = module_name
|
|
1262
1268
|
self._func_name = func_name
|
teradataml/options/configure.py
CHANGED
|
@@ -62,6 +62,7 @@ class _Configure(_ConfigureSuper):
|
|
|
62
62
|
stored_procedure_install_location = _create_property('stored_procedure_install_location')
|
|
63
63
|
table_operator = _create_property('table_operator')
|
|
64
64
|
temp_object_type = _create_property('temp_object_type')
|
|
65
|
+
use_short_object_name = _create_property('use_short_object_name')
|
|
65
66
|
|
|
66
67
|
def __init__(self, default_varchar_size=1024, column_casesensitive_handler=False,
|
|
67
68
|
vantage_version="vantage1.1", val_install_location=None,
|
|
@@ -71,7 +72,7 @@ class _Configure(_ConfigureSuper):
|
|
|
71
72
|
cran_repositories=None, inline_plot=True,
|
|
72
73
|
indb_install_location=None,
|
|
73
74
|
openml_user_env=None, local_storage=None, stored_procedure_install_location="SYSLIB",
|
|
74
|
-
table_operator=None, temp_object_type=None):
|
|
75
|
+
table_operator=None, temp_object_type=None, use_short_object_name=False):
|
|
75
76
|
|
|
76
77
|
"""
|
|
77
78
|
PARAMETERS:
|
|
@@ -140,8 +141,8 @@ class _Configure(_ConfigureSuper):
|
|
|
140
141
|
|
|
141
142
|
indb_install_location:
|
|
142
143
|
Specifies the installation location of In-DB Python package.
|
|
143
|
-
Types: string
|
|
144
144
|
Default Value: "/var/opt/teradata/languages/sles12sp3/Python/"
|
|
145
|
+
Types: string
|
|
145
146
|
Example:
|
|
146
147
|
# Set the installation location for older versions.
|
|
147
148
|
teradataml.options.configure.indb_install_location = "/opt/teradata/languages/Python/"
|
|
@@ -182,9 +183,9 @@ class _Configure(_ConfigureSuper):
|
|
|
182
183
|
Specifies the type of temporary database objects created internally by teradataml.
|
|
183
184
|
Permitted Values:
|
|
184
185
|
* "VT" - Volatile tables.
|
|
185
|
-
Types: String
|
|
186
186
|
Default Value: None
|
|
187
|
-
|
|
187
|
+
Types: String
|
|
188
|
+
Notes:
|
|
188
189
|
* If this option is set to "VT" and "persist" argument of analytic functions is
|
|
189
190
|
set to True, then volatile tables are not created as volatile table can't be
|
|
190
191
|
persisted and "persist" argument takes precedence.
|
|
@@ -193,6 +194,16 @@ class _Configure(_ConfigureSuper):
|
|
|
193
194
|
# Set the type of temporary database objects to "VT" to create volatile internal
|
|
194
195
|
# tables.
|
|
195
196
|
teradataml.options.configure.temp_object_type = "VT"
|
|
197
|
+
|
|
198
|
+
use_short_object_name:
|
|
199
|
+
Specifies whether to use shorter names for temporary tables created internally by teradataml.
|
|
200
|
+
When set to True, teradataml generates internal temporary table names with a maximum length
|
|
201
|
+
of 20 characters. Otherwise, there is no restriction on the length of these table names.
|
|
202
|
+
Default Value: False
|
|
203
|
+
Types: bool
|
|
204
|
+
Example:
|
|
205
|
+
# Set the option to use short names for temporary tables.
|
|
206
|
+
teradataml.options.configure.use_short_object_name = True
|
|
196
207
|
"""
|
|
197
208
|
super().__init__()
|
|
198
209
|
super().__setattr__('default_varchar_size', default_varchar_size)
|
|
@@ -213,6 +224,7 @@ class _Configure(_ConfigureSuper):
|
|
|
213
224
|
super().__setattr__('table_operator', table_operator)
|
|
214
225
|
super().__setattr__('_indb_install_location', indb_install_location)
|
|
215
226
|
super().__setattr__('temp_object_type', self.__get_temp_object_type(temp_object_type))
|
|
227
|
+
super().__setattr__('use_short_object_name', use_short_object_name)
|
|
216
228
|
|
|
217
229
|
# internal configurations
|
|
218
230
|
# These configurations are internal and should not be
|
|
@@ -447,6 +459,10 @@ class _Configure(_ConfigureSuper):
|
|
|
447
459
|
|
|
448
460
|
value = self.__get_temp_object_type(value)
|
|
449
461
|
|
|
462
|
+
elif name == 'use_short_object_name':
|
|
463
|
+
if not isinstance(value, bool):
|
|
464
|
+
raise TypeError(Messages.get_message(MessageCodes.UNSUPPORTED_DATATYPE, name, 'bool'))
|
|
465
|
+
|
|
450
466
|
super().__setattr__(name, value)
|
|
451
467
|
else:
|
|
452
468
|
raise AttributeError("'{}' object has no attribute '{}'".format(self.__class__.__name__, name))
|
teradataml/scriptmgmt/UserEnv.py
CHANGED
|
@@ -20,14 +20,13 @@ import time
|
|
|
20
20
|
from concurrent.futures import ThreadPoolExecutor, wait
|
|
21
21
|
from json.decoder import JSONDecodeError
|
|
22
22
|
from urllib.parse import urlparse
|
|
23
|
+
|
|
23
24
|
import pandas as pd
|
|
24
|
-
import requests
|
|
25
25
|
|
|
26
26
|
from teradataml import configure
|
|
27
|
-
from teradataml.clients.auth_client import _AuthWorkflow
|
|
28
27
|
from teradataml.clients.pkce_client import _DAWorkflow
|
|
29
28
|
from teradataml.common.constants import (AsyncOpStatus, CloudProvider,
|
|
30
|
-
HTTPRequest)
|
|
29
|
+
HTTPRequest, AsyncOpStatusOAFColumns)
|
|
31
30
|
from teradataml.common.exceptions import TeradataMlException
|
|
32
31
|
from teradataml.common.messagecodes import MessageCodes
|
|
33
32
|
from teradataml.common.messages import Messages
|
|
@@ -121,6 +120,7 @@ def _get_ues_url(env_type="users", **kwargs):
|
|
|
121
120
|
|
|
122
121
|
ues_url = "{0}/{1}/{2}".format(ues_url, _get_user(), env_type)
|
|
123
122
|
env_name, files, libs = kwargs.get("env_name"), kwargs.get("files", False), kwargs.get("libs", False)
|
|
123
|
+
models = kwargs.get("models", False)
|
|
124
124
|
|
|
125
125
|
if env_name is not None:
|
|
126
126
|
ues_url = "{0}/{1}".format(ues_url, env_name)
|
|
@@ -132,6 +132,8 @@ def _get_ues_url(env_type="users", **kwargs):
|
|
|
132
132
|
ues_url = "{0}/{1}".format(ues_url, file_name)
|
|
133
133
|
elif libs:
|
|
134
134
|
ues_url = "{0}/{1}".format(ues_url, "libraries")
|
|
135
|
+
elif models:
|
|
136
|
+
ues_url = "{0}/{1}".format(ues_url, "models")
|
|
135
137
|
return ues_url
|
|
136
138
|
|
|
137
139
|
|
|
@@ -3662,7 +3664,7 @@ class UserEnv:
|
|
|
3662
3664
|
record.update(claim_id_details)
|
|
3663
3665
|
return [record]
|
|
3664
3666
|
|
|
3665
|
-
def __get_claim_status(self, claim_id, timeout, action):
|
|
3667
|
+
def __get_claim_status(self, claim_id, timeout, action, **kwargs):
|
|
3666
3668
|
"""
|
|
3667
3669
|
DESCRIPTION:
|
|
3668
3670
|
Function to get the status of asynchronus process using the claim_id.
|
|
@@ -3688,12 +3690,13 @@ class UserEnv:
|
|
|
3688
3690
|
Specifies the action for asynchronous process.
|
|
3689
3691
|
Types: str
|
|
3690
3692
|
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3693
|
+
kwargs:
|
|
3694
|
+
suppress_output:
|
|
3695
|
+
Optional Argument.
|
|
3696
|
+
Specifies whether to print the output message or not.
|
|
3697
|
+
When set to True, then the output message is not printed.
|
|
3698
|
+
Default Value: False
|
|
3699
|
+
Types: bool
|
|
3697
3700
|
|
|
3698
3701
|
RETURNS:
|
|
3699
3702
|
Pandas DataFrame OR claim id.
|
|
@@ -3708,22 +3711,23 @@ class UserEnv:
|
|
|
3708
3711
|
# If user specifies 'timeout', poll only for 'timeout' seconds. Otherwise,
|
|
3709
3712
|
# poll status API indefinitely.
|
|
3710
3713
|
timeout = UtilFuncs._get_positive_infinity() if timeout is None else timeout
|
|
3711
|
-
|
|
3714
|
+
suppress_output = kwargs.get("suppress_output", False)
|
|
3712
3715
|
start_time = time.time()
|
|
3713
3716
|
while time.time() - start_time <= timeout:
|
|
3714
3717
|
time.sleep(3)
|
|
3715
|
-
records = self.__is_async_operation_completed(claim_id)
|
|
3718
|
+
records = self.__is_async_operation_completed(claim_id, suppress_output=suppress_output)
|
|
3716
3719
|
if records:
|
|
3717
3720
|
return pd.DataFrame.from_records(records, columns=self.__status_columns)
|
|
3718
3721
|
|
|
3719
3722
|
# Unable to get the response with in 'timeout' seconds. Print a message and
|
|
3720
3723
|
# return claim id.
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
+
if not suppress_output:
|
|
3725
|
+
print("Request to {} initiated successfully in the remote user environment '{}' "
|
|
3726
|
+
"but Timed out status check. Check the status using status() with the "
|
|
3727
|
+
"claim id '{}'.".format(action, self.env_name, claim_id))
|
|
3724
3728
|
return claim_id
|
|
3725
3729
|
|
|
3726
|
-
def __is_async_operation_completed(self, claim_id):
|
|
3730
|
+
def __is_async_operation_completed(self, claim_id, **kwargs):
|
|
3727
3731
|
"""
|
|
3728
3732
|
DESCRIPTION:
|
|
3729
3733
|
Function to check whether asynchronous process to install/update/uninstall libraries/file
|
|
@@ -3736,6 +3740,14 @@ class UserEnv:
|
|
|
3736
3740
|
started by the UserEnv management methods.
|
|
3737
3741
|
Types: str
|
|
3738
3742
|
|
|
3743
|
+
kwargs:
|
|
3744
|
+
suppress_output:
|
|
3745
|
+
Optional Argument.
|
|
3746
|
+
Specifies whether to print the output message or not.
|
|
3747
|
+
When set to True, then the output message is not printed.
|
|
3748
|
+
Default Value: False
|
|
3749
|
+
Types: bool
|
|
3750
|
+
|
|
3739
3751
|
RETURNS:
|
|
3740
3752
|
list OR bool.
|
|
3741
3753
|
|
|
@@ -3746,6 +3758,7 @@ class UserEnv:
|
|
|
3746
3758
|
# Create a remote user environment.
|
|
3747
3759
|
>>> env.__is_async_operation_completed('123-456')
|
|
3748
3760
|
"""
|
|
3761
|
+
suppress_output = kwargs.get("suppress_output", False)
|
|
3749
3762
|
records = self.__get_claim_id_status(claim_id)
|
|
3750
3763
|
|
|
3751
3764
|
# For library installation/uninstallation/updation, if the background process in
|
|
@@ -3754,12 +3767,17 @@ class UserEnv:
|
|
|
3754
3767
|
action = self.__claim_ids.get(claim_id, {}).get("action")
|
|
3755
3768
|
if action in ["install_file", "install_model"]:
|
|
3756
3769
|
for record in records:
|
|
3757
|
-
if record["Stage"] in [AsyncOpStatus.FILE_INSTALLED.value,
|
|
3758
|
-
|
|
3759
|
-
|
|
3770
|
+
if record["Stage"] in [AsyncOpStatus.FILE_INSTALLED.value,
|
|
3771
|
+
AsyncOpStatus.ERRED.value,
|
|
3772
|
+
AsyncOpStatus.MODEL_INSTALLED.value]:
|
|
3773
|
+
if record["Stage"] in [AsyncOpStatus.FILE_INSTALLED.value,
|
|
3774
|
+
AsyncOpStatus.MODEL_INSTALLED.value]:
|
|
3775
|
+
if not suppress_output:
|
|
3776
|
+
print("Request for {} is {}.".format(action, "completed successfully"))
|
|
3760
3777
|
elif record["Stage"] == AsyncOpStatus.ERRED.value:
|
|
3761
|
-
|
|
3762
|
-
|
|
3778
|
+
if not suppress_output:
|
|
3779
|
+
print("Request for {} is {}.".format(action, AsyncOpStatus.ERRED.value))
|
|
3780
|
+
print("Check the status using status() with the claim id '{}'".format(claim_id))
|
|
3763
3781
|
return records
|
|
3764
3782
|
return False
|
|
3765
3783
|
|
|
@@ -3767,24 +3785,51 @@ class UserEnv:
|
|
|
3767
3785
|
return records if len(records) == 2 else False
|
|
3768
3786
|
|
|
3769
3787
|
@collect_queryband(queryband="InstlMdl")
|
|
3770
|
-
def install_model(self, model_path, **kwargs):
|
|
3788
|
+
def install_model(self, model_path=None, model_name=None, model_type=None, api_key=None, **kwargs):
|
|
3771
3789
|
"""
|
|
3772
3790
|
DESCRIPTION:
|
|
3773
|
-
Function installs a model
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3791
|
+
Function installs a model into the remote user environment created
|
|
3792
|
+
in Vantage Languages Ecosystem. Model can be installed from a zip file
|
|
3793
|
+
containing all the files related to the model or from a model registry
|
|
3794
|
+
like Hugging Face. If model with same name already exists in the remote
|
|
3795
|
+
user environment, error is thrown.
|
|
3777
3796
|
Note:
|
|
3778
|
-
Maximum size of the model should be less than or equal to 5GB
|
|
3797
|
+
Maximum size of the model should be less than or equal to 5GB when
|
|
3798
|
+
installing using zip.
|
|
3779
3799
|
|
|
3780
3800
|
PARAMETERS:
|
|
3781
3801
|
model_path:
|
|
3782
|
-
|
|
3802
|
+
Optional Argument.
|
|
3783
3803
|
Specifies absolute or relative path of the zip file containing
|
|
3784
3804
|
model (including file name) to be installed in the remote user
|
|
3785
3805
|
environment.
|
|
3806
|
+
Notes:
|
|
3807
|
+
* Model file should be in zip format.
|
|
3808
|
+
* Arguments "model_path" and "model_name" are mutually exclusive.
|
|
3809
|
+
Types: str
|
|
3810
|
+
|
|
3811
|
+
model_name:
|
|
3812
|
+
Optional Argument.
|
|
3813
|
+
Specifies the name/identifier of the model in the registry (e.g. "google-t5/t5-small"
|
|
3814
|
+
from Hugging Face registry).
|
|
3815
|
+
Note:
|
|
3816
|
+
* Arguments "model_name" and "model_path" are mutually exclusive.
|
|
3817
|
+
Types: str
|
|
3818
|
+
|
|
3819
|
+
model_type:
|
|
3820
|
+
Optional Argument.
|
|
3821
|
+
Specifies the name of model registry like Hugging Face.
|
|
3822
|
+
Note:
|
|
3823
|
+
* Applicable when model is installed from a model registry.
|
|
3824
|
+
Default Value: "HF" (Hugging Face registry)
|
|
3825
|
+
Permitted Values: "HF"
|
|
3826
|
+
Types: str
|
|
3827
|
+
|
|
3828
|
+
api_key:
|
|
3829
|
+
Optional Argument.
|
|
3830
|
+
Specifies the API key for accessing the private models in registry.
|
|
3786
3831
|
Note:
|
|
3787
|
-
|
|
3832
|
+
Applicable only when model is installed from a model registry.
|
|
3788
3833
|
Types: str
|
|
3789
3834
|
|
|
3790
3835
|
**kwargs:
|
|
@@ -3861,13 +3906,148 @@ class UserEnv:
|
|
|
3861
3906
|
>>> env.models
|
|
3862
3907
|
Model Size Timestamp
|
|
3863
3908
|
0 large_model 6144 2023-10-30T13:34:03Z
|
|
3909
|
+
|
|
3910
|
+
# Example 3: Install the model from default registry 'Hugging Face'
|
|
3911
|
+
# in the 'testenv' environment synchronously.
|
|
3912
|
+
>>> env.install_model(model_name="google-bert/bert-base-uncased")
|
|
3913
|
+
Request for install_model is completed successfully.
|
|
3914
|
+
Model 'google-bert/bert-base-uncased' installed successfully in the remote user environment 'testenv'.
|
|
3915
|
+
|
|
3916
|
+
# Verify the model installation.
|
|
3917
|
+
>>> env.models
|
|
3918
|
+
Model Size Timestamp
|
|
3919
|
+
0 models--google-bert--bert-base-uncased 6144 2025-07-30T03:58:01Z
|
|
3920
|
+
|
|
3921
|
+
# Example 4: Install the model from default registry 'Hugging Face'
|
|
3922
|
+
# in the 'testenv' environment asynchronously.
|
|
3923
|
+
>>> claim_id = env.install_model(model_name="Helsinki-NLP/opus-mt-en-fr", asynchronous=True)
|
|
3924
|
+
Model installation is initiated. Check the status using <UserEnv_obj>.status() with the claim id 'ac284706-0b72-4b83-8add-3cff632747f4'.
|
|
3925
|
+
|
|
3926
|
+
# Check status using claim-id.
|
|
3927
|
+
>>> env.status(claim_id)
|
|
3928
|
+
Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
|
|
3929
|
+
0 ac284706-0b72-4b83-8add-3cff632747f4 Helsinki-NLP/opus-mt-en-fr install_model Started 2025-07-30T03:58:09Z Begin downloading model named Helsinki-NLP/opu...
|
|
3930
|
+
1 ac284706-0b72-4b83-8add-3cff632747f4 Helsinki-NLP/opus-mt-en-fr install_model ModelInstalled 2025-07-30T03:58:28Z Model installed successfully
|
|
3931
|
+
|
|
3932
|
+
# Verify the model installation.
|
|
3933
|
+
>>> env.models
|
|
3934
|
+
Model Size Timestamp
|
|
3935
|
+
0 models--Helsinki-NLP--opus-mt-en-fr 6144 2025-07-30T03:58:27Z
|
|
3936
|
+
1 models--google-bert--bert-base-uncased 6144 2025-07-30T03:58:01Z
|
|
3864
3937
|
"""
|
|
3865
|
-
#
|
|
3866
|
-
kwargs
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3938
|
+
# Get default values for optional keyword arguments.
|
|
3939
|
+
suppress_output = kwargs.get("suppress_output", False)
|
|
3940
|
+
asynchronous = kwargs.get("asynchronous", False)
|
|
3941
|
+
timeout = kwargs.get("timeout", None)
|
|
3942
|
+
|
|
3943
|
+
# Get default value for optional positional argument.
|
|
3944
|
+
model_type = model_type if model_type is not None else "HF"
|
|
3945
|
+
|
|
3946
|
+
# Argument validation.
|
|
3947
|
+
__arg_info_matrix = []
|
|
3948
|
+
__arg_info_matrix.append(["model_path", model_path, True, (str), True])
|
|
3949
|
+
__arg_info_matrix.append(["model_name", model_name, True, (str), True])
|
|
3950
|
+
__arg_info_matrix.append(["model_type", model_type, True, (str), True, ["HF"]])
|
|
3951
|
+
__arg_info_matrix.append(["api_key", api_key, True, (str), True])
|
|
3952
|
+
__arg_info_matrix.append(["suppress_output", suppress_output, True, (bool)])
|
|
3953
|
+
__arg_info_matrix.append(["asynchronous", asynchronous, True, (bool)])
|
|
3954
|
+
__arg_info_matrix.append(["timeout", timeout, True, (int, float)])
|
|
3955
|
+
|
|
3956
|
+
_Validators._validate_function_arguments(__arg_info_matrix)
|
|
3957
|
+
|
|
3958
|
+
# Validate mutually exclusive arguments.
|
|
3959
|
+
_Validators._validate_mutually_exclusive_argument_groups({"model_name": model_name},
|
|
3960
|
+
{"model_path": model_path},
|
|
3961
|
+
all_falsy_check=True)
|
|
3962
|
+
|
|
3963
|
+
# Install model from zip file.
|
|
3964
|
+
if model_path:
|
|
3965
|
+
kwargs["is_model"] = True
|
|
3966
|
+
if not "is_llm" in kwargs:
|
|
3967
|
+
kwargs["is_llm"] = True
|
|
3968
|
+
records = self.install_file(model_path, **kwargs)
|
|
3969
|
+
return records
|
|
3970
|
+
|
|
3971
|
+
# Install models from registry.
|
|
3972
|
+
api_name = "install_model"
|
|
3973
|
+
try:
|
|
3974
|
+
# Prepare the payload
|
|
3975
|
+
payload = {
|
|
3976
|
+
"model_name": model_name,
|
|
3977
|
+
"model_type": model_type
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
if api_key is not None:
|
|
3981
|
+
payload["api_key"] = api_key
|
|
3982
|
+
|
|
3983
|
+
# Make the REST call to install model from registry
|
|
3984
|
+
resource_url = _get_ues_url(env_name=self.env_name, api_name=api_name, models=True)
|
|
3985
|
+
response = UtilFuncs._http_request(resource_url,
|
|
3986
|
+
HTTPRequest.POST,
|
|
3987
|
+
headers=_get_auth_token(),
|
|
3988
|
+
json=payload)
|
|
3989
|
+
|
|
3990
|
+
data = _process_ues_response(api_name, response).json()
|
|
3991
|
+
|
|
3992
|
+
# Get claim-id model install async operation from response.
|
|
3993
|
+
claim_id = data["claim_id"]
|
|
3994
|
+
|
|
3995
|
+
# Store the claim id locally to display the model name in status API.
|
|
3996
|
+
self.__claim_ids[claim_id] = {"action": api_name, "value": model_name}
|
|
3997
|
+
installation_status = "is initiated"
|
|
3998
|
+
|
|
3999
|
+
# In case of synchronous mode, keep polling the status
|
|
4000
|
+
# of underlying asynchronous operation until it is either
|
|
4001
|
+
# successful or errored or timed out.
|
|
4002
|
+
if not asynchronous:
|
|
4003
|
+
installation_status = self.__get_claim_status(claim_id=claim_id,
|
|
4004
|
+
timeout=timeout,
|
|
4005
|
+
action=api_name,
|
|
4006
|
+
suppress_output=True)
|
|
4007
|
+
self.__models_changed = True
|
|
4008
|
+
# If model installation is complete(either success or fail),
|
|
4009
|
+
# pandas DF will be returned.
|
|
4010
|
+
if isinstance(installation_status, pd.DataFrame):
|
|
4011
|
+
# Model installation successful.
|
|
4012
|
+
if AsyncOpStatus.MODEL_INSTALLED.value in installation_status[AsyncOpStatusOAFColumns.STAGE.value].to_list():
|
|
4013
|
+
# Update the models changed flag
|
|
4014
|
+
self.__models_changed = True
|
|
4015
|
+
if not suppress_output:
|
|
4016
|
+
print("Model '{}' installed successfully in the remote user environment '{}'.".format(
|
|
4017
|
+
model_name, self.env_name))
|
|
4018
|
+
return True
|
|
4019
|
+
# Model installation erred out.
|
|
4020
|
+
if AsyncOpStatus.ERRED.value in installation_status[AsyncOpStatusOAFColumns.STAGE.value].to_list():
|
|
4021
|
+
err = ""
|
|
4022
|
+
for record in installation_status.to_dict("records"):
|
|
4023
|
+
if record["Stage"] == AsyncOpStatus.ERRED.value:
|
|
4024
|
+
err = record[AsyncOpStatusOAFColumns.ADDITIONAL_DETAILS.value]
|
|
4025
|
+
msg_code = MessageCodes.FUNC_EXECUTION_FAILED
|
|
4026
|
+
error_msg = Messages.get_message(msg_code, api_name, "Check the details using <UserEnv_obj>.status() with the claim id '{}'".format(claim_id) + "\nAdditional details: {}".format(err))
|
|
4027
|
+
raise TeradataMlException(error_msg, msg_code)
|
|
4028
|
+
|
|
4029
|
+
# Underlying asynchronous operation timed out, claim_id is returned.
|
|
4030
|
+
else:
|
|
4031
|
+
if not suppress_output:
|
|
4032
|
+
print("Request to install_model initiated successfully in the remote user environment '{}' "
|
|
4033
|
+
"but it is timed out. Check the status using <UserEnv_obj>.status() with the "
|
|
4034
|
+
"claim id '{}'.".format(self.env_name, claim_id))
|
|
4035
|
+
return claim_id
|
|
4036
|
+
|
|
4037
|
+
if not suppress_output:
|
|
4038
|
+
# Print a message to user console.
|
|
4039
|
+
print("Model installation {}. Check the status"
|
|
4040
|
+
" using <UserEnv_obj>.status() with the claim id '{}'.".format(installation_status, claim_id))
|
|
4041
|
+
self.__models_changed = True
|
|
4042
|
+
return claim_id
|
|
4043
|
+
|
|
4044
|
+
except (TeradataMlException, RuntimeError):
|
|
4045
|
+
raise
|
|
4046
|
+
except Exception as emsg:
|
|
4047
|
+
msg_code = MessageCodes.FUNC_EXECUTION_FAILED
|
|
4048
|
+
error_msg = Messages.get_message(msg_code, api_name, str(emsg))
|
|
4049
|
+
raise TeradataMlException(error_msg, msg_code)
|
|
4050
|
+
|
|
3871
4051
|
|
|
3872
4052
|
@collect_queryband(queryband="UninstlMdl")
|
|
3873
4053
|
def uninstall_model(self, model_name, **kwargs):
|
|
@@ -3906,7 +4086,7 @@ class UserEnv:
|
|
|
3906
4086
|
# API. Let's assume that all models files are zipped under 'large_model.zip'
|
|
3907
4087
|
>>> model = 'large_model.zip'
|
|
3908
4088
|
|
|
3909
|
-
# Install the model in the 'test_env' environment.
|
|
4089
|
+
# Install the model in the 'test_env' environment using local zip file.
|
|
3910
4090
|
>>> env.install_model(model_path = model)
|
|
3911
4091
|
Request for install_model is completed successfully.
|
|
3912
4092
|
Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
|
|
@@ -3919,9 +4099,28 @@ class UserEnv:
|
|
|
3919
4099
|
Model Size Timestamp
|
|
3920
4100
|
0 large_model 6144 2023-11-09T09:22:30Z
|
|
3921
4101
|
|
|
4102
|
+
# Install model from Hugging Face registry.
|
|
4103
|
+
>>> env.install_model(model_name="google-bert/bert-base-uncased")
|
|
4104
|
+
Request for install_model is completed successfully.
|
|
4105
|
+
Model 'google-bert/bert-base-uncased' installed successfully in the remote user environment 'test_env'.
|
|
4106
|
+
# List models.
|
|
4107
|
+
>>> env.models
|
|
4108
|
+
Model Size Timestamp
|
|
4109
|
+
0 large_model 6144 2023-11-09T09:22:30Z
|
|
4110
|
+
1 models--google-bert--bert-base-uncased 6144 2025-07-30T03:58:01Z
|
|
4111
|
+
|
|
3922
4112
|
# Example 1: Uninstall model from remote user environment.
|
|
3923
4113
|
>>> env.uninstall_model('large_model')
|
|
3924
4114
|
Model 'large_model' uninstalled successfully from the remote user environment 'test_env'.
|
|
4115
|
+
True
|
|
4116
|
+
|
|
4117
|
+
# Verify the uninstallation of model.
|
|
4118
|
+
Model Size Timestamp
|
|
4119
|
+
0 models--google-bert--bert-base-uncased 6144 2025-07-30T03:58:01Z
|
|
4120
|
+
|
|
4121
|
+
# Example 2: Uninstall Hugging Face model from remote user environment.
|
|
4122
|
+
>>> env.uninstall_model('models--google-bert--bert-base-uncased')
|
|
4123
|
+
Model 'models--google-bert--bert-base-uncased' uninstalled successfully from the remote user environment 'test_env'.
|
|
3925
4124
|
True
|
|
3926
4125
|
|
|
3927
4126
|
# Verify the uninstallation of model.
|
|
@@ -4046,6 +4245,14 @@ class _AuthToken:
|
|
|
4046
4245
|
def value(self):
|
|
4047
4246
|
return self.__value
|
|
4048
4247
|
|
|
4248
|
+
@value.setter
|
|
4249
|
+
def value(self, token_value):
|
|
4250
|
+
"""
|
|
4251
|
+
DESCRIPTION:
|
|
4252
|
+
Sets value of _AuthToken.
|
|
4253
|
+
"""
|
|
4254
|
+
self.__value = token_value
|
|
4255
|
+
|
|
4049
4256
|
@property
|
|
4050
4257
|
def auth_type(self):
|
|
4051
4258
|
return self.__auth_type
|
|
@@ -4060,3 +4267,7 @@ class _AuthToken:
|
|
|
4060
4267
|
elif self.auth_type.lower() == "bearer":
|
|
4061
4268
|
# Form the Authorization header value by prepending 'Bearer ' to the JWT token.
|
|
4062
4269
|
return {"Authorization": "Bearer {}".format(self.value)}
|
|
4270
|
+
elif self.auth_type.lower() == "keycloak":
|
|
4271
|
+
# Get valid token value for current time.
|
|
4272
|
+
self.value = _InternalBuffer.get("keycloak_manager").get_token()
|
|
4273
|
+
return {"Authorization": "Bearer {}".format(self.value)}
|