teradataml 20.0.0.2__py3-none-any.whl → 20.0.0.4__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.

Files changed (126) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/README.md +315 -2
  3. teradataml/__init__.py +4 -0
  4. teradataml/_version.py +1 -1
  5. teradataml/analytics/analytic_function_executor.py +95 -8
  6. teradataml/analytics/byom/__init__.py +1 -1
  7. teradataml/analytics/json_parser/metadata.py +12 -3
  8. teradataml/analytics/json_parser/utils.py +7 -2
  9. teradataml/analytics/sqle/__init__.py +5 -1
  10. teradataml/analytics/table_operator/__init__.py +1 -1
  11. teradataml/analytics/uaf/__init__.py +1 -1
  12. teradataml/analytics/utils.py +4 -0
  13. teradataml/analytics/valib.py +18 -4
  14. teradataml/automl/__init__.py +51 -6
  15. teradataml/automl/data_preparation.py +59 -35
  16. teradataml/automl/data_transformation.py +58 -33
  17. teradataml/automl/feature_engineering.py +27 -12
  18. teradataml/automl/model_training.py +73 -46
  19. teradataml/common/constants.py +88 -29
  20. teradataml/common/garbagecollector.py +2 -1
  21. teradataml/common/messagecodes.py +19 -3
  22. teradataml/common/messages.py +6 -1
  23. teradataml/common/sqlbundle.py +64 -12
  24. teradataml/common/utils.py +246 -47
  25. teradataml/common/warnings.py +11 -0
  26. teradataml/context/context.py +161 -27
  27. teradataml/data/amazon_reviews_25.csv +26 -0
  28. teradataml/data/byom_example.json +11 -0
  29. teradataml/data/dataframe_example.json +18 -2
  30. teradataml/data/docs/byom/docs/DataRobotPredict.py +2 -2
  31. teradataml/data/docs/byom/docs/DataikuPredict.py +40 -1
  32. teradataml/data/docs/byom/docs/H2OPredict.py +2 -2
  33. teradataml/data/docs/byom/docs/ONNXEmbeddings.py +242 -0
  34. teradataml/data/docs/byom/docs/ONNXPredict.py +2 -2
  35. teradataml/data/docs/byom/docs/PMMLPredict.py +2 -2
  36. teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +1 -1
  37. teradataml/data/docs/sqle/docs_17_20/Shap.py +34 -6
  38. teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +4 -4
  39. teradataml/data/docs/sqle/docs_17_20/TextParser.py +3 -3
  40. teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
  41. teradataml/data/docs/uaf/docs_17_20/CopyArt.py +145 -0
  42. teradataml/data/docs/uaf/docs_17_20/DWT2D.py +4 -1
  43. teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +18 -21
  44. teradataml/data/hnsw_alter_data.csv +5 -0
  45. teradataml/data/hnsw_data.csv +10 -0
  46. teradataml/data/jsons/byom/h2opredict.json +1 -1
  47. teradataml/data/jsons/byom/onnxembeddings.json +266 -0
  48. teradataml/data/jsons/sqle/17.20/TD_Shap.json +0 -1
  49. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +1 -1
  50. teradataml/data/jsons/sqle/20.00/TD_HNSW.json +296 -0
  51. teradataml/data/jsons/sqle/20.00/TD_HNSWPredict.json +206 -0
  52. teradataml/data/jsons/sqle/20.00/TD_HNSWSummary.json +32 -0
  53. teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
  54. teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
  55. teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
  56. teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
  57. teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -0
  58. teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +10 -19
  59. teradataml/data/jsons/uaf/17.20/TD_SAX.json +3 -1
  60. teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +15 -5
  61. teradataml/data/medical_readings.csv +101 -0
  62. teradataml/data/patient_profile.csv +101 -0
  63. teradataml/data/scripts/lightgbm/dataset.template +157 -0
  64. teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +247 -0
  65. teradataml/data/scripts/lightgbm/lightgbm_function.template +216 -0
  66. teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +159 -0
  67. teradataml/data/scripts/sklearn/sklearn_fit.py +194 -167
  68. teradataml/data/scripts/sklearn/sklearn_fit_predict.py +136 -115
  69. teradataml/data/scripts/sklearn/sklearn_function.template +14 -19
  70. teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +155 -137
  71. teradataml/data/scripts/sklearn/sklearn_transform.py +129 -42
  72. teradataml/data/target_udt_data.csv +8 -0
  73. teradataml/data/templates/open_source_ml.json +3 -2
  74. teradataml/data/teradataml_example.json +8 -0
  75. teradataml/data/vectordistance_example.json +4 -0
  76. teradataml/dataframe/copy_to.py +8 -3
  77. teradataml/dataframe/data_transfer.py +11 -1
  78. teradataml/dataframe/dataframe.py +1049 -285
  79. teradataml/dataframe/dataframe_utils.py +152 -20
  80. teradataml/dataframe/functions.py +578 -35
  81. teradataml/dataframe/setop.py +11 -6
  82. teradataml/dataframe/sql.py +185 -16
  83. teradataml/dbutils/dbutils.py +1049 -115
  84. teradataml/dbutils/filemgr.py +48 -1
  85. teradataml/hyperparameter_tuner/optimizer.py +12 -1
  86. teradataml/lib/aed_0_1.dll +0 -0
  87. teradataml/opensource/__init__.py +1 -1
  88. teradataml/opensource/_base.py +1466 -0
  89. teradataml/opensource/_class.py +464 -0
  90. teradataml/opensource/{sklearn/constants.py → _constants.py} +21 -14
  91. teradataml/opensource/_lightgbm.py +949 -0
  92. teradataml/opensource/_sklearn.py +1008 -0
  93. teradataml/opensource/{sklearn/_wrapper_utils.py → _wrapper_utils.py} +5 -6
  94. teradataml/options/__init__.py +54 -38
  95. teradataml/options/configure.py +131 -27
  96. teradataml/options/display.py +13 -2
  97. teradataml/plot/axis.py +47 -8
  98. teradataml/plot/figure.py +33 -0
  99. teradataml/plot/plot.py +63 -13
  100. teradataml/scriptmgmt/UserEnv.py +5 -5
  101. teradataml/scriptmgmt/lls_utils.py +130 -40
  102. teradataml/store/__init__.py +12 -0
  103. teradataml/store/feature_store/__init__.py +0 -0
  104. teradataml/store/feature_store/constants.py +291 -0
  105. teradataml/store/feature_store/feature_store.py +2318 -0
  106. teradataml/store/feature_store/models.py +1505 -0
  107. teradataml/table_operators/Apply.py +32 -18
  108. teradataml/table_operators/Script.py +3 -1
  109. teradataml/table_operators/TableOperator.py +3 -1
  110. teradataml/table_operators/query_generator.py +3 -0
  111. teradataml/table_operators/table_operator_query_generator.py +3 -1
  112. teradataml/table_operators/table_operator_util.py +37 -38
  113. teradataml/table_operators/templates/dataframe_register.template +69 -0
  114. teradataml/utils/dtypes.py +51 -2
  115. teradataml/utils/internal_buffer.py +18 -0
  116. teradataml/utils/validators.py +99 -8
  117. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/METADATA +321 -5
  118. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/RECORD +121 -94
  119. teradataml/libaed_0_1.dylib +0 -0
  120. teradataml/libaed_0_1.so +0 -0
  121. teradataml/opensource/sklearn/__init__.py +0 -1
  122. teradataml/opensource/sklearn/_class.py +0 -255
  123. teradataml/opensource/sklearn/_sklearn_wrapper.py +0 -1800
  124. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/WHEEL +0 -0
  125. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/top_level.txt +0 -0
  126. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/zip-safe +0 -0
teradataml/plot/plot.py CHANGED
@@ -472,26 +472,78 @@ class _Plot:
472
472
  self.figure = Figure()
473
473
  self._figure = self.figure
474
474
 
475
- axis = kwargs.get("ax")
475
+ self.axis = kwargs.get("ax", None)
476
476
  # If axis is not passed, generate a default one.
477
- if axis is None:
478
- axis = Axis(kind=kind, **kwargs)
477
+ if self.axis is None:
478
+ self.axis = Axis(kind=kind, **kwargs)
479
479
  else:
480
480
  # If user passes axes, i.e., for subplot, add additional params
481
481
  # which is passed as kwargs.
482
- axis.set_params(kind=kind, **kwargs)
482
+ self.axis.set_params(kind=kind, **kwargs)
483
483
 
484
484
  # Set the axis data.
485
- axis._set_data(x, y, scale=scale)
485
+ self.axis._set_data(x, y, scale=scale)
486
486
 
487
487
  # Add the axis to figure.
488
- self._figure._add_axis(axis)
488
+ self._figure._add_axis(self.axis)
489
489
  self._query = None
490
490
  self._plot_image_data = None
491
- self.__heading = kwargs.get("heading")
492
- _Validators._validate_input_columns_not_empty(self.__heading, "heading")
491
+ self.heading = kwargs.get("heading")
492
+ _Validators._validate_input_columns_not_empty(self.heading, "heading")
493
493
  self.__params = kwargs
494
494
 
495
+ def __eq__(self, other):
496
+ """
497
+ DESCRIPTION:
498
+ Magic method to check if two Plot objects are equal or not.
499
+ If all the associated parameters are same, then two Plot objects
500
+ are equal. Else, they are not equal.
501
+
502
+ PARAMETERS:
503
+ other:
504
+ Required Argument.
505
+ Specifies the object of Plot.
506
+ Types: Plot
507
+
508
+ RETURNS:
509
+ bool
510
+
511
+ RAISES:
512
+ None.
513
+
514
+ EXAMPLES:
515
+ >>> _Plot() == _Plot()
516
+ """
517
+
518
+ # Check whether x and y are same or not.
519
+ # If two plots to be same, their data and plot parameters to be same.
520
+ if self.x.compile() != other.x.compile():
521
+ return False
522
+
523
+ self_y = (self.y, ) if isinstance(self.y, ColumnExpression) else self.y
524
+ other_y = (other.y, ) if isinstance(other.y, ColumnExpression) else other.y
525
+
526
+ if len(self_y) != len(other_y):
527
+ return False
528
+
529
+ for self_col, other_col in zip(self_y, other_y):
530
+ if self_col.compile() != other_col.compile():
531
+ return False
532
+
533
+ # Validate plot parameters are same or not.
534
+ attrs = ["scale", "kind",
535
+ "figsize", "figtype", "figdpi",
536
+ "heading", "wiggle_fill", "wiggle_scale",
537
+ "axis", "figure"]
538
+
539
+ for attr in attrs:
540
+ if getattr(self, attr) == getattr(other, attr):
541
+ continue
542
+ else:
543
+ return False
544
+
545
+ return True
546
+
495
547
  def _execute_query(self):
496
548
  """
497
549
  DESCRIPTION:
@@ -504,7 +556,6 @@ class _Plot:
504
556
  query = self._get_query()
505
557
 
506
558
  res = get_connection().execute(text(query))
507
-
508
559
  self._plot_image_data = res.fetchone().IMAGE
509
560
 
510
561
  def show_query(self):
@@ -563,9 +614,8 @@ class _Plot:
563
614
  >>> plot = ibm_stock.plot(x=ibm_stock.period, y=ibm_stock.stockprice, kind="bar")
564
615
  >>> plot.show()
565
616
  """
566
- query = self._get_query()
567
-
568
- self._execute_query()
617
+ if self._plot_image_data is None:
618
+ self._execute_query()
569
619
 
570
620
  # If user choose for inline plot, then check if Python console supports
571
621
  # inline plotting or not. If not supports, then go for outline plot.
@@ -691,7 +741,7 @@ class _Plot:
691
741
  "HEIGHT": height
692
742
  })
693
743
 
694
- heading = self.__heading if self.__heading is not None else self._figure.heading
744
+ heading = self.heading if self.heading is not None else self._figure.heading
695
745
  if heading:
696
746
  func_other_args["TITLE"] = "'{}'".format(heading)
697
747
 
@@ -86,8 +86,8 @@ def _get_ues_url(env_type="users", **kwargs):
86
86
  raise TeradataMlException(error_msg, MessageCodes.FUNC_EXECUTION_FAILED)
87
87
 
88
88
  if configure.ues_url is None:
89
- error_msg = Messages.get_message(MessageCodes.DEPENDENT_ARGUMENT,
90
- api_name, 'configure.ues_url')
89
+ error_msg = Messages.get_message(MessageCodes.SET_REQUIRED_PARAMS,
90
+ 'Authentication Token', api_name, 'set_auth_token')
91
91
  raise RuntimeError(error_msg)
92
92
 
93
93
  ues_url = "{}/{}".format(configure.ues_url, env_type)
@@ -205,7 +205,7 @@ def _process_ues_response(api_name, response, success_status_code=None):
205
205
  def _get_auth_token():
206
206
  """
207
207
  DESCRIPTION:
208
- Internal function to get Authentication token for all UES REST calls
208
+ Internal function to get Authentication token for all CCP enabled REST calls
209
209
 
210
210
  PARAMETERS:
211
211
  None
@@ -238,8 +238,8 @@ def _get_auth_token():
238
238
 
239
239
  # Store the jwt token in internal class attribute.
240
240
  _InternalBuffer.add(auth_token=_AuthToken(token=token_data["access_token"]))
241
-
242
- return {"Authorization": "Bearer {}".format(_InternalBuffer.get("auth_token").value)}
241
+ if _InternalBuffer.get("auth_token"):
242
+ return {"Authorization": "Bearer {}".format(_InternalBuffer.get("auth_token").value)}
243
243
 
244
244
 
245
245
  class UserEnv:
@@ -23,6 +23,7 @@ from json.decoder import JSONDecodeError
23
23
  from teradataml import configure
24
24
  from teradataml.context.context import _get_user, get_connection
25
25
  from teradataml.common.constants import HTTPRequest, AsyncStatusColumns
26
+ from teradataml.common.deprecations import argument_deprecation
26
27
  from teradataml.common.exceptions import TeradataMlException
27
28
  from teradataml.common.messages import Messages
28
29
  from teradataml.common.messagecodes import MessageCodes
@@ -40,7 +41,6 @@ from urllib.parse import parse_qs, urlparse
40
41
  from teradataml.utils.utils import _async_run_id_info
41
42
  from teradataml.telemetry_utils.queryband import collect_queryband
42
43
 
43
-
44
44
  @collect_queryband(queryband="LstBsEnv")
45
45
  def list_base_envs():
46
46
  """
@@ -74,6 +74,11 @@ def list_base_envs():
74
74
  5 r_4.0.2 R 4.0.2
75
75
  >>>
76
76
  """
77
+ # Check if the cache data is available and is not stale.
78
+ # If available, return the data.
79
+ if _InternalBuffer.get('list_base_envs') is not None:
80
+ return _InternalBuffer.get('list_base_envs')
81
+
77
82
  try:
78
83
  response = UtilFuncs._http_request(_get_ues_url("base_environments"), headers=_get_auth_token())
79
84
 
@@ -86,7 +91,8 @@ def list_base_envs():
86
91
  return
87
92
 
88
93
  # Create a pandas DataFrame from data.
89
- return pd.DataFrame.from_records(data)
94
+ _InternalBuffer.add(list_base_envs=pd.DataFrame.from_records(data))
95
+ return _InternalBuffer.get('list_base_envs')
90
96
 
91
97
  except (TeradataMlException, RuntimeError):
92
98
  raise
@@ -417,31 +423,37 @@ def __create_envs(template):
417
423
  # Install files if requested any.
418
424
  if files:
419
425
  print("Installing files in environment '{}'...".format(env_name))
420
- try:
421
- if isinstance(files, str):
422
- files = [files]
426
+ if isinstance(files, str):
427
+ files = [files]
423
428
 
424
- for file in files:
429
+ for file in files:
430
+ try:
425
431
  if os.path.isfile(file):
426
432
  env_handle.install_file(file)
427
433
  elif os.path.isdir(file):
428
- __install_files(env_handle, file)
429
- print("File installation in environment '{}' - Completed.".format(env_name))
430
- except Exception as file_installation_failure:
431
- print("Failed to process file installation request for environment: '{}'".format(env_name))
432
- print(str(file_installation_failure))
433
- errored = errored or True
434
- pass
434
+ errored = __install_files(env_handle, file)
435
+ except Exception as file_installation_failure:
436
+ print("Failed to install file '{}' in environment '{}'.".format(file, env_name))
437
+ print(str(file_installation_failure))
438
+ errored = True
439
+ pass
435
440
 
436
441
  # Install libraries if requested any.
437
442
  if libs or libs_file_path:
438
443
  print("Installing libraries in environment '{}'...".format(env_name))
439
444
  try:
440
- env_handle.install_lib(libs, libs_file_path)
441
- print("Libraries installation in environment '{}' - Completed.".format(env_name))
445
+ status = env_handle.install_lib(libs, libs_file_path)
446
+ if status['Stage'][1] == 'Errored':
447
+ err_message = status['Additional Details'][1].replace("Error with package maintenance -> ", "\n")
448
+ raise Exception(err_message)
449
+ else:
450
+ print("Libraries installation in environment '{}' - Completed.".format(env_name))
442
451
  except Exception as lib_installation_failure:
443
- print("Failed to process library installation request for environment: '{}'".format(env_name))
444
- print(str(lib_installation_failure))
452
+ error_code = MessageCodes.FUNC_EXECUTION_FAILED
453
+ error_msg = Messages.get_message(error_code,
454
+ "'install_lib' request for enviornment: '{}'".format(env_name),
455
+ '\n'+str(lib_installation_failure))
456
+ print(error_msg)
445
457
  errored = errored or True
446
458
  pass
447
459
 
@@ -465,6 +477,10 @@ def __get_default_base_env():
465
477
  Function returns the latest python environment available with
466
478
  Open Analytics Framework.
467
479
  """
480
+ # Check if the default base environment is already available.
481
+ if _InternalBuffer.get('default_base_env') is not None:
482
+ return _InternalBuffer.get('default_base_env')
483
+
468
484
  try:
469
485
  base_envs = list_base_envs()
470
486
  python_versions = base_envs[base_envs.language == 'Python']['version']
@@ -474,7 +490,9 @@ def __get_default_base_env():
474
490
  latest_version_tuple = max(version_tuples)
475
491
  # Convert the latest version tuple back to a string
476
492
  latest_version = '.'.join(map(str, latest_version_tuple))
477
- return base_envs[base_envs.version == latest_version]['base_name'].to_list()[0]
493
+ # Get the base environment name for the latest version
494
+ _InternalBuffer.add(default_base_env=base_envs[base_envs.version == latest_version]['base_name'].to_list()[0])
495
+ return _InternalBuffer.get('default_base_env')
478
496
  except Exception as base_env_err:
479
497
  raise Exception("Failed to obtain default base environment.", str(base_env_err.exception))
480
498
 
@@ -484,9 +502,20 @@ def __install_files(env, directory):
484
502
  Function to install files under given directory and
485
503
  all the subdirectories recursively.
486
504
  """
505
+ errored = False
487
506
  for (dir_path, dir_names, file_names) in os.walk(directory):
507
+ # install the files under all the directories.
508
+ # If any problem with any file installation, skip the error
509
+ # and proceed to install other files.
488
510
  for file_name in file_names:
489
- env.install_file(os.path.join(dir_path, file_name))
511
+ try:
512
+ env.install_file(os.path.join(dir_path, file_name))
513
+ except Exception as file_installation_failure:
514
+ print("Failed to install file '{}' in environment '{}'.".format(file_name, env.env_name))
515
+ print(str(file_installation_failure))
516
+ errored = True
517
+
518
+ return errored
490
519
 
491
520
 
492
521
  @collect_queryband(queryband="CrtEnv")
@@ -741,10 +770,30 @@ def create_env(env_name=None, base_env=None, desc=None, template=None, conda_env
741
770
  # Validate arguments
742
771
  _Validators._validate_function_arguments(__arg_info_matrix, skip_empty_check=False)
743
772
 
744
- # Get the latest python base env in OpenAF, if base_env is not provided.
773
+ # Get the latest python base env in OpenAF, if base_env is not provided,
774
+ # Or if base_env is provided and not in the list of base envs.
745
775
  # Note: By default python base env is obtained.
746
- if not base_env:
747
- base_env = __get_default_base_env()
776
+ if configure.ues_url is not None and \
777
+ get_connection() is not None:
778
+ # Check if base_env is provided or not in the list of base envs.
779
+
780
+ # Check if user requested for conda environment but do not specify the base_env.
781
+ # In such case, set base_env to the default python base environment.
782
+ if conda_env:
783
+ if base_env is None:
784
+ base_env = __get_default_base_env()
785
+ # Not a conda environment.
786
+ else:
787
+ # Check if base_env provided or not. If provided, check if it is available in
788
+ # the list of base envs. If not available, set base_env to the default python base env.
789
+ if not base_env or \
790
+ base_env.lower() not in list_base_envs()['base_name'].str.lower().to_list():
791
+ # Print warning message if base_env provided is not available.
792
+ if base_env:
793
+ print(f"Note: The specified base environment '{base_env}' is unavailable. "\
794
+ "Using the default base environment as specified in the documentation.")
795
+ # Set base_env to the default
796
+ base_env = __get_default_base_env()
748
797
  if not desc:
749
798
  desc = "This env '{}' is created with base env '{}'.".format(env_name, base_env)
750
799
  try:
@@ -1550,7 +1599,7 @@ def get_user_env():
1550
1599
 
1551
1600
 
1552
1601
  @collect_queryband(queryband="StAthTkn")
1553
- def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwargs):
1602
+ def set_auth_token(base_url=None, client_id=None, pat_token=None, pem_file=None, **kwargs):
1554
1603
  """
1555
1604
  DESCRIPTION:
1556
1605
  Function to set the Authentication token to connect to User Environment Service
@@ -1558,14 +1607,14 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1558
1607
  Note:
1559
1608
  User must have a privilege to login with a NULL password to use set_auth_token().
1560
1609
  Please refer to GRANT LOGON section in Teradata Documentation for more details.
1561
- If ues_url and client_id are specified then authentication is through OAuth.
1562
- If ues_url, pat_token, pem_file are specified then authentication is through PAT.
1610
+ If base_url and client_id are specified then authentication is through OAuth.
1611
+ If base_url, pat_token, pem_file are specified then authentication is through PAT.
1563
1612
  Refresh token still works but only for OAuth authentication.
1564
1613
 
1565
1614
  PARAMETERS:
1566
- ues_url:
1615
+ base_url:
1567
1616
  Required Argument.
1568
- Specifies the URL for User Environment Service in VantageCloud Lake.
1617
+ Specifies the CCP endpoint URL.
1569
1618
  Types: str
1570
1619
 
1571
1620
  client_id:
@@ -1601,6 +1650,16 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1601
1650
  Default Value: 31536000
1602
1651
  Types: int
1603
1652
 
1653
+ auth_token:
1654
+ Optional Parameter.
1655
+ Specifies the authentication token to connect to VantageCloud Lake.
1656
+ Notes:
1657
+ * if "auth_token" is set through this function, then this function
1658
+ should always be used only after create_context.
1659
+ * use this option only if user has got JWT token and wants to set the same
1660
+ instead of generating it again from this function.
1661
+ Types: str
1662
+
1604
1663
  RETURNS:
1605
1664
  True, if the operation is successful.
1606
1665
 
@@ -1611,16 +1670,16 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1611
1670
 
1612
1671
  # Example 1: Set the Authentication token using default client_id.
1613
1672
  >>> import getpass
1614
- >>> set_auth_token(ues_url=getpass.getpass("ues_url : "))
1673
+ >>> set_auth_token(base_url=getpass.getpass("ues_url : "))
1615
1674
 
1616
1675
  # Example 2: Set the Authentication token by specifying the client_id.
1617
- >>> set_auth_token(ues_url=getpass.getpass("ues_url : "),
1676
+ >>> set_auth_token(base_url=getpass.getpass("base_url : "),
1618
1677
  ... client_id=getpass.getpass("client_id : "))
1619
1678
 
1620
1679
  # Example 3: Set the Authentication token by specifying the "pem_file" and "pat_token"
1621
1680
  # without specifying "username".
1622
1681
  >>> import getpass
1623
- >>> set_auth_token(ues_url=getpass.getpass("ues_url : "),
1682
+ >>> set_auth_token(base_url=getpass.getpass("base_url : "),
1624
1683
  ... pat_token=getpass.getpass("pat_token : "),
1625
1684
  ... pem_file=getpass.getpass("pem_file : "))
1626
1685
  True
@@ -1628,7 +1687,7 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1628
1687
  # Example 4: Set the Authentication token by specifying the "pem_file" and "pat_token"
1629
1688
  # and "username".
1630
1689
  >>> import getpass
1631
- >>> set_auth_token(ues_url=getpass.getpass("ues_url : "),
1690
+ >>> set_auth_token(base_url=getpass.getpass("base_url : "),
1632
1691
  ... pat_token=getpass.getpass("pat_token : "),
1633
1692
  ... pem_file=getpass.getpass("pem_file : "))
1634
1693
  ... username = "alice")
@@ -1640,8 +1699,12 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1640
1699
  raise TeradataMlException(Messages.get_message(MessageCodes.INVALID_CONTEXT_CONNECTION),
1641
1700
  MessageCodes.INVALID_CONTEXT_CONNECTION)
1642
1701
 
1702
+ # Getting the ues_url.
1703
+ ues_url = kwargs.get("ues_url", None)
1704
+
1643
1705
  __arg_info_matrix = []
1644
- __arg_info_matrix.append(["ues_url", ues_url, False, (str), True])
1706
+ __arg_info_matrix.append(["base_url", base_url, True, (str), True])
1707
+ __arg_info_matrix.append(["ues_url", ues_url, True, (str), True])
1645
1708
  __arg_info_matrix.append(["client_id", client_id, True, (str), True])
1646
1709
  __arg_info_matrix.append(["pat_token", pat_token, True, (str), True])
1647
1710
  __arg_info_matrix.append(["pem_file", pem_file, True, (str), True])
@@ -1649,12 +1712,38 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1649
1712
  username = kwargs.get("username", None)
1650
1713
  __arg_info_matrix.append((["username", username, True, (str), True]))
1651
1714
 
1715
+ auth_token = kwargs.get("auth_token")
1716
+ __arg_info_matrix.append((["auth_token", auth_token, True, (str), True]))
1717
+
1652
1718
  expiration_time = kwargs.get("expiration_time", 31536000)
1653
1719
  __arg_info_matrix.append((["expiration_time", expiration_time, True, (int), True]))
1654
1720
 
1655
1721
  # Validate arguments.
1656
1722
  _Validators._validate_function_arguments(__arg_info_matrix)
1657
1723
 
1724
+ # base_url should not end with 'open-analytics' or 'data-insights'
1725
+ if base_url:
1726
+ if base_url.endswith('open-analytics') or base_url.endswith('data-insights'):
1727
+ message = Messages.get_message(MessageCodes.ARG_NONE,
1728
+ "base_url", "ending with 'data-insights' or 'open-analytics", None)
1729
+ raise TeradataMlException(message, MessageCodes.ARG_NONE)
1730
+
1731
+ # Set the vector_store_base_url. This should only be done if base_url is set.
1732
+ # In case ues_url is set, vector_store_base_url should not be set.
1733
+ configure._vector_store_base_url = f'{base_url}/data-insights'
1734
+
1735
+ # If ues_url is provided, then use it as base_url.
1736
+ base_url = kwargs.get("ues_url", base_url)
1737
+
1738
+ # Set the OpenAF url.
1739
+ # If ues_url is present use that otherwise generate it from base_url.
1740
+ configure.ues_url = ues_url if ues_url else f'{base_url}/open-analytics'
1741
+
1742
+ # If user pass Auth token, set it.
1743
+ if auth_token:
1744
+ _InternalBuffer.add(auth_token=_AuthToken(token=auth_token))
1745
+ return True
1746
+
1658
1747
  if client_id and any([pat_token, pem_file]):
1659
1748
  message = Messages.get_message(MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT,
1660
1749
  "client_id", "pat_token' and 'pem_file")
@@ -1670,16 +1759,16 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1670
1759
  if pem_file is not None:
1671
1760
  _Validators._validate_file_exists(pem_file)
1672
1761
 
1673
- # Extract the base URL from "ues_url".
1674
- url_parser = urlparse(ues_url)
1675
- base_url = "{}://{}".format(url_parser.scheme, url_parser.netloc)
1762
+ # Extract the base URL.
1763
+ url_parser = urlparse(base_url)
1764
+ parsed_base_url = "{}://{}".format(url_parser.scheme, url_parser.netloc)
1676
1765
  netloc = url_parser.netloc.split('.')[0]
1677
1766
 
1678
1767
  # Check if the authentication is PAT based or OAuth.
1679
1768
  if all(arg is None for arg in [pat_token, pem_file]):
1680
1769
  configure._oauth = True
1681
1770
  client_id = "{}-oaf-device".format(netloc) if client_id is None else client_id
1682
- da_wf = _DAWorkflow(base_url, client_id)
1771
+ da_wf = _DAWorkflow(parsed_base_url, client_id)
1683
1772
  token_data = da_wf._get_token_data()
1684
1773
 
1685
1774
  # Set Open AF parameters.
@@ -1702,7 +1791,7 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1702
1791
 
1703
1792
  # Construct a dictionary to be passed to _AuthWorkflow().
1704
1793
  state_dict = {}
1705
- state_dict["base_url"] = base_url
1794
+ state_dict["base_url"] = parsed_base_url
1706
1795
  state_dict["org_id"] = org_id
1707
1796
  state_dict["pat_token"] = pat_token
1708
1797
  state_dict["pem_file"] = pem_file
@@ -1713,8 +1802,9 @@ def set_auth_token(ues_url, client_id=None, pat_token=None, pem_file=None, **kwa
1713
1802
  token_data = auth_wf._proxy_jwt()
1714
1803
  # Store the jwt token in internal class attribute.
1715
1804
  _InternalBuffer.add(auth_token=_AuthToken(token=token_data))
1716
-
1717
- # Set Open AF parameters.
1718
- configure.ues_url = ues_url
1805
+ # If set_auth_token is triggered then it will be ccp_enabled = True.
1806
+ # The function returns if we have just passed the auth_token, thus
1807
+ # having ccp_enabled = False.
1808
+ configure._ccp_enabled = True
1719
1809
 
1720
1810
  return True
@@ -0,0 +1,12 @@
1
+ """
2
+ Copyright (c) 2024 by Teradata Corporation. All rights reserved.
3
+ TERADATA CORPORATION CONFIDENTIAL AND TRADE SECRET
4
+
5
+ Primary Owner: pradeep.garre@teradata.com
6
+ Secondary Owner: aanchal.kavedia@teradata.com
7
+
8
+ This file imports components from Feature Store and Vector Store.
9
+ """
10
+
11
+ from teradataml.store.feature_store.feature_store import FeatureStore
12
+ from teradataml.store.feature_store.models import *
File without changes