teradataml 20.0.0.8__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.
Files changed (1208) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/LICENSE.pdf +0 -0
  3. teradataml/README.md +2762 -0
  4. teradataml/__init__.py +78 -0
  5. teradataml/_version.py +11 -0
  6. teradataml/analytics/Transformations.py +2996 -0
  7. teradataml/analytics/__init__.py +82 -0
  8. teradataml/analytics/analytic_function_executor.py +2416 -0
  9. teradataml/analytics/analytic_query_generator.py +1050 -0
  10. teradataml/analytics/byom/H2OPredict.py +514 -0
  11. teradataml/analytics/byom/PMMLPredict.py +437 -0
  12. teradataml/analytics/byom/__init__.py +16 -0
  13. teradataml/analytics/json_parser/__init__.py +133 -0
  14. teradataml/analytics/json_parser/analytic_functions_argument.py +1805 -0
  15. teradataml/analytics/json_parser/json_store.py +191 -0
  16. teradataml/analytics/json_parser/metadata.py +1666 -0
  17. teradataml/analytics/json_parser/utils.py +805 -0
  18. teradataml/analytics/meta_class.py +236 -0
  19. teradataml/analytics/sqle/DecisionTreePredict.py +456 -0
  20. teradataml/analytics/sqle/NaiveBayesPredict.py +420 -0
  21. teradataml/analytics/sqle/__init__.py +128 -0
  22. teradataml/analytics/sqle/json/decisiontreepredict_sqle.json +78 -0
  23. teradataml/analytics/sqle/json/naivebayespredict_sqle.json +62 -0
  24. teradataml/analytics/table_operator/__init__.py +11 -0
  25. teradataml/analytics/uaf/__init__.py +82 -0
  26. teradataml/analytics/utils.py +828 -0
  27. teradataml/analytics/valib.py +1617 -0
  28. teradataml/automl/__init__.py +5835 -0
  29. teradataml/automl/autodataprep/__init__.py +493 -0
  30. teradataml/automl/custom_json_utils.py +1625 -0
  31. teradataml/automl/data_preparation.py +1384 -0
  32. teradataml/automl/data_transformation.py +1254 -0
  33. teradataml/automl/feature_engineering.py +2273 -0
  34. teradataml/automl/feature_exploration.py +1873 -0
  35. teradataml/automl/model_evaluation.py +488 -0
  36. teradataml/automl/model_training.py +1407 -0
  37. teradataml/catalog/__init__.py +2 -0
  38. teradataml/catalog/byom.py +1759 -0
  39. teradataml/catalog/function_argument_mapper.py +859 -0
  40. teradataml/catalog/model_cataloging_utils.py +491 -0
  41. teradataml/clients/__init__.py +0 -0
  42. teradataml/clients/auth_client.py +137 -0
  43. teradataml/clients/keycloak_client.py +165 -0
  44. teradataml/clients/pkce_client.py +481 -0
  45. teradataml/common/__init__.py +1 -0
  46. teradataml/common/aed_utils.py +2078 -0
  47. teradataml/common/bulk_exposed_utils.py +113 -0
  48. teradataml/common/constants.py +1669 -0
  49. teradataml/common/deprecations.py +166 -0
  50. teradataml/common/exceptions.py +147 -0
  51. teradataml/common/formula.py +743 -0
  52. teradataml/common/garbagecollector.py +666 -0
  53. teradataml/common/logger.py +1261 -0
  54. teradataml/common/messagecodes.py +518 -0
  55. teradataml/common/messages.py +262 -0
  56. teradataml/common/pylogger.py +67 -0
  57. teradataml/common/sqlbundle.py +764 -0
  58. teradataml/common/td_coltype_code_to_tdtype.py +48 -0
  59. teradataml/common/utils.py +3166 -0
  60. teradataml/common/warnings.py +36 -0
  61. teradataml/common/wrapper_utils.py +625 -0
  62. teradataml/config/__init__.py +0 -0
  63. teradataml/config/dummy_file1.cfg +5 -0
  64. teradataml/config/dummy_file2.cfg +3 -0
  65. teradataml/config/sqlengine_alias_definitions_v1.0 +14 -0
  66. teradataml/config/sqlengine_alias_definitions_v1.1 +20 -0
  67. teradataml/config/sqlengine_alias_definitions_v1.3 +19 -0
  68. teradataml/context/__init__.py +0 -0
  69. teradataml/context/aed_context.py +223 -0
  70. teradataml/context/context.py +1462 -0
  71. teradataml/data/A_loan.csv +19 -0
  72. teradataml/data/BINARY_REALS_LEFT.csv +11 -0
  73. teradataml/data/BINARY_REALS_RIGHT.csv +11 -0
  74. teradataml/data/B_loan.csv +49 -0
  75. teradataml/data/BuoyData2.csv +17 -0
  76. teradataml/data/CONVOLVE2_COMPLEX_LEFT.csv +5 -0
  77. teradataml/data/CONVOLVE2_COMPLEX_RIGHT.csv +5 -0
  78. teradataml/data/Convolve2RealsLeft.csv +5 -0
  79. teradataml/data/Convolve2RealsRight.csv +5 -0
  80. teradataml/data/Convolve2ValidLeft.csv +11 -0
  81. teradataml/data/Convolve2ValidRight.csv +11 -0
  82. teradataml/data/DFFTConv_Real_8_8.csv +65 -0
  83. teradataml/data/Employee.csv +5 -0
  84. teradataml/data/Employee_Address.csv +4 -0
  85. teradataml/data/Employee_roles.csv +5 -0
  86. teradataml/data/JulesBelvezeDummyData.csv +100 -0
  87. teradataml/data/Mall_customer_data.csv +201 -0
  88. teradataml/data/Orders1_12mf.csv +25 -0
  89. teradataml/data/Pi_loan.csv +7 -0
  90. teradataml/data/SMOOTHED_DATA.csv +7 -0
  91. teradataml/data/TestDFFT8.csv +9 -0
  92. teradataml/data/TestRiver.csv +109 -0
  93. teradataml/data/Traindata.csv +28 -0
  94. teradataml/data/__init__.py +0 -0
  95. teradataml/data/acf.csv +17 -0
  96. teradataml/data/adaboost_example.json +34 -0
  97. teradataml/data/adaboostpredict_example.json +24 -0
  98. teradataml/data/additional_table.csv +11 -0
  99. teradataml/data/admissions_test.csv +21 -0
  100. teradataml/data/admissions_train.csv +41 -0
  101. teradataml/data/admissions_train_nulls.csv +41 -0
  102. teradataml/data/advertising.csv +201 -0
  103. teradataml/data/ageandheight.csv +13 -0
  104. teradataml/data/ageandpressure.csv +31 -0
  105. teradataml/data/amazon_reviews_25.csv +26 -0
  106. teradataml/data/antiselect_example.json +36 -0
  107. teradataml/data/antiselect_input.csv +8 -0
  108. teradataml/data/antiselect_input_mixed_case.csv +8 -0
  109. teradataml/data/applicant_external.csv +7 -0
  110. teradataml/data/applicant_reference.csv +7 -0
  111. teradataml/data/apriori_example.json +22 -0
  112. teradataml/data/arima_example.json +9 -0
  113. teradataml/data/assortedtext_input.csv +8 -0
  114. teradataml/data/attribution_example.json +34 -0
  115. teradataml/data/attribution_sample_table.csv +27 -0
  116. teradataml/data/attribution_sample_table1.csv +6 -0
  117. teradataml/data/attribution_sample_table2.csv +11 -0
  118. teradataml/data/bank_churn.csv +10001 -0
  119. teradataml/data/bank_marketing.csv +11163 -0
  120. teradataml/data/bank_web_clicks1.csv +43 -0
  121. teradataml/data/bank_web_clicks2.csv +91 -0
  122. teradataml/data/bank_web_url.csv +85 -0
  123. teradataml/data/barrier.csv +2 -0
  124. teradataml/data/barrier_new.csv +3 -0
  125. teradataml/data/betweenness_example.json +14 -0
  126. teradataml/data/bike_sharing.csv +732 -0
  127. teradataml/data/bin_breaks.csv +8 -0
  128. teradataml/data/bin_fit_ip.csv +4 -0
  129. teradataml/data/binary_complex_left.csv +11 -0
  130. teradataml/data/binary_complex_right.csv +11 -0
  131. teradataml/data/binary_matrix_complex_left.csv +21 -0
  132. teradataml/data/binary_matrix_complex_right.csv +21 -0
  133. teradataml/data/binary_matrix_real_left.csv +21 -0
  134. teradataml/data/binary_matrix_real_right.csv +21 -0
  135. teradataml/data/blood2ageandweight.csv +26 -0
  136. teradataml/data/bmi.csv +501 -0
  137. teradataml/data/boston.csv +507 -0
  138. teradataml/data/boston2cols.csv +721 -0
  139. teradataml/data/breast_cancer.csv +570 -0
  140. teradataml/data/buoydata_mix.csv +11 -0
  141. teradataml/data/burst_data.csv +5 -0
  142. teradataml/data/burst_example.json +21 -0
  143. teradataml/data/byom_example.json +34 -0
  144. teradataml/data/bytes_table.csv +4 -0
  145. teradataml/data/cal_housing_ex_raw.csv +70 -0
  146. teradataml/data/callers.csv +7 -0
  147. teradataml/data/calls.csv +10 -0
  148. teradataml/data/cars_hist.csv +33 -0
  149. teradataml/data/cat_table.csv +25 -0
  150. teradataml/data/ccm_example.json +32 -0
  151. teradataml/data/ccm_input.csv +91 -0
  152. teradataml/data/ccm_input2.csv +13 -0
  153. teradataml/data/ccmexample.csv +101 -0
  154. teradataml/data/ccmprepare_example.json +9 -0
  155. teradataml/data/ccmprepare_input.csv +91 -0
  156. teradataml/data/cfilter_example.json +12 -0
  157. teradataml/data/changepointdetection_example.json +18 -0
  158. teradataml/data/changepointdetectionrt_example.json +8 -0
  159. teradataml/data/chi_sq.csv +3 -0
  160. teradataml/data/churn_data.csv +14 -0
  161. teradataml/data/churn_emission.csv +35 -0
  162. teradataml/data/churn_initial.csv +3 -0
  163. teradataml/data/churn_state_transition.csv +5 -0
  164. teradataml/data/citedges_2.csv +745 -0
  165. teradataml/data/citvertices_2.csv +1210 -0
  166. teradataml/data/clicks2.csv +16 -0
  167. teradataml/data/clickstream.csv +13 -0
  168. teradataml/data/clickstream1.csv +11 -0
  169. teradataml/data/closeness_example.json +16 -0
  170. teradataml/data/complaints.csv +21 -0
  171. teradataml/data/complaints_mini.csv +3 -0
  172. teradataml/data/complaints_test_tokenized.csv +353 -0
  173. teradataml/data/complaints_testtoken.csv +224 -0
  174. teradataml/data/complaints_tokens_model.csv +348 -0
  175. teradataml/data/complaints_tokens_test.csv +353 -0
  176. teradataml/data/complaints_traintoken.csv +472 -0
  177. teradataml/data/computers_category.csv +1001 -0
  178. teradataml/data/computers_test1.csv +1252 -0
  179. teradataml/data/computers_train1.csv +5009 -0
  180. teradataml/data/computers_train1_clustered.csv +5009 -0
  181. teradataml/data/confusionmatrix_example.json +9 -0
  182. teradataml/data/conversion_event_table.csv +3 -0
  183. teradataml/data/corr_input.csv +17 -0
  184. teradataml/data/correlation_example.json +11 -0
  185. teradataml/data/covid_confirm_sd.csv +83 -0
  186. teradataml/data/coxhazardratio_example.json +39 -0
  187. teradataml/data/coxph_example.json +15 -0
  188. teradataml/data/coxsurvival_example.json +28 -0
  189. teradataml/data/cpt.csv +41 -0
  190. teradataml/data/credit_ex_merged.csv +45 -0
  191. teradataml/data/creditcard_data.csv +1001 -0
  192. teradataml/data/customer_loyalty.csv +301 -0
  193. teradataml/data/customer_loyalty_newseq.csv +31 -0
  194. teradataml/data/customer_segmentation_test.csv +2628 -0
  195. teradataml/data/customer_segmentation_train.csv +8069 -0
  196. teradataml/data/dataframe_example.json +173 -0
  197. teradataml/data/decisionforest_example.json +37 -0
  198. teradataml/data/decisionforestpredict_example.json +38 -0
  199. teradataml/data/decisiontree_example.json +21 -0
  200. teradataml/data/decisiontreepredict_example.json +45 -0
  201. teradataml/data/dfft2_size4_real.csv +17 -0
  202. teradataml/data/dfft2_test_matrix16.csv +17 -0
  203. teradataml/data/dfft2conv_real_4_4.csv +65 -0
  204. teradataml/data/diabetes.csv +443 -0
  205. teradataml/data/diabetes_test.csv +89 -0
  206. teradataml/data/dict_table.csv +5 -0
  207. teradataml/data/docperterm_table.csv +4 -0
  208. teradataml/data/docs/__init__.py +1 -0
  209. teradataml/data/docs/byom/__init__.py +0 -0
  210. teradataml/data/docs/byom/docs/DataRobotPredict.py +180 -0
  211. teradataml/data/docs/byom/docs/DataikuPredict.py +217 -0
  212. teradataml/data/docs/byom/docs/H2OPredict.py +325 -0
  213. teradataml/data/docs/byom/docs/ONNXEmbeddings.py +242 -0
  214. teradataml/data/docs/byom/docs/ONNXPredict.py +283 -0
  215. teradataml/data/docs/byom/docs/ONNXSeq2Seq.py +255 -0
  216. teradataml/data/docs/byom/docs/PMMLPredict.py +278 -0
  217. teradataml/data/docs/byom/docs/__init__.py +0 -0
  218. teradataml/data/docs/sqle/__init__.py +0 -0
  219. teradataml/data/docs/sqle/docs_17_10/Antiselect.py +83 -0
  220. teradataml/data/docs/sqle/docs_17_10/Attribution.py +200 -0
  221. teradataml/data/docs/sqle/docs_17_10/BincodeFit.py +172 -0
  222. teradataml/data/docs/sqle/docs_17_10/BincodeTransform.py +131 -0
  223. teradataml/data/docs/sqle/docs_17_10/CategoricalSummary.py +86 -0
  224. teradataml/data/docs/sqle/docs_17_10/ChiSq.py +90 -0
  225. teradataml/data/docs/sqle/docs_17_10/ColumnSummary.py +86 -0
  226. teradataml/data/docs/sqle/docs_17_10/ConvertTo.py +96 -0
  227. teradataml/data/docs/sqle/docs_17_10/DecisionForestPredict.py +139 -0
  228. teradataml/data/docs/sqle/docs_17_10/DecisionTreePredict.py +152 -0
  229. teradataml/data/docs/sqle/docs_17_10/FTest.py +161 -0
  230. teradataml/data/docs/sqle/docs_17_10/FillRowId.py +83 -0
  231. teradataml/data/docs/sqle/docs_17_10/Fit.py +88 -0
  232. teradataml/data/docs/sqle/docs_17_10/GLMPredict.py +144 -0
  233. teradataml/data/docs/sqle/docs_17_10/GetRowsWithMissingValues.py +85 -0
  234. teradataml/data/docs/sqle/docs_17_10/GetRowsWithoutMissingValues.py +82 -0
  235. teradataml/data/docs/sqle/docs_17_10/Histogram.py +165 -0
  236. teradataml/data/docs/sqle/docs_17_10/MovingAverage.py +134 -0
  237. teradataml/data/docs/sqle/docs_17_10/NGramSplitter.py +209 -0
  238. teradataml/data/docs/sqle/docs_17_10/NPath.py +266 -0
  239. teradataml/data/docs/sqle/docs_17_10/NaiveBayesPredict.py +116 -0
  240. teradataml/data/docs/sqle/docs_17_10/NaiveBayesTextClassifierPredict.py +176 -0
  241. teradataml/data/docs/sqle/docs_17_10/NumApply.py +147 -0
  242. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingFit.py +135 -0
  243. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingTransform.py +109 -0
  244. teradataml/data/docs/sqle/docs_17_10/OutlierFilterFit.py +166 -0
  245. teradataml/data/docs/sqle/docs_17_10/OutlierFilterTransform.py +105 -0
  246. teradataml/data/docs/sqle/docs_17_10/Pack.py +128 -0
  247. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesFit.py +112 -0
  248. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesTransform.py +102 -0
  249. teradataml/data/docs/sqle/docs_17_10/QQNorm.py +105 -0
  250. teradataml/data/docs/sqle/docs_17_10/RoundColumns.py +110 -0
  251. teradataml/data/docs/sqle/docs_17_10/RowNormalizeFit.py +118 -0
  252. teradataml/data/docs/sqle/docs_17_10/RowNormalizeTransform.py +99 -0
  253. teradataml/data/docs/sqle/docs_17_10/SVMSparsePredict.py +153 -0
  254. teradataml/data/docs/sqle/docs_17_10/ScaleFit.py +197 -0
  255. teradataml/data/docs/sqle/docs_17_10/ScaleTransform.py +99 -0
  256. teradataml/data/docs/sqle/docs_17_10/Sessionize.py +114 -0
  257. teradataml/data/docs/sqle/docs_17_10/SimpleImputeFit.py +116 -0
  258. teradataml/data/docs/sqle/docs_17_10/SimpleImputeTransform.py +98 -0
  259. teradataml/data/docs/sqle/docs_17_10/StrApply.py +187 -0
  260. teradataml/data/docs/sqle/docs_17_10/StringSimilarity.py +146 -0
  261. teradataml/data/docs/sqle/docs_17_10/Transform.py +105 -0
  262. teradataml/data/docs/sqle/docs_17_10/UnivariateStatistics.py +142 -0
  263. teradataml/data/docs/sqle/docs_17_10/Unpack.py +214 -0
  264. teradataml/data/docs/sqle/docs_17_10/WhichMax.py +83 -0
  265. teradataml/data/docs/sqle/docs_17_10/WhichMin.py +83 -0
  266. teradataml/data/docs/sqle/docs_17_10/ZTest.py +155 -0
  267. teradataml/data/docs/sqle/docs_17_10/__init__.py +0 -0
  268. teradataml/data/docs/sqle/docs_17_20/ANOVA.py +186 -0
  269. teradataml/data/docs/sqle/docs_17_20/Antiselect.py +83 -0
  270. teradataml/data/docs/sqle/docs_17_20/Apriori.py +138 -0
  271. teradataml/data/docs/sqle/docs_17_20/Attribution.py +201 -0
  272. teradataml/data/docs/sqle/docs_17_20/BincodeFit.py +172 -0
  273. teradataml/data/docs/sqle/docs_17_20/BincodeTransform.py +139 -0
  274. teradataml/data/docs/sqle/docs_17_20/CFilter.py +132 -0
  275. teradataml/data/docs/sqle/docs_17_20/CategoricalSummary.py +86 -0
  276. teradataml/data/docs/sqle/docs_17_20/ChiSq.py +90 -0
  277. teradataml/data/docs/sqle/docs_17_20/ClassificationEvaluator.py +166 -0
  278. teradataml/data/docs/sqle/docs_17_20/ColumnSummary.py +86 -0
  279. teradataml/data/docs/sqle/docs_17_20/ColumnTransformer.py +246 -0
  280. teradataml/data/docs/sqle/docs_17_20/ConvertTo.py +113 -0
  281. teradataml/data/docs/sqle/docs_17_20/DecisionForest.py +280 -0
  282. teradataml/data/docs/sqle/docs_17_20/DecisionForestPredict.py +144 -0
  283. teradataml/data/docs/sqle/docs_17_20/DecisionTreePredict.py +136 -0
  284. teradataml/data/docs/sqle/docs_17_20/FTest.py +240 -0
  285. teradataml/data/docs/sqle/docs_17_20/FillRowId.py +83 -0
  286. teradataml/data/docs/sqle/docs_17_20/Fit.py +88 -0
  287. teradataml/data/docs/sqle/docs_17_20/GLM.py +541 -0
  288. teradataml/data/docs/sqle/docs_17_20/GLMPerSegment.py +415 -0
  289. teradataml/data/docs/sqle/docs_17_20/GLMPredict.py +144 -0
  290. teradataml/data/docs/sqle/docs_17_20/GLMPredictPerSegment.py +233 -0
  291. teradataml/data/docs/sqle/docs_17_20/GetFutileColumns.py +125 -0
  292. teradataml/data/docs/sqle/docs_17_20/GetRowsWithMissingValues.py +109 -0
  293. teradataml/data/docs/sqle/docs_17_20/GetRowsWithoutMissingValues.py +106 -0
  294. teradataml/data/docs/sqle/docs_17_20/Histogram.py +224 -0
  295. teradataml/data/docs/sqle/docs_17_20/KMeans.py +251 -0
  296. teradataml/data/docs/sqle/docs_17_20/KMeansPredict.py +144 -0
  297. teradataml/data/docs/sqle/docs_17_20/KNN.py +215 -0
  298. teradataml/data/docs/sqle/docs_17_20/MovingAverage.py +134 -0
  299. teradataml/data/docs/sqle/docs_17_20/NERExtractor.py +121 -0
  300. teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +209 -0
  301. teradataml/data/docs/sqle/docs_17_20/NPath.py +266 -0
  302. teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +162 -0
  303. teradataml/data/docs/sqle/docs_17_20/NaiveBayesPredict.py +116 -0
  304. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierPredict.py +177 -0
  305. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierTrainer.py +127 -0
  306. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineFit.py +119 -0
  307. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineTransform.py +112 -0
  308. teradataml/data/docs/sqle/docs_17_20/NumApply.py +147 -0
  309. teradataml/data/docs/sqle/docs_17_20/OneClassSVM.py +307 -0
  310. teradataml/data/docs/sqle/docs_17_20/OneClassSVMPredict.py +185 -0
  311. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingFit.py +231 -0
  312. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingTransform.py +121 -0
  313. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingFit.py +220 -0
  314. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingTransform.py +127 -0
  315. teradataml/data/docs/sqle/docs_17_20/OutlierFilterFit.py +191 -0
  316. teradataml/data/docs/sqle/docs_17_20/OutlierFilterTransform.py +117 -0
  317. teradataml/data/docs/sqle/docs_17_20/Pack.py +128 -0
  318. teradataml/data/docs/sqle/docs_17_20/Pivoting.py +279 -0
  319. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesFit.py +112 -0
  320. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesTransform.py +112 -0
  321. teradataml/data/docs/sqle/docs_17_20/QQNorm.py +105 -0
  322. teradataml/data/docs/sqle/docs_17_20/ROC.py +164 -0
  323. teradataml/data/docs/sqle/docs_17_20/RandomProjectionFit.py +155 -0
  324. teradataml/data/docs/sqle/docs_17_20/RandomProjectionMinComponents.py +106 -0
  325. teradataml/data/docs/sqle/docs_17_20/RandomProjectionTransform.py +120 -0
  326. teradataml/data/docs/sqle/docs_17_20/RegressionEvaluator.py +211 -0
  327. teradataml/data/docs/sqle/docs_17_20/RoundColumns.py +109 -0
  328. teradataml/data/docs/sqle/docs_17_20/RowNormalizeFit.py +118 -0
  329. teradataml/data/docs/sqle/docs_17_20/RowNormalizeTransform.py +111 -0
  330. teradataml/data/docs/sqle/docs_17_20/SMOTE.py +212 -0
  331. teradataml/data/docs/sqle/docs_17_20/SVM.py +414 -0
  332. teradataml/data/docs/sqle/docs_17_20/SVMPredict.py +213 -0
  333. teradataml/data/docs/sqle/docs_17_20/SVMSparsePredict.py +153 -0
  334. teradataml/data/docs/sqle/docs_17_20/ScaleFit.py +315 -0
  335. teradataml/data/docs/sqle/docs_17_20/ScaleTransform.py +202 -0
  336. teradataml/data/docs/sqle/docs_17_20/SentimentExtractor.py +206 -0
  337. teradataml/data/docs/sqle/docs_17_20/Sessionize.py +114 -0
  338. teradataml/data/docs/sqle/docs_17_20/Shap.py +225 -0
  339. teradataml/data/docs/sqle/docs_17_20/Silhouette.py +153 -0
  340. teradataml/data/docs/sqle/docs_17_20/SimpleImputeFit.py +116 -0
  341. teradataml/data/docs/sqle/docs_17_20/SimpleImputeTransform.py +109 -0
  342. teradataml/data/docs/sqle/docs_17_20/StrApply.py +187 -0
  343. teradataml/data/docs/sqle/docs_17_20/StringSimilarity.py +146 -0
  344. teradataml/data/docs/sqle/docs_17_20/TDDecisionForestPredict.py +207 -0
  345. teradataml/data/docs/sqle/docs_17_20/TDGLMPredict.py +333 -0
  346. teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +189 -0
  347. teradataml/data/docs/sqle/docs_17_20/TFIDF.py +142 -0
  348. teradataml/data/docs/sqle/docs_17_20/TargetEncodingFit.py +267 -0
  349. teradataml/data/docs/sqle/docs_17_20/TargetEncodingTransform.py +141 -0
  350. teradataml/data/docs/sqle/docs_17_20/TextMorph.py +119 -0
  351. teradataml/data/docs/sqle/docs_17_20/TextParser.py +224 -0
  352. teradataml/data/docs/sqle/docs_17_20/TrainTestSplit.py +160 -0
  353. teradataml/data/docs/sqle/docs_17_20/Transform.py +123 -0
  354. teradataml/data/docs/sqle/docs_17_20/UnivariateStatistics.py +142 -0
  355. teradataml/data/docs/sqle/docs_17_20/Unpack.py +214 -0
  356. teradataml/data/docs/sqle/docs_17_20/Unpivoting.py +216 -0
  357. teradataml/data/docs/sqle/docs_17_20/VectorDistance.py +169 -0
  358. teradataml/data/docs/sqle/docs_17_20/WhichMax.py +83 -0
  359. teradataml/data/docs/sqle/docs_17_20/WhichMin.py +83 -0
  360. teradataml/data/docs/sqle/docs_17_20/WordEmbeddings.py +237 -0
  361. teradataml/data/docs/sqle/docs_17_20/XGBoost.py +362 -0
  362. teradataml/data/docs/sqle/docs_17_20/XGBoostPredict.py +281 -0
  363. teradataml/data/docs/sqle/docs_17_20/ZTest.py +220 -0
  364. teradataml/data/docs/sqle/docs_17_20/__init__.py +0 -0
  365. teradataml/data/docs/tableoperator/__init__.py +0 -0
  366. teradataml/data/docs/tableoperator/docs_17_00/ReadNOS.py +430 -0
  367. teradataml/data/docs/tableoperator/docs_17_00/__init__.py +0 -0
  368. teradataml/data/docs/tableoperator/docs_17_05/ReadNOS.py +430 -0
  369. teradataml/data/docs/tableoperator/docs_17_05/WriteNOS.py +348 -0
  370. teradataml/data/docs/tableoperator/docs_17_05/__init__.py +0 -0
  371. teradataml/data/docs/tableoperator/docs_17_10/ReadNOS.py +429 -0
  372. teradataml/data/docs/tableoperator/docs_17_10/WriteNOS.py +348 -0
  373. teradataml/data/docs/tableoperator/docs_17_10/__init__.py +0 -0
  374. teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
  375. teradataml/data/docs/tableoperator/docs_17_20/ReadNOS.py +440 -0
  376. teradataml/data/docs/tableoperator/docs_17_20/WriteNOS.py +387 -0
  377. teradataml/data/docs/tableoperator/docs_17_20/__init__.py +0 -0
  378. teradataml/data/docs/uaf/__init__.py +0 -0
  379. teradataml/data/docs/uaf/docs_17_20/ACF.py +186 -0
  380. teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +370 -0
  381. teradataml/data/docs/uaf/docs_17_20/ArimaForecast.py +172 -0
  382. teradataml/data/docs/uaf/docs_17_20/ArimaValidate.py +161 -0
  383. teradataml/data/docs/uaf/docs_17_20/ArimaXEstimate.py +293 -0
  384. teradataml/data/docs/uaf/docs_17_20/AutoArima.py +354 -0
  385. teradataml/data/docs/uaf/docs_17_20/BinaryMatrixOp.py +248 -0
  386. teradataml/data/docs/uaf/docs_17_20/BinarySeriesOp.py +252 -0
  387. teradataml/data/docs/uaf/docs_17_20/BreuschGodfrey.py +178 -0
  388. teradataml/data/docs/uaf/docs_17_20/BreuschPaganGodfrey.py +175 -0
  389. teradataml/data/docs/uaf/docs_17_20/Convolve.py +230 -0
  390. teradataml/data/docs/uaf/docs_17_20/Convolve2.py +218 -0
  391. teradataml/data/docs/uaf/docs_17_20/CopyArt.py +145 -0
  392. teradataml/data/docs/uaf/docs_17_20/CumulPeriodogram.py +185 -0
  393. teradataml/data/docs/uaf/docs_17_20/DFFT.py +204 -0
  394. teradataml/data/docs/uaf/docs_17_20/DFFT2.py +216 -0
  395. teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +216 -0
  396. teradataml/data/docs/uaf/docs_17_20/DFFTConv.py +192 -0
  397. teradataml/data/docs/uaf/docs_17_20/DIFF.py +175 -0
  398. teradataml/data/docs/uaf/docs_17_20/DTW.py +180 -0
  399. teradataml/data/docs/uaf/docs_17_20/DWT.py +235 -0
  400. teradataml/data/docs/uaf/docs_17_20/DWT2D.py +217 -0
  401. teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +142 -0
  402. teradataml/data/docs/uaf/docs_17_20/DurbinWatson.py +184 -0
  403. teradataml/data/docs/uaf/docs_17_20/ExtractResults.py +185 -0
  404. teradataml/data/docs/uaf/docs_17_20/FilterFactory1d.py +160 -0
  405. teradataml/data/docs/uaf/docs_17_20/FitMetrics.py +172 -0
  406. teradataml/data/docs/uaf/docs_17_20/GenseriesFormula.py +206 -0
  407. teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +143 -0
  408. teradataml/data/docs/uaf/docs_17_20/GoldfeldQuandt.py +198 -0
  409. teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +260 -0
  410. teradataml/data/docs/uaf/docs_17_20/IDFFT.py +165 -0
  411. teradataml/data/docs/uaf/docs_17_20/IDFFT2.py +191 -0
  412. teradataml/data/docs/uaf/docs_17_20/IDWT.py +236 -0
  413. teradataml/data/docs/uaf/docs_17_20/IDWT2D.py +226 -0
  414. teradataml/data/docs/uaf/docs_17_20/IQR.py +134 -0
  415. teradataml/data/docs/uaf/docs_17_20/InputValidator.py +121 -0
  416. teradataml/data/docs/uaf/docs_17_20/LineSpec.py +156 -0
  417. teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +215 -0
  418. teradataml/data/docs/uaf/docs_17_20/MAMean.py +174 -0
  419. teradataml/data/docs/uaf/docs_17_20/MInfo.py +134 -0
  420. teradataml/data/docs/uaf/docs_17_20/Matrix2Image.py +297 -0
  421. teradataml/data/docs/uaf/docs_17_20/MatrixMultiply.py +145 -0
  422. teradataml/data/docs/uaf/docs_17_20/MultivarRegr.py +191 -0
  423. teradataml/data/docs/uaf/docs_17_20/PACF.py +157 -0
  424. teradataml/data/docs/uaf/docs_17_20/Portman.py +217 -0
  425. teradataml/data/docs/uaf/docs_17_20/PowerSpec.py +203 -0
  426. teradataml/data/docs/uaf/docs_17_20/PowerTransform.py +155 -0
  427. teradataml/data/docs/uaf/docs_17_20/Resample.py +237 -0
  428. teradataml/data/docs/uaf/docs_17_20/SAX.py +246 -0
  429. teradataml/data/docs/uaf/docs_17_20/SInfo.py +123 -0
  430. teradataml/data/docs/uaf/docs_17_20/SeasonalNormalize.py +173 -0
  431. teradataml/data/docs/uaf/docs_17_20/SelectionCriteria.py +174 -0
  432. teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +171 -0
  433. teradataml/data/docs/uaf/docs_17_20/SignifResidmean.py +164 -0
  434. teradataml/data/docs/uaf/docs_17_20/SimpleExp.py +180 -0
  435. teradataml/data/docs/uaf/docs_17_20/Smoothma.py +208 -0
  436. teradataml/data/docs/uaf/docs_17_20/TrackingOp.py +151 -0
  437. teradataml/data/docs/uaf/docs_17_20/UNDIFF.py +171 -0
  438. teradataml/data/docs/uaf/docs_17_20/Unnormalize.py +202 -0
  439. teradataml/data/docs/uaf/docs_17_20/WhitesGeneral.py +171 -0
  440. teradataml/data/docs/uaf/docs_17_20/WindowDFFT.py +368 -0
  441. teradataml/data/docs/uaf/docs_17_20/__init__.py +0 -0
  442. teradataml/data/dtw_example.json +18 -0
  443. teradataml/data/dtw_t1.csv +11 -0
  444. teradataml/data/dtw_t2.csv +4 -0
  445. teradataml/data/dwt2d_dataTable.csv +65 -0
  446. teradataml/data/dwt2d_example.json +16 -0
  447. teradataml/data/dwt_dataTable.csv +8 -0
  448. teradataml/data/dwt_example.json +15 -0
  449. teradataml/data/dwt_filterTable.csv +3 -0
  450. teradataml/data/dwt_filter_dim.csv +5 -0
  451. teradataml/data/emission.csv +9 -0
  452. teradataml/data/emp_table_by_dept.csv +19 -0
  453. teradataml/data/employee_info.csv +4 -0
  454. teradataml/data/employee_table.csv +6 -0
  455. teradataml/data/excluding_event_table.csv +2 -0
  456. teradataml/data/finance_data.csv +6 -0
  457. teradataml/data/finance_data2.csv +61 -0
  458. teradataml/data/finance_data3.csv +93 -0
  459. teradataml/data/finance_data4.csv +13 -0
  460. teradataml/data/fish.csv +160 -0
  461. teradataml/data/fm_blood2ageandweight.csv +26 -0
  462. teradataml/data/fmeasure_example.json +12 -0
  463. teradataml/data/followers_leaders.csv +10 -0
  464. teradataml/data/fpgrowth_example.json +12 -0
  465. teradataml/data/frequentpaths_example.json +29 -0
  466. teradataml/data/friends.csv +9 -0
  467. teradataml/data/fs_input.csv +33 -0
  468. teradataml/data/fs_input1.csv +33 -0
  469. teradataml/data/genData.csv +513 -0
  470. teradataml/data/geodataframe_example.json +40 -0
  471. teradataml/data/glass_types.csv +215 -0
  472. teradataml/data/glm_admissions_model.csv +12 -0
  473. teradataml/data/glm_example.json +56 -0
  474. teradataml/data/glml1l2_example.json +28 -0
  475. teradataml/data/glml1l2predict_example.json +54 -0
  476. teradataml/data/glmpredict_example.json +54 -0
  477. teradataml/data/gq_t1.csv +21 -0
  478. teradataml/data/grocery_transaction.csv +19 -0
  479. teradataml/data/hconvolve_complex_right.csv +5 -0
  480. teradataml/data/hconvolve_complex_rightmulti.csv +5 -0
  481. teradataml/data/histogram_example.json +12 -0
  482. teradataml/data/hmmdecoder_example.json +79 -0
  483. teradataml/data/hmmevaluator_example.json +25 -0
  484. teradataml/data/hmmsupervised_example.json +10 -0
  485. teradataml/data/hmmunsupervised_example.json +8 -0
  486. teradataml/data/hnsw_alter_data.csv +5 -0
  487. teradataml/data/hnsw_data.csv +10 -0
  488. teradataml/data/house_values.csv +12 -0
  489. teradataml/data/house_values2.csv +13 -0
  490. teradataml/data/housing_cat.csv +7 -0
  491. teradataml/data/housing_data.csv +9 -0
  492. teradataml/data/housing_test.csv +47 -0
  493. teradataml/data/housing_test_binary.csv +47 -0
  494. teradataml/data/housing_train.csv +493 -0
  495. teradataml/data/housing_train_attribute.csv +5 -0
  496. teradataml/data/housing_train_binary.csv +437 -0
  497. teradataml/data/housing_train_parameter.csv +2 -0
  498. teradataml/data/housing_train_response.csv +493 -0
  499. teradataml/data/housing_train_segment.csv +201 -0
  500. teradataml/data/ibm_stock.csv +370 -0
  501. teradataml/data/ibm_stock1.csv +370 -0
  502. teradataml/data/identitymatch_example.json +22 -0
  503. teradataml/data/idf_table.csv +4 -0
  504. teradataml/data/idwt2d_dataTable.csv +5 -0
  505. teradataml/data/idwt_dataTable.csv +8 -0
  506. teradataml/data/idwt_filterTable.csv +3 -0
  507. teradataml/data/impressions.csv +101 -0
  508. teradataml/data/inflation.csv +21 -0
  509. teradataml/data/initial.csv +3 -0
  510. teradataml/data/insect2Cols.csv +61 -0
  511. teradataml/data/insect_sprays.csv +13 -0
  512. teradataml/data/insurance.csv +1339 -0
  513. teradataml/data/interpolator_example.json +13 -0
  514. teradataml/data/interval_data.csv +5 -0
  515. teradataml/data/iris_altinput.csv +481 -0
  516. teradataml/data/iris_attribute_output.csv +8 -0
  517. teradataml/data/iris_attribute_test.csv +121 -0
  518. teradataml/data/iris_attribute_train.csv +481 -0
  519. teradataml/data/iris_category_expect_predict.csv +31 -0
  520. teradataml/data/iris_data.csv +151 -0
  521. teradataml/data/iris_input.csv +151 -0
  522. teradataml/data/iris_response_train.csv +121 -0
  523. teradataml/data/iris_test.csv +31 -0
  524. teradataml/data/iris_train.csv +121 -0
  525. teradataml/data/join_table1.csv +4 -0
  526. teradataml/data/join_table2.csv +4 -0
  527. teradataml/data/jsons/anly_function_name.json +7 -0
  528. teradataml/data/jsons/byom/ONNXSeq2Seq.json +287 -0
  529. teradataml/data/jsons/byom/dataikupredict.json +148 -0
  530. teradataml/data/jsons/byom/datarobotpredict.json +147 -0
  531. teradataml/data/jsons/byom/h2opredict.json +195 -0
  532. teradataml/data/jsons/byom/onnxembeddings.json +267 -0
  533. teradataml/data/jsons/byom/onnxpredict.json +187 -0
  534. teradataml/data/jsons/byom/pmmlpredict.json +147 -0
  535. teradataml/data/jsons/paired_functions.json +450 -0
  536. teradataml/data/jsons/sqle/16.20/Antiselect.json +56 -0
  537. teradataml/data/jsons/sqle/16.20/Attribution.json +249 -0
  538. teradataml/data/jsons/sqle/16.20/DecisionForestPredict.json +156 -0
  539. teradataml/data/jsons/sqle/16.20/DecisionTreePredict.json +170 -0
  540. teradataml/data/jsons/sqle/16.20/GLMPredict.json +122 -0
  541. teradataml/data/jsons/sqle/16.20/MovingAverage.json +367 -0
  542. teradataml/data/jsons/sqle/16.20/NGramSplitter.json +239 -0
  543. teradataml/data/jsons/sqle/16.20/NaiveBayesPredict.json +136 -0
  544. teradataml/data/jsons/sqle/16.20/NaiveBayesTextClassifierPredict.json +235 -0
  545. teradataml/data/jsons/sqle/16.20/Pack.json +98 -0
  546. teradataml/data/jsons/sqle/16.20/SVMSparsePredict.json +162 -0
  547. teradataml/data/jsons/sqle/16.20/Sessionize.json +105 -0
  548. teradataml/data/jsons/sqle/16.20/StringSimilarity.json +86 -0
  549. teradataml/data/jsons/sqle/16.20/Unpack.json +166 -0
  550. teradataml/data/jsons/sqle/16.20/nPath.json +269 -0
  551. teradataml/data/jsons/sqle/17.00/Antiselect.json +56 -0
  552. teradataml/data/jsons/sqle/17.00/Attribution.json +249 -0
  553. teradataml/data/jsons/sqle/17.00/DecisionForestPredict.json +156 -0
  554. teradataml/data/jsons/sqle/17.00/DecisionTreePredict.json +170 -0
  555. teradataml/data/jsons/sqle/17.00/GLMPredict.json +122 -0
  556. teradataml/data/jsons/sqle/17.00/MovingAverage.json +367 -0
  557. teradataml/data/jsons/sqle/17.00/NGramSplitter.json +239 -0
  558. teradataml/data/jsons/sqle/17.00/NaiveBayesPredict.json +136 -0
  559. teradataml/data/jsons/sqle/17.00/NaiveBayesTextClassifierPredict.json +235 -0
  560. teradataml/data/jsons/sqle/17.00/Pack.json +98 -0
  561. teradataml/data/jsons/sqle/17.00/SVMSparsePredict.json +162 -0
  562. teradataml/data/jsons/sqle/17.00/Sessionize.json +105 -0
  563. teradataml/data/jsons/sqle/17.00/StringSimilarity.json +86 -0
  564. teradataml/data/jsons/sqle/17.00/Unpack.json +166 -0
  565. teradataml/data/jsons/sqle/17.00/nPath.json +269 -0
  566. teradataml/data/jsons/sqle/17.05/Antiselect.json +56 -0
  567. teradataml/data/jsons/sqle/17.05/Attribution.json +249 -0
  568. teradataml/data/jsons/sqle/17.05/DecisionForestPredict.json +156 -0
  569. teradataml/data/jsons/sqle/17.05/DecisionTreePredict.json +170 -0
  570. teradataml/data/jsons/sqle/17.05/GLMPredict.json +122 -0
  571. teradataml/data/jsons/sqle/17.05/MovingAverage.json +367 -0
  572. teradataml/data/jsons/sqle/17.05/NGramSplitter.json +239 -0
  573. teradataml/data/jsons/sqle/17.05/NaiveBayesPredict.json +136 -0
  574. teradataml/data/jsons/sqle/17.05/NaiveBayesTextClassifierPredict.json +235 -0
  575. teradataml/data/jsons/sqle/17.05/Pack.json +98 -0
  576. teradataml/data/jsons/sqle/17.05/SVMSparsePredict.json +162 -0
  577. teradataml/data/jsons/sqle/17.05/Sessionize.json +105 -0
  578. teradataml/data/jsons/sqle/17.05/StringSimilarity.json +86 -0
  579. teradataml/data/jsons/sqle/17.05/Unpack.json +166 -0
  580. teradataml/data/jsons/sqle/17.05/nPath.json +269 -0
  581. teradataml/data/jsons/sqle/17.10/Antiselect.json +56 -0
  582. teradataml/data/jsons/sqle/17.10/Attribution.json +249 -0
  583. teradataml/data/jsons/sqle/17.10/DecisionForestPredict.json +185 -0
  584. teradataml/data/jsons/sqle/17.10/DecisionTreePredict.json +172 -0
  585. teradataml/data/jsons/sqle/17.10/GLMPredict.json +151 -0
  586. teradataml/data/jsons/sqle/17.10/MovingAverage.json +368 -0
  587. teradataml/data/jsons/sqle/17.10/NGramSplitter.json +239 -0
  588. teradataml/data/jsons/sqle/17.10/NaiveBayesPredict.json +149 -0
  589. teradataml/data/jsons/sqle/17.10/NaiveBayesTextClassifierPredict.json +288 -0
  590. teradataml/data/jsons/sqle/17.10/Pack.json +133 -0
  591. teradataml/data/jsons/sqle/17.10/SVMSparsePredict.json +193 -0
  592. teradataml/data/jsons/sqle/17.10/Sessionize.json +105 -0
  593. teradataml/data/jsons/sqle/17.10/StringSimilarity.json +86 -0
  594. teradataml/data/jsons/sqle/17.10/TD_BinCodeFit.json +239 -0
  595. teradataml/data/jsons/sqle/17.10/TD_BinCodeTransform.json +70 -0
  596. teradataml/data/jsons/sqle/17.10/TD_CategoricalSummary.json +54 -0
  597. teradataml/data/jsons/sqle/17.10/TD_Chisq.json +68 -0
  598. teradataml/data/jsons/sqle/17.10/TD_ColumnSummary.json +54 -0
  599. teradataml/data/jsons/sqle/17.10/TD_ConvertTo.json +69 -0
  600. teradataml/data/jsons/sqle/17.10/TD_FTest.json +187 -0
  601. teradataml/data/jsons/sqle/17.10/TD_FillRowID.json +52 -0
  602. teradataml/data/jsons/sqle/17.10/TD_FunctionFit.json +46 -0
  603. teradataml/data/jsons/sqle/17.10/TD_FunctionTransform.json +72 -0
  604. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithMissingValues.json +53 -0
  605. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithoutMissingValues.json +53 -0
  606. teradataml/data/jsons/sqle/17.10/TD_Histogram.json +133 -0
  607. teradataml/data/jsons/sqle/17.10/TD_NumApply.json +147 -0
  608. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingFit.json +183 -0
  609. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingTransform.json +66 -0
  610. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterFit.json +197 -0
  611. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterTransform.json +48 -0
  612. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesFit.json +114 -0
  613. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesTransform.json +72 -0
  614. teradataml/data/jsons/sqle/17.10/TD_QQNorm.json +112 -0
  615. teradataml/data/jsons/sqle/17.10/TD_RoundColumns.json +93 -0
  616. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeFit.json +128 -0
  617. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeTransform.json +71 -0
  618. teradataml/data/jsons/sqle/17.10/TD_ScaleFit.json +157 -0
  619. teradataml/data/jsons/sqle/17.10/TD_ScaleTransform.json +71 -0
  620. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeFit.json +148 -0
  621. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeTransform.json +48 -0
  622. teradataml/data/jsons/sqle/17.10/TD_StrApply.json +240 -0
  623. teradataml/data/jsons/sqle/17.10/TD_UnivariateStatistics.json +119 -0
  624. teradataml/data/jsons/sqle/17.10/TD_WhichMax.json +53 -0
  625. teradataml/data/jsons/sqle/17.10/TD_WhichMin.json +53 -0
  626. teradataml/data/jsons/sqle/17.10/TD_ZTest.json +171 -0
  627. teradataml/data/jsons/sqle/17.10/Unpack.json +188 -0
  628. teradataml/data/jsons/sqle/17.10/nPath.json +269 -0
  629. teradataml/data/jsons/sqle/17.20/Antiselect.json +56 -0
  630. teradataml/data/jsons/sqle/17.20/Attribution.json +249 -0
  631. teradataml/data/jsons/sqle/17.20/DecisionForestPredict.json +185 -0
  632. teradataml/data/jsons/sqle/17.20/DecisionTreePredict.json +172 -0
  633. teradataml/data/jsons/sqle/17.20/GLMPredict.json +151 -0
  634. teradataml/data/jsons/sqle/17.20/MovingAverage.json +367 -0
  635. teradataml/data/jsons/sqle/17.20/NGramSplitter.json +239 -0
  636. teradataml/data/jsons/sqle/17.20/NaiveBayesPredict.json +149 -0
  637. teradataml/data/jsons/sqle/17.20/NaiveBayesTextClassifierPredict.json +287 -0
  638. teradataml/data/jsons/sqle/17.20/Pack.json +133 -0
  639. teradataml/data/jsons/sqle/17.20/SVMSparsePredict.json +192 -0
  640. teradataml/data/jsons/sqle/17.20/Sessionize.json +105 -0
  641. teradataml/data/jsons/sqle/17.20/StringSimilarity.json +86 -0
  642. teradataml/data/jsons/sqle/17.20/TD_ANOVA.json +149 -0
  643. teradataml/data/jsons/sqle/17.20/TD_Apriori.json +181 -0
  644. teradataml/data/jsons/sqle/17.20/TD_BinCodeFit.json +239 -0
  645. teradataml/data/jsons/sqle/17.20/TD_BinCodeTransform.json +71 -0
  646. teradataml/data/jsons/sqle/17.20/TD_CFilter.json +118 -0
  647. teradataml/data/jsons/sqle/17.20/TD_CategoricalSummary.json +53 -0
  648. teradataml/data/jsons/sqle/17.20/TD_Chisq.json +68 -0
  649. teradataml/data/jsons/sqle/17.20/TD_ClassificationEvaluator.json +146 -0
  650. teradataml/data/jsons/sqle/17.20/TD_ColumnSummary.json +53 -0
  651. teradataml/data/jsons/sqle/17.20/TD_ColumnTransformer.json +218 -0
  652. teradataml/data/jsons/sqle/17.20/TD_ConvertTo.json +92 -0
  653. teradataml/data/jsons/sqle/17.20/TD_DecisionForest.json +260 -0
  654. teradataml/data/jsons/sqle/17.20/TD_DecisionForestPredict.json +139 -0
  655. teradataml/data/jsons/sqle/17.20/TD_FTest.json +269 -0
  656. teradataml/data/jsons/sqle/17.20/TD_FillRowID.json +52 -0
  657. teradataml/data/jsons/sqle/17.20/TD_FunctionFit.json +46 -0
  658. teradataml/data/jsons/sqle/17.20/TD_FunctionTransform.json +72 -0
  659. teradataml/data/jsons/sqle/17.20/TD_GLM.json +507 -0
  660. teradataml/data/jsons/sqle/17.20/TD_GLMPREDICT.json +168 -0
  661. teradataml/data/jsons/sqle/17.20/TD_GLMPerSegment.json +411 -0
  662. teradataml/data/jsons/sqle/17.20/TD_GLMPredictPerSegment.json +146 -0
  663. teradataml/data/jsons/sqle/17.20/TD_GetFutileColumns.json +93 -0
  664. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithMissingValues.json +76 -0
  665. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithoutMissingValues.json +76 -0
  666. teradataml/data/jsons/sqle/17.20/TD_Histogram.json +152 -0
  667. teradataml/data/jsons/sqle/17.20/TD_KMeans.json +232 -0
  668. teradataml/data/jsons/sqle/17.20/TD_KMeansPredict.json +87 -0
  669. teradataml/data/jsons/sqle/17.20/TD_KNN.json +262 -0
  670. teradataml/data/jsons/sqle/17.20/TD_NERExtractor.json +145 -0
  671. teradataml/data/jsons/sqle/17.20/TD_NaiveBayes.json +193 -0
  672. teradataml/data/jsons/sqle/17.20/TD_NaiveBayesPredict.json +212 -0
  673. teradataml/data/jsons/sqle/17.20/TD_NaiveBayesTextClassifierTrainer.json +137 -0
  674. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineFit.json +102 -0
  675. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineTransform.json +71 -0
  676. teradataml/data/jsons/sqle/17.20/TD_NumApply.json +147 -0
  677. teradataml/data/jsons/sqle/17.20/TD_OneClassSVM.json +316 -0
  678. teradataml/data/jsons/sqle/17.20/TD_OneClassSVMPredict.json +124 -0
  679. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingFit.json +271 -0
  680. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingTransform.json +65 -0
  681. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingFit.json +229 -0
  682. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingTransform.json +75 -0
  683. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterFit.json +217 -0
  684. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterTransform.json +48 -0
  685. teradataml/data/jsons/sqle/17.20/TD_Pivoting.json +280 -0
  686. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesFit.json +114 -0
  687. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesTransform.json +72 -0
  688. teradataml/data/jsons/sqle/17.20/TD_QQNorm.json +111 -0
  689. teradataml/data/jsons/sqle/17.20/TD_ROC.json +179 -0
  690. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionFit.json +179 -0
  691. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionMinComponents.json +74 -0
  692. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionTransform.json +74 -0
  693. teradataml/data/jsons/sqle/17.20/TD_RegressionEvaluator.json +138 -0
  694. teradataml/data/jsons/sqle/17.20/TD_RoundColumns.json +93 -0
  695. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeFit.json +128 -0
  696. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeTransform.json +71 -0
  697. teradataml/data/jsons/sqle/17.20/TD_SMOTE.json +267 -0
  698. teradataml/data/jsons/sqle/17.20/TD_SVM.json +389 -0
  699. teradataml/data/jsons/sqle/17.20/TD_SVMPredict.json +142 -0
  700. teradataml/data/jsons/sqle/17.20/TD_ScaleFit.json +310 -0
  701. teradataml/data/jsons/sqle/17.20/TD_ScaleTransform.json +120 -0
  702. teradataml/data/jsons/sqle/17.20/TD_SentimentExtractor.json +194 -0
  703. teradataml/data/jsons/sqle/17.20/TD_Shap.json +221 -0
  704. teradataml/data/jsons/sqle/17.20/TD_Silhouette.json +143 -0
  705. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeFit.json +147 -0
  706. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeTransform.json +48 -0
  707. teradataml/data/jsons/sqle/17.20/TD_StrApply.json +240 -0
  708. teradataml/data/jsons/sqle/17.20/TD_TFIDF.json +162 -0
  709. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingFit.json +248 -0
  710. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingTransform.json +75 -0
  711. teradataml/data/jsons/sqle/17.20/TD_TextMorph.json +134 -0
  712. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +297 -0
  713. teradataml/data/jsons/sqle/17.20/TD_TrainTestSplit.json +142 -0
  714. teradataml/data/jsons/sqle/17.20/TD_UnivariateStatistics.json +117 -0
  715. teradataml/data/jsons/sqle/17.20/TD_Unpivoting.json +235 -0
  716. teradataml/data/jsons/sqle/17.20/TD_VectorDistance.json +183 -0
  717. teradataml/data/jsons/sqle/17.20/TD_WhichMax.json +53 -0
  718. teradataml/data/jsons/sqle/17.20/TD_WhichMin.json +53 -0
  719. teradataml/data/jsons/sqle/17.20/TD_WordEmbeddings.json +241 -0
  720. teradataml/data/jsons/sqle/17.20/TD_XGBoost.json +330 -0
  721. teradataml/data/jsons/sqle/17.20/TD_XGBoostPredict.json +195 -0
  722. teradataml/data/jsons/sqle/17.20/TD_ZTest.json +247 -0
  723. teradataml/data/jsons/sqle/17.20/Unpack.json +188 -0
  724. teradataml/data/jsons/sqle/17.20/nPath.json +269 -0
  725. teradataml/data/jsons/sqle/20.00/AI_AnalyzeSentiment.json +370 -0
  726. teradataml/data/jsons/sqle/20.00/AI_AskLLM.json +460 -0
  727. teradataml/data/jsons/sqle/20.00/AI_DetectLanguage.json +385 -0
  728. teradataml/data/jsons/sqle/20.00/AI_ExtractKeyPhrases.json +369 -0
  729. teradataml/data/jsons/sqle/20.00/AI_MaskPII.json +369 -0
  730. teradataml/data/jsons/sqle/20.00/AI_RecognizeEntities.json +369 -0
  731. teradataml/data/jsons/sqle/20.00/AI_RecognizePIIEntities.json +369 -0
  732. teradataml/data/jsons/sqle/20.00/AI_TextClassifier.json +400 -0
  733. teradataml/data/jsons/sqle/20.00/AI_TextEmbeddings.json +401 -0
  734. teradataml/data/jsons/sqle/20.00/AI_TextSummarize.json +384 -0
  735. teradataml/data/jsons/sqle/20.00/AI_TextTranslate.json +384 -0
  736. teradataml/data/jsons/sqle/20.00/TD_API_AzureML.json +151 -0
  737. teradataml/data/jsons/sqle/20.00/TD_API_Sagemaker.json +182 -0
  738. teradataml/data/jsons/sqle/20.00/TD_API_VertexAI.json +183 -0
  739. teradataml/data/jsons/sqle/20.00/TD_HNSW.json +296 -0
  740. teradataml/data/jsons/sqle/20.00/TD_HNSWPredict.json +206 -0
  741. teradataml/data/jsons/sqle/20.00/TD_HNSWSummary.json +32 -0
  742. teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
  743. teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
  744. teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
  745. teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
  746. teradataml/data/jsons/storedprocedure/17.20/TD_FILTERFACTORY1D.json +150 -0
  747. teradataml/data/jsons/tableoperator/17.00/read_nos.json +198 -0
  748. teradataml/data/jsons/tableoperator/17.05/read_nos.json +198 -0
  749. teradataml/data/jsons/tableoperator/17.05/write_nos.json +195 -0
  750. teradataml/data/jsons/tableoperator/17.10/read_nos.json +184 -0
  751. teradataml/data/jsons/tableoperator/17.10/write_nos.json +195 -0
  752. teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -0
  753. teradataml/data/jsons/tableoperator/17.20/read_nos.json +183 -0
  754. teradataml/data/jsons/tableoperator/17.20/write_nos.json +224 -0
  755. teradataml/data/jsons/uaf/17.20/TD_ACF.json +132 -0
  756. teradataml/data/jsons/uaf/17.20/TD_ARIMAESTIMATE.json +396 -0
  757. teradataml/data/jsons/uaf/17.20/TD_ARIMAFORECAST.json +77 -0
  758. teradataml/data/jsons/uaf/17.20/TD_ARIMAVALIDATE.json +153 -0
  759. teradataml/data/jsons/uaf/17.20/TD_ARIMAXESTIMATE.json +362 -0
  760. teradataml/data/jsons/uaf/17.20/TD_AUTOARIMA.json +469 -0
  761. teradataml/data/jsons/uaf/17.20/TD_BINARYMATRIXOP.json +107 -0
  762. teradataml/data/jsons/uaf/17.20/TD_BINARYSERIESOP.json +106 -0
  763. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_GODFREY.json +89 -0
  764. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_PAGAN_GODFREY.json +104 -0
  765. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE.json +78 -0
  766. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE2.json +66 -0
  767. teradataml/data/jsons/uaf/17.20/TD_CUMUL_PERIODOGRAM.json +87 -0
  768. teradataml/data/jsons/uaf/17.20/TD_DFFT.json +134 -0
  769. teradataml/data/jsons/uaf/17.20/TD_DFFT2.json +144 -0
  770. teradataml/data/jsons/uaf/17.20/TD_DFFT2CONV.json +108 -0
  771. teradataml/data/jsons/uaf/17.20/TD_DFFTCONV.json +108 -0
  772. teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +78 -0
  773. teradataml/data/jsons/uaf/17.20/TD_DIFF.json +92 -0
  774. teradataml/data/jsons/uaf/17.20/TD_DTW.json +114 -0
  775. teradataml/data/jsons/uaf/17.20/TD_DURBIN_WATSON.json +101 -0
  776. teradataml/data/jsons/uaf/17.20/TD_DWT.json +173 -0
  777. teradataml/data/jsons/uaf/17.20/TD_DWT2D.json +160 -0
  778. teradataml/data/jsons/uaf/17.20/TD_EXTRACT_RESULTS.json +39 -0
  779. teradataml/data/jsons/uaf/17.20/TD_FITMETRICS.json +101 -0
  780. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4FORMULA.json +85 -0
  781. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4SINUSOIDS.json +71 -0
  782. teradataml/data/jsons/uaf/17.20/TD_GOLDFELD_QUANDT.json +139 -0
  783. teradataml/data/jsons/uaf/17.20/TD_HOLT_WINTERS_FORECASTER.json +313 -0
  784. teradataml/data/jsons/uaf/17.20/TD_IDFFT.json +58 -0
  785. teradataml/data/jsons/uaf/17.20/TD_IDFFT2.json +81 -0
  786. teradataml/data/jsons/uaf/17.20/TD_IDWT.json +162 -0
  787. teradataml/data/jsons/uaf/17.20/TD_IDWT2D.json +149 -0
  788. teradataml/data/jsons/uaf/17.20/TD_INPUTVALIDATOR.json +64 -0
  789. teradataml/data/jsons/uaf/17.20/TD_IQR.json +117 -0
  790. teradataml/data/jsons/uaf/17.20/TD_LINEAR_REGR.json +182 -0
  791. teradataml/data/jsons/uaf/17.20/TD_LINESPEC.json +103 -0
  792. teradataml/data/jsons/uaf/17.20/TD_MAMEAN.json +181 -0
  793. teradataml/data/jsons/uaf/17.20/TD_MATRIX2IMAGE.json +209 -0
  794. teradataml/data/jsons/uaf/17.20/TD_MATRIXMULTIPLY.json +68 -0
  795. teradataml/data/jsons/uaf/17.20/TD_MINFO.json +67 -0
  796. teradataml/data/jsons/uaf/17.20/TD_MULTIVAR_REGR.json +179 -0
  797. teradataml/data/jsons/uaf/17.20/TD_PACF.json +114 -0
  798. teradataml/data/jsons/uaf/17.20/TD_PORTMAN.json +119 -0
  799. teradataml/data/jsons/uaf/17.20/TD_POWERSPEC.json +175 -0
  800. teradataml/data/jsons/uaf/17.20/TD_POWERTRANSFORM.json +98 -0
  801. teradataml/data/jsons/uaf/17.20/TD_RESAMPLE.json +194 -0
  802. teradataml/data/jsons/uaf/17.20/TD_SAX.json +210 -0
  803. teradataml/data/jsons/uaf/17.20/TD_SEASONALNORMALIZE.json +143 -0
  804. teradataml/data/jsons/uaf/17.20/TD_SELECTION_CRITERIA.json +90 -0
  805. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_PERIODICITIES.json +80 -0
  806. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_RESIDMEAN.json +68 -0
  807. teradataml/data/jsons/uaf/17.20/TD_SIMPLEEXP.json +184 -0
  808. teradataml/data/jsons/uaf/17.20/TD_SINFO.json +58 -0
  809. teradataml/data/jsons/uaf/17.20/TD_SMOOTHMA.json +163 -0
  810. teradataml/data/jsons/uaf/17.20/TD_TRACKINGOP.json +101 -0
  811. teradataml/data/jsons/uaf/17.20/TD_UNDIFF.json +112 -0
  812. teradataml/data/jsons/uaf/17.20/TD_UNNORMALIZE.json +95 -0
  813. teradataml/data/jsons/uaf/17.20/TD_WHITES_GENERAL.json +78 -0
  814. teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +410 -0
  815. teradataml/data/kmeans_example.json +23 -0
  816. teradataml/data/kmeans_table.csv +10 -0
  817. teradataml/data/kmeans_us_arrests_data.csv +51 -0
  818. teradataml/data/knn_example.json +19 -0
  819. teradataml/data/knnrecommender_example.json +7 -0
  820. teradataml/data/knnrecommenderpredict_example.json +12 -0
  821. teradataml/data/lar_example.json +17 -0
  822. teradataml/data/larpredict_example.json +30 -0
  823. teradataml/data/lc_new_predictors.csv +5 -0
  824. teradataml/data/lc_new_reference.csv +9 -0
  825. teradataml/data/lda_example.json +9 -0
  826. teradataml/data/ldainference_example.json +15 -0
  827. teradataml/data/ldatopicsummary_example.json +9 -0
  828. teradataml/data/levendist_input.csv +13 -0
  829. teradataml/data/levenshteindistance_example.json +10 -0
  830. teradataml/data/linreg_example.json +10 -0
  831. teradataml/data/load_example_data.py +350 -0
  832. teradataml/data/loan_prediction.csv +295 -0
  833. teradataml/data/lungcancer.csv +138 -0
  834. teradataml/data/mappingdata.csv +12 -0
  835. teradataml/data/medical_readings.csv +101 -0
  836. teradataml/data/milk_timeseries.csv +157 -0
  837. teradataml/data/min_max_titanic.csv +4 -0
  838. teradataml/data/minhash_example.json +6 -0
  839. teradataml/data/ml_ratings.csv +7547 -0
  840. teradataml/data/ml_ratings_10.csv +2445 -0
  841. teradataml/data/mobile_data.csv +13 -0
  842. teradataml/data/model1_table.csv +5 -0
  843. teradataml/data/model2_table.csv +5 -0
  844. teradataml/data/models/License_file.txt +1 -0
  845. teradataml/data/models/License_file_empty.txt +0 -0
  846. teradataml/data/models/dataiku_iris_data_ann_thin +0 -0
  847. teradataml/data/models/dr_iris_rf +0 -0
  848. teradataml/data/models/iris_db_dt_model_sklearn.onnx +0 -0
  849. teradataml/data/models/iris_db_dt_model_sklearn_floattensor.onnx +0 -0
  850. teradataml/data/models/iris_db_glm_model.pmml +57 -0
  851. teradataml/data/models/iris_db_xgb_model.pmml +4471 -0
  852. teradataml/data/models/iris_kmeans_model +0 -0
  853. teradataml/data/models/iris_mojo_glm_h2o_model +0 -0
  854. teradataml/data/models/iris_mojo_xgb_h2o_model +0 -0
  855. teradataml/data/modularity_example.json +12 -0
  856. teradataml/data/movavg_example.json +8 -0
  857. teradataml/data/mtx1.csv +7 -0
  858. teradataml/data/mtx2.csv +13 -0
  859. teradataml/data/multi_model_classification.csv +401 -0
  860. teradataml/data/multi_model_regression.csv +401 -0
  861. teradataml/data/mvdfft8.csv +9 -0
  862. teradataml/data/naivebayes_example.json +10 -0
  863. teradataml/data/naivebayespredict_example.json +19 -0
  864. teradataml/data/naivebayestextclassifier2_example.json +7 -0
  865. teradataml/data/naivebayestextclassifier_example.json +8 -0
  866. teradataml/data/naivebayestextclassifierpredict_example.json +32 -0
  867. teradataml/data/name_Find_configure.csv +10 -0
  868. teradataml/data/namedentityfinder_example.json +14 -0
  869. teradataml/data/namedentityfinderevaluator_example.json +10 -0
  870. teradataml/data/namedentityfindertrainer_example.json +6 -0
  871. teradataml/data/nb_iris_input_test.csv +31 -0
  872. teradataml/data/nb_iris_input_train.csv +121 -0
  873. teradataml/data/nbp_iris_model.csv +13 -0
  874. teradataml/data/ner_dict.csv +8 -0
  875. teradataml/data/ner_extractor_text.csv +2 -0
  876. teradataml/data/ner_input_eng.csv +7 -0
  877. teradataml/data/ner_rule.csv +5 -0
  878. teradataml/data/ner_sports_test2.csv +29 -0
  879. teradataml/data/ner_sports_train.csv +501 -0
  880. teradataml/data/nerevaluator_example.json +6 -0
  881. teradataml/data/nerextractor_example.json +18 -0
  882. teradataml/data/nermem_sports_test.csv +18 -0
  883. teradataml/data/nermem_sports_train.csv +51 -0
  884. teradataml/data/nertrainer_example.json +7 -0
  885. teradataml/data/ngrams_example.json +7 -0
  886. teradataml/data/notebooks/__init__.py +0 -0
  887. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Aggregate Functions using SQLAlchemy.ipynb +1455 -0
  888. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Arithmetic Functions Using SQLAlchemy.ipynb +1993 -0
  889. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Bit-Byte Manipulation Functions using SQLAlchemy.ipynb +1492 -0
  890. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Built-in functions using SQLAlchemy.ipynb +536 -0
  891. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Regular Expressions Using SQLAlchemy.ipynb +570 -0
  892. teradataml/data/notebooks/sqlalchemy/Teradata Vantage String Functions Using SQLAlchemy.ipynb +2559 -0
  893. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Window Aggregate Functions using SQLAlchemy.ipynb +2911 -0
  894. teradataml/data/notebooks/sqlalchemy/Using Generic SQLAlchemy ClauseElements teradataml DataFrame assign method.ipynb +698 -0
  895. teradataml/data/notebooks/sqlalchemy/__init__.py +0 -0
  896. teradataml/data/notebooks/sqlalchemy/teradataml filtering using SQLAlchemy ClauseElements.ipynb +784 -0
  897. teradataml/data/npath_example.json +23 -0
  898. teradataml/data/ntree_example.json +14 -0
  899. teradataml/data/numeric_strings.csv +5 -0
  900. teradataml/data/numerics.csv +4 -0
  901. teradataml/data/ocean_buoy.csv +17 -0
  902. teradataml/data/ocean_buoy2.csv +17 -0
  903. teradataml/data/ocean_buoys.csv +28 -0
  904. teradataml/data/ocean_buoys2.csv +10 -0
  905. teradataml/data/ocean_buoys_nonpti.csv +28 -0
  906. teradataml/data/ocean_buoys_seq.csv +29 -0
  907. teradataml/data/onehot_encoder_train.csv +4 -0
  908. teradataml/data/openml_example.json +92 -0
  909. teradataml/data/optional_event_table.csv +4 -0
  910. teradataml/data/orders1.csv +11 -0
  911. teradataml/data/orders1_12.csv +13 -0
  912. teradataml/data/orders_ex.csv +4 -0
  913. teradataml/data/pack_example.json +9 -0
  914. teradataml/data/package_tracking.csv +19 -0
  915. teradataml/data/package_tracking_pti.csv +19 -0
  916. teradataml/data/pagerank_example.json +13 -0
  917. teradataml/data/paragraphs_input.csv +6 -0
  918. teradataml/data/pathanalyzer_example.json +8 -0
  919. teradataml/data/pathgenerator_example.json +8 -0
  920. teradataml/data/patient_profile.csv +101 -0
  921. teradataml/data/pattern_matching_data.csv +11 -0
  922. teradataml/data/payment_fraud_dataset.csv +10001 -0
  923. teradataml/data/peppers.png +0 -0
  924. teradataml/data/phrases.csv +7 -0
  925. teradataml/data/pivot_example.json +9 -0
  926. teradataml/data/pivot_input.csv +22 -0
  927. teradataml/data/playerRating.csv +31 -0
  928. teradataml/data/pos_input.csv +40 -0
  929. teradataml/data/postagger_example.json +7 -0
  930. teradataml/data/posttagger_output.csv +44 -0
  931. teradataml/data/production_data.csv +17 -0
  932. teradataml/data/production_data2.csv +7 -0
  933. teradataml/data/randomsample_example.json +32 -0
  934. teradataml/data/randomwalksample_example.json +9 -0
  935. teradataml/data/rank_table.csv +6 -0
  936. teradataml/data/real_values.csv +14 -0
  937. teradataml/data/ref_mobile_data.csv +4 -0
  938. teradataml/data/ref_mobile_data_dense.csv +2 -0
  939. teradataml/data/ref_url.csv +17 -0
  940. teradataml/data/restaurant_reviews.csv +7 -0
  941. teradataml/data/retail_churn_table.csv +27772 -0
  942. teradataml/data/river_data.csv +145 -0
  943. teradataml/data/roc_example.json +8 -0
  944. teradataml/data/roc_input.csv +101 -0
  945. teradataml/data/rule_inputs.csv +6 -0
  946. teradataml/data/rule_table.csv +2 -0
  947. teradataml/data/sales.csv +7 -0
  948. teradataml/data/sales_transaction.csv +501 -0
  949. teradataml/data/salesdata.csv +342 -0
  950. teradataml/data/sample_cities.csv +3 -0
  951. teradataml/data/sample_shapes.csv +11 -0
  952. teradataml/data/sample_streets.csv +3 -0
  953. teradataml/data/sampling_example.json +16 -0
  954. teradataml/data/sax_example.json +17 -0
  955. teradataml/data/scale_attributes.csv +3 -0
  956. teradataml/data/scale_example.json +74 -0
  957. teradataml/data/scale_housing.csv +11 -0
  958. teradataml/data/scale_housing_test.csv +6 -0
  959. teradataml/data/scale_input_part_sparse.csv +31 -0
  960. teradataml/data/scale_input_partitioned.csv +16 -0
  961. teradataml/data/scale_input_sparse.csv +11 -0
  962. teradataml/data/scale_parameters.csv +3 -0
  963. teradataml/data/scale_stat.csv +11 -0
  964. teradataml/data/scalebypartition_example.json +13 -0
  965. teradataml/data/scalemap_example.json +13 -0
  966. teradataml/data/scalesummary_example.json +12 -0
  967. teradataml/data/score_category.csv +101 -0
  968. teradataml/data/score_summary.csv +4 -0
  969. teradataml/data/script_example.json +10 -0
  970. teradataml/data/scripts/deploy_script.py +84 -0
  971. teradataml/data/scripts/lightgbm/dataset.template +175 -0
  972. teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +264 -0
  973. teradataml/data/scripts/lightgbm/lightgbm_function.template +234 -0
  974. teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +177 -0
  975. teradataml/data/scripts/mapper.R +20 -0
  976. teradataml/data/scripts/mapper.py +16 -0
  977. teradataml/data/scripts/mapper_replace.py +16 -0
  978. teradataml/data/scripts/sklearn/__init__.py +0 -0
  979. teradataml/data/scripts/sklearn/sklearn_fit.py +205 -0
  980. teradataml/data/scripts/sklearn/sklearn_fit_predict.py +148 -0
  981. teradataml/data/scripts/sklearn/sklearn_function.template +144 -0
  982. teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +166 -0
  983. teradataml/data/scripts/sklearn/sklearn_neighbors.py +161 -0
  984. teradataml/data/scripts/sklearn/sklearn_score.py +145 -0
  985. teradataml/data/scripts/sklearn/sklearn_transform.py +327 -0
  986. teradataml/data/sdk/modelops/modelops_spec.json +101737 -0
  987. teradataml/data/seeds.csv +10 -0
  988. teradataml/data/sentenceextractor_example.json +7 -0
  989. teradataml/data/sentiment_extract_input.csv +11 -0
  990. teradataml/data/sentiment_train.csv +16 -0
  991. teradataml/data/sentiment_word.csv +20 -0
  992. teradataml/data/sentiment_word_input.csv +20 -0
  993. teradataml/data/sentimentextractor_example.json +24 -0
  994. teradataml/data/sentimenttrainer_example.json +8 -0
  995. teradataml/data/sequence_table.csv +10 -0
  996. teradataml/data/seriessplitter_example.json +8 -0
  997. teradataml/data/sessionize_example.json +17 -0
  998. teradataml/data/sessionize_table.csv +116 -0
  999. teradataml/data/setop_test1.csv +24 -0
  1000. teradataml/data/setop_test2.csv +22 -0
  1001. teradataml/data/soc_nw_edges.csv +11 -0
  1002. teradataml/data/soc_nw_vertices.csv +8 -0
  1003. teradataml/data/souvenir_timeseries.csv +168 -0
  1004. teradataml/data/sparse_iris_attribute.csv +5 -0
  1005. teradataml/data/sparse_iris_test.csv +121 -0
  1006. teradataml/data/sparse_iris_train.csv +601 -0
  1007. teradataml/data/star1.csv +6 -0
  1008. teradataml/data/star_pivot.csv +8 -0
  1009. teradataml/data/state_transition.csv +5 -0
  1010. teradataml/data/stock_data.csv +53 -0
  1011. teradataml/data/stock_movement.csv +11 -0
  1012. teradataml/data/stock_vol.csv +76 -0
  1013. teradataml/data/stop_words.csv +8 -0
  1014. teradataml/data/store_sales.csv +37 -0
  1015. teradataml/data/stringsimilarity_example.json +8 -0
  1016. teradataml/data/strsimilarity_input.csv +13 -0
  1017. teradataml/data/students.csv +101 -0
  1018. teradataml/data/svm_iris_input_test.csv +121 -0
  1019. teradataml/data/svm_iris_input_train.csv +481 -0
  1020. teradataml/data/svm_iris_model.csv +7 -0
  1021. teradataml/data/svmdense_example.json +10 -0
  1022. teradataml/data/svmdensepredict_example.json +19 -0
  1023. teradataml/data/svmsparse_example.json +8 -0
  1024. teradataml/data/svmsparsepredict_example.json +14 -0
  1025. teradataml/data/svmsparsesummary_example.json +8 -0
  1026. teradataml/data/target_mobile_data.csv +13 -0
  1027. teradataml/data/target_mobile_data_dense.csv +5 -0
  1028. teradataml/data/target_udt_data.csv +8 -0
  1029. teradataml/data/tdnerextractor_example.json +14 -0
  1030. teradataml/data/templatedata.csv +1201 -0
  1031. teradataml/data/templates/open_source_ml.json +11 -0
  1032. teradataml/data/teradata_icon.ico +0 -0
  1033. teradataml/data/teradataml_example.json +1473 -0
  1034. teradataml/data/test_classification.csv +101 -0
  1035. teradataml/data/test_loan_prediction.csv +53 -0
  1036. teradataml/data/test_pacf_12.csv +37 -0
  1037. teradataml/data/test_prediction.csv +101 -0
  1038. teradataml/data/test_regression.csv +101 -0
  1039. teradataml/data/test_river2.csv +109 -0
  1040. teradataml/data/text_inputs.csv +6 -0
  1041. teradataml/data/textchunker_example.json +8 -0
  1042. teradataml/data/textclassifier_example.json +7 -0
  1043. teradataml/data/textclassifier_input.csv +7 -0
  1044. teradataml/data/textclassifiertrainer_example.json +7 -0
  1045. teradataml/data/textmorph_example.json +11 -0
  1046. teradataml/data/textparser_example.json +15 -0
  1047. teradataml/data/texttagger_example.json +12 -0
  1048. teradataml/data/texttokenizer_example.json +7 -0
  1049. teradataml/data/texttrainer_input.csv +11 -0
  1050. teradataml/data/tf_example.json +7 -0
  1051. teradataml/data/tfidf_example.json +14 -0
  1052. teradataml/data/tfidf_input1.csv +201 -0
  1053. teradataml/data/tfidf_train.csv +6 -0
  1054. teradataml/data/time_table1.csv +535 -0
  1055. teradataml/data/time_table2.csv +14 -0
  1056. teradataml/data/timeseriesdata.csv +1601 -0
  1057. teradataml/data/timeseriesdatasetsd4.csv +105 -0
  1058. teradataml/data/timestamp_data.csv +4 -0
  1059. teradataml/data/titanic.csv +892 -0
  1060. teradataml/data/titanic_dataset_unpivoted.csv +19 -0
  1061. teradataml/data/to_num_data.csv +4 -0
  1062. teradataml/data/tochar_data.csv +5 -0
  1063. teradataml/data/token_table.csv +696 -0
  1064. teradataml/data/train_multiclass.csv +101 -0
  1065. teradataml/data/train_regression.csv +101 -0
  1066. teradataml/data/train_regression_multiple_labels.csv +101 -0
  1067. teradataml/data/train_tracking.csv +28 -0
  1068. teradataml/data/trans_dense.csv +16 -0
  1069. teradataml/data/trans_sparse.csv +55 -0
  1070. teradataml/data/transformation_table.csv +6 -0
  1071. teradataml/data/transformation_table_new.csv +2 -0
  1072. teradataml/data/tv_spots.csv +16 -0
  1073. teradataml/data/twod_climate_data.csv +117 -0
  1074. teradataml/data/uaf_example.json +529 -0
  1075. teradataml/data/univariatestatistics_example.json +9 -0
  1076. teradataml/data/unpack_example.json +10 -0
  1077. teradataml/data/unpivot_example.json +25 -0
  1078. teradataml/data/unpivot_input.csv +8 -0
  1079. teradataml/data/url_data.csv +10 -0
  1080. teradataml/data/us_air_pass.csv +37 -0
  1081. teradataml/data/us_population.csv +624 -0
  1082. teradataml/data/us_states_shapes.csv +52 -0
  1083. teradataml/data/varmax_example.json +18 -0
  1084. teradataml/data/vectordistance_example.json +30 -0
  1085. teradataml/data/ville_climatedata.csv +121 -0
  1086. teradataml/data/ville_tempdata.csv +12 -0
  1087. teradataml/data/ville_tempdata1.csv +12 -0
  1088. teradataml/data/ville_temperature.csv +11 -0
  1089. teradataml/data/waveletTable.csv +1605 -0
  1090. teradataml/data/waveletTable2.csv +1605 -0
  1091. teradataml/data/weightedmovavg_example.json +9 -0
  1092. teradataml/data/wft_testing.csv +5 -0
  1093. teradataml/data/windowdfft.csv +16 -0
  1094. teradataml/data/wine_data.csv +1600 -0
  1095. teradataml/data/word_embed_input_table1.csv +6 -0
  1096. teradataml/data/word_embed_input_table2.csv +5 -0
  1097. teradataml/data/word_embed_model.csv +23 -0
  1098. teradataml/data/words_input.csv +13 -0
  1099. teradataml/data/xconvolve_complex_left.csv +6 -0
  1100. teradataml/data/xconvolve_complex_leftmulti.csv +6 -0
  1101. teradataml/data/xgboost_example.json +36 -0
  1102. teradataml/data/xgboostpredict_example.json +32 -0
  1103. teradataml/data/ztest_example.json +16 -0
  1104. teradataml/dataframe/__init__.py +0 -0
  1105. teradataml/dataframe/copy_to.py +2446 -0
  1106. teradataml/dataframe/data_transfer.py +2840 -0
  1107. teradataml/dataframe/dataframe.py +20908 -0
  1108. teradataml/dataframe/dataframe_utils.py +2114 -0
  1109. teradataml/dataframe/fastload.py +794 -0
  1110. teradataml/dataframe/functions.py +2110 -0
  1111. teradataml/dataframe/indexer.py +424 -0
  1112. teradataml/dataframe/row.py +160 -0
  1113. teradataml/dataframe/setop.py +1171 -0
  1114. teradataml/dataframe/sql.py +10904 -0
  1115. teradataml/dataframe/sql_function_parameters.py +440 -0
  1116. teradataml/dataframe/sql_functions.py +652 -0
  1117. teradataml/dataframe/sql_interfaces.py +220 -0
  1118. teradataml/dataframe/vantage_function_types.py +675 -0
  1119. teradataml/dataframe/window.py +694 -0
  1120. teradataml/dbutils/__init__.py +3 -0
  1121. teradataml/dbutils/dbutils.py +2871 -0
  1122. teradataml/dbutils/filemgr.py +318 -0
  1123. teradataml/gen_ai/__init__.py +2 -0
  1124. teradataml/gen_ai/convAI.py +473 -0
  1125. teradataml/geospatial/__init__.py +4 -0
  1126. teradataml/geospatial/geodataframe.py +1105 -0
  1127. teradataml/geospatial/geodataframecolumn.py +392 -0
  1128. teradataml/geospatial/geometry_types.py +926 -0
  1129. teradataml/hyperparameter_tuner/__init__.py +1 -0
  1130. teradataml/hyperparameter_tuner/optimizer.py +4115 -0
  1131. teradataml/hyperparameter_tuner/utils.py +303 -0
  1132. teradataml/lib/__init__.py +0 -0
  1133. teradataml/lib/aed_0_1.dll +0 -0
  1134. teradataml/lib/libaed_0_1.dylib +0 -0
  1135. teradataml/lib/libaed_0_1.so +0 -0
  1136. teradataml/lib/libaed_0_1_aarch64.so +0 -0
  1137. teradataml/lib/libaed_0_1_ppc64le.so +0 -0
  1138. teradataml/opensource/__init__.py +1 -0
  1139. teradataml/opensource/_base.py +1321 -0
  1140. teradataml/opensource/_class.py +464 -0
  1141. teradataml/opensource/_constants.py +61 -0
  1142. teradataml/opensource/_lightgbm.py +949 -0
  1143. teradataml/opensource/_sklearn.py +1008 -0
  1144. teradataml/opensource/_wrapper_utils.py +267 -0
  1145. teradataml/options/__init__.py +148 -0
  1146. teradataml/options/configure.py +489 -0
  1147. teradataml/options/display.py +187 -0
  1148. teradataml/plot/__init__.py +3 -0
  1149. teradataml/plot/axis.py +1427 -0
  1150. teradataml/plot/constants.py +15 -0
  1151. teradataml/plot/figure.py +431 -0
  1152. teradataml/plot/plot.py +810 -0
  1153. teradataml/plot/query_generator.py +83 -0
  1154. teradataml/plot/subplot.py +216 -0
  1155. teradataml/scriptmgmt/UserEnv.py +4273 -0
  1156. teradataml/scriptmgmt/__init__.py +3 -0
  1157. teradataml/scriptmgmt/lls_utils.py +2157 -0
  1158. teradataml/sdk/README.md +79 -0
  1159. teradataml/sdk/__init__.py +4 -0
  1160. teradataml/sdk/_auth_modes.py +422 -0
  1161. teradataml/sdk/_func_params.py +487 -0
  1162. teradataml/sdk/_json_parser.py +453 -0
  1163. teradataml/sdk/_openapi_spec_constants.py +249 -0
  1164. teradataml/sdk/_utils.py +236 -0
  1165. teradataml/sdk/api_client.py +900 -0
  1166. teradataml/sdk/constants.py +62 -0
  1167. teradataml/sdk/modelops/__init__.py +98 -0
  1168. teradataml/sdk/modelops/_client.py +409 -0
  1169. teradataml/sdk/modelops/_constants.py +304 -0
  1170. teradataml/sdk/modelops/models.py +2308 -0
  1171. teradataml/sdk/spinner.py +107 -0
  1172. teradataml/series/__init__.py +0 -0
  1173. teradataml/series/series.py +537 -0
  1174. teradataml/series/series_utils.py +71 -0
  1175. teradataml/store/__init__.py +12 -0
  1176. teradataml/store/feature_store/__init__.py +0 -0
  1177. teradataml/store/feature_store/constants.py +658 -0
  1178. teradataml/store/feature_store/feature_store.py +4814 -0
  1179. teradataml/store/feature_store/mind_map.py +639 -0
  1180. teradataml/store/feature_store/models.py +7330 -0
  1181. teradataml/store/feature_store/utils.py +390 -0
  1182. teradataml/table_operators/Apply.py +979 -0
  1183. teradataml/table_operators/Script.py +1739 -0
  1184. teradataml/table_operators/TableOperator.py +1343 -0
  1185. teradataml/table_operators/__init__.py +2 -0
  1186. teradataml/table_operators/apply_query_generator.py +262 -0
  1187. teradataml/table_operators/query_generator.py +493 -0
  1188. teradataml/table_operators/table_operator_query_generator.py +462 -0
  1189. teradataml/table_operators/table_operator_util.py +726 -0
  1190. teradataml/table_operators/templates/dataframe_apply.template +184 -0
  1191. teradataml/table_operators/templates/dataframe_map.template +176 -0
  1192. teradataml/table_operators/templates/dataframe_register.template +73 -0
  1193. teradataml/table_operators/templates/dataframe_udf.template +67 -0
  1194. teradataml/table_operators/templates/script_executor.template +170 -0
  1195. teradataml/telemetry_utils/__init__.py +0 -0
  1196. teradataml/telemetry_utils/queryband.py +53 -0
  1197. teradataml/utils/__init__.py +0 -0
  1198. teradataml/utils/docstring.py +527 -0
  1199. teradataml/utils/dtypes.py +943 -0
  1200. teradataml/utils/internal_buffer.py +122 -0
  1201. teradataml/utils/print_versions.py +206 -0
  1202. teradataml/utils/utils.py +451 -0
  1203. teradataml/utils/validators.py +3305 -0
  1204. teradataml-20.0.0.8.dist-info/METADATA +2804 -0
  1205. teradataml-20.0.0.8.dist-info/RECORD +1208 -0
  1206. teradataml-20.0.0.8.dist-info/WHEEL +5 -0
  1207. teradataml-20.0.0.8.dist-info/top_level.txt +1 -0
  1208. teradataml-20.0.0.8.dist-info/zip-safe +1 -0
@@ -0,0 +1,4273 @@
1
+ #!/usr/bin/python
2
+ # ####################################################################
3
+ #
4
+ # Copyright (c) 2023 by Teradata Corporation. All rights reserved.
5
+ # TERADATA CORPORATION CONFIDENTIAL AND TRADE SECRET
6
+ #
7
+ # Primary Owner: Pradeep Garre (pradeep.garre@teradata.com)
8
+ # Secondary Owner: Pankaj Purandare (pankajvinod.purandare@teradata.com)
9
+ #
10
+ # Version: 1.0
11
+ # Represents remote user environment from Vantage Languages Ecosystem.
12
+ # ####################################################################
13
+
14
+ import functools
15
+ import inspect
16
+ import json
17
+ import os
18
+ import tempfile
19
+ import time
20
+ from concurrent.futures import ThreadPoolExecutor, wait
21
+ from json.decoder import JSONDecodeError
22
+ from urllib.parse import urlparse
23
+
24
+ import pandas as pd
25
+
26
+ from teradataml import configure
27
+ from teradataml.clients.pkce_client import _DAWorkflow
28
+ from teradataml.common.constants import (AsyncOpStatus, CloudProvider,
29
+ HTTPRequest, AsyncOpStatusOAFColumns)
30
+ from teradataml.common.exceptions import TeradataMlException
31
+ from teradataml.common.messagecodes import MessageCodes
32
+ from teradataml.common.messages import Messages
33
+ from teradataml.common.utils import UtilFuncs
34
+ from teradataml.context.context import _get_user
35
+ from teradataml.telemetry_utils.queryband import collect_queryband
36
+ from teradataml.utils.internal_buffer import _InternalBuffer
37
+ from teradataml.utils.validators import _Validators
38
+
39
+
40
+ def _get_ues_url(env_type="users", **kwargs):
41
+ """
42
+ DESCRIPTION:
43
+ Function to get the URL for inititating REST call to UES.
44
+
45
+ PARAMETERS:
46
+ env_type:
47
+ Optional Argument.
48
+ Specifies the type of resource in URL.
49
+ Default Value: users
50
+ Types: str
51
+
52
+ api_name:
53
+ Optional Argument.
54
+ Specifies the name of the teradataml UES API to mention in the error message.
55
+ Types: str
56
+
57
+ kwargs:
58
+ Specifies keyword arguments that can be passed to get the URL.
59
+
60
+ RETURNS:
61
+ str
62
+
63
+ RAISES:
64
+ TeradataMlException, RuntimeError
65
+
66
+ EXAMPLES:
67
+ >>> _get_ues_url("base_environments") # URL for listing base environments.
68
+ >>> _get_ues_url() # URL to create/remove/list the user environment(s).
69
+ >>> _get_ues_url(remove_all_envs=True) # URL requires for remove_all_envs().
70
+ >>> _get_ues_url(logs=True, query_id='307161028465226056') # URL requires for query-logs.
71
+ >>> _get_ues_url(env_name="alice_env") # URL to delete/list files in an environment.
72
+ >>> _get_ues_url(env_name="alice_env", files=True, api_name="install_file") # URL to install/replace file in environment.
73
+ >>> _get_ues_url(env_name="alice_env", files=True, file_name="a.py") # URL to remove a file in environment.
74
+ >>> _get_ues_url(env_name="alice_env", libs=True, api_name="libs") # URL to install/uninstall/update/list library in environment.
75
+ >>> _get_ues_url(env_type="fm", claim_id="123-456", api_name=status) # URL for checking the task status.
76
+ >>> _get_ues_url(env_type="fm", fm_type="export", claim_id="123-456") # URL for exporting a file.
77
+ >>> _get_ues_url(env_type="fm", fm_type="import", api_name="install_file") # URL for generating end point to upload file.
78
+ >>> _get_ues_url(env_name=self.env_name, files=True, is_property=True, api_name="files") # URL for listing down the files.
79
+ """
80
+ api_name = kwargs.pop("api_name", inspect.stack()[1].function)
81
+ conda_env = kwargs.get("conda_env", False)
82
+
83
+ # Raise error if user is not connected to Vantage.
84
+ if _get_user() is None:
85
+ error_msg = Messages.get_message(MessageCodes.FUNC_EXECUTION_FAILED,
86
+ api_name,
87
+ "Create context before using {}.".format(api_name))
88
+ raise TeradataMlException(error_msg, MessageCodes.FUNC_EXECUTION_FAILED)
89
+
90
+ if configure.ues_url is None:
91
+ error_msg = Messages.get_message(MessageCodes.SET_REQUIRED_PARAMS,
92
+ 'Authentication Token', api_name, 'set_auth_token')
93
+ raise RuntimeError(error_msg)
94
+
95
+ ues_url = "{}/{}".format(configure.ues_url, env_type)
96
+
97
+ if kwargs.get("remove_all_envs", False):
98
+ return "{0}/{1}".format(ues_url, _get_user())
99
+ if kwargs.get("logs", False):
100
+ return "{0}/{1}/{2}/{3}".format(ues_url, _get_user(), 'query-logs', kwargs['query_id'])
101
+
102
+ if env_type not in ("users", "fm"):
103
+ return ues_url
104
+
105
+ elif env_type == "fm":
106
+ fm_type = kwargs.get("fm_type")
107
+ if fm_type == "import":
108
+ return "{}/import".format(ues_url)
109
+ elif fm_type == "export":
110
+ return "{}/export/{}".format(ues_url, kwargs["claim_id"])
111
+ else:
112
+ return "{}/users/{}/{}/tasks/{}".format(configure.ues_url,
113
+ _get_user(),
114
+ env_type, kwargs["claim_id"])
115
+
116
+ # We will reach here to process "users" env type.
117
+ env_type = "environments"
118
+ if conda_env:
119
+ env_type = "conda-environments"
120
+
121
+ ues_url = "{0}/{1}/{2}".format(ues_url, _get_user(), env_type)
122
+ env_name, files, libs = kwargs.get("env_name"), kwargs.get("files", False), kwargs.get("libs", False)
123
+ models = kwargs.get("models", False)
124
+
125
+ if env_name is not None:
126
+ ues_url = "{0}/{1}".format(ues_url, env_name)
127
+
128
+ if files:
129
+ ues_url = "{0}/{1}".format(ues_url, "files")
130
+ file_name = kwargs.get("file_name")
131
+ if file_name is not None:
132
+ ues_url = "{0}/{1}".format(ues_url, file_name)
133
+ elif libs:
134
+ ues_url = "{0}/{1}".format(ues_url, "libraries")
135
+ elif models:
136
+ ues_url = "{0}/{1}".format(ues_url, "models")
137
+ return ues_url
138
+
139
+
140
+ def _process_ues_response(api_name, response, success_status_code=None):
141
+ """
142
+ DESCRIPTION:
143
+ Function to process and validate the UES Response.
144
+
145
+ PARAMETERS:
146
+ api_name:
147
+ Required Argument.
148
+ Specifies the name of the teradataml UES API.
149
+ Types: str
150
+
151
+ response:
152
+ Required Argument.
153
+ Specifies the response recieved from UES.
154
+ Types: requests.Response
155
+
156
+ success_status_code:
157
+ Optional Argument.
158
+ Specifies the expected success status code for the corresponding UES API.
159
+ Default Value: None
160
+ Types: int
161
+
162
+ RETURNS:
163
+ Response object.
164
+
165
+ RAISES:
166
+ TeradataMlException.
167
+
168
+ EXAMPLES:
169
+ >>> _process_ues_response("list_base_envs", resp)
170
+ """
171
+ try:
172
+ # Success status code ranges between 200-300.
173
+ if (success_status_code is None and 200 <= response.status_code < 300) or \
174
+ (success_status_code == response.status_code):
175
+ return response
176
+
177
+ # teradataml API got an error response. Error response is expected as follows -
178
+ # {
179
+ # "status": 404,
180
+ # "req_id": "1122.3.1",
181
+ # "error_code": "201",
182
+ # "error_description": "Environment not found."
183
+ # }
184
+ # Extract the fields and raise error accordingly.
185
+
186
+ add_paranthesis = lambda msg: "({})".format(msg) if msg else msg
187
+
188
+ data = response.json()
189
+ request_id = add_paranthesis(data.get("req_id", ""))
190
+ error_code = add_paranthesis(data.get("error_code", ""))
191
+ error_description = "{}{} {}".format(request_id, error_code, data.get("error_description",
192
+ response.text))
193
+
194
+ exception_message = "Request Failed - {}".format(error_description)
195
+
196
+ error_msg = Messages.get_message(MessageCodes.FUNC_EXECUTION_FAILED,
197
+ api_name,
198
+ exception_message)
199
+ raise TeradataMlException(error_msg, MessageCodes.FUNC_EXECUTION_FAILED)
200
+
201
+ # teradataml API may not get a Json API response in some cases.
202
+ # So, raise an error with the response received as it is.
203
+ except JSONDecodeError:
204
+ error_msg = Messages.get_message(MessageCodes.FUNC_EXECUTION_FAILED,
205
+ api_name,
206
+ response.text)
207
+ raise TeradataMlException(error_msg, MessageCodes.FUNC_EXECUTION_FAILED)
208
+
209
+
210
+ def _get_auth_token():
211
+ """
212
+ DESCRIPTION:
213
+ Internal function to get authentication token required to access services
214
+ running on Teradata Vantage.
215
+
216
+ PARAMETERS:
217
+ None
218
+
219
+ RETURNS:
220
+ dict
221
+
222
+ RAISES:
223
+ TeradataMlException
224
+
225
+ EXAMPLES:
226
+ >>>_get_auth_token()
227
+ """
228
+ # Check the current time. If token is expiring, get another one from refresh token.
229
+ if configure._oauth:
230
+ if configure._auth_token_expiry_time and time.time() > configure._auth_token_expiry_time:
231
+ # Extract the base URL from "ues_url".
232
+ ues_url = configure.ues_url
233
+ client_id = configure._oauth_client_id
234
+
235
+ url_parser = urlparse(ues_url)
236
+ base_url = "{}://{}".format(url_parser.scheme, url_parser.netloc)
237
+
238
+ # Get the JWT Token details.
239
+ da_wf = _DAWorkflow(base_url, client_id)
240
+ token_data = da_wf._get_token_data()
241
+
242
+ # Replace the options with new values.
243
+ configure._auth_token_expiry_time = time.time() + token_data["expires_in"] - 15
244
+
245
+ # Store the jwt token in internal class attribute.
246
+ _InternalBuffer.add(auth_token=_AuthToken(token=token_data["access_token"],
247
+ auth_type='bearer'))
248
+
249
+ auth_token = _InternalBuffer.get("auth_token")
250
+ if auth_token:
251
+ return auth_token.get_header()
252
+
253
+
254
+ def _get_ccp_url(base_url):
255
+ """
256
+ DESCRIPTION:
257
+ Internal function to get ccp URL from base_url.
258
+
259
+ PARAMETERS:
260
+ base_url:
261
+ Required Argument.
262
+ Specifies the base url.
263
+ Types: str
264
+
265
+ RETURNS:
266
+ str
267
+
268
+ RAISES:
269
+ None
270
+
271
+ EXAMPLES:
272
+ >>> base_url = 'https://<part_1>.<part_2>.<part_3>.com/<part_4>/<part_5>/<part_6>'
273
+ >>> _get_ccp_url(base_url)
274
+ 'https://<part_1>.<part_2>.<part_3>.com'
275
+ """
276
+ parsed_url = urlparse(base_url)
277
+ return f"{parsed_url.scheme}://{parsed_url.netloc}"
278
+
279
+
280
+ class UserEnv:
281
+
282
+ def __init__(self, env_name, base_env, desc=None, conda_env=False):
283
+ """
284
+ DESCRIPTION:
285
+ Represents remote user environment from Vantage Languages Ecosystem.
286
+ The object of the class can be created either by using create_env() function which will
287
+ create a new remote user environment and returns an object of UserEnv class or
288
+ by using get_env() function which will return an object representing the existing remote user environment.
289
+
290
+ PARAMETERS:
291
+ env_name:
292
+ Required Argument.
293
+ Specifies the name of the remote user environment.
294
+ Types: str
295
+
296
+ base_env:
297
+ Required Argument.
298
+ Specifies base environment interpreter which is used to create remote user environment.
299
+ Types: str
300
+
301
+ desc:
302
+ Optional Argument.
303
+ Specifies description associated with the remote user environment.
304
+ Types: str
305
+
306
+ conda_env:
307
+ Optional Argument.
308
+ Specifies whether the environment to be created is a conda environment or not.
309
+ When set to True, conda environment is created. Otherwise, non conda environment is created.
310
+ Default value: False
311
+ Types: bool
312
+
313
+ RETURNS:
314
+ Instance of the class UserEnv.
315
+
316
+ RAISES:
317
+ TeradataMlException
318
+
319
+ EXAMPLES:
320
+ # Create a new environment and get instance of UserEnv class.
321
+ env1 = create_env('testenv', 'python_3.7.9', 'Test environment')
322
+
323
+ # Get an object for existing user environment.
324
+ env2 = get_env('testenv')
325
+ """
326
+
327
+ # Make sure the initialization happens only using either create_env() or get_env().
328
+ if inspect.stack()[1][3] not in ['create_env', 'get_env']:
329
+ raise TeradataMlException(Messages.get_message(
330
+ MessageCodes.USE_FUNCTION_TO_INSTANTIATE).format("A teradataml UserEnv object",
331
+ "create_env() and get_env() functions from teradataml.scriptmgmt.lls_utils"),
332
+ MessageCodes.USE_FUNCTION_TO_INSTANTIATE)
333
+
334
+ self.env_name = env_name
335
+ self.base_env = base_env
336
+ self.desc = desc
337
+
338
+ self.conda_env = conda_env
339
+ # Initialize variable for R environment.
340
+ self._r_env = True if self.base_env.lower().startswith("r_") else False
341
+
342
+ # Initialize variables to store files, libraries and models from
343
+ # the remote user environment.
344
+ self.__files = None
345
+ self.__libs = None
346
+ self.__models = None
347
+
348
+ # This variable will be used to detect if files from the remote user environment are changed by
349
+ # install_file or remove_file functions.
350
+ self.__files_changed = None
351
+
352
+ # This variable will be used to detect if libraries from the remote user environment are changed by
353
+ # install_lib, remove_lib or update_lib functions in teradataml.
354
+ # Updates from only current session are recorded by this variable.
355
+ self.__libs_changed = None
356
+
357
+ # This variable will be used to detect if models from the remote
358
+ # user environment are changed by install_model or remove_model functions.
359
+ self.__models_changed = None
360
+
361
+ # This variable will be set to False when remove() method is called to indicate that.
362
+ self.__exists = True
363
+
364
+ # Create argument information matrix to do parameter checking
365
+ self.__arg_info_matrix = []
366
+ self.__arg_info_matrix.append(["env_name", self.env_name, False, (str), True])
367
+ self.__arg_info_matrix.append(["base_env", self.base_env, False, (str), True])
368
+ self.__arg_info_matrix.append(["desc", self.desc, True, (str), False])
369
+
370
+ # Argument validation.
371
+ _Validators._validate_function_arguments(self.__arg_info_matrix)
372
+
373
+ # Map to store the claim id and corresponding file.
374
+ self.__claim_ids = {}
375
+
376
+ # Define the order of columns in output DataFrame.
377
+ self.__status_columns = ['Claim Id', 'File/Libs/Model', 'Method Name', 'Stage', 'Timestamp', 'Additional Details']
378
+
379
+ def __repr__(self):
380
+ """
381
+ Returns the string representation for class instance.
382
+ """
383
+ repr_string = "\n================================================\n"
384
+ repr_string = repr_string + "Environment Name: {}\n".format(self.env_name)
385
+ repr_string = repr_string + "Base Environment: {}\n".format(self.base_env)
386
+ repr_string = repr_string + "Description: {}\n".format(self.desc)
387
+
388
+ # Fetch latest state of remote env.
389
+ self._set_files()
390
+ self._set_libs()
391
+ self._set_models()
392
+
393
+ if self.__files is not None and len(self.__files) > 0:
394
+ repr_string_files = "############ Files installed in User Environment ############"
395
+ repr_string = "{}\n{}\n\n{}\n".format(repr_string, repr_string_files, self.__files)
396
+
397
+ if self.__libs is not None and len(self.__libs) > 0:
398
+ repr_string_libs = "############ Libraries installed in User Environment ############"
399
+ repr_string = "{}\n{}\n\n{}\n".format(repr_string, repr_string_libs, self.__libs)
400
+
401
+ if self.__models is not None and len(self.__models) > 0:
402
+ repr_string_models = "############ Models installed in User Environment ############"
403
+ repr_string = "{}\n{}\n\n{}\n".format(repr_string, repr_string_models, self.__models)
404
+
405
+ repr_string = repr_string + "\n================================================\n"
406
+ return repr_string
407
+
408
+ @collect_queryband(queryband="InstlFl")
409
+ def install_file(self, file_path, replace=False, **kwargs):
410
+ """
411
+ DESCRIPTION:
412
+ Function installs or replaces a file from client machine to the remote user environment created in
413
+ Vantage Languages Ecosystem.
414
+ * If the size of the file is more than 10 MB, the function installs the file synchronously
415
+ and returns the status of installation when 'asynchronous' is set to False. Otherwise, the
416
+ function installs the file asynchronously and returns claim-id to check the installation status
417
+ using status().
418
+ * If the size of the file is less than or equal to 10 MB, the function installs the
419
+ file synchronously and returns the status of installation.
420
+
421
+ PARAMETERS:
422
+ file_path:
423
+ Required Argument.
424
+ Specifies absolute or relative path of the file (including file name) to be installed in the
425
+ remote user environment.
426
+ Types: str
427
+
428
+ replace:
429
+ Optional Argument.
430
+ Specifies if the file should be forcefully replaced in remote user environment.
431
+ * When set to True,
432
+ * If the file already exists in remote user environment, it will be replaced with the file
433
+ specified by argument "file_path".
434
+ * If the file does not already exist in remote user environment, then the specified file will
435
+ be installed.
436
+ * Argument is ignored when file size <= 10MB.
437
+ Default Value: False
438
+ Types: bool
439
+
440
+ **kwargs:
441
+ Specifies the keyword arguments.
442
+ suppress_output:
443
+ Optional Argument.
444
+ Specifies whether to print the output message or not.
445
+ When set to True, then the output message is not printed.
446
+ Default Value: False
447
+ Types: bool
448
+
449
+ asynchronous:
450
+ Optional Argument.
451
+ Specifies whether to install the file in remote user environment
452
+ synchronously or asynchronously. When set to True, file is installed
453
+ asynchronously. Otherwise, file is installed synchronously.
454
+ Note:
455
+ Argument is ignored when file size <= 10MB.
456
+ Default Value: False
457
+ Types: bool
458
+
459
+ timeout:
460
+ Optional Argument.
461
+ Specifies the time to wait in seconds for installing the file. If the file is
462
+ not installed with in "timeout" seconds, the function returns a claim-id and one
463
+ can check the status using the claim-id. If "timeout" is not specified, then there
464
+ is no limit on the wait time.
465
+ Note:
466
+ Argument is ignored when "asynchronous" is True.
467
+ Types: int OR float
468
+
469
+ RETURNS:
470
+ True, if the file size is less than or equal to 10 MB and operation is successful.
471
+ str(claim-id), if the file size is greater than 10 MB.
472
+
473
+ RAISES:
474
+ TeradataMlException.
475
+
476
+ EXAMPLES:
477
+ # Create remote user environment.
478
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
479
+ User environment testenv created.
480
+
481
+ # Create conda environment.
482
+ >>> testenv_conda = create_env('testenv_conda', 'python_3.8', 'Test conda environment', conda_env=True)
483
+ Conda environment creation initiated.
484
+ User environment 'testenv_conda' created.
485
+
486
+ # Example 1: Install the file mapper.py in the 'testenv' environment.
487
+ >>> import os, teradataml
488
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
489
+ >>> env.install_file(file_path = file_path)
490
+ File 'mapper.py' installed successfully in the remote user environment 'testenv'.
491
+
492
+ # Example 2: Replace the file mapper.py.
493
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
494
+ >>> env.install_file(file_path = file_path, replace=True)
495
+ File 'mapper.py' replaced successfully in the remote user environment 'testenv'.
496
+
497
+ # Example 3: Install the file 'large_file' asynchronously with 'large_file' found in
498
+ temp folder and check the status of installation.
499
+ # Note:
500
+ # Running this example creates a file 'large_file' with size
501
+ # approximately 11MB in the temp folder.
502
+ >>> import tempfile, os
503
+ >>> def create_large_file():
504
+ ... file_name = os.path.join(tempfile.gettempdir(),"large_file")
505
+ ... with open(file_name, 'xb') as fp:
506
+ ... fp.seek((1024 * 1024 * 11) - 1)
507
+ ... fp.write(b'\0')
508
+ ...
509
+ >>> create_large_file()
510
+ >>> claim_id = env.install_file(file_path = os.path.join(tempfile.gettempdir(),"large_file"), asynchronous=True)
511
+ File installation is initiated. Check the status using status() with the claim id 76588d13-6e20-4892-9686-37768adcfadb.
512
+ >>> env.status(claim_id)
513
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
514
+ 0 76588d13-6e20-4892-9686-37768adcfadb large_file install_file File Uploaded 2022-07-13T10:34:02Z None
515
+ >>> env.status(claim_id, stack=True)
516
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
517
+ 0 76588d13-6e20-4892-9686-37768adcfadb large_file install_file Endpoint Generated 2022-07-13T10:34:00Z None
518
+ 1 76588d13-6e20-4892-9686-37768adcfadb large_file install_file File Uploaded 2022-07-13T10:34:02Z None
519
+ 2 76588d13-6e20-4892-9686-37768adcfadb large_file install_file File Installed 2022-07-13T10:34:08Z None
520
+
521
+ # Example 4: Install the file 'large_file' synchronously with 'large_file' found in
522
+ temp folder and check the status of installation.
523
+ # Note:
524
+ # Running this example creates a file 'large_file' with size
525
+ # approximately 11MB in the temp folder.
526
+ >>> import tempfile, os
527
+ >>> def create_large_file():
528
+ ... file_name = os.path.join(tempfile.gettempdir(), "large_file")
529
+ ... with open(file_name, 'xb') as fp:
530
+ ... fp.seek((1024 * 1024 * 11) - 1)
531
+ ... fp.write(b'\0')
532
+ ...
533
+ >>> create_large_file()
534
+ >>> result = env.install_file(file_path = os.path.join(tempfile.gettempdir(),"large_file"))
535
+
536
+ >>> result
537
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
538
+ 0 87588d13-5f20-3461-9686-46668adcfadb large_file install_file Endpoint Generated 2022-07-13T10:34:00Z None
539
+ 1 87588d13-5f20-3461-9686-46668adcfadb large_file install_file File Uploaded 2022-07-13T10:34:02Z None
540
+ 2 87588d13-5f20-3461-9686-46668adcfadb large_file install_file File Installed 2022-07-13T10:34:08Z None
541
+
542
+ >>> os.remove(os.path.join(tempfile.gettempdir(),"large_file")) # Remove the file created using function 'create_large_file'.
543
+
544
+ # Example 5: Install the file mapper.py in the 'testenv_conda' environment.
545
+ >>> import os, teradataml
546
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
547
+ >>> testenv_conda.install_file(file_path = file_path)
548
+ File 'mapper.py' installed successfully in the remote user environment 'testenv_conda'.
549
+
550
+ # Remove the environment.
551
+ >>> remove_env('testenv')
552
+ User environment 'testenv' removed.
553
+ >>> remove_env("testenv_conda")
554
+ User environment 'testenv_conda' removed.
555
+ """
556
+ # Install/Replace file on Vantage
557
+ asynchronous = kwargs.get("asynchronous", False)
558
+ timeout = kwargs.get("timeout")
559
+ suppress_output = kwargs.get("suppress_output", False)
560
+ is_model = kwargs.get("is_model", False)
561
+ is_llm = kwargs.pop("is_llm", False)
562
+ api_name = "install_file"
563
+ path_arg_name = "file_path"
564
+ if is_model:
565
+ api_name = "install_model"
566
+ path_arg_name = "model_path"
567
+
568
+ __arg_info_matrix = []
569
+ __arg_info_matrix.append([path_arg_name, file_path, False, (str), True])
570
+ __arg_info_matrix.append(["replace", replace, True, (bool)])
571
+ __arg_info_matrix.append(["asynchronous", asynchronous, True, (bool)])
572
+ __arg_info_matrix.append(["timeout", timeout, True, (int, float)])
573
+ __arg_info_matrix.append(["suppress_output", suppress_output, True, (bool)])
574
+
575
+ # Argument validation.
576
+ _Validators._validate_function_arguments(__arg_info_matrix)
577
+
578
+ # For LLM, only zip file is allowed.
579
+ if is_model and is_llm:
580
+ _Validators._validate_file_extension(file_path, ['zip'])
581
+
582
+ # Check if file exists or not.
583
+ _Validators._validate_file_exists(file_path)
584
+ # Check if file is empty or not.
585
+ _Validators._check_empty_file(file_path)
586
+
587
+ try:
588
+ # If file size is more than 10 MB, upload the file to cloud and export it to UES.
589
+ if is_model or UtilFuncs._get_file_size(file_path) > configure._ues_max_file_upload_size:
590
+ res = self.__install_file_from_cloud(file_path, asynchronous, timeout,
591
+ suppress_output, is_model)
592
+ else:
593
+ res = self.__install_file_from_local(file_path, replace, suppress_output)
594
+
595
+ # Update the flags which are used by refresh API and
596
+ # APIs for listing entities like files and models.
597
+ if is_model:
598
+ self.__models_changed = True
599
+ else:
600
+ self.__files_changed = True
601
+ return res
602
+
603
+ except (TeradataMlException, RuntimeError):
604
+ raise
605
+
606
+ except Exception as emsg:
607
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
608
+ error_msg = Messages.get_message(msg_code, api_name, str(emsg))
609
+ raise TeradataMlException(error_msg, msg_code)
610
+
611
+ def __install_file_from_local(self, file_path, replace, suppress_output=False):
612
+ """
613
+ DESCRIPTION:
614
+ Internal function to install or replace a file from client machine to the remote
615
+ user environment created in Vantage Languages Ecosystem.
616
+
617
+ PARAMETERS:
618
+ file_path:
619
+ Required Argument.
620
+ Specifies absolute or relative path of the file (including file name) to be installed in the
621
+ remote user environment.
622
+ Types: str
623
+
624
+ replace:
625
+ Required Argument.
626
+ Specifies if the file should be forcefully replaced in remote user environment.
627
+ When set to True,
628
+ * If the file already exists in remote user environment, it will be replaced with the file
629
+ specified by argument "file_path".
630
+ * If the file does not already exist in remote user environment, then the specified file will
631
+ be installed.
632
+ Types: bool
633
+
634
+ suppress_output:
635
+ Optional Argument.
636
+ Specifies whether to print the output message or not.
637
+ When set to True, then the output message is not printed.
638
+ Default Value: False
639
+ Types: bool
640
+
641
+ RETURNS:
642
+ True, if the operation is successful.
643
+
644
+ RAISES:
645
+ TeradataMlException.
646
+
647
+ EXAMPLES:
648
+ # Create remote user environment.
649
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
650
+ User environment testenv created.
651
+ >>> env.__install_file_from_local("abc.py")
652
+ File 'abc.py' is installed successfully in 'testenv' environment.
653
+ """
654
+ file_name = os.path.basename(file_path)
655
+
656
+ # Prepare the payload.
657
+ files = {
658
+ 'env-file': (file_name, UtilFuncs._get_file_contents(file_path, read_in_binary_mode=True))
659
+ }
660
+
661
+ http_method = HTTPRequest.POST
662
+ success_msg = "installed"
663
+ params = {"env_name": self.env_name, "files": True, "api_name": "install_file"}
664
+
665
+ if replace:
666
+ http_method = HTTPRequest.PUT
667
+ success_msg = "replaced"
668
+ params["file_name"] = file_name
669
+
670
+ resource_url = _get_ues_url(**params)
671
+ # UES accepts multiform data. Specifying the 'files' attribute makes 'requests'
672
+ # module to send it as multiform data.
673
+ resp = UtilFuncs._http_request(resource_url, http_method, headers=_get_auth_token(), files=files)
674
+
675
+ # Process the response.
676
+ _process_ues_response(api_name="install_file", response=resp)
677
+
678
+ if not suppress_output:
679
+ print("File '{}' {} successfully in the remote user environment '{}'.".format(
680
+ file_name, success_msg, self.env_name))
681
+
682
+ return True
683
+
684
+ @staticmethod
685
+ def __upload_file_to_cloud(file_path, is_model=False, api_name="install_file"):
686
+ """
687
+ DESCRIPTION:
688
+ Internal function to upload a file to the cloud environment.
689
+
690
+ PARAMETERS:
691
+ file_path:
692
+ Required Argument.
693
+ Specifies absolute or relative path of the file (including file name) to be uploaded
694
+ to the cloud.
695
+ Types: str
696
+
697
+ RETURNS:
698
+ str, if the operation is successful.
699
+
700
+ RAISES:
701
+ TeradataMlException.
702
+
703
+ EXAMPLES:
704
+ # Create remote user environment.
705
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
706
+ User environment testenv created.
707
+ >>> env.__upload_file_to_cloud("abc.txt")
708
+ """
709
+ # Prepare the payload for UES to get the URL and claim-id.
710
+ payload = {"user": _get_user(), "file": os.path.basename(file_path)}
711
+
712
+ response = UtilFuncs._http_request(_get_ues_url(env_type="fm", fm_type="import", api_name=api_name),
713
+ HTTPRequest.POST,
714
+ json=payload,
715
+ headers=_get_auth_token())
716
+ response_header = response.headers
717
+ data = _process_ues_response(api_name, response).json()
718
+
719
+ # Get the URL to upload file to cloud and the claim-id from response.
720
+ cloud_storage_url, claim_id = data["url"], data["claim_id"]
721
+ # Get the Cloud Provider from response header.
722
+ cloud_provider = response_header["X-Oaf-Cloud-Provider"]
723
+
724
+ headers = None
725
+ if cloud_provider == CloudProvider.AZURE.value:
726
+ headers = {"Content-Type": "application/octet-stream",
727
+ "x-ms-date": response_header["Date"],
728
+ "x-ms-version": CloudProvider.X_MS_VERSION.value,
729
+ "x-ms-blob-type": CloudProvider.X_MS_BLOB_TYPE.value}
730
+
731
+ # Initiate file upload to cloud.
732
+ with open(file_path, 'rb') as fp:
733
+ response = UtilFuncs._http_request(cloud_storage_url,
734
+ HTTPRequest.PUT,
735
+ data=fp,
736
+ headers=headers)
737
+
738
+ # Since the API is not for UES, it is better to validate and raise error separately.
739
+ if not (200 <= response.status_code < 300):
740
+ raise Exception("{} upload failed with status code - {}"
741
+ .format('Model' if is_model else 'File',
742
+ response.status_code))
743
+
744
+ return claim_id
745
+
746
+ def __install_file_from_cloud(self, file_path, asynchronous=False, timeout=None,
747
+ suppress_output=False, is_model=False):
748
+ """
749
+ DESCRIPTION:
750
+ Internal Function to export file from cloud environment to the remote user
751
+ environment created in Vantage Languages Ecosystem.
752
+
753
+ PARAMETERS:
754
+ file_path:
755
+ Required Argument.
756
+ Specifies absolute or relative path of the file (including file name) to
757
+ be installed in the remote user environment.
758
+ Types: str
759
+
760
+ asynchronous:
761
+ Optional Argument.
762
+ Specifies whether to install the file in remote user environment
763
+ synchronously or asynchronously. When set to True, file is installed
764
+ asynchronously. Otherwise, file is installed synchronously.
765
+ Default Value: False
766
+ Types: bool
767
+
768
+ timeout:
769
+ Optional Argument.
770
+ Specifies the time to wait in seconds for installing the file. If the file is
771
+ not installed with in "timeout" seconds, the function returns a claim-id and one
772
+ can check the status using the claim-id. If "timeout" is not specified, then there
773
+ is no limit on the wait time.
774
+ Note:
775
+ Argument is ignored when "asynchronous" is True.
776
+ Types: int OR float
777
+
778
+ suppress_output:
779
+ Optional Argument.
780
+ Specifies whether to print the output message or not.
781
+ When set to True, then the output message is not printed.
782
+ Default Value: False
783
+ Types: bool
784
+
785
+ RETURNS:
786
+ str, if the operation is successful.
787
+
788
+ RAISES:
789
+ TeradataMlException.
790
+
791
+ EXAMPLES:
792
+ # Create remote user environment.
793
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
794
+ User environment testenv created.
795
+ >>> env.__install_file_from_cloud("abc.py")
796
+ File installation is initiated. Check the status using 'status' API with the claim id abc-xyz.
797
+ abc-xyz
798
+ """
799
+ # Decide API type.
800
+ api_name = "install_file"
801
+ if is_model:
802
+ api_name = "install_model"
803
+
804
+ # Upload file to cloud.
805
+ claim_id = self.__upload_file_to_cloud(file_path, is_model, api_name)
806
+
807
+ # Initiate file export from cloud to UES file system. Note that, the corresponding call to
808
+ # UES is an asynchronous call.
809
+ data = {"user": _get_user(),
810
+ "environment": self.env_name,
811
+ "claim_id": claim_id
812
+ }
813
+ # Add additional payload field to specify that
814
+ # model is getting installed.
815
+ if is_model:
816
+ data['model'] = True
817
+
818
+ url = _get_ues_url(env_type="fm", fm_type="export", claim_id=claim_id,
819
+ api_name=api_name)
820
+ response = UtilFuncs._http_request(url, HTTPRequest.POST, json=data,
821
+ headers=_get_auth_token())
822
+
823
+ # Validate the response.
824
+ _process_ues_response(api_name, response)
825
+
826
+ # Store the claim id locally to display the file/library name in status API.
827
+ self.__claim_ids[claim_id] = {"action": api_name, "value": file_path}
828
+
829
+ # In case of synchronous mode, keep polling the status
830
+ # of underlying asynchronous operation until it is either
831
+ # successful or errored or timed out.
832
+ if not asynchronous:
833
+ return self.__get_claim_status(claim_id, timeout, api_name)
834
+
835
+ if not suppress_output:
836
+ # Print a message to user console.
837
+ print("{} installation is initiated. Check the status"
838
+ " using status() with the claim id {}.".
839
+ format('Model' if is_model else 'File', claim_id))
840
+
841
+ return claim_id
842
+
843
+ @collect_queryband(queryband="RmFl")
844
+ def remove_file(self, file_name, **kwargs):
845
+ """
846
+ DESCRIPTION:
847
+ Function removes the specified file from the remote user environment.
848
+
849
+ PARAMETERS:
850
+ file_name:
851
+ Required Argument.
852
+ Specifies the file name to be removed. If the file has an extension, specify the filename with extension.
853
+ Types: str
854
+
855
+ **kwargs:
856
+ Specifies the keyword arguments.
857
+ suppress_output:
858
+ Optional Argument.
859
+ Specifies whether to print the output message or not.
860
+ When set to True, then the output message is not printed.
861
+ Types: bool
862
+
863
+ RETURNS:
864
+ True, if the operation is successful.
865
+
866
+ RAISES:
867
+ TeradataMlException, RuntimeError
868
+
869
+ EXAMPLES:
870
+ # Create a Python 3.7.3 environment with given name and description in Vantage.
871
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
872
+ User environment 'testenv' created.
873
+
874
+ # Install the file "mapper.py" using the default text mode in the remote user environment.
875
+ >>> import os, teradataml
876
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
877
+ >>> env.install_file(file_path = file_path)
878
+ File 'mapper.py' installed successfully in the remote user environment 'testenv'.
879
+
880
+ # Example 1: Remove file from remote user environment.
881
+ >>> env.remove_file('mapper.py')
882
+ File 'mapper.py' removed successfully from the remote user environment 'testenv'.
883
+
884
+ # Remove the environment.
885
+ >>> remove_env('testenv')
886
+ User environment 'testenv' removed.
887
+ """
888
+
889
+ api_name = "remove_file"
890
+ file_model_arg_name = "file_name"
891
+
892
+ is_model = kwargs.get("is_model", False)
893
+ if is_model:
894
+ api_name = "uninstall_model"
895
+ file_model_arg_name = "model_name"
896
+
897
+ __arg_info_matrix = []
898
+ __arg_info_matrix.append([file_model_arg_name, file_name, False, (str), True])
899
+ __arg_info_matrix.append(["suppress_output", kwargs.get("suppress_output", False), True, (bool)])
900
+
901
+ # Argument validation.
902
+ _Validators._validate_missing_required_arguments(__arg_info_matrix)
903
+ _Validators._validate_function_arguments(__arg_info_matrix)
904
+
905
+ try:
906
+ response = UtilFuncs._http_request(_get_ues_url(env_name=self.env_name, files=True, file_name=file_name),
907
+ HTTPRequest.DELETE,
908
+ headers=_get_auth_token())
909
+
910
+ _process_ues_response(api_name=api_name, response=response)
911
+
912
+ if not kwargs.get("suppress_output", False):
913
+ msg = "File '{0}' removed"
914
+ if is_model:
915
+ msg = "Model '{0}' uninstalled"
916
+ print("{0} successfully from the remote user environment '{1}'.".
917
+ format(msg, self.env_name).format(file_name))
918
+
919
+ # Files/Models are changed, change the flag.
920
+ if is_model:
921
+ self.__models_changed = True
922
+ else:
923
+ self.__files_changed = True
924
+ return True
925
+
926
+ except (TeradataMlException, RuntimeError):
927
+ raise
928
+ except Exception as err:
929
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
930
+ error_msg = Messages.get_message(msg_code, api_name, err)
931
+ raise TeradataMlException(error_msg, msg_code)
932
+
933
+ @property
934
+ @collect_queryband(queryband="EnvFls")
935
+ def files(self):
936
+ """
937
+ DESCRIPTION:
938
+ A class property that returns list of files installed in remote user environment.
939
+
940
+ PARAMETERS:
941
+ None
942
+
943
+ RETURNS:
944
+ Pandas DataFrame containing files and it's details.
945
+
946
+ RAISES:
947
+ TeradataMlException
948
+
949
+ EXAMPLES:
950
+ # Create a remote user environment.
951
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
952
+ User environment testenv created.
953
+
954
+ >>> env.install_file(file_path = 'data/scripts/mapper.py')
955
+ File mapper.py installed successfully in the remote user environment testenv.
956
+
957
+ # List files installed in the user environment.
958
+ >>> env.files
959
+ File Size Timestamp
960
+ 0 mapper.py 233 2020-08-06T21:59:22Z
961
+ """
962
+ # Fetch the list of files from remote user environment only when they are not already fetched in this object
963
+ # or files are changed either by install or remove functions.
964
+ if self.__files is None or self.__files_changed:
965
+ self._set_files()
966
+
967
+ if len(self.__files) == 0:
968
+ print("No files found in remote user environment {}.".format(self.env_name))
969
+ else:
970
+ return self.__files
971
+
972
+ def _set_files(self):
973
+ """
974
+ DESCRIPTION:
975
+ Function fetches the list of files installed in a remote user environment using
976
+ the REST call to User Environment Service.
977
+
978
+ PARAMETERS:
979
+ None
980
+
981
+ RETURNS:
982
+ None
983
+
984
+ RAISES:
985
+ TeradataMlException
986
+
987
+ EXAMPLES:
988
+ >>> self._set_files()
989
+ """
990
+
991
+ try:
992
+ response = UtilFuncs._http_request(_get_ues_url(env_name=self.env_name, files=True, api_name="files"),
993
+ headers=_get_auth_token())
994
+ data = _process_ues_response(api_name="files", response=response).json()
995
+
996
+ # Create a lamda function to extract only required columns from the data.
997
+ get_details = lambda data: {"File": data.pop("name", None),
998
+ "Size": data.pop("size", None),
999
+ "Timestamp": data.pop("last_updated_dttm", None)
1000
+ }
1001
+
1002
+ if len(data) > 0:
1003
+ self.__files = pd.DataFrame.from_records([get_details(file) for file in data
1004
+ if file['is_model'] == False])
1005
+ else:
1006
+ self.__files = pd.DataFrame(columns=["File", "Size", "Timestamp"])
1007
+
1008
+ # Latest files are fetched; reset the flag.
1009
+ self.__files_changed = False
1010
+
1011
+ except (TeradataMlException, RuntimeError):
1012
+ raise
1013
+
1014
+ except Exception as err:
1015
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
1016
+ error_msg = Messages.get_message(msg_code, "files", err)
1017
+ raise TeradataMlException(error_msg, msg_code)
1018
+
1019
+ def _set_libs(self):
1020
+ """
1021
+ DESCRIPTION:
1022
+ Function lists the installed libraries in the remote user environment using
1023
+ the REST call to User Environment Service and sets the '__libs' data member.
1024
+
1025
+ PARAMETERS:
1026
+ None
1027
+
1028
+ RETURNS:
1029
+ None
1030
+
1031
+ RAISES:
1032
+ TeradataMlException
1033
+
1034
+ EXAMPLES:
1035
+ self._set_libs()
1036
+ """
1037
+ try:
1038
+ response = UtilFuncs._http_request(_get_ues_url(env_name=self.env_name, libs=True, api_name="libs"),
1039
+ headers=_get_auth_token())
1040
+ data = _process_ues_response(api_name="libs", response=response).json()
1041
+
1042
+ if len(data) > 0:
1043
+ # Return result as Pandas dataframe.
1044
+ df = pd.DataFrame.from_records(data)
1045
+ self.__libs = df
1046
+
1047
+ # Latest libraries are fetched; reset the flag.
1048
+ self.__libs_changed = False
1049
+
1050
+ except (TeradataMlException, RuntimeError):
1051
+ raise
1052
+ except Exception as emsg:
1053
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
1054
+ error_msg = Messages.get_message(msg_code, "libs", emsg)
1055
+ raise TeradataMlException(error_msg, msg_code)
1056
+
1057
+ @property
1058
+ @collect_queryband(queryband="EnvLbs")
1059
+ def libs(self):
1060
+ """
1061
+ DESCRIPTION:
1062
+ A class property that returns list of libraries installed in the remote user environment.
1063
+
1064
+ PARAMETERS:
1065
+ None
1066
+
1067
+ RETURNS:
1068
+ Pandas DataFrame containing libraries and their versions.
1069
+
1070
+ RAISES:
1071
+ TeradataMlException
1072
+
1073
+ EXAMPLES:
1074
+ # Example 1: libs property for Python environment.
1075
+ # Create a remote Python user environment.
1076
+ >>> env = create_env('test_env', 'python_3.7.9', 'Test environment')
1077
+ User environment test_env created.
1078
+
1079
+ # View existing libraries installed.
1080
+ >>> env.libs
1081
+ name version
1082
+ 0 pip 20.1.1
1083
+ 1 setuptools 47.1.0
1084
+
1085
+ # Install additional Python libraries.
1086
+ >>> env.install_lib(['numpy','nltk>=3.3'])
1087
+ Request to install libraries initiated successfully in the remote user environment test_env. Check the status using status() with the claim id '1e23d244-3c88-401f-a432-277d72dc6835'.
1088
+ '1e23d244-3c88-401f-a432-277d72dc6835'
1089
+
1090
+ # List libraries installed.
1091
+ >>> env.libs
1092
+ name version
1093
+ 0 nltk 3.4.5
1094
+ 1 numpy 1.21.6
1095
+ 2 pip 20.1.1
1096
+ 3 setuptools 47.1.0
1097
+ 4 six 1.16.0
1098
+
1099
+ # Example 2: libs property for R environment.
1100
+ # Create a remote R user environment.
1101
+ >>> r_env = create_env('test_r_env', 'r_4.1', 'Test R environment')
1102
+ User environment 'test_r_env' created.
1103
+
1104
+ # List installed libraries in environment.
1105
+ >>> r_env.libs
1106
+ name version
1107
+ 0 KernSmooth 2.23-20
1108
+ 1 MASS 7.3-55
1109
+ 2 Matrix 1.4-0
1110
+ 3 base 4.1.3
1111
+ 4 boot 1.3-28
1112
+ .. ... ...
1113
+ 26 survival 3.2-13
1114
+ 27 tcltk 4.1.3
1115
+ 28 tools 4.1.3
1116
+ 29 utils 4.1.3
1117
+
1118
+ # Install additional R libraries.
1119
+ >>> r_env.install_lib(['dplyr','testthat==3.0.4'])
1120
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1121
+ 0 3823217b-89ee-423c-9ed1-f72a6b6d0511 dplyr, testthat=3.0.4 install_lib Started 2023-08-31T07:14:57Z
1122
+ 1 3823217b-89ee-423c-9ed1-f72a6b6d0511 dplyr, testthat=3.0.4 install_lib Finished 2023-08-31T07:20:35Z
1123
+
1124
+ # List installed libraries in environment.
1125
+ >>> r_env.libs
1126
+ name version
1127
+ 0 KernSmooth 2.23-20
1128
+ 1 MASS 7.3-55
1129
+ 2 Matrix 1.4-0
1130
+ 3 base 4.1.3
1131
+ .. ... ...
1132
+ 9 dplyr 1.1.2
1133
+ .. ... ...
1134
+ 58 testthat 3.0.4
1135
+ .. ... ...
1136
+ 61 vctrs 0.6.3
1137
+ 62 waldo 0.5.1
1138
+ 63 withr 2.5.0
1139
+ [64 rows x 2 columns]
1140
+
1141
+ """
1142
+ # Fetch the list of libraries from remote user environment only when they are not
1143
+ # already fetched in this object or libraries are changed either by
1144
+ # install_lib/uninstall_lib/update_lib functions.
1145
+ if self.__libs is None or self.__libs_changed:
1146
+ self._set_libs()
1147
+
1148
+ return self.__libs
1149
+
1150
+ def _set_models(self):
1151
+ """
1152
+ DESCRIPTION:
1153
+ Function fetches the list of models installed in a remote user environment using
1154
+ the REST call to User Environment Service.
1155
+
1156
+ PARAMETERS:
1157
+ None
1158
+
1159
+ RETURNS:
1160
+ None
1161
+
1162
+ RAISES:
1163
+ TeradataMlException
1164
+
1165
+ EXAMPLES:
1166
+ >>> self._set_models()
1167
+ """
1168
+ try:
1169
+ response = UtilFuncs._http_request(_get_ues_url(env_name=self.env_name, files=True, api_name="models"),
1170
+ headers=_get_auth_token())
1171
+ data = _process_ues_response(api_name="models", response=response).json()
1172
+
1173
+ # Create a lamda function to extract only required columns from the data.
1174
+ get_details = lambda data: {"Model": data.pop("name", None),
1175
+ "Size": data.pop("size", None),
1176
+ "Timestamp": data.pop("last_updated_dttm", None)
1177
+ }
1178
+
1179
+ if len(data) > 0:
1180
+ self.__models = pd.DataFrame.from_records([get_details(model) for model in data
1181
+ if model['is_model'] == True])
1182
+ else:
1183
+ self.__models = pd.DataFrame(columns=["Model", "Size", "Timestamp"])
1184
+
1185
+ # Latest models are fetched; reset the flag.
1186
+ self.__models_changed = False
1187
+
1188
+ except (TeradataMlException, RuntimeError):
1189
+ raise
1190
+
1191
+ except Exception as err:
1192
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
1193
+ error_msg = Messages.get_message(msg_code, "models", err)
1194
+ raise TeradataMlException(error_msg, msg_code)
1195
+
1196
+ @property
1197
+ @collect_queryband(queryband="EnvMdls")
1198
+ def models(self):
1199
+ """
1200
+ DESCRIPTION:
1201
+ A class property that returns list of models installed in remote user environment.
1202
+
1203
+ PARAMETERS:
1204
+ None
1205
+
1206
+ RETURNS:
1207
+ Pandas DataFrame containing models and their details.
1208
+
1209
+ RAISES:
1210
+ TeradataMlException
1211
+
1212
+ EXAMPLES:
1213
+ # Create a remote user environment.
1214
+ >>> env = create_env('testenv', 'python_3.8.13', 'Test environment')
1215
+ User environment testenv created.
1216
+
1217
+ # User should create a zip file containing all files related to model
1218
+ # and use path to that zip file to install model using install_model()
1219
+ # API. Let's assume that all models files are zipped under 'large_model.zip'
1220
+ >>> model = 'large_model.zip'
1221
+
1222
+ # Install the model in the 'testenv' environment.
1223
+ >>> env.install_model(model_path = model)
1224
+ Request for install_model is completed successfully.
1225
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
1226
+ 0 70ba8bb6-9c0b-41f1-af44-5fd1b9e31c7d large_model.zip install_model Endpoint Generated 2023-10-31T07:34:21Z
1227
+ 1 70ba8bb6-9c0b-41f1-af44-5fd1b9e31c7d large_model.zip install_model File Uploaded 2023-10-31T07:35:37Z
1228
+ 2 70ba8bb6-9c0b-41f1-af44-5fd1b9e31c7d large_model.zip install_model File Installed 2023-10-31T07:35:38Z
1229
+
1230
+ # List models installed in the user environment.
1231
+ >>> env.models
1232
+ Model Size Timestamp
1233
+ 0 large_model 6144 2023-10-31T07:35:38Z
1234
+ """
1235
+ # Fetch the list of files from remote user environment only when they are not already fetched in this object
1236
+ # or files are changed either by install or remove functions.
1237
+ if self.__models is None or self.__models_changed:
1238
+ self._set_models()
1239
+
1240
+ if len(self.__models) == 0:
1241
+ print("No models found in remote user environment {}.".format(self.env_name))
1242
+ else:
1243
+ return self.__models
1244
+
1245
+ def __manage(self, file_contents, option="INSTALL"):
1246
+ """
1247
+ DESCRIPTION:
1248
+ Function installs, removes and updates Python libraries from
1249
+ remote user environment.
1250
+
1251
+ PARAMETERS:
1252
+ file_contents:
1253
+ Required Argument.
1254
+ Specifies the contents of the file in binary format.
1255
+ Types: binary
1256
+
1257
+ option:
1258
+ Required Argument.
1259
+ Specifies the action intended to be performed on the libraries.
1260
+ Permitted Values: INSTALL, UNINSTALL, UPDATE
1261
+ Types: str
1262
+ Default Value: INSTALL
1263
+
1264
+ RETURNS:
1265
+ True, if the operation is successful.
1266
+
1267
+ RAISES:
1268
+ TeradataMlException, SqlOperationalError
1269
+
1270
+ EXAMPLES:
1271
+ self.__manage(b'pandas' ,"INSTALL")
1272
+ self.__manage(b'pandas', "UNINSTALL")
1273
+ self.__manage(b'pandas', "UPDATE")
1274
+ """
1275
+ # Common code to call XSP manage_libraries with options "INSTALL", "UNINSTALL", "update"
1276
+ # This internal method will be called by install_lib, uninstall_lib and update_lib.
1277
+ __arg_info_matrix = []
1278
+ __arg_info_matrix.append(["option", option, False, (str), True, ["INSTALL", "UNINSTALL", "UPDATE"]])
1279
+
1280
+ # Validate arguments
1281
+ _Validators._validate_missing_required_arguments(__arg_info_matrix)
1282
+ _Validators._validate_function_arguments(__arg_info_matrix)
1283
+
1284
+ try:
1285
+ # Prepare the payload.
1286
+ # Update the action to 'UPGRADE' for the post call as the UES accepts 'UPGRADE'.
1287
+ http_req = HTTPRequest.POST
1288
+ if option == "UPDATE":
1289
+ http_req = HTTPRequest.PUT
1290
+ elif option == "UNINSTALL":
1291
+ http_req = HTTPRequest.DELETE
1292
+
1293
+ files = {
1294
+ 'reqs-file': ("requirements.txt", file_contents),
1295
+ }
1296
+
1297
+ # Get the API name (install_lib or uninstall_lib or update_lib) which calls
1298
+ # __manage_libraries which ends up calling this function.
1299
+ api_name = inspect.stack()[2].function
1300
+
1301
+ # UES accepts multiform data. Specifying the 'files' attribute makes 'requests'
1302
+ # module to send it as multiform data.
1303
+ resp = UtilFuncs._http_request(url=_get_ues_url(env_name=self.env_name, libs=True, api_name=api_name),
1304
+ method_type=http_req,
1305
+ headers=_get_auth_token(),
1306
+ files=files)
1307
+
1308
+ # Process the response.
1309
+ resp = _process_ues_response(api_name="{}_lib".format(option.lower()), response=resp)
1310
+
1311
+ # Set the flag to indicate that libraries are changed in remote user environment.
1312
+ self.__libs_changed = True
1313
+ return resp.json().get("claim_id", "")
1314
+
1315
+ except (TeradataMlException, RuntimeError):
1316
+ raise
1317
+ except Exception as emsg:
1318
+ msg_code = MessageCodes.FUNC_EXECUTION_FAILED
1319
+ error_msg = Messages.get_message(msg_code, "{}_lib".format(option.lower()), str(emsg))
1320
+ raise TeradataMlException(error_msg, msg_code)
1321
+
1322
+ def __validate(self, libs=None, libs_file_path=None, asynchronous=True, timeout=None):
1323
+ """
1324
+ DESCRIPTION:
1325
+ Function performs argument validations.
1326
+
1327
+ PARAMETERS:
1328
+ libs:
1329
+ Optional Argument.
1330
+ Specifies the add-on library name(s).
1331
+ Types: str OR list of Strings(str)
1332
+
1333
+ libs_file_path:
1334
+ Optional Argument.
1335
+ Specifies file path with extension.
1336
+ Types: str
1337
+
1338
+ asynchronous:
1339
+ Optional Argument.
1340
+ Specifies whether to install/uninstall/update the library in remote user environment
1341
+ synchronously or asynchronously. When set to True, libraries are installed/uninstalled/updated
1342
+ asynchronously. Otherwise, libraries are installed/uninstalled/updated synchronously.
1343
+ Default Value: True
1344
+ Types: bool
1345
+
1346
+ timeout:
1347
+ Optional Argument.
1348
+ Specifies the time to wait in seconds for installing the libraries. If the library is
1349
+ not installed/uninstalled/updated with in 'timeout' seconds, the function returns a
1350
+ claim-id and one can check the status using the claim-id. If 'timeout' is not specified,
1351
+ then there is no limit on the wait time.
1352
+ Types: int OR float
1353
+
1354
+ RETURNS:
1355
+ None
1356
+
1357
+ RAISES:
1358
+ TeradataMlException
1359
+
1360
+ EXAMPLES:
1361
+ __validate_requirement_filename(libs_file_path = 'data/requirements.txt')
1362
+ __validate_requirement_filename(libs="numpy")
1363
+ __validate_requirement_filename(libs=['pandas','numpy'])
1364
+ """
1365
+ __arg_info_matrix = []
1366
+ __arg_info_matrix.append(["libs", libs, True, (str, list), True])
1367
+ __arg_info_matrix.append(["libs_file_path", libs_file_path, True, str, True])
1368
+ __arg_info_matrix.append(["asynchronous", asynchronous, True, bool])
1369
+ __arg_info_matrix.append(["timeout", timeout, True, (int, float)])
1370
+
1371
+ # Argument validation.
1372
+ _Validators._validate_missing_required_arguments(__arg_info_matrix)
1373
+ _Validators._validate_function_arguments(__arg_info_matrix)
1374
+ _Validators._validate_mutually_exclusive_arguments(libs, "libs", libs_file_path, "libs_file_path")
1375
+
1376
+ if libs_file_path is not None:
1377
+ # If user has specified libraries in a file.
1378
+ _Validators._validate_file_exists(libs_file_path)
1379
+
1380
+ # Verify only files with .txt extension are allowed for Python environment and
1381
+ # with .txt or .json extension are allowed for R environment.
1382
+ if self.base_env.lower().startswith('python_'):
1383
+ _Validators._validate_file_extension(libs_file_path, ['txt'])
1384
+ elif self.base_env.lower().startswith('r_'):
1385
+ if self.conda_env:
1386
+ _Validators._validate_file_extension(libs_file_path, ['txt'])
1387
+ else:
1388
+ _Validators._validate_file_extension(libs_file_path, ['txt', 'json'])
1389
+
1390
+ _Validators._check_empty_file(libs_file_path)
1391
+
1392
+ if timeout is not None:
1393
+ _Validators._validate_argument_range(timeout, 'timeout', lbound=0, lbound_inclusive=False)
1394
+
1395
+ def __manage_libraries(self, libs=None, libs_file_path=None, action="INSTALL", asynchronous=False, timeout=None):
1396
+ """
1397
+ DESCRIPTION:
1398
+ Internal function to perform argument validation, requirement text file
1399
+ generation and executing XSP call to get the results.
1400
+
1401
+ PARAMETERS:
1402
+ libs:
1403
+ Optional Argument.
1404
+ Specifies the add-on library name(s).
1405
+ Types: str OR list of Strings(str)
1406
+
1407
+ libs_file_path:
1408
+ Optional Argument.
1409
+ Specifies the absolute/relative path of the file (including file name)
1410
+ which supplies a list of libraries to be installed in remote user
1411
+ environment. Path specified should include the filename with extension.
1412
+ Notes:
1413
+ 1. The file must have an ".txt" extension for Python environment
1414
+ and ".txt"/".json" extension for R environment.
1415
+ 2. Either "libs" or "libs_file_path" argument must be specified.
1416
+ Types: str
1417
+
1418
+ action:
1419
+ Optional Argument.
1420
+ Specifies if libraries are to be installed or uninstalled or updated
1421
+ from remote user environment.
1422
+ Default Value: 'INSTALL'
1423
+ Types: str
1424
+
1425
+ asynchronous:
1426
+ Optional Argument.
1427
+ Specifies whether to install/uninstall/update the library in
1428
+ remote user environment synchronously or asynchronously. When
1429
+ set to True, libraries are installed/uninstalled/updated asynchronously.
1430
+ Otherwise, libraries are installed/uninstalled/updated synchronously.
1431
+ Default Value: False
1432
+ Types: bool
1433
+
1434
+ timeout:
1435
+ Optional Argument.
1436
+ Specifies the maximum number of seconds to install/uninstall/update
1437
+ the libraries in remote user environment. If None, then there is
1438
+ no limit on the wait time.
1439
+ * Argument is ignored when 'asynchronous' is True.
1440
+ Types: int OR float
1441
+
1442
+ RETURNS:
1443
+ None
1444
+
1445
+ RAISES:
1446
+ TeradataMlException
1447
+
1448
+ EXAMPLES:
1449
+ __manage_libraries(libs_file_path="/data/requirement.txt", action="INSTALL")
1450
+ __manage_libraries(libs="pandas", action="UNINSTALL")
1451
+ __manage_libraries(libs=["pandas","numpy","joblib==0.13.2"], action="UPDATE")
1452
+ """
1453
+ # Argument validation.
1454
+ self.__validate(libs, libs_file_path, asynchronous, timeout)
1455
+
1456
+ # If file is provided, store the file_name and also extracts it contents
1457
+ if libs_file_path is not None:
1458
+ value = libs_file_path
1459
+ file_contents = UtilFuncs._get_file_contents(libs_file_path, read_in_binary_mode=True)
1460
+ else:
1461
+ # If libs are provided as string or list, convert the contents to binary.
1462
+ # When library names are provided in a list, create a string.
1463
+ file_contents = self.__get_file_contents(libs, action)
1464
+ # Store it with comma separated values if it is a list.
1465
+ value = ', '.join(libs) if isinstance(libs, list) else libs
1466
+ # Convert to binary.
1467
+ file_contents = file_contents.encode('ascii')
1468
+
1469
+ claim_id = self.__manage(file_contents, action)
1470
+ action = action.lower()
1471
+ self.__claim_ids[claim_id] = {"action": "{}_lib".format(action), "value": value}
1472
+
1473
+ # Check if installation should be asynchronous or not. If it is, then
1474
+ # return claim id and let user poll the status using status API.
1475
+ # Else, poll the status API for 'timeout' seconds.
1476
+ if asynchronous:
1477
+ print("Request to {} libraries initiated successfully in the remote user environment {}. "
1478
+ "Check the status using status() with the claim id '{}'.".format(
1479
+ action, self.env_name, claim_id))
1480
+ return claim_id
1481
+ else:
1482
+ return self.__get_claim_status(claim_id, timeout, "{} libraries".format(action))
1483
+
1484
+ def __get_file_contents(self, libs, action):
1485
+ """
1486
+ DESCRIPTION:
1487
+ Function takes the list of string or string and converts it to
1488
+ a single string in case of Python environment and converts it
1489
+ to Json format for the R environment.
1490
+
1491
+ PARAMETER:
1492
+ libs: Specifies the add-on library name(s), to be converted to
1493
+ file content.
1494
+
1495
+ Returns:
1496
+ None
1497
+ """
1498
+ # Check if the env is python or conda env
1499
+ if not self._r_env or self.conda_env:
1500
+ if isinstance(libs, list):
1501
+ return '\n'.join(libs)
1502
+ return libs
1503
+ else:
1504
+ # render library and version from libs parameter, as dict
1505
+ # with lib as key and value as version
1506
+ result = UtilFuncs._get_dict_from_libs(libs)
1507
+ # When action is 'UNINSTALL' return in json format which is different from 'INSTALL' json format
1508
+ if action == 'UNINSTALL':
1509
+ return json.dumps({"packages": [key for key in result.keys()]})
1510
+
1511
+ return json.dumps({"repositories": configure.cran_repositories if configure.cran_repositories is not None else [],
1512
+ "cran_packages": [{
1513
+ "name": key,
1514
+ "version": value
1515
+ } for key, value in result.items()]
1516
+ })
1517
+
1518
+ @collect_queryband(queryband="InstlLbs")
1519
+ def install_lib(self, libs=None, libs_file_path=None, **kwargs):
1520
+ """
1521
+ DESCRIPTION:
1522
+ Function installs Python or R libraries in the remote user environment.
1523
+ Note:
1524
+ * Use "install_lib" API call for first time package installation within
1525
+ the environment. Use "update_lib" API only to upgrade or downgrade installed
1526
+ packages and do not use it for fresh package installation when multiple
1527
+ packages have the same dependency as it messes pip's package resolution ability.
1528
+ * For Conda R environment:
1529
+ * The library version cannot be specified. Conda only install packages to the
1530
+ latest compatible version and cannot install to a specific version.
1531
+ * The libraries should have "r-" prefix in the library name.
1532
+
1533
+
1534
+ PARAMETERS:
1535
+ libs:
1536
+ Optional Argument.
1537
+ Specifies the add-on library name(s).
1538
+ Notes:
1539
+ * Either "libs" or "libs_file_path" argument must be specified.
1540
+ * Version specified during the installation of R libraries
1541
+ is not taken into consideration. The versions specified
1542
+ in the parameters are only considered when update_lib()
1543
+ is used.
1544
+ Types: str OR list of Strings(str)
1545
+
1546
+ libs_file_path:
1547
+ Optional Argument.
1548
+ Specifies the absolute/relative path of the file (including file name)
1549
+ which supplies a list of libraries to be installed in remote user environment.
1550
+ Path specified should include the filename with extension.
1551
+ The file should contain library names and version number(optional) of libraries.
1552
+ Notes:
1553
+ * Either "libs" or "libs_file_path" argument must be specified.
1554
+ * The file must have ".txt" extension for Python environment
1555
+ and ".txt"/".json" extension for R environment.
1556
+ * The file must have ".txt" extension for conda environment.
1557
+ * The file format should adhere to the specifications of the
1558
+ requirements file used by underlying language's package
1559
+ manager to install libraries.
1560
+ Sample text file content for Python environment:
1561
+ numpy
1562
+ joblib==0.13.2
1563
+ Sample json/txt file content for R environment:
1564
+ {
1565
+ "cran_packages": [{
1566
+ "name": "anytime",
1567
+ "version": ""
1568
+ }, {
1569
+ "name": "glm2",
1570
+ "version": ""
1571
+ }]
1572
+ }
1573
+ * Version specified during the installation of R libraries
1574
+ is not taken into consideration. The versions specified in
1575
+ the parameters are only considered when update_lib() is used.
1576
+ Types: str
1577
+
1578
+ **kwargs:
1579
+ asynchronous:
1580
+ Optional Argument.
1581
+ Specifies whether to install the library in remote user environment
1582
+ synchronously or asynchronously. When set to True, libraries are installed
1583
+ asynchronously. Otherwise, libraries are installed synchronously.
1584
+ Note:
1585
+ One should not use remove_env() on the same environment till the
1586
+ asynchronous call is complete.
1587
+ Default Value: False
1588
+ Types: bool
1589
+
1590
+ timeout:
1591
+ Optional Argument.
1592
+ Specifies the time to wait in seconds for installing the libraries. If the library is
1593
+ not installed with in "timeout" seconds, the function returns a claim-id and one
1594
+ can check the status using the claim-id. If "timeout" is not specified, then there
1595
+ is no limit on the wait time.
1596
+ Note:
1597
+ Argument is ignored when "asynchronous" is True.
1598
+ Types: int OR float
1599
+
1600
+ RETURNS:
1601
+ Pandas DataFrame when libraries are installed synchronously.
1602
+ claim_id, to track status when libraries are installed asynchronously.
1603
+
1604
+ RAISES:
1605
+ TeradataMlException
1606
+
1607
+ EXAMPLES:
1608
+ # Create remote user Python environment.
1609
+ >>> env = create_env('testenv', 'python_3.7.9', 'Test environment')
1610
+ User environment testenv created.
1611
+
1612
+ # Example 1: Install single Python library asynchronously.
1613
+ >>> env.install_lib('numpy', asynchronous=True)
1614
+ Request to install libraries initiated successfully in the remote user environment testenv.
1615
+ Check the status using status() with the claim id '4b062b0e-6e9f-4996-b92b-5b20ac23b0f9'.
1616
+
1617
+ # Check the status.
1618
+ >>> env.status('4b062b0e-6e9f-4996-b92b-5b20ac23b0f9')
1619
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1620
+ 0 4b062b0e-6e9f-4996-b92b-5b20ac23b0f9 numpy install_lib Started 2022-07-13T11:07:34Z None
1621
+ 1 4b062b0e-6e9f-4996-b92b-5b20ac23b0f9 numpy install_lib Finished 2022-07-13T11:07:35Z None
1622
+ >>>
1623
+
1624
+ # Verify if libraries are installed.
1625
+ >>> env.libs
1626
+ library version
1627
+ 0 numpy 1.21.6
1628
+ 1 pip 20.1.1
1629
+ 2 setuptools 47.1.0
1630
+
1631
+ # Example 2: Install libraries asynchronously by passing them as list of library names.
1632
+ >>> env.install_lib(["pandas",
1633
+ ... "joblib==0.13.2",
1634
+ ... "scikit-learn",
1635
+ ... "numpy>=1.17.1",
1636
+ ... "nltk>=3.3,<3.5"], asynchronous=True)
1637
+ Request to install libraries initiated successfully in the remote user environment testenv.
1638
+ Check the status using status() with the claim id '90aae7df-5efe-4b5a-af26-150aab35f1fb'.
1639
+
1640
+ # Check the status.
1641
+ >>> env.status('90aae7df-5efe-4b5a-af26-150aab35f1fb')
1642
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1643
+ 0 90aae7df-5efe-4b5a-af26-150aab35f1fb pandas, joblib==0.13.2, scikit-learn, numpy>=1.17.1, nltk>=3.3,<3.5 install_lib Started 2022-07-13T11:09:39Z None
1644
+ 1 90aae7df-5efe-4b5a-af26-150aab35f1fb pandas, joblib==0.13.2, scikit-learn, numpy>=1.17.1, nltk>=3.3,<3.5 install_lib Finished 2022-07-13T11:09:40Z None
1645
+
1646
+ # Verify if libraries are installed with specific version.
1647
+ >>> env.libs
1648
+ library version
1649
+ 0 joblib 0.13.2
1650
+ 1 nltk 3.4.5
1651
+ 2 numpy 1.21.6
1652
+ 3 pandas 1.3.5
1653
+ 4 pip 20.1.1
1654
+ 5 python-dateutil 2.8.2
1655
+ 6 pytz 2022.1
1656
+ 7 scikit-learn 1.0.2
1657
+ 8 scipy 1.7.3
1658
+ 9 setuptools 47.1.0
1659
+ 10 six 1.16.0
1660
+ 11 threadpoolctl 3.1.0
1661
+
1662
+ # Example 3: Install libraries synchronously by passing them as list of library names.
1663
+ >>> env.install_lib(["Flask", "gunicorn"])
1664
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1665
+ 0 ebc11a82-4606-4ce3-9c90-9f54d1260f47 Flask, gunicorn install_lib Started 2022-08-12T05:35:58Z
1666
+ 1 ebc11a82-4606-4ce3-9c90-9f54d1260f47 Flask, gunicorn install_lib Finished 2022-08-12T05:36:13Z
1667
+ >>>
1668
+
1669
+ # Verify if libraries are installed with specific version.
1670
+ >>> env.libs
1671
+ name version
1672
+ 0 click 8.1.3
1673
+ 1 Flask 2.2.2
1674
+ 2 gunicorn 20.1.0
1675
+ 3 importlib-metadata 4.12.0
1676
+ 4 itsdangerous 2.1.2
1677
+ 5 Jinja2 3.1.2
1678
+ 6 joblib 0.13.2
1679
+ 7 MarkupSafe 2.1.1
1680
+ 8 nltk 3.4.5
1681
+ 9 numpy 1.21.6
1682
+ 10 pandas 1.3.5
1683
+ 11 pip 20.1.1
1684
+ 12 python-dateutil 2.8.2
1685
+ 13 pytz 2022.2
1686
+ 14 scikit-learn 1.0.2
1687
+ 15 scipy 1.7.3
1688
+ 16 setuptools 64.0.1
1689
+ 17 six 1.16.0
1690
+ 18 threadpoolctl 3.1.0
1691
+ 19 typing-extensions 4.3.0
1692
+ 20 Werkzeug 2.2.2
1693
+ 21 zipp 3.8.1
1694
+ >>>
1695
+
1696
+ # Example 4: Install libraries synchronously by passing them as list of library names within a
1697
+ # specific timeout of 5 seconds.
1698
+ >>> env.install_lib(["teradataml", "teradatasqlalchemy"], timeout=5)
1699
+ Request to install libraries initiated successfully in the remote user environment 'testenv' but unable to get the status. Check the status using status() with the claim id '30185e0e-bb09-485a-8312-c267fb4b3c1b'.
1700
+ '30185e0e-bb09-485a-8312-c267fb4b3c1b'
1701
+
1702
+ # Check the status.
1703
+ >>> env.status('30185e0e-bb09-485a-8312-c267fb4b3c1b')
1704
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1705
+ 0 30185e0e-bb09-485a-8312-c267fb4b3c1b teradataml, teradatasqlalchemy install_lib Started 2022-08-12T05:42:58Z
1706
+ 1 30185e0e-bb09-485a-8312-c267fb4b3c1b teradataml, teradatasqlalchemy install_lib Finished 2022-08-12T05:43:29Z
1707
+ >>>
1708
+
1709
+ # Verify if libraries are installed with specific version.
1710
+ >>> env.libs
1711
+ name version
1712
+ 0 certifi 2022.6.15
1713
+ 1 charset-normalizer 2.1.0
1714
+ 2 click 8.1.3
1715
+ 3 docker 5.0.3
1716
+ 4 Flask 2.2.2
1717
+ 5 greenlet 1.1.2
1718
+ 6 gunicorn 20.1.0
1719
+ 7 idna 3.3
1720
+ 8 importlib-metadata 4.12.0
1721
+ 9 itsdangerous 2.1.2
1722
+ 10 Jinja2 3.1.2
1723
+ 11 joblib 0.13.2
1724
+ 12 MarkupSafe 2.1.1
1725
+ 13 nltk 3.4.5
1726
+ 14 numpy 1.21.6
1727
+ 15 pandas 1.3.5
1728
+ 16 pip 20.1.1
1729
+ 17 psutil 5.9.1
1730
+ 18 pycryptodome 3.15.0
1731
+ 19 python-dateutil 2.8.2
1732
+ 20 pytz 2022.2
1733
+ 21 requests 2.28.1
1734
+ 22 scikit-learn 1.0.2
1735
+ 23 scipy 1.7.3
1736
+ 24 setuptools 64.0.1
1737
+ 25 six 1.16.0
1738
+ 26 SQLAlchemy 1.4.40
1739
+ 27 teradataml 17.10.0.1
1740
+ 28 teradatasql 17.20.0.1
1741
+ 29 teradatasqlalchemy 17.0.0.3
1742
+ 30 threadpoolctl 3.1.0
1743
+ 31 typing-extensions 4.3.0
1744
+ 32 urllib3 1.26.11
1745
+ 33 websocket-client 1.3.3
1746
+ 34 Werkzeug 2.2.2
1747
+ 35 zipp 3.8.1
1748
+ >>>
1749
+
1750
+ # Example 5: Install libraries asynchronously by creating requirement.txt file.
1751
+ # Create a requirement.txt file with below contents.
1752
+ -----------------------------------------------------------
1753
+ pandas
1754
+ joblib==0.13.2
1755
+ scikit-learn
1756
+ numpy>=1.17.1
1757
+ nltk>=3.3,<3.5
1758
+ -----------------------------------------------------------
1759
+
1760
+ # Install libraries specified in the file.
1761
+ >>> env.install_lib(libs_file_path="requirement.txt", asynchronous=True)
1762
+ Request to install libraries initiated successfully in the remote user environment testenv.
1763
+ Check the status using status() with the claim id 'f11c7f28-f958-4cae-80a8-926733954bdc'.
1764
+
1765
+ # Check the status.
1766
+ >>> env.status('8709b464-f144-4c37-8918-ef6a98ecf295')
1767
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1768
+ 0 f11c7f28-f958-4cae-80a8-926733954bdc requirements.txt install_lib Started 2022-07-13T11:23:23Z None
1769
+ 1 f11c7f28-f958-4cae-80a8-926733954bdc requirements.txt install_lib Finished 2022-07-13T11:25:37Z None
1770
+ >>>
1771
+
1772
+ # Verify if libraries are installed with specific version.
1773
+ >>> env.libs
1774
+ library version
1775
+ 0 joblib 0.13.2
1776
+ 1 nltk 3.4.5
1777
+ 2 numpy 1.21.6
1778
+ 3 pandas 1.3.5
1779
+ 4 pip 20.1.1
1780
+ 5 python-dateutil 2.8.2
1781
+ 6 pytz 2022.1
1782
+ 7 scikit-learn 1.0.2
1783
+ 8 scipy 1.7.3
1784
+ 9 setuptools 47.1.0
1785
+ 10 six 1.16.0
1786
+ 11 threadpoolctl 3.1.0
1787
+
1788
+ # Example 6: Install libraries synchronously by creating requirement.txt file.
1789
+ # Create a requirement.txt file with below contents.
1790
+ -----------------------------------------------------------
1791
+ matplotlib
1792
+ -----------------------------------------------------------
1793
+
1794
+ # Install libraries specified in the file.
1795
+ >>> env.install_lib(libs_file_path="requirements.txt")
1796
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1797
+ 0 6221681b-f663-435c-80a9-3f99d2af5d83 requirements.txt install_lib Started 2022-08-12T05:49:09Z
1798
+ 1 6221681b-f663-435c-80a9-3f99d2af5d83 requirements.txt install_lib Finished 2022-08-12T05:49:41Z
1799
+ >>>
1800
+
1801
+ # Verify if libraries are installed with specific version.
1802
+ >>> env.libs
1803
+ name version
1804
+ 0 certifi 2022.6.15
1805
+ 1 charset-normalizer 2.1.0
1806
+ 2 click 8.1.3
1807
+ 3 cycler 0.11.0
1808
+ 4 docker 5.0.3
1809
+ 5 Flask 2.2.2
1810
+ 6 fonttools 4.34.4
1811
+ 7 greenlet 1.1.2
1812
+ 8 gunicorn 20.1.0
1813
+ 9 idna 3.3
1814
+ 10 importlib-metadata 4.12.0
1815
+ 11 itsdangerous 2.1.2
1816
+ 12 Jinja2 3.1.2
1817
+ 13 joblib 0.13.2
1818
+ 14 kiwisolver 1.4.4
1819
+ 15 MarkupSafe 2.1.1
1820
+ 16 matplotlib 3.5.3
1821
+ 17 nltk 3.4.5
1822
+ 18 numpy 1.21.6
1823
+ 19 packaging 21.3
1824
+ 20 pandas 1.3.5
1825
+ 21 Pillow 9.2.0
1826
+ 22 pip 20.1.1
1827
+ 23 psutil 5.9.1
1828
+ 24 pycryptodome 3.15.0
1829
+ 25 pyparsing 3.0.9
1830
+ 26 python-dateutil 2.8.2
1831
+ 27 pytz 2022.2
1832
+ 28 requests 2.28.1
1833
+ 29 scikit-learn 1.0.2
1834
+ 30 scipy 1.7.3
1835
+ 31 setuptools 64.0.1
1836
+ 32 six 1.16.0
1837
+ 33 SQLAlchemy 1.4.40
1838
+ 34 teradataml 17.10.0.1
1839
+ 35 teradatasql 17.20.0.1
1840
+ 36 teradatasqlalchemy 17.0.0.3
1841
+ 37 threadpoolctl 3.1.0
1842
+ 38 typing-extensions 4.3.0
1843
+ 39 urllib3 1.26.11
1844
+ 40 websocket-client 1.3.3
1845
+ 41 Werkzeug 2.2.2
1846
+ 42 zipp 3.8.1
1847
+ >>>
1848
+
1849
+ # Create remote user R environment.
1850
+ >>> env = create_env('testenv', 'r_4.1', 'Test environment')
1851
+ User environment 'testenv' created.
1852
+
1853
+ # Example 1: Install single R library asynchronously.
1854
+ >>> env.install_lib('glm2', asynchronous=True)
1855
+ Request to install libraries initiated successfully in the remote user environment testenv.
1856
+ Check the status using status() with the claim id 'd073a1c8-08bc-45d0-99de-65dc189db408'.
1857
+
1858
+ # Check the status.
1859
+ >>> env.status('d073a1c8-08bc-45d0-99de-65dc189db408')
1860
+
1861
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1862
+ 0 d073a1c8-08bc-45d0-99de-65dc189db408 glm2 install_lib Started 2023-08-29T09:09:30Z
1863
+ 1 d073a1c8-08bc-45d0-99de-65dc189db408 glm2 install_lib Finished 2023-08-29T09:09:35Z
1864
+ >>>
1865
+
1866
+ # Verify if libraries are installed.
1867
+ >>> env.libs
1868
+ name version
1869
+ 0 KernSmooth 2.23-20
1870
+ 1 MASS 7.3-55
1871
+ 2 Matrix 1.4-0
1872
+ 3 base 4.1.3
1873
+ 4 boot 1.3-28
1874
+ 5 class 7.3-20
1875
+ 6 cluster 2.1.2
1876
+ 7 codetools 0.2-18
1877
+ 8 compiler 4.1.3
1878
+ 9 datasets 4.1.3
1879
+ 10 foreign 0.8-82
1880
+ 11 grDevices 4.1.3
1881
+ 12 graphics 4.1.3
1882
+ 13 grid 4.1.3
1883
+ 14 lattice 0.20-45
1884
+ 15 methods 4.1.3
1885
+ 16 mgcv 1.8-39
1886
+ 17 nlme 3.1-155
1887
+ 18 nnet 7.3-17
1888
+ 19 parallel 4.1.3
1889
+ 20 remotes 2.4.2
1890
+ 21 rpart 4.1.16
1891
+ 22 spatial 7.3-15
1892
+ 23 splines 4.1.3
1893
+ 24 stats 4.1.3
1894
+ 25 stats4 4.1.3
1895
+ 26 survival 3.2-13
1896
+ 27 tcltk 4.1.3
1897
+ 28 tools 4.1.3
1898
+ 29 utils 4.1.3
1899
+ 30 glm2 1.2.1
1900
+ >>>
1901
+
1902
+ # Example 2: Install libraries asynchronously by passing them as list of library names.
1903
+ >>> env.install_lib(['glm2', 'stringi'], asynchronous=True)
1904
+ Request to install libraries initiated successfully in the remote user environment testenv.
1905
+ Check the status using status() with the claim id '6b2ca7ac-f113-440c-bf24-1ce75ed59f36'.
1906
+
1907
+ # Check the status.
1908
+ >>> env.status('90aae7df-5efe-4b5a-af26-150aab35f1fb')
1909
+
1910
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1911
+ 0 6b2ca7ac-f113-440c-bf24-1ce75ed59f36 glm2==1.2.1, stringi install_lib Started 2023-08-29T09:42:39Z
1912
+ 1 6b2ca7ac-f113-440c-bf24-1ce75ed59f36 glm2==1.2.1, stringi install_lib Finished 2023-08-29T09:43:58Z
1913
+ >>>
1914
+
1915
+ # Verify if libraries are installed or not.
1916
+ >>> env.libs
1917
+ name version
1918
+ 0 KernSmooth 2.23-20
1919
+ 1 MASS 7.3-55
1920
+ 2 Matrix 1.4-0
1921
+ 3 base 4.1.3
1922
+ 4 boot 1.3-28
1923
+ 5 class 7.3-20
1924
+ 6 cluster 2.1.2
1925
+ 7 codetools 0.2-18
1926
+ 8 compiler 4.1.3
1927
+ 9 datasets 4.1.3
1928
+ 10 foreign 0.8-82
1929
+ 11 grDevices 4.1.3
1930
+ 12 graphics 4.1.3
1931
+ 13 grid 4.1.3
1932
+ 14 lattice 0.20-45
1933
+ 15 methods 4.1.3
1934
+ 16 mgcv 1.8-39
1935
+ 17 nlme 3.1-155
1936
+ 18 nnet 7.3-17
1937
+ 19 parallel 4.1.3
1938
+ 20 remotes 2.4.2
1939
+ 21 rpart 4.1.16
1940
+ 22 spatial 7.3-15
1941
+ 23 splines 4.1.3
1942
+ 24 stats 4.1.3
1943
+ 25 stats4 4.1.3
1944
+ 26 survival 3.2-13
1945
+ 27 tcltk 4.1.3
1946
+ 28 tools 4.1.3
1947
+ 29 utils 4.1.3
1948
+ 30 glm2 1.2.1
1949
+ 31 stringi 1.7.12
1950
+ >>>
1951
+
1952
+ # Example 3: Install libraries synchronously by passing them as list of library names.
1953
+ >>> env.install_lib(["lubridate", "zoo"])
1954
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
1955
+ 0 7483fa01-dedb-4fb2-9262-403da6b49a3b lubridate, zoo install_lib Started 2023-08-29T09:51:25Z
1956
+ 1 7483fa01-dedb-4fb2-9262-403da6b49a3b lubridate, zoo install_lib Finished 2023-08-29T09:52:20Z
1957
+ >>>
1958
+
1959
+ # Verify if libraries are installed with specific version.
1960
+ >>> env.libs
1961
+ name version
1962
+ 0 KernSmooth 2.23-20
1963
+ 1 MASS 7.3-55
1964
+ 2 Matrix 1.4-0
1965
+ 3 base 4.1.3
1966
+ 4 boot 1.3-28
1967
+ 5 class 7.3-20
1968
+ 6 cluster 2.1.2
1969
+ 7 codetools 0.2-18
1970
+ 8 compiler 4.1.3
1971
+ 9 datasets 4.1.3
1972
+ 10 foreign 0.8-82
1973
+ 11 grDevices 4.1.3
1974
+ 12 graphics 4.1.3
1975
+ 13 grid 4.1.3
1976
+ 14 lattice 0.20-45
1977
+ 15 methods 4.1.3
1978
+ 16 mgcv 1.8-39
1979
+ 17 nlme 3.1-155
1980
+ 18 nnet 7.3-17
1981
+ 19 parallel 4.1.3
1982
+ 20 remotes 2.4.2
1983
+ 21 rpart 4.1.16
1984
+ 22 spatial 7.3-15
1985
+ 23 splines 4.1.3
1986
+ 24 stats 4.1.3
1987
+ 25 stats4 4.1.3
1988
+ 26 survival 3.2-13
1989
+ 27 tcltk 4.1.3
1990
+ 28 tools 4.1.3
1991
+ 29 utils 4.1.3
1992
+ 30 cpp11 0.4.6
1993
+ 31 generics 0.1.3
1994
+ 32 glm2 1.2.1
1995
+ 33 lubridate 1.9.2
1996
+ 34 stringi 1.7.12
1997
+ 35 timechange 0.2.0
1998
+ 36 zoo 1.8-12
1999
+ >>>
2000
+
2001
+ # Example 4: Install libraries synchronously by passing them as list of library names within a
2002
+ # specific timeout of 1 seconds.
2003
+ >>> env.install_lib(["stringi", "glm2"], timeout=1)
2004
+ Request to install libraries initiated successfully in the remote user environment 'testenv' but Timed out
2005
+ status check. Check the status using status() with the claim id '7303cf6d-acea-4ab0-83b8-e6cf9149fe51'.
2006
+
2007
+ # Check the status.
2008
+ >>> env.status('7303cf6d-acea-4ab0-83b8-e6cf9149fe51')
2009
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2010
+ 0 7303cf6d-acea-4ab0-83b8-e6cf9149fe51 stringi, glm2 install_lib Started 2023-08-29T10:18:48Z
2011
+ 1 7303cf6d-acea-4ab0-83b8-e6cf9149fe51 stringi, glm2 install_lib Finished 2023-08-29T10:20:08Z
2012
+ >>>
2013
+
2014
+ # Verify if libraries are installed with specific version.
2015
+ >>> env.libs
2016
+ name version
2017
+ 0 KernSmooth 2.23-20
2018
+ 1 MASS 7.3-55
2019
+ 2 Matrix 1.4-0
2020
+ 3 base 4.1.3
2021
+ 4 boot 1.3-28
2022
+ 5 class 7.3-20
2023
+ 6 cluster 2.1.2
2024
+ 7 codetools 0.2-18
2025
+ 8 compiler 4.1.3
2026
+ 9 datasets 4.1.3
2027
+ 10 foreign 0.8-82
2028
+ 11 grDevices 4.1.3
2029
+ 12 graphics 4.1.3
2030
+ 13 grid 4.1.3
2031
+ 14 lattice 0.20-45
2032
+ 15 methods 4.1.3
2033
+ 16 mgcv 1.8-39
2034
+ 17 nlme 3.1-155
2035
+ 18 nnet 7.3-17
2036
+ 19 parallel 4.1.3
2037
+ 20 remotes 2.4.2
2038
+ 21 rpart 4.1.16
2039
+ 22 spatial 7.3-15
2040
+ 23 splines 4.1.3
2041
+ 24 stats 4.1.3
2042
+ 25 stats4 4.1.3
2043
+ 26 survival 3.2-13
2044
+ 27 tcltk 4.1.3
2045
+ 28 tools 4.1.3
2046
+ 29 utils 4.1.3
2047
+ 30 cpp11 0.4.6
2048
+ 31 generics 0.1.3
2049
+ 32 glm2 1.2.1
2050
+ 33 lubridate 1.9.2
2051
+ 34 stringi 1.7.12
2052
+ 35 timechange 0.2.0
2053
+ 36 zoo 1.8-12
2054
+ >>>
2055
+
2056
+ # Example 5: Install libraries synchronously by creating requirement.txt file.
2057
+ # Create a requirement.txt file with below contents.
2058
+ -----------------------------------------------------------
2059
+ {
2060
+ "cran_packages": [{
2061
+ "name": "anytime",
2062
+ "version": ""
2063
+ }, {
2064
+ "name": "glm2",
2065
+ "version": ""
2066
+ }]
2067
+ }
2068
+ -----------------------------------------------------------
2069
+
2070
+ # Install libraries specified in the file.
2071
+ >>> env.install_lib(libs_file_path="requirement.txt")
2072
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2073
+ 0 eab69326-5e14-4c81-8157-408fe0b633c2 requirement.txt install_lib Started 2023-08-29T12:18:26Z
2074
+ 1 eab69326-5e14-4c81-8157-408fe0b633c2 requirement.txt install_lib Finished 2023-08-29T12:23:12Z
2075
+ >>>
2076
+
2077
+ # Verify if libraries are installed with specific version.
2078
+ >>> env.libs
2079
+ name version
2080
+ 0 KernSmooth 2.23-20
2081
+ 1 MASS 7.3-55
2082
+ 2 Matrix 1.4-0
2083
+ 3 base 4.1.3
2084
+ 4 boot 1.3-28
2085
+ 5 class 7.3-20
2086
+ 6 cluster 2.1.2
2087
+ 7 codetools 0.2-18
2088
+ 8 compiler 4.1.3
2089
+ 9 datasets 4.1.3
2090
+ 10 foreign 0.8-82
2091
+ 11 grDevices 4.1.3
2092
+ 12 graphics 4.1.3
2093
+ 13 grid 4.1.3
2094
+ 14 lattice 0.20-45
2095
+ 15 methods 4.1.3
2096
+ 16 mgcv 1.8-39
2097
+ 17 nlme 3.1-155
2098
+ 18 nnet 7.3-17
2099
+ 19 parallel 4.1.3
2100
+ 20 remotes 2.4.2
2101
+ 21 rpart 4.1.16
2102
+ 22 spatial 7.3-15
2103
+ 23 splines 4.1.3
2104
+ 24 stats 4.1.3
2105
+ 25 stats4 4.1.3
2106
+ 26 survival 3.2-13
2107
+ 27 tcltk 4.1.3
2108
+ 28 tools 4.1.3
2109
+ 29 utils 4.1.3
2110
+ 30 BH 1.81.0-1
2111
+ 31 Rcpp 1.0.11
2112
+ 32 anytime 0.3.9
2113
+ 33 cpp11 0.4.6
2114
+ 34 generics 0.1.3
2115
+ 35 glm2 1.2.1
2116
+ 36 lubridate 1.9.2
2117
+ 37 stringi 1.7.12
2118
+ 38 timechange 0.2.0
2119
+ 39 zoo 1.8-12
2120
+ >>>
2121
+
2122
+ # Create remote user conda R environment.
2123
+ >>> env = create_env('testenv', base_env='r_4.3', desc='Test environment', conda_env=True)
2124
+ Conda environment creation initiated.
2125
+ User environment 'testenv' created.
2126
+
2127
+ # Example 1: Install single R library asynchronously.
2128
+ >>> env.install_lib('r-glm2', asynchronous=True)
2129
+ Request to install libraries initiated successfully in the remote user environment testenv.
2130
+ Check the status using status() with the claim id 'cccc29fe-ca45-49a6-9565-3d50bf310c92'.
2131
+
2132
+ # Check the status.
2133
+ >>> env.status('cccc29fe-ca45-49a6-9565-3d50bf310c92')
2134
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2135
+ cccc29fe-ca45-49a6-9565-3d50bf310c92 r-glm2 install_lib Started 2024-12-27T08:42:10Z
2136
+ cccc29fe-ca45-49a6-9565-3d50bf310c92 r-glm2 install_lib Finished 2024-12-27T08:42:20Z
2137
+
2138
+ # Verify if libraries are installed.
2139
+ >>> env.libs[env.libs['name'].isin(['r-glm2'])]
2140
+ name version
2141
+ 91 r-glm2 1.2.1
2142
+
2143
+ # Example 2: Install libraries asynchronously by passing them as list of library names.
2144
+ >>> env.install_lib(['r-ggplot2', 'r-dplyr'], asynchronous=True)
2145
+ Request to install libraries initiated successfully in the remote user environment testenv.
2146
+ Check the status using status() with the claim id '1125fa9e-b0f4-49cb-9c9f-d4931a22222d'.
2147
+
2148
+ # Check the status.
2149
+ >>> env.status('1125fa9e-b0f4-49cb-9c9f-d4931a22222d')
2150
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2151
+ 1125fa9e-b0f4-49cb-9c9f-d4931a22222d r-ggplot2, r-dplyr install_lib Started 2024-12-27T08:42:10Z
2152
+ 1125fa9e-b0f4-49cb-9c9f-d4931a22222d r-ggplot2, r-dplyr install_lib Finished 2024-12-27T08:42:20Z
2153
+
2154
+ # Verify if libraries are installed or not.
2155
+ >>> env.libs[env.libs['name'].isin(['r-ggplot2', 'r-dplyr'])]
2156
+ name version
2157
+ 79 r-dplyr 1.1.3
2158
+ 90 r-ggplot2 3.4.4
2159
+
2160
+ # Example 3: Install libraries synchronously by passing them as list of library names.
2161
+ >>> env.install_lib(["r-lubridate", "r-zoo"])
2162
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2163
+ 7a026a0d-6616-4398-bd89-9f8d0e06a54f r-lubridate, r-zoo install_lib Started 2024-12-27T08:46:55Z
2164
+ 7a026a0d-6616-4398-bd89-9f8d0e06a54f r-lubridate, r-zoo install_lib Finished 2024-12-27T08:47:06Z
2165
+
2166
+ # Verify if libraries are installed.
2167
+ >>> env.libs[env.libs['name'].isin(['r-lubridate', 'r-zoo'])]
2168
+ name version
2169
+ 108 r-lubridate 1.9.3
2170
+ 157 r-zoo 1.8_12
2171
+
2172
+ # Example 4: Install libraries synchronously by passing them as list of library names within a
2173
+ # specific timeout of 1 seconds.
2174
+ >>> env.install_lib(["r-stringi", "r-glm2"], timeout=1)
2175
+ Request to install libraries initiated successfully in the remote user environment 'testenv' but Timed out status check.
2176
+ Check the status using status() with the claim id '440eff39-c6d7-4efc-b797-1201a5906065'.
2177
+
2178
+ # Check the status.
2179
+ >>> env.status('440eff39-c6d7-4efc-b797-1201a5906065')
2180
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2181
+ 440eff39-c6d7-4efc-b797-1201a5906065 r-stringi, r-glm2 install_lib Started 2024-12-27T08:49:17Z
2182
+ 440eff39-c6d7-4efc-b797-1201a5906065 r-stringi, r-glm2 install_lib Finished 2024-12-27T08:49:27Z
2183
+
2184
+ # Verify if libraries are installed.
2185
+ >>> env.libs[env.libs['name'].isin(['r-stringi', 'r-glm2'])]
2186
+ name version
2187
+ 91 r-glm2 1.2.1
2188
+ 140 r-stringi 1.7.12
2189
+
2190
+ # Example 5: Install libraries synchronously by creating requirement.txt file.
2191
+ # Create a requirement.txt file with below contents.
2192
+ -----------------------------------------------------------
2193
+ r-caret
2194
+ r-forecast
2195
+ -----------------------------------------------------------
2196
+
2197
+ # Install libraries specified in the file.
2198
+ >>> env.install_lib(libs_file_path="requirement.txt")
2199
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2200
+ f3963a46-2225-412d-a470-17f26c759b42 requirement.txt install_lib Started 2024-12-27T08:52:28Z
2201
+ f3963a46-2225-412d-a470-17f26c759b42 requirement.txt install_lib Finished 2024-12-27T08:53:32Z
2202
+
2203
+ # Verify if libraries are installed.
2204
+ >>> env.libs[env.libs['name'].isin(['r-caret', 'r-forecast'])]
2205
+ name version
2206
+ 68 r-caret 6.0_94
2207
+ 85 r-forecast 8.21.1
2208
+ """
2209
+ asynchronous = kwargs.get("asynchronous", False)
2210
+ timeout = kwargs.get("timeout")
2211
+ async_task_info = self.__manage_libraries(libs, libs_file_path, "INSTALL", asynchronous, timeout)
2212
+ return async_task_info
2213
+
2214
+ @collect_queryband(queryband="UninstlLbs")
2215
+ def uninstall_lib(self, libs=None, libs_file_path=None, **kwargs):
2216
+ """
2217
+ DESCRIPTION:
2218
+ Function uninstalls libraries from corresponding Python or R
2219
+ remote user environment.
2220
+ Note:
2221
+ * For Conda R environment, the libraries should have "r-" prefix in the library name.
2222
+
2223
+ PARAMETERS:
2224
+ libs:
2225
+ Optional Argument.
2226
+ Specifies the library name(s).
2227
+ Note:
2228
+ Either "libs" or "libs_file_path" argument must be specified.
2229
+ Types: str OR list of Strings(str)
2230
+
2231
+ libs_file_path:
2232
+ Optional Argument.
2233
+ Specifies the absolute/relative path of the file (including file name)
2234
+ which supplies a list of libraries to be uninstalled from the remote user
2235
+ environment. Path specified should include the filename with extension.
2236
+ The file should contain library names and version number(optional) of libraries.
2237
+ Notes:
2238
+ * Either "libs" or "libs_file_path" argument must be specified.
2239
+ * The file must have ".txt" extension for Python environment
2240
+ and ".txt"/".json" extension for R environment.
2241
+ * The file must have ".txt" extension for conda environment.
2242
+ * The file format should adhere to the specifications of the
2243
+ requirements file used by underlying language's package
2244
+ manager for uninstalling libraries.
2245
+ Sample text file content for Python environment:
2246
+ numpy
2247
+ joblib==0.13.2
2248
+ Sample json/txt file content for R environment:
2249
+ {
2250
+ "packages": ["anytime","glm2"]
2251
+ }
2252
+ Types: str
2253
+
2254
+ **kwargs:
2255
+ asynchronous:
2256
+ Optional Argument.
2257
+ Specifies whether to uninstall the library in remote user environment
2258
+ synchronously or asynchronously. When set to True, libraries are uninstalled
2259
+ asynchronously. Otherwise, libraries are uninstalled synchronously.
2260
+ Note:
2261
+ One should not use remove_env() on the same environment till the
2262
+ asynchronous call is complete.
2263
+ Default Value: False
2264
+ Types: bool
2265
+
2266
+ timeout:
2267
+ Optional Argument.
2268
+ Specifies the time to wait in seconds for uninstalling the libraries. If the library is
2269
+ not uninstalled with in "timeout" seconds, the function returns a claim-id and one
2270
+ can check the status using the claim-id. If "timeout" is not specified, then there
2271
+ is no limit on the wait time.
2272
+ Note:
2273
+ Argument is ignored when "asynchronous" is True.
2274
+ Types: int OR float
2275
+
2276
+ RETURNS:
2277
+ Pandas DataFrame when libraries are uninstalled synchronously.
2278
+ claim_id, to track status when libraries are uninstalled asynchronously.
2279
+
2280
+ RAISES:
2281
+ TeradataMlException
2282
+
2283
+ EXAMPLES:
2284
+ # Examples for Python environment.
2285
+ # Create remote Python user environment.
2286
+ >>> testenv = create_env('testenv', 'python_3.7.9', 'Test environment')
2287
+ User environment testenv created.
2288
+
2289
+ # Example 1: Install and uninstall a single Python library.
2290
+ >>> testenv.install_lib('numpy')
2291
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2292
+ 0 407e644d-3630-4085-8a0b-169406f52340 numpy install_lib Started 2022-07-13T11:32:32Z None
2293
+ 1 407e644d-3630-4085-8a0b-169406f52340 numpy install_lib Finished 2022-07-13T11:32:33Z None
2294
+ >>>
2295
+
2296
+ # Verify installed library.
2297
+ >>> testenv.libs
2298
+ library version
2299
+ 0 numpy 1.21.6
2300
+ 1 pip 20.1.1
2301
+ 2 setuptools 47.1.0
2302
+
2303
+ # Uninstall single Python library asynchronously.
2304
+ >>> testenv.uninstall_lib('numpy', asynchronous=True)
2305
+ Request to uninstall libraries initiated successfully in the remote user environment testenv.
2306
+ Check the status using status() with the claim id '16036846-b9d7-4c5b-be92-d7cf14aa2016'.
2307
+
2308
+ # Check the status.
2309
+ >>> testenv.status('16036846-b9d7-4c5b-be92-d7cf14aa2016')
2310
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2311
+ 0 16036846-b9d7-4c5b-be92-d7cf14aa2016 numpy uninstall_lib Started 2022-07-13T11:33:42Z None
2312
+ 1 16036846-b9d7-4c5b-be92-d7cf14aa2016 numpy uninstall_lib Finished 2022-07-13T11:33:42Z None
2313
+ >>>
2314
+
2315
+ # Verify library is uninstalled.
2316
+ >>> testenv.libs
2317
+ library version
2318
+ 0 pip 20.1.1
2319
+ 1 setuptools 47.1.0
2320
+
2321
+ # Example 2: Install list of Python libraries asynchronously and uninstall them synchronously.
2322
+ >>> testenv.install_lib(["pandas", "scikit-learn"], asynchronous=True)
2323
+ Request to install libraries initiated successfully in the remote user environment testenv.
2324
+ Check the status using status() with the claim id 'a91af321-cf57-43cc-b864-a67fa374cb42'.
2325
+
2326
+ # Check the status
2327
+ >>> testenv.status('a91af321-cf57-43cc-b864-a67fa374cb42')
2328
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2329
+ 0 a91af321-cf57-43cc-b864-a67fa374cb42 pandas, scikit-learn install_lib Started 2022-07-13T11:34:38Z None
2330
+ 1 a91af321-cf57-43cc-b864-a67fa374cb42 pandas, scikit-learn install_lib Finished 2022-07-13T11:36:40Z None
2331
+ >>>
2332
+
2333
+ # Verify libraries are installed along with its dependant libraries.
2334
+ >>> testenv.libs
2335
+ library version
2336
+ 0 joblib 1.1.0
2337
+ 1 numpy 1.21.6
2338
+ 2 pandas 1.3.5
2339
+ 3 pip 20.1.1
2340
+ 4 python-dateutil 2.8.2
2341
+ 5 pytz 2022.1
2342
+ 6 scikit-learn 1.0.2
2343
+ 7 scipy 1.7.3
2344
+ 8 setuptools 47.1.0
2345
+ 9 six 1.16.0
2346
+ 10 threadpoolctl 3.1.0
2347
+
2348
+ # Uninstall libraries by passing them as a list of library names.
2349
+ >>> testenv.uninstall_lib(["pandas", "scikit-learn"])
2350
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2351
+ 0 8d6bb524-c047-4aae-8597-b48ab467ef37 pandas, scikit-learn uninstall_lib Started 2022-07-13T11:46:55Z None
2352
+ 1 8d6bb524-c047-4aae-8597-b48ab467ef37 pandas, scikit-learn uninstall_lib Finished 2022-07-13T11:47:20Z None
2353
+ >>>
2354
+
2355
+ # Verify if the specified libraries are uninstalled.
2356
+ >>> testenv.libs
2357
+ library version
2358
+ 0 joblib 1.1.0
2359
+ 1 numpy 1.21.6
2360
+ 2 pip 20.1.1
2361
+ 3 python-dateutil 2.8.2
2362
+ 4 pytz 2022.1
2363
+ 5 scipy 1.7.3
2364
+ 6 setuptools 47.1.0
2365
+ 7 six 1.16.0
2366
+ 8 threadpoolctl 3.1.0
2367
+
2368
+ # Example 3: Install and uninstall libraries specified in
2369
+ # requirement text file asynchronously.
2370
+
2371
+ # Install libraries by creating requirement.txt file.
2372
+ # Create a requirement.txt file with below contents.
2373
+ -----------------------------------------------------------
2374
+ pandas
2375
+ joblib==0.13.2
2376
+ scikit-learn
2377
+ numpy>=1.17.1
2378
+ nltk>=3.3,<3.5
2379
+ -----------------------------------------------------------
2380
+
2381
+ # Install libraries specified in the file.
2382
+ >>> testenv.install_lib(libs_file_path="requirements.txt", asynchronous=True)
2383
+ Request to install libraries initiated successfully in the remote user environment testenv.
2384
+ Check the status using status() with the claim id 'c3669eea-327c-453f-b068-6b5f3f4768a5'.
2385
+
2386
+ # Check the status.
2387
+ >>> testenv.status('c3669eea-327c-453f-b068-6b5f3f4768a5')
2388
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2389
+ 0 c3669eea-327c-453f-b068-6b5f3f4768a5 requirements.txt install_lib Started 2022-07-13T11:48:46Z None
2390
+ 1 c3669eea-327c-453f-b068-6b5f3f4768a5 requirements.txt install_lib Finished 2022-07-13T11:50:09Z None
2391
+ >>>
2392
+
2393
+ # Verify libraries are installed along with its dependant libraries.
2394
+ library version
2395
+ 0 joblib 1.1.0
2396
+ 1 numpy 1.21.6
2397
+ 2 pandas 1.3.5
2398
+ 3 pip 20.1.1
2399
+ 4 python-dateutil 2.8.2
2400
+ 5 pytz 2022.1
2401
+ 6 scikit-learn 1.0.2
2402
+ 7 scipy 1.7.3
2403
+ 8 setuptools 47.1.0
2404
+ 9 six 1.16.0
2405
+ 10 threadpoolctl 3.1.0
2406
+
2407
+ # Uninstall libraries specified in the file.
2408
+ >>> testenv.uninstall_lib(libs_file_path="requirements.txt", asynchronous=True)
2409
+ Request to uninstall libraries initiated successfully in the remote user environment testenv.
2410
+ Check the status using status() with the claim id '95ebfc7b-2910-4aab-be80-3e47f84737bd'.
2411
+
2412
+ # Check the status.
2413
+ >>> testenv.status('95ebfc7b-2910-4aab-be80-3e47f84737bd')
2414
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2415
+ 0 95ebfc7b-2910-4aab-be80-3e47f84737bd requirements.txt uninstall_lib Started 2022-07-13T11:52:03Z None
2416
+ 1 95ebfc7b-2910-4aab-be80-3e47f84737bd requirements.txt uninstall_lib Finished 2022-07-13T11:52:39Z None
2417
+ >>>
2418
+
2419
+ # Verify if the specified libraries are uninstalled.
2420
+ >>> testenv.libs
2421
+ library version
2422
+ 0 joblib 1.1.0
2423
+ 1 numpy 1.21.6
2424
+ 2 pip 20.1.1
2425
+ 3 python-dateutil 2.8.2
2426
+ 4 pytz 2022.1
2427
+ 5 scipy 1.7.3
2428
+ 6 setuptools 47.1.0
2429
+ 7 six 1.16.0
2430
+ 8 threadpoolctl 3.1.0
2431
+
2432
+ # Example 4: Install and uninstall libraries specified in requirement text file synchronously
2433
+ # by specifying the timeout.
2434
+
2435
+ # Install libraries by creating requirement.txt file.
2436
+ # Create a requirement.txt file with below contents.
2437
+ -----------------------------------------------------------
2438
+ matplotlib
2439
+ -----------------------------------------------------------
2440
+
2441
+ # Install libraries specified in the file.
2442
+ >>> testenv.install_lib(libs_file_path="requirements.txt")
2443
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2444
+ 0 d441bc45-6594-4244-ba26-de2ca3272d3f requirements.txt install_lib Started 2022-08-12T06:03:54Z
2445
+ 1 d441bc45-6594-4244-ba26-de2ca3272d3f requirements.txt install_lib Finished 2022-08-12T06:04:44Z
2446
+ >>>
2447
+
2448
+ # Verify libraries are installed along with its dependant libraries.
2449
+ >>> testenv.libs
2450
+ name version
2451
+ 0 cycler 0.11.0
2452
+ 1 fonttools 4.34.4
2453
+ 2 kiwisolver 1.4.4
2454
+ 3 matplotlib 3.5.3
2455
+ 4 numpy 1.21.6
2456
+ 5 packaging 21.3
2457
+ 6 Pillow 9.2.0
2458
+ 7 pip 20.1.1
2459
+ 8 pyparsing 3.0.9
2460
+ 9 python-dateutil 2.8.2
2461
+ 10 setuptools 47.1.0
2462
+ 11 six 1.16.0
2463
+ 12 typing-extensions 4.3.0
2464
+ >>>
2465
+
2466
+ # Uninstall libraries specified in the file.
2467
+ >>> testenv.uninstall_lib(libs_file_path="requirements.txt", timeout=1)
2468
+ Request to uninstall libraries initiated successfully in the remote user environment 'testenv' but unable to get the status. Check the status using status() with the claim id '3e811857-969d-418c-893d-29ec38f54020'.
2469
+ '3e811857-969d-418c-893d-29ec38f54020'
2470
+ >>>
2471
+
2472
+ # Check the status.
2473
+ >>> testenv.status('3e811857-969d-418c-893d-29ec38f54020')
2474
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2475
+ 0 3e811857-969d-418c-893d-29ec38f54020 requirements.txt uninstall_lib Started 2022-08-12T06:05:51Z
2476
+ 1 3e811857-969d-418c-893d-29ec38f54020 requirements.txt uninstall_lib Finished 2022-08-12T06:05:57Z
2477
+ >>>
2478
+
2479
+ # Verify if the specified libraries are uninstalled.
2480
+ >>> testenv.libs
2481
+ name version
2482
+ 0 cycler 0.11.0
2483
+ 1 fonttools 4.34.4
2484
+ 2 kiwisolver 1.4.4
2485
+ 3 numpy 1.21.6
2486
+ 4 packaging 21.3
2487
+ 5 Pillow 9.2.0
2488
+ 6 pip 20.1.1
2489
+ 7 pyparsing 3.0.9
2490
+ 8 python-dateutil 2.8.2
2491
+ 9 setuptools 47.1.0
2492
+ 10 six 1.16.0
2493
+ 11 typing-extensions 4.3.0
2494
+ >>>
2495
+
2496
+ # Examples for R environment.
2497
+ # Create remote R user environment.
2498
+ >>> r_env = create_env('test_r_env', 'r_4.1', 'Test R environment')
2499
+ User environment 'test_r_env' created.
2500
+ >>>
2501
+
2502
+ # Install R libraries in environment.
2503
+ >>> r_env.install_lib(['glm2', 'stringi', "lubridate", "zoo", "anytime", "plyr", "testthat", "dplyr"])
2504
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2505
+ 0 6c7d049e-bf80-49a3-bee3-e058f78655fd glm2, stringi, lubridate, zoo, anytime, plyr, ... install_lib Started 2023-09-12T09:30:14Z
2506
+ 1 6c7d049e-bf80-49a3-bee3-e058f78655fd glm2, stringi, lubridate, zoo, anytime, plyr, ... install_lib Finished 2023-09-12T09:42:48Z
2507
+ >>>
2508
+
2509
+ # Verify installed libraries.
2510
+ >>> r_env.libs
2511
+ name version
2512
+ 0 KernSmooth 2.23-20
2513
+ 1 MASS 7.3-55
2514
+ 2 Matrix 1.4-0
2515
+ 3 base 4.1.3
2516
+ .. ... ...
2517
+ 33 anytime 0.3.9
2518
+ .. ... ...
2519
+ 42 dplyr 1.1.3
2520
+ .. ... ...
2521
+ 48 glm2 1.2.1
2522
+ .. ... ...
2523
+ 52 lubridate 1.9.2
2524
+ .. ... ...
2525
+ 57 plyr 1.8.8
2526
+ .. ... ...
2527
+ 64 stringi 1.7.12
2528
+ 65 testthat 3.1.10
2529
+ .. ... ...
2530
+ 72 withr 2.5.0
2531
+ 73 zoo 1.8-12
2532
+ >>>
2533
+
2534
+ # Example 5: Uninstall single R library synchronously.
2535
+ >>> r_env.uninstall_lib('glm2')
2536
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2537
+ 0 f98cfbfd-8b1d-4ff8-8145-001a1e5b2009 glm2 uninstall_lib Started 2023-09-12T10:14:59Z
2538
+ 1 f98cfbfd-8b1d-4ff8-8145-001a1e5b2009 glm2 uninstall_lib Finished 2023-09-12T10:15:01Z
2539
+
2540
+ # Verify if library is uninstalled.
2541
+ >>> r_env.libs
2542
+ name version
2543
+ 0 KernSmooth 2.23-20
2544
+ 1 MASS 7.3-55
2545
+ 2 Matrix 1.4-0
2546
+ 3 base 4.1.3
2547
+ .. ... ...
2548
+ 33 anytime 0.3.9
2549
+ .. ... ...
2550
+ 42 dplyr 1.1.3
2551
+ .. ... ...
2552
+ 51 lubridate 1.9.2
2553
+ .. ... ...
2554
+ 56 plyr 1.8.8
2555
+ .. ... ...
2556
+ 63 stringi 1.7.12
2557
+ 64 testthat 3.1.10
2558
+ .. ... ...
2559
+ 71 withr 2.5.0
2560
+ 72 zoo 1.8-12
2561
+ >>>
2562
+
2563
+ # Example 6: Uninstall multiple R libraries synchronously
2564
+ # by passing them as a list of library names.
2565
+ >>> r_env.uninstall_lib(['stringi', "lubridate"])
2566
+
2567
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2568
+ 0 11103430-62fa-4983-ae52-fa176c5efa93 stringi, lubridate uninstall_lib Started 2023-09-12T10:21:21Z
2569
+ 1 11103430-62fa-4983-ae52-fa176c5efa93 stringi, lubridate uninstall_lib Finished 2023-09-12T10:21:23Z
2570
+ >>>
2571
+
2572
+ # Verify if libraries are uninstalled.
2573
+ >>> r_env.libs
2574
+ name version
2575
+ 0 KernSmooth 2.23-20
2576
+ 1 MASS 7.3-55
2577
+ 2 Matrix 1.4-0
2578
+ 3 base 4.1.3
2579
+ .. ... ...
2580
+ 33 anytime 0.3.9
2581
+ .. ... ...
2582
+ 42 dplyr 1.1.3
2583
+ .. ... ...
2584
+ 55 plyr 1.8.8
2585
+ .. ... ...
2586
+ 62 testthat 3.1.10
2587
+ .. ... ...
2588
+ 69 withr 2.5.0
2589
+ 70 zoo 1.8-12
2590
+ >>>
2591
+
2592
+ # Example 7: Uninstall libraries synchronously by specifying
2593
+ # them in a file.
2594
+
2595
+ # Create a requirement.json file with below contents.
2596
+ -----------------------------------------------------------
2597
+ {
2598
+ "packages": ["zoo", "anytime"]
2599
+ }
2600
+ -----------------------------------------------------------
2601
+
2602
+ # Uninstall libraries specified in the file.
2603
+ >>> r_env.uninstall_lib(libs_file_path="requirement.json")
2604
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2605
+ 0 7fbba8d7-7f16-47d1-b02d-b1df8a79ad6b requirement.json uninstall_lib Started 2023-09-12T12:14:31Z
2606
+ 1 7fbba8d7-7f16-47d1-b02d-b1df8a79ad6b requirement.json uninstall_lib Finished 2023-09-12T12:14:33Z
2607
+ >>>
2608
+
2609
+ # Verify if libraries are uninstalled.
2610
+ >>> r_env.libs
2611
+ name version
2612
+ 0 KernSmooth 2.23-20
2613
+ 1 MASS 7.3-55
2614
+ 2 Matrix 1.4-0
2615
+ 3 base 4.1.3
2616
+ .. ... ...
2617
+ 41 dplyr 1.1.3
2618
+ .. ... ...
2619
+ 54 plyr 1.8.8
2620
+ .. ... ...
2621
+ 61 testthat 3.1.10
2622
+ .. ... ...
2623
+ 68 withr 2.5.0
2624
+
2625
+ # Example 8: Uninstall R libraries asynchronously.
2626
+ >>> r_env.uninstall_lib(["plyr", "testthat"], asynchronous=True)
2627
+ Request to uninstall libraries initiated successfully in the remote user environment test_r_env. Check the status using status() with the claim id 'e6f90aaf-ecf5-467d-95cb-8032444494d6'.
2628
+ 'e6f90aaf-ecf5-467d-95cb-8032444494d6'
2629
+ >>>
2630
+
2631
+ # Check the status using claim id.
2632
+ >>> r_env.status('e6f90aaf-ecf5-467d-95cb-8032444494d6')
2633
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2634
+ 0 e6f90aaf-ecf5-467d-95cb-8032444494d6 plyr, testthat uninstall_lib Started 2023-09-12T12:18:50Z
2635
+ 1 e6f90aaf-ecf5-467d-95cb-8032444494d6 plyr, testthat uninstall_lib Finished 2023-09-12T12:18:51Z
2636
+ >>>
2637
+
2638
+ # Verify if libraries are uninstalled.
2639
+ >>> r_env.libs
2640
+ name version
2641
+ 0 KernSmooth 2.23-20
2642
+ 1 MASS 7.3-55
2643
+ 2 Matrix 1.4-0
2644
+ 3 base 4.1.3
2645
+ 4 boot 1.3-28
2646
+ .. ... ...
2647
+ 41 dplyr 1.1.3
2648
+ .. ... ...
2649
+ 65 waldo 0.5.1
2650
+ 66 withr 2.5.0
2651
+ >>>
2652
+
2653
+ # Examples for conda R environment.
2654
+ # Create remote conda R user environment.
2655
+ >>> conda_r_env = create_env('test_conda_r_env', 'r_4.3', 'Test conda R environment', conda_env=True)
2656
+ Conda environment creation initiated.
2657
+ User environment 'test_conda_r_env' created.
2658
+
2659
+ # Install R libraries in conda environment.
2660
+ >>> conda_r_env.install_lib(['r-caret', 'r-forecast', 'r-glm2', 'r-anytime'])
2661
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
2662
+ ec6c087e-aee5-42fd-8677-a5f2a8bc5050 r-caret, r-forecast, r-glm2, r-anytime install_lib Started 2024-12-27T10:23:34Z
2663
+ ec6c087e-aee5-42fd-8677-a5f2a8bc5050 r-caret, r-forecast, r-glm2, r-anytime install_lib Finished 2024-12-27T10:28:15Z
2664
+
2665
+ # Verify installed libraries.
2666
+ >>> conda_r_env.libs[conda_r_env.libs['name'].isin(['r-caret', 'r-forecast', 'r-glm2', 'r-anytime'])]
2667
+ name version
2668
+ 67 r-anytime 0.3.9
2669
+ 70 r-caret 6.0_94
2670
+ 87 r-forecast 8.21.1
2671
+ 93 r-glm2 1.2.1
2672
+
2673
+ # Uninstall single R library asynchronously.
2674
+ >>> conda_r_env.uninstall_lib('r-caret', asynchronous=True)
2675
+ Request to uninstall libraries initiated successfully in the remote user environment testenv.
2676
+ Check the status using status() with the claim id '77db7baf-1c4f-4de0-8019-d0f72718b90f'.
2677
+
2678
+ # Check the status.
2679
+ >>> conda_r_env.status('77db7baf-1c4f-4de0-8019-d0f72718b90f')
2680
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2681
+ 77db7baf-1c4f-4de0-8019-d0f72718b90f r-caret uninstall_lib Started 2024-12-27T08:49:17Z
2682
+ 77db7baf-1c4f-4de0-8019-d0f72718b90f r-caret uninstall_lib Finished 2024-12-27T08:49:19Z
2683
+
2684
+
2685
+ # Verify if library is uninstalled.
2686
+ >>> conda_r_env.libs[conda_r_env.libs['name'].isin(['r-caret'])]
2687
+ name version
2688
+
2689
+ # Example 5: Uninstall libraries synchronously by creating requirement.txt file.
2690
+ # Create a requirement.txt file with below contents.
2691
+ -----------------------------------------------------------
2692
+ r-glm2
2693
+ r-anytime
2694
+ -----------------------------------------------------------
2695
+
2696
+ # Uninstall libraries specified in the file.
2697
+ >>> conda_r_env.uninstall_lib(libs_file_path="requirement.txt")
2698
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2699
+ 0f3963a46-2225-412d-a470-17f26c759b42 requirement.txt install_lib Started 2024-12-27T08:52:28Z
2700
+ 0f3963a46-2225-412d-a470-17f26c759b42 requirement.txt install_lib Finished 2024-12-27T08:52:32Z
2701
+
2702
+ # Verify if libraries are uninstalled.
2703
+ >>> conda_r_env.libs[conda_r_env.libs['name'].isin(['r-glm2', 'r-anytime'])]
2704
+ name version
2705
+
2706
+ """
2707
+ asynchronous = kwargs.get("asynchronous", False)
2708
+ timeout = kwargs.get("timeout")
2709
+ async_task_info = self.__manage_libraries(libs, libs_file_path, "UNINSTALL", asynchronous, timeout)
2710
+ return async_task_info
2711
+
2712
+ @collect_queryband(queryband="UpdtLbs")
2713
+ def update_lib(self, libs=None, libs_file_path=None, **kwargs):
2714
+ """
2715
+ DESCRIPTION:
2716
+ Function updates Python or R libraries if already installed,
2717
+ otherwise installs the libraries in remote user environment.
2718
+ Notes:
2719
+ * Use "install_lib" API call for first time package installation within
2720
+ the environment. Use "update_lib" API only to upgrade or downgrade installed
2721
+ packages and do not use it for fresh package installation when multiple
2722
+ packages have the same dependency as it messes pip's package resolution ability.
2723
+ * Use "update_lib" to update packages one at a time to prevent dependency resolution
2724
+ issues.
2725
+ * For Conda R environment:
2726
+ * The library version cannot be specified. Conda only updates the installed packages to the
2727
+ latest compatible version and cannot update to a specific version.
2728
+ * The libraries should have "r-" prefix in the library name.
2729
+
2730
+ PARAMETERS:
2731
+ libs:
2732
+ Optional Argument.
2733
+ Specifies the library name(s).
2734
+ Notes:
2735
+ * Either "libs" or "libs_file_path" argument must be specified.
2736
+ * While passing the libraries as string or list of
2737
+ strings, one should adhere to the requirements
2738
+ specified by underlying language's package manager.
2739
+ For conda environment:
2740
+ * Only library name(s) should be specified. Library version
2741
+ cannot be specified.
2742
+ Conda only updates the installed packages to the latest
2743
+ compatible version and cannot update to a specific version.
2744
+ For R environment:
2745
+ * Refer to allowed formats here:
2746
+ https://remotes.r-lib.org/reference/install_version.html
2747
+ * Specifying as a character vector is not supported as one
2748
+ of the accepted value.
2749
+ * Whitespace is required between comparator operator(s) and
2750
+ version.
2751
+ * '==' should be used for exact version, '=' is not allowed.
2752
+ Types: str OR list of Strings(str)
2753
+
2754
+ libs_file_path:
2755
+ Optional Argument.
2756
+ Specifies the absolute/relative path of the file (including file name)
2757
+ which supplies a list of libraries to be updated from the remote user
2758
+ environment. Path specified should include the filename with extension.
2759
+ The file should contain library name and version number(optional) of
2760
+ libraries.
2761
+ Notes:
2762
+ * Either "libs" or "libs_file_path" argument must be specified.
2763
+ * The file must have ".txt" extension for Python environment
2764
+ and ".txt"/".json" extension for R environment.
2765
+ * The file format should adhere to the specifications of the
2766
+ requirements file used by underlying language's package
2767
+ manager for updating libraries.
2768
+ Sample text file content for Python environment:
2769
+ numpy
2770
+ joblib==0.13.2
2771
+ Sample json/txt file content for R environment:
2772
+ {
2773
+ "cran_packages": [{
2774
+ "name": "anytime",
2775
+ "version": "0.3.9"
2776
+ }, {
2777
+ "name": "glm2",
2778
+ "version": ">= 1.1.2, < 1.2"
2779
+ }]
2780
+ }
2781
+ * For conda environment:
2782
+ * The file should only contain the package names.
2783
+ Library version cannot be specified. Conda only updates the
2784
+ installed packages to the latest compatible version and
2785
+ cannot update to a specific version.
2786
+ * The file should have ".txt" extension for R environment.
2787
+ Sample text file content for R conda environment:
2788
+ r-glm2
2789
+ r-anytime
2790
+ Types: str
2791
+
2792
+ **kwargs:
2793
+ asynchronous:
2794
+ Optional Argument.
2795
+ Specifies whether to update the library in remote user environment
2796
+ synchronously or asynchronously. When set to True, libraries are updated
2797
+ asynchronously. Otherwise, libraries are updated synchronously.
2798
+ Note:
2799
+ One should not use remove_env() on the same environment till the
2800
+ asynchronous call is complete.
2801
+ Default Value: False
2802
+ Types: bool
2803
+
2804
+ timeout:
2805
+ Optional Argument.
2806
+ Specifies the time to wait in seconds for updating the libraries. If the library is
2807
+ not updated with in "timeout" seconds, the function returns a claim-id and one
2808
+ can check the status using the claim-id. If "timeout" is not specified, then there
2809
+ is no limit on the wait time.
2810
+ Note:
2811
+ Argument is ignored when "asynchronous" is True.
2812
+ Types: int OR float
2813
+
2814
+ RETURNS:
2815
+ claim_id, to track status.
2816
+
2817
+ RAISES:
2818
+ TeradataMlException
2819
+
2820
+ EXAMPLES:
2821
+ # Examples for Python environment.
2822
+ # Create remote Python user environment.
2823
+ >>> testenv = create_env('testenv', 'python_3.7.9', 'Test environment')
2824
+ User environment testenv created.
2825
+
2826
+ # Example 1: Update a single Python library asynchronously.
2827
+ # Install a Python library.
2828
+ >>> testenv.install_lib(["joblib==0.13.2"], asynchronous=True)
2829
+ Request to install libraries initiated successfully in the remote user environment testenv.
2830
+ Check the status using status() with the claim id 'f44443a9-42c3-4fd3-b4a2-735d1bfb7c27'.
2831
+
2832
+ # Check the status.
2833
+ >>> testenv.status('f44443a9-42c3-4fd3-b4a2-735d1bfb7c27')
2834
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2835
+ 0 f44443a9-42c3-4fd3-b4a2-735d1bfb7c27 joblib==0.13.2 install_lib Finished 2022-07-13T11:54:31Z None
2836
+ >>>
2837
+
2838
+ # Verify joblib library is installed with specified version.
2839
+ >>> testenv.libs
2840
+ library version
2841
+ 0 joblib 0.13.2
2842
+ 1 pip 20.1.1
2843
+ 2 setuptools 47.1.0
2844
+
2845
+ # Update joblib libary to the new version specified.
2846
+ >>> testenv.update_lib("joblib==0.14.1", asynchronous=True)
2847
+ Request to update libraries initiated successfully in the remote user environment testenv.
2848
+ Check the status using status() with the claim id '8bfe55fc-efaa-44c7-9137-af24b6bb9ef8'.
2849
+
2850
+ # Check the status.
2851
+ >>> testenv.status('8bfe55fc-efaa-44c7-9137-af24b6bb9ef8')
2852
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2853
+ 0 8bfe55fc-efaa-44c7-9137-af24b6bb9ef8 joblib==0.14.1 update_lib Finished 2022-07-13T11:55:29Z None
2854
+ >>>
2855
+
2856
+ # Verify joblib library version is updated with specified version.
2857
+ >>> testenv.libs
2858
+ library version
2859
+ 0 joblib 0.14.1
2860
+ 1 pip 20.1.1
2861
+ 2 setuptools 47.1.0
2862
+
2863
+ # Example 2: Update multiple Python libraries synchronously.
2864
+ >>> testenv.update_lib(["joblib==0.14.1","numpy==1.19.5"])
2865
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2866
+ 0 28e0e03e-469b-440c-a939-a0e8a901078f joblib==0.14.1, numpy==1.19.5 update_lib Started 2022-07-13T11:56:32Z None
2867
+ 1 28e0e03e-469b-440c-a939-a0e8a901078f joblib==0.14.1, numpy==1.19.5 update_lib Finished 2022-07-13T11:56:34Z None
2868
+ >>>
2869
+
2870
+ # Verify if numpy is installed with the specific version.
2871
+ >>> testenv.libs
2872
+ library version
2873
+ 0 joblib 0.14.1
2874
+ 1 numpy 1.19.5
2875
+ 2 pip 20.1.1
2876
+ 3 setuptools 47.1.0
2877
+
2878
+ # Example 3: update libraries specified in the requirements text file asynchrnously.
2879
+ # Create a requirement.txt file with below contents.
2880
+ -----------------------------------------------------------
2881
+ numpy==1.21.6
2882
+ -----------------------------------------------------------
2883
+ >>> testenv.update_lib(libs_file_path="requirement.txt", asynchronous=True)
2884
+ Request to update libraries initiated successfully in the remote user environment testenv.
2885
+ Check the status using status() with the claim id 'd3301da5-f5cb-4248-95dc-a59e77fe9db5'.
2886
+
2887
+ # Verify if numpy is updated to the specific version.
2888
+ >>> testenv.libs
2889
+ library version
2890
+ 0 joblib 0.14.1
2891
+ 1 numpy 1.21.6
2892
+ 2 pip 20.1.1
2893
+ 3 setuptools 47.1.0
2894
+
2895
+ # Example 4: Downgrade the Python library joblib to 0.13.2 synchronously by specifying timeout.
2896
+ # As higher version of the package is not automatically uninstalled, we need to uninstall the higher version
2897
+ # to use the lower version.
2898
+ >>> testenv.uninstall_lib("joblib", asynchronous=True)
2899
+ Request to uninstall libraries initiated successfully in the remote user environment testenv.
2900
+ Check the status using status() with the claim id 'e32d69d9-452b-4600-be4b-1d5c60647a54'.
2901
+
2902
+ >>> testenv.status('e32d69d9-452b-4600-be4b-1d5c60647a54')
2903
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2904
+ 0 e32d69d9-452b-4600-be4b-1d5c60647a54 joblib uninstall_lib Started 2022-07-13T11:59:14Z None
2905
+ 1 e32d69d9-452b-4600-be4b-1d5c60647a54 joblib uninstall_lib Finished 2022-07-13T11:59:17Z None
2906
+ >>>
2907
+
2908
+ # Verify if joblib package is uninstalled or not.
2909
+ >>> testenv.libs
2910
+ library version
2911
+ 0 pip 20.1.1
2912
+ 1 setuptools 47.1.0
2913
+
2914
+ >>> testenv.update_lib(["joblib==0.13.2"], timeout=1)
2915
+ Request to update libraries initiated successfully in the remote user environment 'testenv' but unable to get the status. Check the status using status() with the claim id 'ca669e5b-bd2c-4037-ae65-e0147954b85d'.
2916
+ 'ca669e5b-bd2c-4037-ae65-e0147954b85d'
2917
+
2918
+ # Check the status.
2919
+ >>> testenv.status('ca669e5b-bd2c-4037-ae65-e0147954b85d')
2920
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2921
+ 0 ca669e5b-bd2c-4037-ae65-e0147954b85d joblib==0.13.2 update_lib Started 2022-07-13T11:57:41Z None
2922
+ 1 ca669e5b-bd2c-4037-ae65-e0147954b85d joblib==0.13.2 update_lib Finished 2022-07-13T11:57:47Z None
2923
+ >>>
2924
+
2925
+ # Listing the available libraries.
2926
+ >>> testenv.libs
2927
+ library version
2928
+ 0 joblib 0.13.2
2929
+ 1 pip 20.1.1
2930
+ 2 setuptools 47.1.0
2931
+ >>>
2932
+
2933
+ # Examples for R environment.
2934
+ # Create remote R user environment.
2935
+ >>> r_env = create_env('test_r_env', 'r_4.1', 'Test R environment')
2936
+ User environment 'test_r_env' created.
2937
+ >>>
2938
+
2939
+ # Install R libraries in environment.
2940
+ >>> r_env.install_lib(['glm2', 'stringi', "plyr"])
2941
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2942
+ 0 6b9c006a-35a6-4f98-ab88-7010af98c3b9 glm2, stringi, plyr install_lib Started 2023-09-15T17:14:12Z
2943
+ 1 6b9c006a-35a6-4f98-ab88-7010af98c3b9 glm2, stringi, plyr install_lib Finished 2023-09-15T17:16:37Z
2944
+ >>>
2945
+
2946
+ # Verify installed libraries.
2947
+ >>> r_env.libs
2948
+ name version
2949
+ 0 KernSmooth 2.23-20
2950
+ 1 MASS 7.3-55
2951
+ 2 Matrix 1.4-0
2952
+ 3 base 4.1.3
2953
+ 4 boot 1.3-28
2954
+ 5 class 7.3-20
2955
+ 6 cluster 2.1.2
2956
+ .. ... ...
2957
+ 31 glm2 1.2.1
2958
+ 32 plyr 1.8.8
2959
+ 33 stringi 1.7.12
2960
+ >>>
2961
+
2962
+ # Example 5: Update single R library synchronously which is not present.
2963
+ # in environment. This installs the library with specified
2964
+ # version.
2965
+ >>> r_env.update_lib('dplyr== 1.1.1')
2966
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2967
+ 0 44d7ef77-e904-4bb9-bc6f-fd10e6294d2d dplyr== 1.1.1 update_lib Started 2023-09-15T17:58:23Z
2968
+ 1 44d7ef77-e904-4bb9-bc6f-fd10e6294d2d dplyr== 1.1.1 update_lib Finished 2023-09-15T18:01:23Z
2969
+ >>>
2970
+
2971
+ # Verify if library is installed with correct version.
2972
+ >>> r_env.libs
2973
+ name version
2974
+ 0 KernSmooth 2.23-20
2975
+ 1 MASS 7.3-55
2976
+ 2 Matrix 1.4-0
2977
+ 3 base 4.1.3
2978
+ .. ... ...
2979
+ 33 dplyr 1.1.1
2980
+ .. ... ...
2981
+ 37 glm2 1.2.1
2982
+ .. ... ...
2983
+ 43 plyr 1.8.8
2984
+ .. ... ...
2985
+ 45 stringi 1.7.12
2986
+ .. ... ...
2987
+ 50 withr 2.5.0
2988
+ >>>
2989
+
2990
+ # Example 6: Downgrade multiple R libraries synchronously
2991
+ # by passing them as a list of library names.
2992
+ >>> r_env.update_lib(['stringi== 1.1.5', 'dplyr== 1.0.8'])
2993
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
2994
+ 0 0b481a55-66c5-41b3-bba6-bec553274538 stringi== 1.1.5, dplyr== 1.0.8 update_lib Started 2023-09-15T18:11:00Z
2995
+ 1 0b481a55-66c5-41b3-bba6-bec553274538 stringi== 1.1.5, dplyr== 1.0.8 update_lib Finished 2023-09-15T18:15:11Z
2996
+ >>>
2997
+
2998
+ # Verify if libraries are downgraded.
2999
+ >>> r_env.libs
3000
+ 0 KernSmooth 2.23-20
3001
+ 1 MASS 7.3-55
3002
+ 2 Matrix 1.4-0
3003
+ 3 base 4.1.3
3004
+ .. ... ...
3005
+ 33 dplyr 1.0.8
3006
+ .. ... ...
3007
+ 37 glm2 1.2.1
3008
+ .. ... ...
3009
+ 43 plyr 1.8.8
3010
+ .. ... ...
3011
+ 45 stringi 1.1.5
3012
+ .. ... ...
3013
+ 50 withr 2.5.0
3014
+ >>>
3015
+
3016
+ # Example 7: Update libraries synchronously by specifying
3017
+ # them in a file.
3018
+
3019
+ # Create a requirement.json file with below contents.
3020
+ -----------------------------------------------------------
3021
+ {
3022
+ "cran_packages":
3023
+ [{
3024
+ "name": "dplyr",
3025
+ "version": "1.1.1"
3026
+ },
3027
+ {
3028
+ "name": "glm2",
3029
+ "version": ">= 1.1.2, < 1.2"
3030
+ }]
3031
+ }
3032
+ -----------------------------------------------------------
3033
+
3034
+ # Update libraries specified in the file.
3035
+ >>> r_env.update_lib(libs_file_path="requirement.json")
3036
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3037
+ 0 3399d416-8daa-49b5-a608-55e15fcbe89e requirement.json update_lib Started 2023-09-15T18:23:24Z
3038
+ 1 3399d416-8daa-49b5-a608-55e15fcbe89e requirement.json update_lib Finished 2023-09-15T18:26:33Z
3039
+ >>>
3040
+
3041
+ # Verify if libraries are updated.
3042
+ >>> r_env.libs
3043
+ name version
3044
+ 0 KernSmooth 2.23-20
3045
+ 1 MASS 7.3-55
3046
+ 2 Matrix 1.4-0
3047
+ 3 base 4.1.3
3048
+ .. ... ...
3049
+ 33 dplyr 1.1.1
3050
+ .. ... ...
3051
+ 37 glm2 1.1.3
3052
+ .. ... ...
3053
+ 43 plyr 1.8.8
3054
+ .. ... ...
3055
+ 45 stringi 1.1.5
3056
+ .. ... ...
3057
+ 50 withr 2.5.0
3058
+ >>>
3059
+
3060
+ # Example 8: Update R libraries asynchronously.
3061
+ >>> r_env.update_lib(["plyr== 1.0.3", "glm2<= 1.1.1"], asynchronous=True)
3062
+ Request to update libraries initiated successfully in the remote user environment r2_env_spk. Check the status using status() with the claim id '81c60527-88c8-4372-9336-c3bd7793b2b1'.
3063
+ '81c60527-88c8-4372-9336-c3bd7793b2b1'
3064
+ >>>
3065
+
3066
+ # Check the status using claim id.
3067
+ >>> r_env.status('81c60527-88c8-4372-9336-c3bd7793b2b1')
3068
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3069
+ 0 81c60527-88c8-4372-9336-c3bd7793b2b1 plyr== 1.0.3, glm2== 1.1.1 update_lib Started 2023-09-15T18:35:02Z
3070
+ 1 81c60527-88c8-4372-9336-c3bd7793b2b1 plyr== 1.0.3, glm2== 1.1.1 update_lib Finished 2023-09-15T18:35:19Z
3071
+ >>>
3072
+
3073
+ # Verify if libraries are updated.
3074
+ >>> r_env.libs
3075
+ name version
3076
+ 0 KernSmooth 2.23-20
3077
+ 1 MASS 7.3-55
3078
+ 2 Matrix 1.4-0
3079
+ 3 base 4.1.3
3080
+ .. ... ...
3081
+ 33 dplyr 1.1.1
3082
+ .. ... ...
3083
+ 37 glm2 1.1.1
3084
+ .. ... ...
3085
+ 43 plyr 1.0.3
3086
+ .. ... ...
3087
+ 45 stringi 1.1.5
3088
+ .. ... ...
3089
+ 50 withr 2.5.0
3090
+
3091
+ # Example 9: Update Conda R libraries.
3092
+ # Create remote R conda user environment.
3093
+ >>> r_env = create_env('test_r_env', 'r_4.3', 'Test R environment', conda_env=True)
3094
+ Conda environment creation initiated
3095
+ User environment 'test_r_env' created.
3096
+
3097
+ # Install R libraries in environment.
3098
+ # Create a requirement.txt file with below contents.
3099
+ -----------------------------------------------------------
3100
+ r-glm2
3101
+ r-anytime
3102
+ r-ggplot2
3103
+ -----------------------------------------------------------
3104
+
3105
+ >>> r_env.install_lib(libs_file_path="requirement.txt")
3106
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
3107
+ 0 10afb2ae-8517-4858-8cf9-82bc54abd7ed requirement.txt install_lib Started 2024-12-17T07:17:26Z
3108
+ 1 10afb2ae-8517-4858-8cf9-82bc54abd7ed requirement.txt install_lib Finished 2024-12-17T07:21:06Z
3109
+
3110
+ # update the libraries in the environment through libs
3111
+ >>> r_env.update_lib(libs=["r-glm2", "r-anytime"])
3112
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
3113
+ 0 7106cb78-2dcf-4638-ab91-500fe8144787 libs.txt update_lib Started 2024-12-17T07:23:57Z
3114
+ 1 7106cb78-2dcf-4638-ab91-500fe8144787 libs.txt update_lib Finished 2024-12-17T07:24:11Z
3115
+
3116
+ # update the libraries in the environment through libs_file_path
3117
+ >>> r_env.update_lib(libs_file_path="requirement.txt")
3118
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
3119
+ 0 6d6a3b3d-7b9d-4b0b-8f7f-1d1c7b4b3b5a requirement.txt update_lib Started 2024-12-17T07:25:35Z
3120
+ 1 6d6a3b3d-7b9d-4b0b-8f7f-1d1c7b4b3b5a requirement.txt update_lib Finished 2024-12-17T07:25:49Z
3121
+
3122
+ # Verify if libraries are updated.
3123
+ >>> r_env.libs
3124
+ name version
3125
+ 0 _libgcc_mutex 0.1
3126
+ 1 _openmp_mutex 5.1
3127
+ 2 _r-mutex 1.0.0
3128
+ ... ... ...
3129
+ 103 tzdata 2024b
3130
+ 104 wheel 0.44.0
3131
+ 105 xz 5.4.6
3132
+ 106 zlib 1.2.13
3133
+ 107 zstd 1.5.6
3134
+ """
3135
+ asynchronous = kwargs.get("asynchronous", False)
3136
+ timeout = kwargs.get("timeout")
3137
+ async_task_info = self.__manage_libraries(libs, libs_file_path, "UPDATE", asynchronous, timeout)
3138
+ return async_task_info
3139
+
3140
+ @collect_queryband(queryband="EnvRfrsh")
3141
+ def refresh(self):
3142
+ """
3143
+ DESCRIPTION:
3144
+ Function refreshes the UserEnv properties 'files' and 'libs'.
3145
+ 'files' and 'libs' properties cache user environment file and library
3146
+ information respectively when invoked. This information is refreshed
3147
+ when user invokes any of the following methods of 'UserEnv' class:
3148
+ * install_lib
3149
+ * uninstall_lib
3150
+ * update_lib
3151
+ * install_file
3152
+ * remove_file
3153
+ * refresh
3154
+
3155
+ This method should be used when user environment is updated outside
3156
+ of teradataml or cache is not updated after user environment updates.
3157
+
3158
+ PARAMETERS:
3159
+ None
3160
+
3161
+ RETURNS:
3162
+ None
3163
+
3164
+ RAISES:
3165
+ NOne
3166
+
3167
+ EXAMPLES:
3168
+ # Create a remote user environment.
3169
+ >>> env = create_env('test_env', 'python_3.7.9', 'Test environment')
3170
+ User environment 'test_env' created.
3171
+
3172
+ # Example 1: Install the libs in the 'test_env' environment.
3173
+ # View existing libraries installed.
3174
+ >>> env.libs
3175
+ name version
3176
+ 0 pip 22.0.4
3177
+ 1 setuptools 47.1.0
3178
+
3179
+ # Install additional Python library using UserEnv method.
3180
+ >>> env.install_lib("joblib")
3181
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3182
+ 0 263c4600-9b68-4cae-b601-270936cb965a joblib install_lib Started 2023-09-22T10:47:09Z
3183
+ 1 263c4600-9b68-4cae-b601-270936cb965a joblib install_lib Finished 2023-09-22T10:47:15Z
3184
+
3185
+ # View installed libraries.
3186
+ >>> env.libs
3187
+ name version
3188
+ 0 joblib 1.3.2
3189
+ 1 pip 22.0.4
3190
+ 2 setuptools 47.1.0
3191
+
3192
+ # Install additional 'numpy' Python library from outside, i.e. without using the UserEnv methods.
3193
+
3194
+ # View installed libraries. Note that 'numpy' library is not visible as "libs" cache is not updated.
3195
+ # To refresh cache execute the 'refresh()' method.
3196
+ >>> env.libs
3197
+ name version
3198
+ 0 joblib 1.3.2
3199
+ 1 pip 22.0.4
3200
+ 2 setuptools 47.1.0
3201
+
3202
+ # Refresh the 'libs' and 'files' in the environment.
3203
+ >>> env.refresh()
3204
+
3205
+ # View refreshed libraries.
3206
+ >>> env.libs
3207
+ name version
3208
+ 0 joblib 1.3.2
3209
+ 1 numpy 1.21.6
3210
+ 2 pip 22.0.4
3211
+ 3 setuptools 47.1.0
3212
+
3213
+ # Example 2: Install the files in the 'test_env' environment.
3214
+ # View existing files.
3215
+ >>> env.files
3216
+ No files found in remote user environment test_env.
3217
+
3218
+ # Install the file mapper.py in the 'test_env' environment using UserEnv method.
3219
+ >>> import os, teradataml
3220
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
3221
+ >>> env.install_file(file_path = file_path)
3222
+ File 'mapper.py' installed successfully in the remote user environment 'test_env'.
3223
+ True
3224
+
3225
+ # View installed files.
3226
+ >>> env.files
3227
+ File Size Timestamp
3228
+ 0 mapper.py 532 2023-09-22T11:28:02Z
3229
+
3230
+ # Install 'mapper_replace.py' file from outside, i.e. without using the UserEnv methods.
3231
+
3232
+ # View installed files. Note that recently installed file using REST call
3233
+ # is not visible as "files" cache is not updated. To refresh cache execute the 'refresh()' method.
3234
+ >>> env.files
3235
+ File Size Timestamp
3236
+ 0 mapper.py 532 2023-09-22T11:28:02Z
3237
+
3238
+ # Refresh the 'libs' and 'files' in the environment.
3239
+ >>> env.refresh()
3240
+
3241
+ # View refreshed files.
3242
+ >>> env.files
3243
+ File Size Timestamp
3244
+ 0 mapper.py 532 2023-09-22T11:28:02Z
3245
+ 1 mapper_replace.py 537 2023-09-22T11:30:11Z
3246
+
3247
+ # Create a remote R user environment.
3248
+ >>> env = create_env('r_test_env', 'r_4.1', 'R Test environment')
3249
+ User environment 'test_env' created.
3250
+
3251
+ # Example 1: Install the libs in the R environment 'r_test_env'.
3252
+ # View existing libraries installed.
3253
+ >>> env.libs
3254
+ name version
3255
+ 0 KernSmooth 2.23-20
3256
+ 1 MASS 7.3-55
3257
+ 2 Matrix 1.4-0
3258
+ 3 base 4.1.3
3259
+ 4 boot 1.3-28
3260
+ 5 class 7.3-20
3261
+ 6 cluster 2.1.2
3262
+ 7 codetools 0.2-18
3263
+ 8 compiler 4.1.3
3264
+ 9 datasets 4.1.3
3265
+ 10 foreign 0.8-82
3266
+ 11 grDevices 4.1.3
3267
+ 12 graphics 4.1.3
3268
+ 13 grid 4.1.3
3269
+ 14 lattice 0.20-45
3270
+ 15 methods 4.1.3
3271
+ 16 mgcv 1.8-39
3272
+ 17 nlme 3.1-155
3273
+ 18 nnet 7.3-17
3274
+ 19 parallel 4.1.3
3275
+ 20 remotes 2.4.2
3276
+ 21 rpart 4.1.16
3277
+ 22 spatial 7.3-15
3278
+ 23 splines 4.1.3
3279
+ 24 stats 4.1.3
3280
+ 25 stats4 4.1.3
3281
+ 26 survival 3.2-13
3282
+ 27 tcltk 4.1.3
3283
+ 28 tools 4.1.3
3284
+ 29 utils 4.1.3
3285
+
3286
+ # Install additional R library using UserEnv method.
3287
+ >>> env.install_lib("glm2")
3288
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3289
+ 0 8eceab10-cc12-4889-b17e-8bed3757a123 glm2 install_lib Started 2023-09-22T11:38:27Z
3290
+ 1 8eceab10-cc12-4889-b17e-8bed3757a123 glm2 install_lib Finished 2023-09-22T11:38:33Z
3291
+
3292
+ # View installed libraries.
3293
+ >>> env.libs
3294
+ name version
3295
+ 0 KernSmooth 2.23-20
3296
+ 1 MASS 7.3-55
3297
+ 2 Matrix 1.4-0
3298
+ 3 base 4.1.3
3299
+ 4 boot 1.3-28
3300
+ 5 class 7.3-20
3301
+ 6 cluster 2.1.2
3302
+ 7 codetools 0.2-18
3303
+ 8 compiler 4.1.3
3304
+ 9 datasets 4.1.3
3305
+ 10 foreign 0.8-82
3306
+ 11 grDevices 4.1.3
3307
+ 12 graphics 4.1.3
3308
+ 13 grid 4.1.3
3309
+ 14 lattice 0.20-45
3310
+ 15 methods 4.1.3
3311
+ 16 mgcv 1.8-39
3312
+ 17 nlme 3.1-155
3313
+ 18 nnet 7.3-17
3314
+ 19 parallel 4.1.3
3315
+ 20 remotes 2.4.2
3316
+ 21 rpart 4.1.16
3317
+ 22 spatial 7.3-15
3318
+ 23 splines 4.1.3
3319
+ 24 stats 4.1.3
3320
+ 25 stats4 4.1.3
3321
+ 26 survival 3.2-13
3322
+ 27 tcltk 4.1.3
3323
+ 28 tools 4.1.3
3324
+ 29 utils 4.1.3
3325
+ 30 glm2 1.2.1
3326
+
3327
+ # Install additional 'anytime' and 'stringi' R libraries from outside, i.e. without using the UserEnv methods.
3328
+
3329
+ # View installed libraries. Note that 'anytime' and 'stringi' libraries are not visible as "libs" cache is not updated.
3330
+ # To refresh cache execute the 'refresh()' method.
3331
+ >>> env.libs
3332
+ name version
3333
+ 0 KernSmooth 2.23-20
3334
+ 1 MASS 7.3-55
3335
+ 2 Matrix 1.4-0
3336
+ 3 base 4.1.3
3337
+ 4 boot 1.3-28
3338
+ 5 class 7.3-20
3339
+ 6 cluster 2.1.2
3340
+ 7 codetools 0.2-18
3341
+ 8 compiler 4.1.3
3342
+ 9 datasets 4.1.3
3343
+ 10 foreign 0.8-82
3344
+ 11 grDevices 4.1.3
3345
+ 12 graphics 4.1.3
3346
+ 13 grid 4.1.3
3347
+ 14 lattice 0.20-45
3348
+ 15 methods 4.1.3
3349
+ 16 mgcv 1.8-39
3350
+ 17 nlme 3.1-155
3351
+ 18 nnet 7.3-17
3352
+ 19 parallel 4.1.3
3353
+ 20 remotes 2.4.2
3354
+ 21 rpart 4.1.16
3355
+ 22 spatial 7.3-15
3356
+ 23 splines 4.1.3
3357
+ 24 stats 4.1.3
3358
+ 25 stats4 4.1.3
3359
+ 26 survival 3.2-13
3360
+ 27 tcltk 4.1.3
3361
+ 28 tools 4.1.3
3362
+ 29 utils 4.1.3
3363
+ 30 glm2 1.2.1
3364
+
3365
+ # Refresh the 'libs' and 'files' in the environment.
3366
+ >>> env.refresh()
3367
+
3368
+ # View refreshed libraries.
3369
+ >>> env.libs
3370
+ name version
3371
+ 0 KernSmooth 2.23-20
3372
+ 1 MASS 7.3-55
3373
+ 2 Matrix 1.4-0
3374
+ 3 base 4.1.3
3375
+ 4 boot 1.3-28
3376
+ 5 class 7.3-20
3377
+ 6 cluster 2.1.2
3378
+ 7 codetools 0.2-18
3379
+ 8 compiler 4.1.3
3380
+ 9 datasets 4.1.3
3381
+ 10 foreign 0.8-82
3382
+ 11 grDevices 4.1.3
3383
+ 12 graphics 4.1.3
3384
+ 13 grid 4.1.3
3385
+ 14 lattice 0.20-45
3386
+ 15 methods 4.1.3
3387
+ 16 mgcv 1.8-39
3388
+ 17 nlme 3.1-155
3389
+ 18 nnet 7.3-17
3390
+ 19 parallel 4.1.3
3391
+ 20 remotes 2.4.2
3392
+ 21 rpart 4.1.16
3393
+ 22 spatial 7.3-15
3394
+ 23 splines 4.1.3
3395
+ 24 stats 4.1.3
3396
+ 25 stats4 4.1.3
3397
+ 26 survival 3.2-13
3398
+ 27 tcltk 4.1.3
3399
+ 28 tools 4.1.3
3400
+ 29 utils 4.1.3
3401
+ 30 BH 1.81.0-1
3402
+ 31 Rcpp 1.0.11
3403
+ 32 anytime 0.3.9
3404
+ 33 glm2 1.2.1
3405
+ 34 stringi 1.7.12
3406
+
3407
+ # Example 2: Install the files in the R environment 'r_test_env'.
3408
+ # View existing files.
3409
+ >>> env.files
3410
+ No files found in remote user environment r_test_env.
3411
+
3412
+ # Install the file temp_file.R in the 'r_test_env' environment using UserEnv method.
3413
+ >>> file_path = "temp_file.R"
3414
+ >>> with open(file_path, "w") as fp:
3415
+ ... fp.write("print('HelloWorld')")
3416
+ >>> env.install_file(file_path = file_path)
3417
+ File 'temp_file.R' installed successfully in the remote user environment 'r_test_env'.
3418
+ True
3419
+
3420
+ # View installed files.
3421
+ >>> env.files
3422
+ File Size Timestamp
3423
+ 0 temp_file.R 19 2023-09-25T04:54:44Z
3424
+
3425
+ # Install 'temp_file_1.R' file from outside, i.e. without using the UserEnv methods.
3426
+
3427
+ # View installed files. Note that recently installed file using REST call
3428
+ # is not visible as "files" cache is not updated. To refresh cache execute the 'refresh()' method.
3429
+ >>> env.files
3430
+ File Size Timestamp
3431
+ 0 temp_file.R 19 2023-09-25T04:54:44Z
3432
+
3433
+ # Refresh the 'libs' and 'files' in the environment.
3434
+ >>> env.refresh()
3435
+
3436
+ # View refreshed files.
3437
+ >>> env.files
3438
+ File Size Timestamp
3439
+ 0 temp_file_1.R 20 2023-09-25T05:01:11Z
3440
+ 1 temp_file.R 19 2023-09-25T04:54:44Z
3441
+ """
3442
+ # Set self.__libs_changed, self.__files_changed and self.__models_changed flags to True.
3443
+ self.__libs_changed = True
3444
+ self.__files_changed = True
3445
+ self.__models_changed = True
3446
+
3447
+ @collect_queryband(queryband="EnvSts")
3448
+ def status(self, claim_ids=None):
3449
+ """
3450
+ DESCRIPTION:
3451
+ Function to check the status of the operations performed by the library/file
3452
+ management methods of UserEnv. Status of the following operations can be checked:
3453
+ * File installation, when installed asynchronously. Applicable for the files
3454
+ with size greater than 10 MB.
3455
+ * Install/Uninstall/Update of the libraries in user environment.
3456
+
3457
+ PARAMETERS:
3458
+ claim_ids:
3459
+ Optional Argument.
3460
+ Specifies the unique identifier(s) of the asynchronous process
3461
+ started by the UserEnv management methods.
3462
+ If user do not pass claim_ids, then function gets the status
3463
+ of all the asynchronus process'es in the current session.
3464
+ Types: str OR list of Strings (str)
3465
+
3466
+ RETURNS:
3467
+ Pandas DataFrame.
3468
+
3469
+ RAISES:
3470
+ None
3471
+
3472
+ EXAMPLES:
3473
+ # Create a remote user environment.
3474
+ >>> env = create_env('test_env', 'python_3.7.9', 'Test environment')
3475
+ User environment test_env created.
3476
+
3477
+ # Example 1: Install the file 'large_file' asynchronously with 'large_file' found in
3478
+ temp folder and check the latest status of installation.
3479
+ # Note:
3480
+ # Running this example creates a file 'large_file' with size
3481
+ # approximately 41MB in the temp folder.
3482
+ >>> import tempfile, os
3483
+ >>> def create_large_file():
3484
+ ... file_name = os.path.join(tempfile.gettempdir(),"large_file")
3485
+ ... with open(file_name, 'xb') as fp:
3486
+ ... fp.seek((1024 * 1024 * 41) - 1)
3487
+ ... fp.write(b'\0')
3488
+ ...
3489
+ >>> claim_id = env.install_file('large_file')
3490
+ File installation is initiated. Check the status using status() with the claim id 53e44892-1952-45eb-b828-6635c0447b59.
3491
+ >>> env.status(claim_id)
3492
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3493
+ 0 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file Endpoint Generated 2022-07-27T18:20:34Z None
3494
+ 1 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file File Uploaded 2022-07-27T18:20:35Z None
3495
+ 2 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file File Installed 2022-07-27T18:20:38Z None
3496
+ >>>
3497
+
3498
+ # Example 2: Install the library 'teradataml' asynchronously and check the status of installation.
3499
+ >>> claim_id = env.install_lib('teradataml')
3500
+ Request to install libraries initiated successfully in the remote user environment test_env. Check the status using status() with the claim id '349615e2-9257-4a70-8304-ac76f50712f8'.
3501
+ >>> env.status(claim_id)
3502
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3503
+ 0 349615e2-9257-4a70-8304-ac76f50712f8 teradataml install_lib Started 2022-07-13T10:37:40Z None
3504
+ 1 349615e2-9257-4a70-8304-ac76f50712f8 teradataml install_lib Finished 2022-07-13T10:39:29Z None
3505
+ >>>
3506
+
3507
+ # Example 3: update the library 'teradataml' to 17.10.0.0 asynchronously and check the status of installation.
3508
+ >>> claim_id = env.update_lib('teradataml==17.10.0.0')
3509
+ Request to update libraries initiated successfully in the remote user environment test_env. Check the status using status() with the claim id '29d06296-7444-4851-adef-ca1f921b1dd6'.
3510
+ >>> env.status(claim_id)
3511
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3512
+ 0 29d06296-7444-4851-adef-ca1f921b1dd6 teradataml==17.10.0.0 update_lib Started 2022-07-13T10:47:39Z None
3513
+ 1 29d06296-7444-4851-adef-ca1f921b1dd6 teradataml==17.10.0.0 update_lib Finished 2022-07-13T10:49:52Z None
3514
+ >>>
3515
+
3516
+ # Example 4: uninstall the library 'teradataml' and check the complete status of all the asynchronous process'es.
3517
+ >>> claim_id = env.uninstall_lib('teradataml')
3518
+ Request to uninstall libraries initiated successfully in the remote user environment test_env. Check the status using status() with the claim id '5cd3b3f7-f3b8-4bfd-8abe-7c811a6728db'.
3519
+ >>> env.status()
3520
+ Claim Id File/Libs Method Name Stage Timestamp Additional Details
3521
+ 0 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file Endpoint Generated 2022-07-27T18:20:34Z None
3522
+ 1 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file File Uploaded 2022-07-27T18:20:35Z None
3523
+ 2 53e44892-1952-45eb-b828-6635c0447b59 TeradataToolsAndUtilitiesBase__ubuntu_x8664.17.10.19.00.tar.gz install_file File Installed 2022-07-27T18:20:38Z None
3524
+ 3 29d06296-7444-4851-adef-ca1f921b1dd6 teradataml==17.10.0.0 update_lib Started 2022-07-13T10:47:39Z None
3525
+ 4 29d06296-7444-4851-adef-ca1f921b1dd6 teradataml==17.10.0.0 update_lib Finished 2022-07-13T10:49:52Z None
3526
+ 5 349615e2-9257-4a70-8304-ac76f50712f8 teradataml install_lib Started 2022-07-13T10:37:40Z None
3527
+ 6 349615e2-9257-4a70-8304-ac76f50712f8 teradataml install_lib Finished 2022-07-13T10:39:29Z None
3528
+ 7 5cd3b3f7-f3b8-4bfd-8abe-7c811a6728db teradataml uninstall_lib Started 2022-07-13T10:37:40Z None
3529
+ 8 5cd3b3f7-f3b8-4bfd-8abe-7c811a6728db teradataml uninstall_lib Finished 2022-07-13T10:39:29Z None
3530
+
3531
+ """
3532
+ __arg_info_matrix = []
3533
+ __arg_info_matrix.append(["claim_ids", claim_ids, True, (list, str), True])
3534
+
3535
+ # Validate arguments
3536
+ _Validators._validate_function_arguments(__arg_info_matrix)
3537
+
3538
+ # Raise error if user is not connected to Vantage.
3539
+ if _get_user() is None:
3540
+ error_msg = Messages.get_message(MessageCodes.FUNC_EXECUTION_FAILED,
3541
+ "status",
3542
+ "Create context before using {}.".format("status"))
3543
+ raise TeradataMlException(error_msg, MessageCodes.FUNC_EXECUTION_FAILED)
3544
+
3545
+ # If user do not pass any claim_ids, get the status for all the claim-ids
3546
+ # created in the current session.
3547
+ if claim_ids is None:
3548
+
3549
+ # If there are no claim_ids in the current session, print a message and return.
3550
+ if not self.__claim_ids:
3551
+ print("No file/library management operations found.")
3552
+ return
3553
+
3554
+ # Get all the claim_ids.
3555
+ claim_ids = self.__claim_ids.keys()
3556
+ else:
3557
+ # If user pass a single claim_id as string, convert to list.
3558
+ claim_ids = UtilFuncs._as_list(claim_ids)
3559
+
3560
+ return pd.DataFrame.from_records(self.__process_claim_ids(claim_ids=claim_ids), columns=self.__status_columns)
3561
+
3562
+ def __process_claim_ids(self, claim_ids):
3563
+ """
3564
+ DESCRIPTION:
3565
+ Function processes the claim IDs of asynchronous process using
3566
+ their 'claim_ids' parallelly to get the status.
3567
+
3568
+ PARAMETERS:
3569
+ claim_ids:
3570
+ Required Argument.
3571
+ Specifies the unique identifier(s) of the asynchronous process
3572
+ started by the UserEnv management methods.
3573
+ Types: str OR list of Strings (str)
3574
+
3575
+ RETURNS:
3576
+ list
3577
+
3578
+ RAISES:
3579
+ None
3580
+
3581
+ EXAMPLES:
3582
+ # Create a remote user environment.
3583
+ >>> env.__process_claim_ids(['123-456-789', 'abc-xyz'])
3584
+ """
3585
+ # Create thread pool executor to get the status parallelly.
3586
+ executor = ThreadPoolExecutor(max_workers=10)
3587
+
3588
+ # executor.submit returns a future object. Store all the futures in a list.
3589
+ futures = [executor.submit(self.__get_claim_id_status, claim_id) for claim_id in claim_ids]
3590
+
3591
+ # Wait forever, till all the futures complete.
3592
+ wait(futures)
3593
+
3594
+ # Add all the results to a list.
3595
+ return functools.reduce(lambda x, y: x + y, (future.result() for future in futures))
3596
+
3597
+ def __get_claim_id_status(self, claim_id):
3598
+ """
3599
+ DESCRIPTION:
3600
+ Function to get the status of asynchronus process using the claim_id.
3601
+
3602
+ PARAMETERS:
3603
+ claim_id:
3604
+ Required Argument.
3605
+ Specifies the unique identifier of the asynchronous process
3606
+ started by the UserEnv management methods.
3607
+ Types: str
3608
+
3609
+ RETURNS:
3610
+ Pandas DataFrame.
3611
+
3612
+ RAISES:
3613
+ None
3614
+
3615
+ EXAMPLES:
3616
+ # Create a remote user environment.
3617
+ >>> env.__get_claim_id_status('123-456')
3618
+ """
3619
+ # Get the claim_id details.
3620
+ claim_id_details = {"Claim Id": claim_id,
3621
+ "Method Name": self.__claim_ids.get(claim_id, {}).get("action", "Unknown"),
3622
+ "File/Libs/Model": self.__claim_ids.get(claim_id, {}).get("value", "Unknown")}
3623
+
3624
+ try:
3625
+ # TODO: _get_status() from teradataml.scriptmgmt.lls_utils does similar job.
3626
+ # _get_status() can be reused.
3627
+ response = UtilFuncs._http_request(_get_ues_url(env_type="fm",
3628
+ claim_id=claim_id,
3629
+ api_name="status"),
3630
+ headers=_get_auth_token())
3631
+ data = _process_ues_response(api_name="status", response=response).json()
3632
+ # if claim_id is for install_file - 'data' looks as below:
3633
+ # [
3634
+ # {'timestamp': '2022-06-29T17:03:49Z', 'stage': 'Endpoint Generated'},
3635
+ # {'timestamp': '2022-06-29T17:03:50Z', 'stage': 'File Uploaded'},
3636
+ # {'timestamp': '2022-06-29T17:03:52Z', 'stage': 'File Installed'}
3637
+ # ]
3638
+
3639
+ # if claim_id is for install_lib/uninstall_lib/update_lib - 'data' looks as below:
3640
+ # [
3641
+ # {
3642
+ # "timestamp": "2022-07-07T09:43:04Z",
3643
+ # "stage": "Started"
3644
+ # },
3645
+ # {
3646
+ # "timestamp": "2022-07-07T09:43:06Z",
3647
+ # "stage": "Finished",
3648
+ # "details": "WARNING: Skipping numpysts as it is not installed."
3649
+ # "WARNING: Skipping pytest as it is not installed."
3650
+ # }
3651
+ # ]
3652
+
3653
+ # Create a lamda function to extract the data.
3654
+ get_details = lambda data: {"Additional Details": data.pop("details", None),
3655
+ "Stage": data.pop("stage", None),
3656
+ "Timestamp": data.pop("timestamp", None),
3657
+ **claim_id_details}
3658
+
3659
+ return [get_details(sub_step) for sub_step in data]
3660
+
3661
+ except Exception as e:
3662
+ # For any errors, construct a row with error reason in 'additional_details' column.
3663
+ record = {"Additional Details": str(e), "Timestamp": None, "Stage": AsyncOpStatus.ERRED.value}
3664
+ record.update(claim_id_details)
3665
+ return [record]
3666
+
3667
+ def __get_claim_status(self, claim_id, timeout, action, **kwargs):
3668
+ """
3669
+ DESCRIPTION:
3670
+ Function to get the status of asynchronus process using the claim_id.
3671
+ The function polls the status of asynchronous process using the 'status' API
3672
+ for 'timeout' seconds and gets the status of it. When asynchronus process
3673
+ is not completed in 'timeout' seconds, the function stops polling the status
3674
+ API and returns the claim-id.
3675
+
3676
+ PARAMETERS:
3677
+ claim_id:
3678
+ Required Argument.
3679
+ Specifies the unique identifier of the asynchronous process
3680
+ started by the UserEnv management methods.
3681
+ Types: str
3682
+
3683
+ timeout:
3684
+ Required Argument.
3685
+ Specifies the maximum time in seconds to poll the status.
3686
+ Types: int OR float
3687
+
3688
+ action:
3689
+ Required Argument.
3690
+ Specifies the action for asynchronous process.
3691
+ Types: str
3692
+
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
3700
+
3701
+ RETURNS:
3702
+ Pandas DataFrame OR claim id.
3703
+
3704
+ RAISES:
3705
+ None
3706
+
3707
+ EXAMPLES:
3708
+ # Create a remote user environment.
3709
+ >>> env.__get_claim_status('123-456', 5, 'install_file')
3710
+ """
3711
+ # If user specifies 'timeout', poll only for 'timeout' seconds. Otherwise,
3712
+ # poll status API indefinitely.
3713
+ timeout = UtilFuncs._get_positive_infinity() if timeout is None else timeout
3714
+ suppress_output = kwargs.get("suppress_output", False)
3715
+ start_time = time.time()
3716
+ while time.time() - start_time <= timeout:
3717
+ time.sleep(3)
3718
+ records = self.__is_async_operation_completed(claim_id, suppress_output=suppress_output)
3719
+ if records:
3720
+ return pd.DataFrame.from_records(records, columns=self.__status_columns)
3721
+
3722
+ # Unable to get the response with in 'timeout' seconds. Print a message and
3723
+ # return claim id.
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))
3728
+ return claim_id
3729
+
3730
+ def __is_async_operation_completed(self, claim_id, **kwargs):
3731
+ """
3732
+ DESCRIPTION:
3733
+ Function to check whether asynchronous process to install/update/uninstall libraries/file
3734
+ has completed or not.
3735
+
3736
+ PARAMETERS:
3737
+ claim_id:
3738
+ Required Argument.
3739
+ Specifies the unique identifier of the asynchronous process
3740
+ started by the UserEnv management methods.
3741
+ Types: str
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
+
3751
+ RETURNS:
3752
+ list OR bool.
3753
+
3754
+ RAISES:
3755
+ None
3756
+
3757
+ EXAMPLES:
3758
+ # Create a remote user environment.
3759
+ >>> env.__is_async_operation_completed('123-456')
3760
+ """
3761
+ suppress_output = kwargs.get("suppress_output", False)
3762
+ records = self.__get_claim_id_status(claim_id)
3763
+
3764
+ # For library installation/uninstallation/updation, if the background process in
3765
+ # UES completes, it always returns two records. However, for file, this may not
3766
+ # be the case. So, validating both separately.
3767
+ action = self.__claim_ids.get(claim_id, {}).get("action")
3768
+ if action in ["install_file", "install_model"]:
3769
+ for record in records:
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"))
3777
+ elif record["Stage"] == AsyncOpStatus.ERRED.value:
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))
3781
+ return records
3782
+ return False
3783
+
3784
+ # For library installation/uninstallation/updation.
3785
+ return records if len(records) == 2 else False
3786
+
3787
+ @collect_queryband(queryband="InstlMdl")
3788
+ def install_model(self, model_path=None, model_name=None, model_type=None, api_key=None, **kwargs):
3789
+ """
3790
+ DESCRIPTION:
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.
3796
+ Note:
3797
+ Maximum size of the model should be less than or equal to 5GB when
3798
+ installing using zip.
3799
+
3800
+ PARAMETERS:
3801
+ model_path:
3802
+ Optional Argument.
3803
+ Specifies absolute or relative path of the zip file containing
3804
+ model (including file name) to be installed in the remote user
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.
3831
+ Note:
3832
+ Applicable only when model is installed from a model registry.
3833
+ Types: str
3834
+
3835
+ **kwargs:
3836
+ Specifies the keyword arguments.
3837
+ suppress_output:
3838
+ Optional Argument.
3839
+ Specifies whether to print the output message or not.
3840
+ When set to True, then the output message is not printed.
3841
+ Default Value: False
3842
+ Types: bool
3843
+
3844
+ asynchronous:
3845
+ Optional Argument.
3846
+ Specifies whether to install the model in remote user environment
3847
+ synchronously or asynchronously. When set to True, model is installed
3848
+ asynchronously. Otherwise, model is installed synchronously.
3849
+ Default Value: False
3850
+ Types: bool
3851
+
3852
+ timeout:
3853
+ Optional Argument.
3854
+ Specifies the time to wait in seconds for installing the model.
3855
+ If the model is not installed with in "timeout" seconds, the
3856
+ function returns a claim-id and one can check the status using
3857
+ the claim-id. If "timeout" is not specified, then there is no
3858
+ limit on the wait time.
3859
+ Note:
3860
+ Argument is ignored when "asynchronous" is True.
3861
+ Types: int OR float
3862
+
3863
+ RETURNS:
3864
+ Pandas DataFrame when model is installed synchronously and installation
3865
+ is completed before timeout.
3866
+ claim_id, to track status, when model is getting installed asynchronously
3867
+ or installation times out in synchronous execution mode.
3868
+
3869
+ RAISES:
3870
+ TeradataMlException.
3871
+
3872
+ EXAMPLES:
3873
+ # Create remote user environment.
3874
+ >>> env = create_env('testenv', 'python_3.9.13', 'Test environment')
3875
+ User environment 'testenv' created.
3876
+
3877
+ # User should create a zip file containing all files related to model
3878
+ # and use path to that zip file to install model using install_model()
3879
+ # API. Let's assume that all models files are zipped under 'large_model.zip'
3880
+ >>> model = 'large_model.zip'
3881
+
3882
+ # Example 1: Install the model in the 'testenv' environment.
3883
+ >>> env.install_model(model_path = model)
3884
+ Request for install_model is completed successfully.
3885
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
3886
+ 0 3fe99ef5-cc5b-41c6-92a4-595d60ecfbb5 large_model.zip install_model Endpoint Generated 2023-10-30T12:04:40Z
3887
+ 1 3fe99ef5-cc5b-41c6-92a4-595d60ecfbb5 large_model.zip install_model File Uploaded 2023-10-30T12:05:37Z
3888
+ 2 3fe99ef5-cc5b-41c6-92a4-595d60ecfbb5 large_model.zip install_model File Installed 2023-10-30T12:05:39Z
3889
+
3890
+ # Verify the model installation.
3891
+ >>> env.models
3892
+ Model Size Timestamp
3893
+ 0 large_model 6144 2023-10-30T13:11:00Z
3894
+
3895
+ # Example 2: Install the model asynchronously and check the
3896
+ # status of installation.
3897
+ >>> claim_id = env.install_model(model_path = model, asynchronous=True)
3898
+ Model installation is initiated. Check the status using status() with the claim id 7e840c47-3d70-4a11-a079-698203603854.
3899
+ >>> env.status(claim_id)
3900
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
3901
+ 0 7e840c47-3d70-4a11-a079-698203603854 large_model.zip install_model Endpoint Generated 2023-10-30T13:32:52Z
3902
+ 1 7e840c47-3d70-4a11-a079-698203603854 large_model.zip install_model File Uploaded 2023-10-30T13:34:02Z
3903
+ 2 7e840c47-3d70-4a11-a079-698203603854 large_model.zip install_model File Installed 2023-10-30T13:34:03Z
3904
+
3905
+ # Verify the model installation.
3906
+ >>> env.models
3907
+ Model Size Timestamp
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
3937
+ """
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
+
4051
+
4052
+ @collect_queryband(queryband="UninstlMdl")
4053
+ def uninstall_model(self, model_name, **kwargs):
4054
+ """
4055
+ DESCRIPTION:
4056
+ Function uninstalls the specified model from the
4057
+ user environment.
4058
+
4059
+ PARAMETERS:
4060
+ model_name:
4061
+ Required Argument.
4062
+ Specifies the name of the model to be uninstalled.
4063
+ Types: str
4064
+
4065
+ **kwargs:
4066
+ Specifies the keyword arguments.
4067
+ suppress_output:
4068
+ Optional Argument.
4069
+ Specifies whether to print the output message or not.
4070
+ When set to True, then the output message is not printed.
4071
+ Types: bool
4072
+
4073
+ RETURNS:
4074
+ True, if the operation is successful.
4075
+
4076
+ RAISES:
4077
+ TeradataMlException, RuntimeError
4078
+
4079
+ EXAMPLES:
4080
+ # Create a Python_3.8.13 environment with given name and description in Vantage.
4081
+ >>> env = create_env("test_env", "python_3.8.13", "Test environment")
4082
+ User environment 'test_env' created.
4083
+
4084
+ # User should create a zip file containing all files related to model
4085
+ # and use path to that zip file to install model using install_model()
4086
+ # API. Let's assume that all models files are zipped under 'large_model.zip'
4087
+ >>> model = 'large_model.zip'
4088
+
4089
+ # Install the model in the 'test_env' environment using local zip file.
4090
+ >>> env.install_model(model_path = model)
4091
+ Request for install_model is completed successfully.
4092
+ Claim Id File/Libs/Model Method Name Stage Timestamp Additional Details
4093
+ 0 766423af-7cc4-46db-8ee2-b6b5ded299c6 large_model.zip install_model Endpoint Generated 2023-11-09T09:21:24Z
4094
+ 1 766423af-7cc4-46db-8ee2-b6b5ded299c6 large_model.zip install_model File Uploaded 2023-11-09T09:22:28Z
4095
+ 2 766423af-7cc4-46db-8ee2-b6b5ded299c6 large_model.zip install_model File Installed 2023-11-09T09:22:30Z
4096
+
4097
+ # List models.
4098
+ >>> env.models
4099
+ Model Size Timestamp
4100
+ 0 large_model 6144 2023-11-09T09:22:30Z
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
+
4112
+ # Example 1: Uninstall model from remote user environment.
4113
+ >>> env.uninstall_model('large_model')
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'.
4124
+ True
4125
+
4126
+ # Verify the uninstallation of model.
4127
+ >>> env.models
4128
+ No models found in remote user environment test_env.
4129
+
4130
+ """
4131
+ # Uninstall model from User environment.
4132
+ kwargs["is_model"] = True
4133
+ return self.remove_file(model_name, **kwargs)
4134
+
4135
+ @collect_queryband(queryband="EnvSnpsht")
4136
+ def snapshot(self, dir=None):
4137
+ """
4138
+ DESCRIPTION:
4139
+ Take the snapshot of the user environment.
4140
+ Function stores the snapshot of the user environment in a
4141
+ JSON file, which can be used as input to re-create the exact
4142
+ same user environment by passing the snapshot file to create_env().
4143
+
4144
+ PARAMETERS:
4145
+ dir:
4146
+ Optional Argument.
4147
+ Specifies the directory path to store the snapshot file.
4148
+ Note:
4149
+ * when "dir" is not provided, function creates temporary folder
4150
+ and store the snapshot files in the temp folder.
4151
+ * While taking the snapshot, if file is installed in the enviornment,
4152
+ to re-create the exact same user environment user has to provide
4153
+ the absolute path of file to be installed in the generated snapshot
4154
+ file by replacing <ADD_YOUR_LOCAL_FILE_PATH>.
4155
+
4156
+ Types: str
4157
+
4158
+ RAISES:
4159
+ TeradataMlException
4160
+
4161
+ EXAMPLES:
4162
+ # Create a Python environment with name"env_1" in the Vantage.
4163
+ >>> env = create_env("env_1")
4164
+ ... User environment 'env_1' created.
4165
+
4166
+ # Install the file mapper.py in the 'testenv' environment.
4167
+ >>> import os, teradataml
4168
+ >>> file_path = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "mapper.py")
4169
+ >>> env.install_file(file_path = file_path)
4170
+ File 'mapper.py' installed successfully in the remote user environment 'env_1'.
4171
+ True
4172
+
4173
+ # Install 'numpy' Python library.
4174
+ >>> env.install_lib('numpy')
4175
+ Claim Id ... Additional Details
4176
+ 0 fa72b8ec-429e-4a63-a6d1-598869a57bc3 ...
4177
+ 1 fa72b8ec-429e-4a63-a6d1-598869a57bc3 ...
4178
+
4179
+ # Take a snapshot of 'env_1'.
4180
+ >>> env.snapshot()
4181
+ Snapshot for environment "env_1" is stored at "...:\\...\\...\\snapshot_env_1_python_3.10.5_1700740261.2757893.json"
4182
+ """
4183
+
4184
+ __arg_info_matrix = []
4185
+ __arg_info_matrix.append(["dir", dir, True, (str), True])
4186
+
4187
+ # Validate argument.
4188
+ _Validators._validate_function_arguments(__arg_info_matrix)
4189
+
4190
+ if dir is not None:
4191
+ if not os.path.exists(dir):
4192
+ err_msg = "The directory path '{}' does not exist.".format(
4193
+ dir)
4194
+ raise TeradataMlException(err_msg, MessageCodes.INPUT_FILE_NOT_FOUND)
4195
+ if not os.path.isdir(dir):
4196
+ err_msg = 'Please provide directory path instead of file path.'.format(
4197
+ dir)
4198
+ raise TeradataMlException(err_msg, MessageCodes.INPUT_FILE_NOT_FOUND)
4199
+
4200
+ env_name = self.env_name
4201
+ base_env = self.base_env
4202
+ env_specs = [
4203
+ {
4204
+ "env_name": env_name,
4205
+ "base_env": base_env,
4206
+ "desc": self.desc
4207
+ }
4208
+ ]
4209
+
4210
+ if self.libs is not None:
4211
+ libs = ["{}=={}".format(name, version)
4212
+ for name, version in
4213
+ zip(self.libs.name.to_list(), self.libs.version.to_list())]
4214
+
4215
+ env_specs[0].update({"libs": libs})
4216
+
4217
+ if self.files is not None:
4218
+ files = ["<ADD_YOUR_LOCAL_FILE_PATH>/{}".format(file)
4219
+ for file in self.files.File.to_list()]
4220
+
4221
+ env_specs[0].update({"files": files})
4222
+
4223
+ if not dir:
4224
+ dir = tempfile.mkdtemp()
4225
+
4226
+ snap_file_path = os.path.join(dir,
4227
+ "snapshot_{}_{}_{}.json".format(env_name, base_env, time.time()))
4228
+
4229
+ json_data = {"env_specs": env_specs}
4230
+ with open(snap_file_path, "w",) as json_file:
4231
+ json.dump(json_data, json_file, indent=4)
4232
+
4233
+ print('Snapshot for environment "{}" is stored at "{}"'.format(env_name, snap_file_path))
4234
+
4235
+
4236
+ class _AuthToken:
4237
+ """
4238
+ Internal class for storing details of authentication data to be used in headers.
4239
+ """
4240
+ def __init__(self, token, auth_type):
4241
+ self.__value = token
4242
+ self.__auth_type = auth_type
4243
+
4244
+ @property
4245
+ def value(self):
4246
+ return self.__value
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
+
4256
+ @property
4257
+ def auth_type(self):
4258
+ return self.__auth_type
4259
+
4260
+ def get_header(self):
4261
+ """
4262
+ Method for generating header using authentication data and type.
4263
+ """
4264
+ if self.auth_type.lower() == "basic":
4265
+ # Form the Authorization header value by prepending 'Basic ' to the encoded credentials string.
4266
+ return {"Authorization": "Basic {}".format(self.value)}
4267
+ elif self.auth_type.lower() == "bearer":
4268
+ # Form the Authorization header value by prepending 'Bearer ' to the JWT token.
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)}