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,62 @@
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
+ # ModelOps SDK Version: 1.0
11
+ #
12
+ # This file contains the constants needed for SDK.
13
+ #
14
+ # ################################################################################################
15
+
16
+ import os
17
+ from enum import Enum
18
+
19
+ from teradataml import _TDML_DIRECTORY
20
+
21
+
22
+ class SdkPackagePaths(Enum):
23
+ """
24
+ This class contains enums holding paths to json file for each SDK.
25
+ Note:
26
+ Developers should add paths to json files and use it in corresponding __init__.py file/
27
+ """
28
+ MODELOPS = os.path.join(_TDML_DIRECTORY, "data", "sdk", "modelops", "modelops_spec.json")
29
+
30
+ class SdkNames(Enum):
31
+ """
32
+ This class contains enums holding names of SDKs.
33
+ Note:
34
+ Developers should add names to SDKs and use it in corresponding __init__.py file/
35
+ """
36
+ MODELOPS = "ModelOps"
37
+
38
+ _OPENAPI_TO_PYTHON_PARAM_TYPE_MAPPER = {
39
+ "string": str,
40
+ "number": float,
41
+ "integer": int,
42
+ "boolean": bool,
43
+ "array": list,
44
+ "object": dict,
45
+ "null": type(None)
46
+ }
47
+
48
+ _REQUEST_FUNCTION_MAPPER = {
49
+ 'get': 'get_request',
50
+ 'post': 'post_request',
51
+ 'put': 'put_request',
52
+ 'patch': 'patch_request',
53
+ 'delete': 'delete_request'}
54
+
55
+ class ParameterTypes(Enum):
56
+ """
57
+ This class contains enum holding parameter types.
58
+ """
59
+ PARAM = "PARAM"
60
+ BODY = "BODY"
61
+ PROJECTION = "PROJECTION"
62
+ RESPONSE = "RESPONSE"
@@ -0,0 +1,98 @@
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
+ # ModelOps SDK Version: 1.0
11
+ #
12
+ # This file initializes the ModelOps SDK by reading the OpenAPI specification file and dynamically
13
+ # creating classes and methods based on the parsed JSON data. It also provides a mechanism to
14
+ # generate classes and methods for the SDK using the OpenAPI spec.
15
+ #
16
+ # ################################################################################################
17
+
18
+ import os
19
+ import sys
20
+
21
+ import pandas as pd
22
+
23
+ from teradataml.common.garbagecollector import GarbageCollector
24
+
25
+ from .._json_parser import _SdkJsonParser
26
+ from .._utils import _constructor, _create_methods
27
+ from ..constants import SdkNames, SdkPackagePaths
28
+ from . import _constants as module_constants
29
+ from . import models
30
+ from ._client import ModelOpsClient
31
+
32
+ _debug = False
33
+
34
+ __current_module = sys.modules[__name__]
35
+
36
+ def _generate_sdk(openapi_json_path):
37
+ """
38
+ Function takes path to OpenAPI spec json, creates dynamic classes and class modules.
39
+ It also returns object of _SdkJsonParser which contains the fields for processing.
40
+ """
41
+ _json_parser = _SdkJsonParser(openapi_spec_path=openapi_json_path,
42
+ current_module=__current_module,
43
+ debug=_debug)
44
+
45
+ for _tag_name, _class_name in _json_parser._class_name_dict.items():
46
+ _class_namespaces = {"__doc__": _json_parser._tag_description_dict[_tag_name],
47
+ "__init__": _constructor}
48
+ globals()[_class_name] = type(_class_name, (object,), _class_namespaces)
49
+
50
+ _create_methods(_json_parser, __current_module, debug=_debug)
51
+
52
+ return _json_parser
53
+
54
+ _json_parser = _generate_sdk(SdkPackagePaths.MODELOPS.value)
55
+
56
+ def _write_missing_information_to_csv():
57
+ """
58
+ This function is used to save the missing information about paths and tags to CSV files to
59
+ share it to team which developed OpenAPI spec so that they can fix the missing information
60
+ in the OpenAPI spec.
61
+ """
62
+ global _json_parser
63
+ missing_info = _json_parser._missing_information
64
+ temp_dir = GarbageCollector._get_temp_dir_name()
65
+ df = pd.DataFrame(missing_info["paths"])
66
+ file_path = os.path.join(temp_dir, 'missing_information_in_paths.csv') # Save as CSV instead of Excel
67
+ df.to_csv(file_path, index=False) # Write to CSV
68
+ print(f"Missing paths information written to {file_path}")
69
+
70
+ df = pd.DataFrame(missing_info["tags"], columns=["missing_tag_description"])
71
+ file_path = os.path.join(temp_dir, 'missing_description_for_tags.csv') # Save as CSV instead of Excel
72
+ df.to_csv(file_path, index=False) # Write to CSV
73
+ print(f"Missing tags description written to {file_path}")
74
+
75
+
76
+ def blueprint():
77
+ """
78
+ DESCRIPTION:
79
+ Prints the available classes for the ModelOps SDK.
80
+
81
+ PARAMETERS:
82
+ None
83
+
84
+ RETURNS:
85
+ None
86
+
87
+ RAISES:
88
+ None
89
+
90
+ EXAMPLES:
91
+ >>> blueprint()
92
+ ----------------------------------------------------------------
93
+ Available classes for ModelOps SDK:
94
+ * teradataml.sdk.modelops.ClassName1
95
+ * teradataml.sdk.modelops.ClassName2
96
+ ----------------------------------------------------------------
97
+ """
98
+ _json_parser._print_classes(__current_module, SdkNames.MODELOPS.value)
@@ -0,0 +1,406 @@
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 ModelOpsClient class for OpenAPI SDK
13
+ #
14
+ # ################################################################################################
15
+
16
+ import logging
17
+ import os
18
+ from typing import Dict, List, Optional, Union
19
+
20
+ from teradataml.common.garbagecollector import GarbageCollector
21
+ from teradataml.utils.validators import _Validators
22
+
23
+ from .._utils import _select_header_accept
24
+ from ..api_client import Client
25
+ from ..constants import SdkNames
26
+
27
+
28
+ class ModelOpsClient(Client):
29
+ DEFAULT_CONFIG_DIR = os.path.join(GarbageCollector._get_temp_dir_name(), "sdk", "modelops")
30
+ SDK_NAME = SdkNames.MODELOPS.value
31
+
32
+ def __init__(self, base_url=None, auth=None, ssl_verify=True, config_file=None, project_id=None):
33
+ """
34
+ DESCRIPTION:
35
+ Initializes the client object and sets up the configuration for the ModelOps client.
36
+
37
+ PARAMETERS:
38
+ base_url:
39
+ Optional Argument.
40
+ Specifies the base URL of API endpoint. All requests are made to a relative path to
41
+ this URL. It can be provided directly, or derived from the "BASE_URL" environment
42
+ variable or the YAML configuration variable "base_url". If not provided in any of
43
+ these 3 ways, appropriate Exception is raised.
44
+ Types: str or None
45
+
46
+ auth:
47
+ Optional Argument.
48
+ Specifies the type of authentication to be used. It can be one of the following
49
+ authentication type objects:
50
+ - ClientCredentialsAuth: For client credentials authentication.
51
+ - DeviceCodeAuth: For device code authentication.
52
+ - BearerAuth: For bearer token authentication.
53
+
54
+ Authentication mode is property of the auth object that is passed to this argument.
55
+ If this argument is not provided, authentication mode is derived from the
56
+ "BASE_API_AUTH_MODE" environment variable or the YAML configuration variable
57
+ "auth_mode". If this argument and the above 2 (environment variable and YAML
58
+ configuration variable) are not provided, appropriate Exception is raised.
59
+
60
+ For Authentication modes through environment variables without passing auth
61
+ argument and config file, the following environment variables are used:
62
+ - BASE_URL: Specifies the base URL of API endpoint.
63
+ - BASE_API_AUTH_MODE: Specifies the authentication mode. It can be one of the
64
+ following:
65
+ - "client_credentials": For client credentials authentication.
66
+ - "device_code": For device code authentication.
67
+ - "bearer": For bearer token authentication.
68
+ - BASE_SSL_VERIFY: Similar to 'ssl_verify' argument.
69
+ - BASE_API_AUTH_CLIENT_ID: OAuth2 client ID. Required for "client_credentials" and
70
+ "device_code" authentication modes.
71
+ - BASE_API_AUTH_CLIENT_SECRET: OAuth2 client secret. Required for "client_credentials"
72
+ and "device_code" authentication modes.
73
+ - BASE_API_AUTH_TOKEN_URL: OAuth2 token endpoint. Required for "client_credentials"
74
+ and "device_code" authentication modes.
75
+ - BASE_API_AUTH_DEVICE_AUTH_URL: OAuth2 device code endpoint. Required for
76
+ "device_code" authentication mode.
77
+ - BASE_API_AUTH_BEARER_TOKEN: The raw bearer token. Required for "bearer"
78
+ authentication.
79
+
80
+ Note:
81
+ - For "device_code" authentication, token is searched in
82
+ "~/.teradataml/sdk/modelops/.token". If it is not present, token is created,
83
+ used for authentication and saved in the same location.
84
+
85
+ Types: ClientCredentialsAuth, DeviceCodeAuth, BearerAuth or None
86
+
87
+ ssl_verify:
88
+ Optional Argument.
89
+ Specifies whether to enable or disable TLS Cert validation. If True, TLS cert
90
+ validation is enabled. If False, TLS cert validation is disabled. It can be provided
91
+ directly, or derived from the "BASE_SSL_VERIFY" environment variable or the YAML
92
+ configuration variable "ssl_verify". If 'ssl_verify' is not provided in any of
93
+ these 3 ways, it is set to True by default.
94
+ Default Value: True (Enable TLS cert validation)
95
+ Types: bool or None
96
+
97
+ config_file:
98
+ Optional Argument.
99
+ Specifies the path to the YAML configuration file.
100
+
101
+ Note:
102
+ - At least one of YAML config file or environment variables or above arguments
103
+ must be provided. If not provided, appropriate Exception is raised.
104
+ - If config_file is not provided, the default config file
105
+ ~/.teradataml/sdk/modelops/config.yaml is used. If the default config file
106
+ is not found, this function tries to read the configuration from the
107
+ environment variables or other arguments.
108
+
109
+ If YAML file is provided, it should have the following details, depending on the
110
+ what is provided in other arguments:
111
+ - ssl_verify (bool) : Same as ssl_verify argument.
112
+ - base_url (str) : Same as base_url argument.
113
+ - auth_mode (str) : Authentication mode to be used. It can be one of the following:
114
+ - client_credentials: For client credentials authentication.
115
+ - device_code: For device code authentication.
116
+ - bearer: For bearer token authentication.
117
+ - auth_client_id (str) : OAuth2 client ID. Required for client_credentials and
118
+ device_code authentication modes.
119
+ - auth_client_secret (str) : OAuth2 client secret. Required for client_credentials
120
+ and device_code authentication modes.
121
+ - auth_token_url (str) : OAuth2 token endpoint. Required for client_credentials and
122
+ device_code authentication modes.
123
+ - auth_device_auth_url (str) : OAuth2 device code endpoint. Required for device_code
124
+ authentication mode.
125
+ - auth_bearer (str) : The raw bearer token. Required for bearer authentication mode.
126
+
127
+ Types: str or None
128
+
129
+ project_id:
130
+ Specifies the project ID to be used by the client. If provided, it sets the project
131
+ context for the client. If not provided, the project context is not set, and the
132
+ client operates without a specific project context.
133
+ Note:
134
+ Some functions may require a project context to be set, and if 'project_id'
135
+ is not provided, it can be set using the `<client_obj>.set_project_id()` method.
136
+ Types: str or None
137
+
138
+ RETURNS:
139
+ None
140
+
141
+ RAISES:
142
+ - TeradataMlException: If the base_url, auth_mode, or ssl_verify is not provided in
143
+ any of the 3 ways (YAML config file, environment variables, or constructor arguments).
144
+ - ValueError: If the base_url is not provided in any of the 3 ways.
145
+ - FileNotFoundError: If the specified YAML config file does not exist.
146
+ - yaml.YAMLError: If there is an error in parsing the YAML file.
147
+
148
+ EXAMPLES:
149
+ >>> from teradataml.sdk import ClientCredentialsAuth, DeviceCodeAuth
150
+ >>> import os
151
+ >>> from teradataml.sdk.modelops import ModelOpsclient
152
+
153
+ # Example 1: Using a custom configuration file for client credentials authentication.
154
+ >>> cc_auth_dict = {"auth_client_id": "your_client_id",
155
+ "auth_client_secret": "your_client_secret",
156
+ "auth_token_url": "https://example.com/token",
157
+ "auth_mode": "client_credentials",
158
+ "base_url": "https://example.com",
159
+ "ssl_verify": False}
160
+
161
+ >>> # Write data to config file.
162
+ >>> cc_config_file = "custom_config.yaml"
163
+ >>> import yaml
164
+ >>> with open(cc_config_file, "w") as f:
165
+ yaml.dump(cc_auth_dict, f, sort_keys=False)
166
+
167
+ >>> # Create client object using config file.
168
+ >>> obj = ModelOpsclient(config_file=cc_config_file)
169
+
170
+ # Example 2: Using environment variables and set project id using
171
+ # set_project_id() method.
172
+ >>> os.environ["BASE_URL"] = "https://example.com"
173
+ >>> os.environ["BASE_API_AUTH_MODE"] = "client_credentials"
174
+ >>> os.environ["BASE_API_AUTH_CLIENT_ID"] = "your_client_id"
175
+ >>> os.environ["BASE_API_AUTH_CLIENT_SECRET"] = "your_client_secret"
176
+ >>> os.environ["BASE_API_AUTH_TOKEN_URL"] = "https://example.com/token"
177
+ >>> os.environ["BASE_SSL_VERIFY"] = "false"
178
+ >>> obj = ModelOpsclient()
179
+ >>> obj.set_project_id("70d4659b-92a2-4723-841a-9ba5629b5f27")
180
+
181
+ # Example 3: Using constructor arguments and passing "project_id" argument.
182
+ >>> obj = ModelOpsclient(
183
+ base_url="https://example.com",
184
+ auth=DeviceCodeAuth(
185
+ auth_client_id="your_client_id",
186
+ auth_client_secret="your_client_secret",
187
+ auth_token_url="https://example.com/token",
188
+ auth_device_auth_url="https://example.com/device_auth"
189
+ ),
190
+ ssl_verify=True,
191
+ project_id="70d4659b-92a2-4723-841a-9ba5629b5f27"
192
+ )
193
+ """
194
+ super().__init__(base_url, auth, ssl_verify, config_file)
195
+
196
+ arg_info_matrix = []
197
+ arg_info_matrix.append(["project_id", project_id, True, (str,)])
198
+
199
+ _Validators._validate_function_arguments(arg_info_matrix)
200
+
201
+ if project_id:
202
+ self.set_project_id(project_id)
203
+ else:
204
+ self.project_id = None
205
+
206
+ def set_project_id(self, project_id: str):
207
+ """
208
+ set project id
209
+
210
+ Parameters:
211
+ project_id (str): project id(uuid)
212
+ """
213
+ self.project_id = project_id
214
+ if not self.projects().find_by_id(id=project_id):
215
+ logging.warning(
216
+ f"Project with id {project_id} not found, but we'll set it anyway."
217
+ )
218
+
219
+ def get_current_project(self):
220
+ """
221
+ get project id
222
+
223
+ Return:
224
+ project_id (str): project id(uuid)
225
+ """
226
+ return self.project_id
227
+
228
+ def projects(self):
229
+ """
230
+ get projects client
231
+ """
232
+ from teradataml.sdk.modelops import Projects
233
+
234
+ return Projects(client=self)
235
+
236
+ def datasets(self):
237
+ """
238
+ get datasets client
239
+ """
240
+ from teradataml.sdk.modelops import Datasets
241
+
242
+ return Datasets(client=self)
243
+
244
+ def dataset_templates(self):
245
+ """
246
+ get dataset templates client
247
+ """
248
+
249
+ from teradataml.sdk.modelops import DatasetTemplates
250
+ return DatasetTemplates(client=self)
251
+
252
+ def dataset_connections(self):
253
+ """
254
+ get dataset connections client
255
+ """
256
+
257
+ from teradataml.sdk.modelops import DatasetConnections
258
+ return DatasetConnections(client=self)
259
+
260
+ def deployments(self):
261
+ """
262
+ get deployments client
263
+ """
264
+
265
+ from teradataml.sdk.modelops import Deployments
266
+ return Deployments(client=self)
267
+
268
+ def feature_engineering(self):
269
+ """
270
+ get feature engineering client
271
+ """
272
+
273
+ from teradataml.sdk.modelops import FeatureEngineeringTasks
274
+ return FeatureEngineeringTasks(client=self)
275
+
276
+ def jobs(self):
277
+ """
278
+ get jobs client
279
+ """
280
+
281
+ from teradataml.sdk.modelops import Jobs
282
+ return Jobs(client=self)
283
+
284
+ def job_events(self):
285
+ """
286
+ get job events client
287
+ """
288
+
289
+ from teradataml.sdk.modelops import JobEvents
290
+ return JobEvents(client=self)
291
+
292
+ def models(self):
293
+ """
294
+ get models client
295
+ """
296
+
297
+ from teradataml.sdk.modelops import Models
298
+ return Models(client=self)
299
+
300
+ def trained_models(self):
301
+ """
302
+ get trained models client
303
+ """
304
+
305
+ from teradataml.sdk.modelops import TrainedModels
306
+ return TrainedModels(client=self)
307
+
308
+ def trained_model_artefacts(self):
309
+ """
310
+ get trained model artefacts client
311
+ """
312
+
313
+ from teradataml.sdk.modelops import TrainedModelsArtefacts
314
+ return TrainedModelsArtefacts(client=self)
315
+
316
+ def trained_model_events(self):
317
+ """
318
+ get trained model events client
319
+ """
320
+
321
+ from teradataml.sdk.modelops import TrainedModelEvents
322
+ return TrainedModelEvents(client=self)
323
+
324
+ def user_attributes(self):
325
+ """
326
+ get user attributes client
327
+ """
328
+
329
+ from teradataml.sdk.modelops import UserAttributes
330
+ return UserAttributes(client=self)
331
+
332
+ def describe_current_project(self):
333
+ """
334
+ get details of currently selected project
335
+ """
336
+ import pandas as pd
337
+
338
+ if self.project_id:
339
+ project_dict = self.projects().find_by_id(self.project_id, "expandProject")
340
+ if project_dict:
341
+ project_data = [
342
+ [k, v]
343
+ for (k, v) in list(project_dict.items())
344
+ if k not in ["_links", "userAttributes"]
345
+ ]
346
+ return pd.DataFrame(project_data, columns=["attribute", "value"])
347
+ else:
348
+ return None
349
+ else:
350
+ return None
351
+
352
+ def get_default_connection_id(self):
353
+ """
354
+ get default dataset connection id
355
+ """
356
+ try:
357
+ conn = self.user_attributes().get_default_connection()
358
+ if conn:
359
+ return conn["value"]["defaultDatasetConnectionId"]
360
+ else:
361
+ return None
362
+ except:
363
+ return None
364
+
365
+ def _prepare_header_dict(self, content_type: Optional[Union[str, List[str]]] = "application/json",
366
+ accept: Optional[Union[str, List[str]]] = "application/json",
367
+ additional_headers: Optional[Dict[str, str]] = None) -> Dict[str, str]:
368
+ """
369
+ DESCRIPTION:
370
+ Prepares a header dictionary for API requests.
371
+
372
+ PARAMETERS:
373
+ content_type:
374
+ Optional Argument.
375
+ Specifies the Content-Type header value(s) to be included in the request.
376
+ Default Value: "application/json"
377
+ Types: List[str]
378
+
379
+ accept:
380
+ Optional Argument.
381
+ Specifies the Accept header value(s) to be included in the request.
382
+ Default Value: "application/json"
383
+ Types: List[str]
384
+
385
+ additional_headers:
386
+ Optional Argument.
387
+ Specifies any additional headers to be included in the request.
388
+ Types: Dict[str, str]
389
+
390
+ RETURNS:
391
+ A dictionary containing the prepared headers.
392
+
393
+ RAISES:
394
+ None
395
+
396
+ EXAMPLES:
397
+ >>> client = Client(...)
398
+ >>> headers = client._prepare_header_dict(content_type=["application/json"], accept=["application/json"])
399
+ """
400
+ headers = super()._prepare_header_dict(content_type=content_type,
401
+ accept=accept,
402
+ additional_headers=additional_headers
403
+ )
404
+ # ModelOps client requires project ID in headers.
405
+ headers.update({"AOA-Project-ID": self.project_id, "VMO-Project-ID": self.project_id})
406
+ return headers