teradataml 20.0.0.4__py3-none-any.whl → 20.0.0.6__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 (131) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/README.md +182 -13
  3. teradataml/__init__.py +2 -1
  4. teradataml/_version.py +2 -2
  5. teradataml/analytics/analytic_function_executor.py +8 -13
  6. teradataml/analytics/json_parser/analytic_functions_argument.py +4 -0
  7. teradataml/analytics/sqle/__init__.py +16 -1
  8. teradataml/analytics/utils.py +60 -1
  9. teradataml/automl/__init__.py +290 -106
  10. teradataml/automl/autodataprep/__init__.py +471 -0
  11. teradataml/automl/data_preparation.py +29 -10
  12. teradataml/automl/data_transformation.py +11 -0
  13. teradataml/automl/feature_engineering.py +64 -4
  14. teradataml/automl/feature_exploration.py +639 -25
  15. teradataml/automl/model_training.py +1 -1
  16. teradataml/clients/auth_client.py +12 -8
  17. teradataml/clients/keycloak_client.py +165 -0
  18. teradataml/common/constants.py +71 -26
  19. teradataml/common/exceptions.py +32 -0
  20. teradataml/common/messagecodes.py +28 -0
  21. teradataml/common/messages.py +13 -4
  22. teradataml/common/sqlbundle.py +3 -2
  23. teradataml/common/utils.py +345 -45
  24. teradataml/context/context.py +259 -93
  25. teradataml/data/apriori_example.json +22 -0
  26. teradataml/data/docs/sqle/docs_17_20/Apriori.py +138 -0
  27. teradataml/data/docs/sqle/docs_17_20/NERExtractor.py +121 -0
  28. teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +3 -3
  29. teradataml/data/docs/sqle/docs_17_20/SMOTE.py +212 -0
  30. teradataml/data/docs/sqle/docs_17_20/TextMorph.py +119 -0
  31. teradataml/data/docs/sqle/docs_17_20/TextParser.py +54 -3
  32. teradataml/data/docs/uaf/docs_17_20/ACF.py +1 -1
  33. teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +2 -2
  34. teradataml/data/docs/uaf/docs_17_20/ArimaXEstimate.py +2 -2
  35. teradataml/data/docs/uaf/docs_17_20/DFFT.py +1 -1
  36. teradataml/data/docs/uaf/docs_17_20/DFFT2.py +1 -1
  37. teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +1 -1
  38. teradataml/data/docs/uaf/docs_17_20/DFFTConv.py +1 -1
  39. teradataml/data/docs/uaf/docs_17_20/FilterFactory1d.py +4 -4
  40. teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +2 -2
  41. teradataml/data/docs/uaf/docs_17_20/GoldfeldQuandt.py +2 -2
  42. teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +6 -6
  43. teradataml/data/docs/uaf/docs_17_20/LineSpec.py +1 -1
  44. teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +1 -1
  45. teradataml/data/docs/uaf/docs_17_20/Matrix2Image.py +4 -4
  46. teradataml/data/docs/uaf/docs_17_20/MultivarRegr.py +1 -1
  47. teradataml/data/docs/uaf/docs_17_20/PACF.py +1 -1
  48. teradataml/data/docs/uaf/docs_17_20/PowerSpec.py +2 -2
  49. teradataml/data/docs/uaf/docs_17_20/PowerTransform.py +3 -3
  50. teradataml/data/docs/uaf/docs_17_20/Resample.py +5 -5
  51. teradataml/data/docs/uaf/docs_17_20/SAX.py +3 -3
  52. teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +1 -1
  53. teradataml/data/docs/uaf/docs_17_20/SimpleExp.py +1 -1
  54. teradataml/data/docs/uaf/docs_17_20/Smoothma.py +3 -3
  55. teradataml/data/docs/uaf/docs_17_20/UNDIFF.py +1 -1
  56. teradataml/data/jsons/byom/onnxembeddings.json +1 -0
  57. teradataml/data/jsons/sqle/17.20/NGramSplitter.json +6 -6
  58. teradataml/data/jsons/sqle/17.20/TD_Apriori.json +181 -0
  59. teradataml/data/jsons/sqle/17.20/TD_NERExtractor.json +145 -0
  60. teradataml/data/jsons/sqle/17.20/TD_SMOTE.json +267 -0
  61. teradataml/data/jsons/sqle/17.20/TD_TextMorph.json +134 -0
  62. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +114 -9
  63. teradataml/data/jsons/sqle/20.00/AI_AnalyzeSentiment.json +328 -0
  64. teradataml/data/jsons/sqle/20.00/AI_AskLLM.json +420 -0
  65. teradataml/data/jsons/sqle/20.00/AI_DetectLanguage.json +343 -0
  66. teradataml/data/jsons/sqle/20.00/AI_ExtractKeyPhrases.json +328 -0
  67. teradataml/data/jsons/sqle/20.00/AI_MaskPII.json +328 -0
  68. teradataml/data/jsons/sqle/20.00/AI_RecognizeEntities.json +328 -0
  69. teradataml/data/jsons/sqle/20.00/AI_RecognizePIIEntities.json +328 -0
  70. teradataml/data/jsons/sqle/20.00/AI_TextClassifier.json +359 -0
  71. teradataml/data/jsons/sqle/20.00/AI_TextEmbeddings.json +360 -0
  72. teradataml/data/jsons/sqle/20.00/AI_TextSummarize.json +343 -0
  73. teradataml/data/jsons/sqle/20.00/AI_TextTranslate.json +343 -0
  74. teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +2 -2
  75. teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +1 -1
  76. teradataml/data/ner_dict.csv +8 -0
  77. teradataml/data/ner_input_eng.csv +7 -0
  78. teradataml/data/ner_rule.csv +5 -0
  79. teradataml/data/pattern_matching_data.csv +11 -0
  80. teradataml/data/pos_input.csv +40 -0
  81. teradataml/data/sdk/modelops/modelops_spec.json +101737 -0
  82. teradataml/data/tdnerextractor_example.json +14 -0
  83. teradataml/data/teradataml_example.json +21 -1
  84. teradataml/data/textmorph_example.json +5 -0
  85. teradataml/data/to_num_data.csv +4 -0
  86. teradataml/data/tochar_data.csv +5 -0
  87. teradataml/data/trans_dense.csv +16 -0
  88. teradataml/data/trans_sparse.csv +55 -0
  89. teradataml/data/url_data.csv +10 -9
  90. teradataml/dataframe/copy_to.py +38 -27
  91. teradataml/dataframe/data_transfer.py +61 -45
  92. teradataml/dataframe/dataframe.py +1110 -132
  93. teradataml/dataframe/dataframe_utils.py +73 -27
  94. teradataml/dataframe/functions.py +1070 -9
  95. teradataml/dataframe/sql.py +750 -959
  96. teradataml/dbutils/dbutils.py +33 -13
  97. teradataml/dbutils/filemgr.py +14 -10
  98. teradataml/hyperparameter_tuner/utils.py +4 -2
  99. teradataml/lib/aed_0_1.dll +0 -0
  100. teradataml/opensource/_base.py +12 -157
  101. teradataml/options/configure.py +24 -9
  102. teradataml/scriptmgmt/UserEnv.py +317 -39
  103. teradataml/scriptmgmt/lls_utils.py +456 -135
  104. teradataml/sdk/README.md +79 -0
  105. teradataml/sdk/__init__.py +4 -0
  106. teradataml/sdk/_auth_modes.py +422 -0
  107. teradataml/sdk/_func_params.py +487 -0
  108. teradataml/sdk/_json_parser.py +453 -0
  109. teradataml/sdk/_openapi_spec_constants.py +249 -0
  110. teradataml/sdk/_utils.py +236 -0
  111. teradataml/sdk/api_client.py +897 -0
  112. teradataml/sdk/constants.py +62 -0
  113. teradataml/sdk/modelops/__init__.py +98 -0
  114. teradataml/sdk/modelops/_client.py +406 -0
  115. teradataml/sdk/modelops/_constants.py +304 -0
  116. teradataml/sdk/modelops/models.py +2308 -0
  117. teradataml/sdk/spinner.py +107 -0
  118. teradataml/store/__init__.py +1 -1
  119. teradataml/table_operators/Apply.py +16 -1
  120. teradataml/table_operators/Script.py +20 -1
  121. teradataml/table_operators/query_generator.py +4 -21
  122. teradataml/table_operators/table_operator_util.py +58 -9
  123. teradataml/utils/dtypes.py +4 -2
  124. teradataml/utils/internal_buffer.py +22 -2
  125. teradataml/utils/utils.py +0 -1
  126. teradataml/utils/validators.py +318 -58
  127. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/METADATA +188 -14
  128. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/RECORD +131 -84
  129. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/WHEEL +0 -0
  130. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/top_level.txt +0 -0
  131. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/zip-safe +0 -0
@@ -0,0 +1,453 @@
1
+ # ################################################################################################
2
+ #
3
+ # Copyright 2025 Teradata. All rights reserved.
4
+ # TERADATA CONFIDENTIAL AND TRADE SECRET
5
+ #
6
+ # Primary Owner: Adithya Avvaru (adithya.avvaru@teradata.com)
7
+ # Secondary Owner: Pankaj Purandare (pankajvinod.purandare@teradata.com)
8
+ #
9
+ # Version: 1.0
10
+ # SDK Version: 1.0
11
+ #
12
+ # This file contains the _SdkJsonParser class which is used to parse the OpenAPI specification
13
+ # JSON file and populate the required properties to be accessed later during dynamic class and
14
+ # method generation.
15
+ # The class also exposes some properties to be used by the SDK - openapi_version,
16
+ # openapi_description, openapi_title, sdk_version, contact_details.
17
+ #
18
+ # ################################################################################################
19
+
20
+ import logging
21
+ import re
22
+
23
+ from teradataml.common.utils import UtilFuncs
24
+
25
+ from ._func_params import _SDKParam
26
+ from ._openapi_spec_constants import ContactObject as co
27
+ from ._openapi_spec_constants import DefaultConstants as dc
28
+ from ._openapi_spec_constants import InfoObject as ioo
29
+ from ._openapi_spec_constants import OpenAPIObject as oapi
30
+ from ._openapi_spec_constants import OperationObject as oo
31
+ from ._openapi_spec_constants import ParameterObject as po
32
+ from ._openapi_spec_constants import RequestBodyObject as rbo
33
+ from ._openapi_spec_constants import SchemaObject as so
34
+ from ._openapi_spec_constants import TagObject as to
35
+ from ._utils import (_camel_case, _camel_to_snake, _read_openapi_spec,
36
+ _remove_duplicate_preserve_order)
37
+ from .constants import ParameterTypes as pt
38
+
39
+ _logger = logging.getLogger(__name__)
40
+
41
+ class _SdkJsonParser:
42
+
43
+ def __init__(self, openapi_spec_path, current_module, debug=False):
44
+ self._openapi_spec = _read_openapi_spec(openapi_spec_path)
45
+ self._current_module = current_module # Current module where the SDK needsto be generated.
46
+
47
+ self._tag_names = [] # List of all tag names
48
+ self._class_names = [] # List of all class names
49
+ self._tag_description_dict = {} # Dict of tag name to tag description
50
+ self._class_name_dict = {} # Dict of tag name to class name
51
+ self._debug = debug # Debug flag
52
+
53
+ self._missing_information = {} # List of missing information in the OpenAPI spec
54
+ self._missing_information["tags"] = []
55
+ self._missing_information["paths"] = []
56
+
57
+ self._class_name_to_function_dict = {} # Dict of class name to function information.
58
+ self._parse_tags()
59
+ self._parse_paths()
60
+
61
+ def _openapi_version(self):
62
+ """
63
+ Returns the OpenAPI version from the spec.
64
+ """
65
+ return self._openapi_spec.get(oapi.OPENAPI.value)
66
+
67
+ def _openapi_description(self):
68
+ """
69
+ Returns the OpenAPI description from the spec.
70
+ """
71
+ return self._openapi_spec.get(oapi.INFO.value, {}).get(ioo.DESCRIPTION.value, None)
72
+
73
+ def _openapi_title(self):
74
+ """
75
+ Returns the OpenAPI title from the spec.
76
+ """
77
+ return self._openapi_spec.get(oapi.INFO.value, {}).get(ioo.TITLE.value)
78
+
79
+ def _sdk_version(self):
80
+ """
81
+ Returns the SDK version from the OpenAPI spec.
82
+ """
83
+ return self._openapi_spec.get(oapi.INFO.value, {}).get(ioo.VERSION.value)
84
+
85
+ def _contact_details(self):
86
+ """
87
+ Returns contact details of the OpenAPI spec Owners.
88
+ """
89
+ return self._openapi_spec.get(oapi.INFO.value, {}).get(ioo.CONTACT.value, {})
90
+
91
+ def _parse_tags(self):
92
+ """
93
+ Parses the OpenAPI spec to create dictionaries for tag descriptions and class names.
94
+
95
+ """
96
+ _tags = self._openapi_spec.get(oapi.TAGS.value, None)
97
+ if _tags is None:
98
+ return
99
+ for tag in _tags:
100
+ tag_name = tag.get(to.NAME.value)
101
+
102
+ if tag_name:
103
+ self._tag_names.append(tag_name)
104
+ _tag_description = tag.get(to.DESCRIPTION.value)
105
+ if _tag_description is None:
106
+ _tag_description = dc.DEFAULT_DESCRIPTION.value
107
+ self._missing_information["tags"].append(tag_name)
108
+ self._tag_description_dict[tag_name] = _tag_description
109
+
110
+ class_name = _camel_case(tag_name)
111
+ self._class_names.append(class_name)
112
+ self._class_name_dict[tag_name] = class_name
113
+
114
+ self._class_name_to_function_dict[class_name] = []
115
+
116
+ def _process_request_body(self, body, path, method, operation_id):
117
+ """
118
+ Processes the request body from the OpenAPI spec.
119
+ """
120
+ arg_list = []
121
+ param_arg_docstrings = []
122
+ body_params_dict = {}
123
+ arg_info_matrix_dict = {}
124
+
125
+ misssing_description = []
126
+
127
+ if body is not None:
128
+ body_obj = _SDKParam(path=path, method=method, operation_id=operation_id,
129
+ current_module=self._current_module, parameter=body,
130
+ param_type=pt.BODY, debug=self._debug)
131
+
132
+ body_params_dict[body_obj._old_name] = body_obj._new_name
133
+
134
+ if body_obj._missing_description:
135
+ # We are saving missing argument description to CSV files to share it to team which
136
+ # developed OpenAPI spec so that they can fix the missing information
137
+ # in the OpenAPI spec.
138
+ misssing_description.append(body_obj._missing_description)
139
+
140
+ _docstr_lines = [body_obj._docstr_arg_details, body_obj._docstr_desc,
141
+ body_obj._docstr_perm_types, body_obj._docstr_perm_values]
142
+ param_arg_docstrings.append(_docstr_lines)
143
+
144
+ arg_info_matrix_dict[body_obj._new_name] = body_obj
145
+
146
+ # arg_list.append(self.__get_param_arg_signature(p_name=body_param_name,
147
+ # p_type=schema_type,
148
+ # p_required=b_required,
149
+ # p_default="None"))
150
+
151
+ return {"doc_strings": param_arg_docstrings, "arg_signature": arg_list,
152
+ "body_params_dict": body_params_dict, "arg_info_matrix_dict": arg_info_matrix_dict,
153
+ "missing_description": misssing_description}
154
+
155
+ def _process_parameters(self, parameters, path, method, operation_id):
156
+ """
157
+ Processes the parameters from the OpenAPI spec.
158
+ """
159
+ arg_list = []
160
+ param_arg_docstrings = []
161
+ path_params_dict = {} # Dictionary of old to new path params.
162
+ query_params_dict = {} # Dictionary of old to new query params.
163
+ arg_info_matrix_dict = {} # Dictionary of new argument to _SDKParam objects.
164
+ missing_description = []
165
+
166
+ if parameters is not None:
167
+ for param in parameters:
168
+ param_obj = _SDKParam(path=path, method=method, operation_id=operation_id,
169
+ current_module=self._current_module, parameter=param,
170
+ param_type=pt.PARAM, debug=self._debug)
171
+
172
+ if param_obj._missing_description:
173
+ # We are saving missing argument description to CSV files to share it to team
174
+ # which developed OpenAPI spec so that they can fix the missing information
175
+ # in the OpenAPI spec.
176
+ missing_description.append(param_obj._old_name)
177
+
178
+ param_obj._update_params_dict(path_params_dict=path_params_dict,
179
+ query_params_dict=query_params_dict)
180
+
181
+ _docstr_lines = [param_obj._docstr_arg_details, param_obj._docstr_desc,
182
+ param_obj._docstr_perm_types, param_obj._docstr_perm_values]
183
+ param_arg_docstrings.append(_docstr_lines)
184
+
185
+ arg_info_matrix_dict[param_obj._new_name] = param_obj
186
+
187
+ # arg_list.append(self.__get_param_arg_signature(p_name=p_name,
188
+ # p_type=p_types,
189
+ # p_required=p_required,
190
+ # p_default=p_default))
191
+
192
+ # `projection` argument is present in some endpoints, not in others.
193
+ # ModelOps team says that it is used when the path contains `/search`.
194
+ # For more info, read through comments in
195
+ # https://teradata-pe.atlassian.net/browse/VMO-1821
196
+
197
+ # `projection` argument is also used by `get` endpoints of format `/api/<func_name>/{id}`.
198
+ # Hence adding `projection` argument for those endpoints as well.
199
+
200
+ if ("/search" in path and "projection" not in query_params_dict.keys()) or \
201
+ (re.search(pattern="^/api/[a-zA-Z]+/\{id\}$", string=path) is not None and method == "get"):
202
+ # TODO: Confirm with ModelOps team.
203
+ # There is "projection" parameter in query params for some endpoints
204
+ # but missing in some other endpoints.
205
+ # Need to confirm with ModelOps team if this "projection" parameter is same as
206
+ # excerpt projection.
207
+ # "projection" related issues will be fixed in JSON spec by modelOps team as per
208
+ # https://teradata-pe.atlassian.net/browse/VMO-1821.
209
+ # Currently, adding for only those endpoints which don't have "projection" in query params.
210
+
211
+ proj_obj = _SDKParam(path=path, method=method, operation_id=operation_id,
212
+ current_module=self._current_module, param_type=pt.PROJECTION,
213
+ debug=self._debug)
214
+
215
+ if proj_obj._missing_description:
216
+ # We are saving missing argument description to CSV files to share it to team which
217
+ # developed OpenAPI spec so that they can fix the missing information
218
+ # in the OpenAPI spec.
219
+ missing_description.append(proj_obj._old_name)
220
+
221
+ proj_obj._update_params_dict(path_params_dict=path_params_dict,
222
+ query_params_dict=query_params_dict)
223
+
224
+ _docstr_lines = [proj_obj._docstr_arg_details, proj_obj._docstr_desc,
225
+ proj_obj._docstr_perm_types, proj_obj._docstr_perm_values]
226
+ param_arg_docstrings.append(_docstr_lines)
227
+
228
+ arg_info_matrix_dict[proj_obj._new_name] = proj_obj
229
+ # arg_list.append(self.__get_param_arg_signature(p_name=proj_obj._new_name,
230
+ # p_type=proj_obj._param_type,
231
+ # p_required=proj_obj._required,
232
+ # p_default=proj_obj._default))
233
+
234
+ return {"doc_strings": param_arg_docstrings, "arg_signature": arg_list,
235
+ "path_params_dict": path_params_dict, "query_params_dict": query_params_dict,
236
+ "arg_info_matrix_dict": arg_info_matrix_dict,
237
+ "missing_description": missing_description}
238
+
239
+ def _process_responses(self, responses:dict, path:str, method:str, operation_id:str):
240
+ """
241
+ Processes the responses from the OpenAPI spec.
242
+ """
243
+ _all_return_types = []
244
+ _all_code_docstrings = []
245
+ _all_header_values = []
246
+
247
+ for resp_code, response in responses.items():
248
+ resp_obj = _SDKParam(path=path, method=method, operation_id=operation_id,
249
+ current_module=self._current_module,
250
+ parameter=(resp_code, response),
251
+ param_type=pt.RESPONSE, debug=self._debug)
252
+
253
+ _all_header_values.extend(resp_obj._header_values)
254
+ if resp_obj._response_docstr:
255
+ _all_code_docstrings.append(resp_obj._response_docstr)
256
+ if resp_obj._return_types is not None:
257
+ _all_return_types.extend(resp_obj._return_types)
258
+
259
+ return {"response_docstrings": _all_code_docstrings,
260
+ "return_types": _remove_duplicate_preserve_order(_all_return_types),
261
+ "header_values": _remove_duplicate_preserve_order(_all_header_values)}
262
+
263
+ def _process_security(self, security):
264
+ """
265
+ Processes the security details from the OpenAPI spec.
266
+ """
267
+ if security is None:
268
+ return None
269
+ return "SECURITY"
270
+
271
+ def _process_function(self, function_details, path, method):
272
+ """
273
+ Processes a function from the OpenAPI spec to create a method.
274
+ """
275
+ ret_func_details = {}
276
+
277
+ _missing_info = {}
278
+ _missing_info["path"] = path
279
+ _missing_info["method"] = method
280
+ _missing_info["operation_id"] = function_details.get(oo.OPERATION_ID.value)
281
+ _missing_info["missing_arg_descriptions"] = None # Default - all arg descriptions exist.
282
+
283
+
284
+ _func_description = function_details.get(oo.DESCRIPTION.value) or \
285
+ function_details.get(oo.SUMMARY.value)
286
+ _missing_info["missing_func_description"] = "NO" # Default - Function description exists.
287
+ if _func_description is None:
288
+ _func_description = dc.DEFAULT_DESCRIPTION.value
289
+ _missing_info["missing_func_description"] = "YES" # Function description missing.
290
+
291
+ _operation_id = function_details.get(oo.OPERATION_ID.value)
292
+ ret_func_details["func_description"] = _func_description
293
+ ret_func_details["operation_id"] = _operation_id
294
+ ret_func_details["func_name"] = _camel_to_snake(_operation_id.replace("-", '_'))
295
+
296
+ request_body_dict = self._process_request_body(body=function_details.get(oo.REQUEST_BODY.value),
297
+ path=path,
298
+ method=method,
299
+ operation_id=_operation_id)
300
+ body_arg_descriptions = request_body_dict["doc_strings"]
301
+ body_arg_signature = request_body_dict["arg_signature"]
302
+ body_arg_info_matrix_dict = request_body_dict["arg_info_matrix_dict"]
303
+ ret_func_details["body_params_dict"] = request_body_dict["body_params_dict"]
304
+
305
+ parameter_dict = self._process_parameters(parameters=function_details.get(oo.PARAMETERS.value),
306
+ path=path,
307
+ method=method,
308
+ operation_id=_operation_id)
309
+
310
+ _missing_info["missing_arg_descriptions"] = ",".join(request_body_dict["missing_description"] + \
311
+ parameter_dict["missing_description"])
312
+
313
+ params_arg_descriptions = body_arg_descriptions + parameter_dict["doc_strings"]
314
+ ret_func_details["arg_signature"] = body_arg_signature + parameter_dict["arg_signature"]
315
+ ret_func_details["path_params_dict"] = parameter_dict["path_params_dict"]
316
+ ret_func_details["query_params_dict"] = parameter_dict["query_params_dict"]
317
+ ret_func_details["arg_info_matrix_dict"] = {**parameter_dict["arg_info_matrix_dict"],
318
+ **body_arg_info_matrix_dict}
319
+
320
+ response_dict = self._process_responses(responses=function_details.get(oo.RESPONSES.value),
321
+ path=path,
322
+ method=method,
323
+ operation_id=_operation_id)
324
+ ret_func_details["return_types"] = response_dict["return_types"]
325
+ ret_func_details["header_values"] = response_dict["header_values"]
326
+
327
+ ret_func_details["required_security"] = self._process_security(function_details.get(oo.SECURITY.value))
328
+
329
+
330
+ _doc_string = self._build_docstring(params_arg_descriptions=params_arg_descriptions,
331
+ response_docstrings=response_dict["response_docstrings"])
332
+
333
+ if self._debug:
334
+ print(f"\nPath: {path}, Method: {method}, "\
335
+ f"OperationID: {ret_func_details['operation_id']}, "\
336
+ f"function name: {ret_func_details['func_name']}")
337
+ print("request body dict: \n", request_body_dict)
338
+ print("parameter dict: \n", parameter_dict)
339
+ print(f"Doc string: \n{_doc_string}\n\n")
340
+
341
+ # TODO: Add response details to doc string.
342
+ ret_func_details["doc_string"] = _doc_string
343
+
344
+ self._missing_information["paths"].append(_missing_info)
345
+
346
+ return ret_func_details
347
+
348
+ def _build_docstring(self, params_arg_descriptions, response_docstrings=None):
349
+ _doc_string = (
350
+ " DESCRIPTION: \n"
351
+ " The function '{function_name}' does the following: \n"
352
+ " - {description}\n\n"
353
+ )
354
+
355
+ # Parameters section.
356
+ _comma_with_tab = "\t "
357
+ _doc_string += " PARAMETERS:\n"
358
+ if params_arg_descriptions:
359
+ for param in params_arg_descriptions:
360
+ _doc_string_1 = " " + param[0] + "\n"
361
+ _doc_string_2 = f"{_comma_with_tab}{param[1]}\n"
362
+ _doc_string += _doc_string_1 + _doc_string_2
363
+
364
+ if param[3] is not None:
365
+ # Permitted values can be None i.e., no permitted values.
366
+ _doc_string += f"{_comma_with_tab}{param[3]}\n"
367
+
368
+ _doc_string += f"{_comma_with_tab}{param[2]}\n\n" # permitted types
369
+ else:
370
+ _doc_string += " None\n\n"
371
+
372
+ if params_arg_descriptions:
373
+ # Add another argument `return_dict` to the docstring, if parameters exist.
374
+ _doc_string += " return_dict (Optional):\n"
375
+ _doc_string += f"{_comma_with_tab}Specifies whether to return dict. When set to" \
376
+ f" False, schema class objects are returned. Otherwise, the function" \
377
+ f" returns dict.\n{_comma_with_tab}If the API in the backend does not return" \
378
+ " schema object, the function returns the output as it is returned by backend, "\
379
+ "irrespective of this argument's value.\n"
380
+ _doc_string += f"{_comma_with_tab}Default Value: False\n"
381
+ _doc_string += f"{_comma_with_tab}Types: bool\n\n"
382
+
383
+ # Returns section.
384
+ _doc_string += " RETURNS:\n"
385
+ for resp_doc in response_docstrings:
386
+ _doc_string += " - " + resp_doc + "\n"
387
+ _doc_string += "\n"
388
+
389
+
390
+ # Raises section.
391
+ _doc_string += " RAISES:\n"
392
+ _doc_string += " - requests.exceptions.HTTPError\n"
393
+ _doc_string += " - teradataml.common.exceptions.TeradatamlException\n"
394
+ _doc_string += " - teradataml.common.exceptions.TeradatamlRestException\n\n"
395
+
396
+ # Examples section.
397
+ _doc_string += " EXAMPLES:\n"
398
+ _doc_string += (
399
+ " # Instantiate client object. It can be specific client for SDK. Using `Client` now.\n"
400
+ " >>> from teradataml.sdk import Client # For, modelops SDK, use `teradataml.sdk.modelops.ModelOpsClient`.\n"
401
+ " >>> client = Client(...) # Run `help(Client)` or `help(ModelOpsClient)` for supported arguments.\n\n"
402
+ " # Instantiate SDK class '{class_name}' from module '{module_name}'.\n"
403
+ " >>> from {module_name} import {class_name}\n"
404
+ " >>> obj = {class_name}(client=client)\n"
405
+ " >>> obj.{function_name}(...)\n\n"
406
+ )
407
+
408
+ return _doc_string
409
+
410
+ def _print_classes(self, module_name, sdk_name):
411
+ """
412
+ Print available classes for the SDK.
413
+ """
414
+ parent_module = module_name.__name__
415
+
416
+ print("----------------------------------------------------------------")
417
+ print(f"Available classes for {sdk_name} SDK:")
418
+ for _class_name in self._class_names:
419
+ print(f" * {parent_module}.{_class_name}")
420
+ print("----------------------------------------------------------------")
421
+
422
+ def _parse_paths(self):
423
+ """
424
+ Parses the OpenAPI spec to create dictionaries for path details.
425
+ """
426
+ paths = self._openapi_spec[oapi.PATHS.value]
427
+
428
+ _is_empty_tag = False
429
+
430
+ # Create classes and attach methods
431
+ for path, methods in paths.items():
432
+ for method, details in methods.items():
433
+ tags_ = details.get(oo.TAGS.value, [dc.DEFAULT_TAG.value])
434
+ if tags_[0] == dc.DEFAULT_TAG.value and not _is_empty_tag:
435
+ _is_empty_tag = True
436
+ class_name = dc.DEFAULT_CLASS.value
437
+ self._tag_names.append(tags_[0])
438
+ self._tag_description_dict[tags_[0]] = dc.DEFAULT_TAG_DESC.value
439
+
440
+ self._class_names.append(class_name)
441
+ self._class_name_dict[dc.DEFAULT_TAG.value] = class_name
442
+ self._class_name_to_function_dict[class_name] = []
443
+
444
+
445
+ processed_func_details = self._process_function(details, path, method)
446
+ processed_func_details["path"] = path
447
+ processed_func_details["method"] = method
448
+
449
+ for tag_ in tags_:
450
+ class_name = self._class_name_dict[tag_]
451
+
452
+ self._class_name_to_function_dict[class_name].append(
453
+ (details, processed_func_details))