sagemaker-core 1.0.62__py3-none-any.whl → 2.3.1__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 (358) hide show
  1. sagemaker/__init__.py +2 -0
  2. sagemaker/core/__init__.py +16 -0
  3. sagemaker/core/_studio.py +116 -0
  4. sagemaker/core/_version.py +11 -0
  5. sagemaker/core/accept_types.py +131 -0
  6. sagemaker/core/analytics.py +744 -0
  7. sagemaker/core/apiutils/__init__.py +13 -0
  8. sagemaker/core/apiutils/_base_types.py +228 -0
  9. sagemaker/core/apiutils/_boto_functions.py +130 -0
  10. sagemaker/core/apiutils/_utils.py +34 -0
  11. sagemaker/core/base_deserializers.py +35 -0
  12. sagemaker/core/base_serializers.py +35 -0
  13. sagemaker/core/clarify/__init__.py +2898 -0
  14. sagemaker/core/collection.py +467 -0
  15. sagemaker/core/common_utils.py +2399 -0
  16. sagemaker/core/compute_resource_requirements/__init__.py +18 -0
  17. sagemaker/core/compute_resource_requirements/resource_requirements.py +94 -0
  18. sagemaker/core/config/__init__.py +181 -0
  19. sagemaker/core/config/config.py +238 -0
  20. sagemaker/core/config/config_manager.py +595 -0
  21. sagemaker/core/config/config_schema.py +1220 -0
  22. sagemaker/core/config/config_utils.py +297 -0
  23. {sagemaker_core/main → sagemaker/core}/config_schema.py +408 -3
  24. sagemaker/core/constants.py +73 -0
  25. sagemaker/core/content_types.py +137 -0
  26. sagemaker/core/debugger/__init__.py +39 -0
  27. sagemaker/core/debugger/debugger.py +945 -0
  28. sagemaker/core/debugger/framework_profile.py +292 -0
  29. sagemaker/core/debugger/metrics_config.py +468 -0
  30. sagemaker/core/debugger/profiler.py +42 -0
  31. sagemaker/core/debugger/profiler_config.py +190 -0
  32. sagemaker/core/debugger/profiler_constants.py +40 -0
  33. sagemaker/core/debugger/utils.py +148 -0
  34. sagemaker/core/deprecations.py +254 -0
  35. sagemaker/core/deserializers/__init__.py +10 -0
  36. sagemaker/core/deserializers/base.py +424 -0
  37. sagemaker/core/deserializers/implementations.py +157 -0
  38. sagemaker/core/drift_check_baselines.py +106 -0
  39. sagemaker/core/enums.py +51 -0
  40. sagemaker/core/environment_variables.py +101 -0
  41. sagemaker/core/exceptions.py +108 -0
  42. sagemaker/core/experiments/__init__.py +53 -0
  43. sagemaker/core/experiments/_api_types.py +251 -0
  44. sagemaker/core/experiments/_environment.py +124 -0
  45. sagemaker/core/experiments/_helper.py +294 -0
  46. sagemaker/core/experiments/_metrics.py +333 -0
  47. sagemaker/core/experiments/_run_context.py +58 -0
  48. sagemaker/core/experiments/_utils.py +216 -0
  49. sagemaker/core/experiments/experiment.py +247 -0
  50. sagemaker/core/experiments/run.py +970 -0
  51. sagemaker/core/experiments/trial.py +296 -0
  52. sagemaker/core/experiments/trial_component.py +387 -0
  53. sagemaker/core/explainer/__init__.py +24 -0
  54. sagemaker/core/explainer/clarify_explainer_config.py +298 -0
  55. sagemaker/core/explainer/explainer_config.py +44 -0
  56. sagemaker/core/fw_utils.py +1220 -0
  57. sagemaker/core/git_utils.py +415 -0
  58. sagemaker/core/helper/pipeline_variable.py +82 -0
  59. sagemaker/core/helper/session_helper.py +2977 -0
  60. sagemaker/core/hyperparameters.py +172 -0
  61. sagemaker/core/image_retriever/__init__.py +3 -0
  62. sagemaker/core/image_retriever/image_retriever.py +640 -0
  63. sagemaker/core/image_retriever/image_retriever_utils.py +509 -0
  64. sagemaker/core/image_retriever/test.py +7 -0
  65. sagemaker/core/image_uri_config/autogluon.json +1335 -0
  66. sagemaker/core/image_uri_config/blazingtext.json +50 -0
  67. sagemaker/core/image_uri_config/chainer.json +104 -0
  68. sagemaker/core/image_uri_config/clarify.json +39 -0
  69. sagemaker/core/image_uri_config/coach-mxnet.json +70 -0
  70. sagemaker/core/image_uri_config/coach-tensorflow.json +186 -0
  71. sagemaker/core/image_uri_config/data-wrangler.json +91 -0
  72. sagemaker/core/image_uri_config/debugger.json +34 -0
  73. sagemaker/core/image_uri_config/detailed-profiler.json +18 -0
  74. sagemaker/core/image_uri_config/djl-deepspeed.json +385 -0
  75. sagemaker/core/image_uri_config/djl-fastertransformer.json +167 -0
  76. sagemaker/core/image_uri_config/djl-lmi.json +136 -0
  77. sagemaker/core/image_uri_config/djl-neuronx.json +258 -0
  78. sagemaker/core/image_uri_config/djl-tensorrtllm.json +262 -0
  79. sagemaker/core/image_uri_config/factorization-machines.json +50 -0
  80. sagemaker/core/image_uri_config/forecasting-deepar.json +50 -0
  81. sagemaker/core/image_uri_config/huggingface-llm-neuronx.json +770 -0
  82. sagemaker/core/image_uri_config/huggingface-llm.json +1267 -0
  83. sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
  84. sagemaker/core/image_uri_config/huggingface-neuronx.json +686 -0
  85. sagemaker/core/image_uri_config/huggingface-tei-cpu.json +298 -0
  86. sagemaker/core/image_uri_config/huggingface-tei.json +298 -0
  87. sagemaker/core/image_uri_config/huggingface-training-compiler.json +195 -0
  88. sagemaker/core/image_uri_config/huggingface-vllm-neuronx.json +38 -0
  89. sagemaker/core/image_uri_config/huggingface.json +2287 -0
  90. sagemaker/core/image_uri_config/hyperpod-recipes-neuron.json +52 -0
  91. sagemaker/core/image_uri_config/image-classification-neo.json +43 -0
  92. sagemaker/core/image_uri_config/image-classification.json +50 -0
  93. sagemaker/core/image_uri_config/inferentia-mxnet.json +88 -0
  94. sagemaker/core/image_uri_config/inferentia-pytorch.json +127 -0
  95. sagemaker/core/image_uri_config/inferentia-tensorflow.json +88 -0
  96. sagemaker/core/image_uri_config/instance_gpu_info.json +782 -0
  97. sagemaker/core/image_uri_config/ipinsights.json +50 -0
  98. sagemaker/core/image_uri_config/kmeans.json +50 -0
  99. sagemaker/core/image_uri_config/knn.json +50 -0
  100. sagemaker/core/image_uri_config/lda.json +26 -0
  101. sagemaker/core/image_uri_config/linear-learner.json +50 -0
  102. sagemaker/core/image_uri_config/model-monitor.json +42 -0
  103. sagemaker/core/image_uri_config/mxnet.json +1154 -0
  104. sagemaker/core/image_uri_config/neo-mxnet.json +64 -0
  105. sagemaker/core/image_uri_config/neo-pytorch.json +341 -0
  106. sagemaker/core/image_uri_config/neo-tensorflow.json +109 -0
  107. sagemaker/core/image_uri_config/ntm.json +50 -0
  108. sagemaker/core/image_uri_config/object-detection.json +50 -0
  109. sagemaker/core/image_uri_config/object2vec.json +50 -0
  110. sagemaker/core/image_uri_config/pca.json +50 -0
  111. sagemaker/core/image_uri_config/pytorch-neuron.json +43 -0
  112. sagemaker/core/image_uri_config/pytorch-smp.json +218 -0
  113. sagemaker/core/image_uri_config/pytorch-training-compiler.json +80 -0
  114. sagemaker/core/image_uri_config/pytorch.json +3101 -0
  115. sagemaker/core/image_uri_config/randomcutforest.json +50 -0
  116. sagemaker/core/image_uri_config/ray-pytorch.json +46 -0
  117. sagemaker/core/image_uri_config/ray-tensorflow.json +194 -0
  118. sagemaker/core/image_uri_config/sagemaker-base-python.json +46 -0
  119. sagemaker/core/image_uri_config/sagemaker-distribution.json +37 -0
  120. sagemaker/core/image_uri_config/sagemaker-geospatial.json +13 -0
  121. sagemaker/core/image_uri_config/sagemaker-tritonserver.json +252 -0
  122. sagemaker/core/image_uri_config/semantic-segmentation.json +50 -0
  123. sagemaker/core/image_uri_config/seq2seq.json +50 -0
  124. sagemaker/core/image_uri_config/sklearn.json +494 -0
  125. sagemaker/core/image_uri_config/spark.json +280 -0
  126. sagemaker/core/image_uri_config/sparkml-serving.json +97 -0
  127. sagemaker/core/image_uri_config/stabilityai.json +53 -0
  128. sagemaker/core/image_uri_config/tensorflow.json +5086 -0
  129. sagemaker/core/image_uri_config/vw.json +25 -0
  130. sagemaker/core/image_uri_config/xgboost-neo.json +43 -0
  131. sagemaker/core/image_uri_config/xgboost.json +972 -0
  132. sagemaker/core/image_uris.py +816 -0
  133. sagemaker/core/inference_config.py +144 -0
  134. sagemaker/core/inference_recommender/__init__.py +18 -0
  135. sagemaker/core/inference_recommender/inference_recommender_mixin.py +622 -0
  136. sagemaker/core/inputs.py +366 -0
  137. sagemaker/core/instance_group.py +61 -0
  138. sagemaker/core/instance_types.py +164 -0
  139. sagemaker/core/instance_types_gpu_info.py +43 -0
  140. sagemaker/core/interactive_apps/__init__.py +41 -0
  141. sagemaker/core/interactive_apps/base_interactive_app.py +204 -0
  142. sagemaker/core/interactive_apps/detail_profiler_app.py +139 -0
  143. sagemaker/core/interactive_apps/tensorboard.py +149 -0
  144. sagemaker/core/iterators.py +197 -0
  145. sagemaker/core/job.py +380 -0
  146. sagemaker/core/jumpstart/__init__.py +156 -0
  147. sagemaker/core/jumpstart/accessors.py +390 -0
  148. sagemaker/core/jumpstart/artifacts/__init__.py +69 -0
  149. sagemaker/core/jumpstart/artifacts/environment_variables.py +252 -0
  150. sagemaker/core/jumpstart/artifacts/hyperparameters.py +120 -0
  151. sagemaker/core/jumpstart/artifacts/image_uris.py +139 -0
  152. sagemaker/core/jumpstart/artifacts/incremental_training.py +87 -0
  153. sagemaker/core/jumpstart/artifacts/instance_types.py +223 -0
  154. sagemaker/core/jumpstart/artifacts/kwargs.py +289 -0
  155. sagemaker/core/jumpstart/artifacts/metric_definitions.py +117 -0
  156. sagemaker/core/jumpstart/artifacts/model_packages.py +202 -0
  157. sagemaker/core/jumpstart/artifacts/model_uris.py +252 -0
  158. sagemaker/core/jumpstart/artifacts/payloads.py +96 -0
  159. sagemaker/core/jumpstart/artifacts/predictors.py +540 -0
  160. sagemaker/core/jumpstart/artifacts/resource_names.py +86 -0
  161. sagemaker/core/jumpstart/artifacts/resource_requirements.py +162 -0
  162. sagemaker/core/jumpstart/artifacts/script_uris.py +172 -0
  163. sagemaker/core/jumpstart/cache.py +663 -0
  164. sagemaker/core/jumpstart/configs.py +50 -0
  165. sagemaker/core/jumpstart/constants.py +198 -0
  166. sagemaker/core/jumpstart/deserializers.py +81 -0
  167. sagemaker/core/jumpstart/document.py +76 -0
  168. sagemaker/core/jumpstart/enums.py +168 -0
  169. sagemaker/core/jumpstart/exceptions.py +236 -0
  170. sagemaker/core/jumpstart/factory/utils.py +833 -0
  171. sagemaker/core/jumpstart/filters.py +597 -0
  172. sagemaker/core/jumpstart/hub/constants.py +16 -0
  173. sagemaker/core/jumpstart/hub/hub.py +291 -0
  174. sagemaker/core/jumpstart/hub/interfaces.py +936 -0
  175. sagemaker/core/jumpstart/hub/parser_utils.py +70 -0
  176. sagemaker/core/jumpstart/hub/parsers.py +288 -0
  177. sagemaker/core/jumpstart/hub/types.py +35 -0
  178. sagemaker/core/jumpstart/hub/utils.py +260 -0
  179. sagemaker/core/jumpstart/models.py +501 -0
  180. sagemaker/core/jumpstart/notebook_utils.py +575 -0
  181. sagemaker/core/jumpstart/parameters.py +20 -0
  182. sagemaker/core/jumpstart/payload_utils.py +239 -0
  183. sagemaker/core/jumpstart/region_config.json +171 -0
  184. sagemaker/core/jumpstart/search.py +171 -0
  185. sagemaker/core/jumpstart/serializers.py +81 -0
  186. sagemaker/core/jumpstart/session_utils.py +234 -0
  187. sagemaker/core/jumpstart/types.py +3044 -0
  188. sagemaker/core/jumpstart/utils.py +1731 -0
  189. sagemaker/core/jumpstart/validators.py +257 -0
  190. sagemaker/core/lambda_helper.py +312 -0
  191. sagemaker/core/lineage/__init__.py +42 -0
  192. sagemaker/core/lineage/_api_types.py +239 -0
  193. sagemaker/core/lineage/_utils.py +49 -0
  194. sagemaker/core/lineage/action.py +345 -0
  195. sagemaker/core/lineage/artifact.py +646 -0
  196. sagemaker/core/lineage/association.py +190 -0
  197. sagemaker/core/lineage/context.py +505 -0
  198. sagemaker/core/lineage/lineage_trial_component.py +191 -0
  199. sagemaker/core/lineage/query.py +732 -0
  200. sagemaker/core/lineage/visualizer.py +346 -0
  201. sagemaker/core/local/__init__.py +18 -0
  202. sagemaker/core/local/data.py +423 -0
  203. sagemaker/core/local/entities.py +678 -0
  204. sagemaker/core/local/exceptions.py +17 -0
  205. sagemaker/core/local/image.py +1243 -0
  206. sagemaker/core/local/local_session.py +739 -0
  207. sagemaker/core/local/utils.py +246 -0
  208. sagemaker/core/logs.py +181 -0
  209. sagemaker/core/metadata_properties.py +56 -0
  210. sagemaker/core/metric_definitions.py +91 -0
  211. sagemaker/core/mlflow/__init__.py +38 -0
  212. sagemaker/core/mlflow/forward_sagemaker_metrics.py +44 -0
  213. sagemaker/core/model_card/__init__.py +26 -0
  214. sagemaker/core/model_life_cycle.py +51 -0
  215. sagemaker/core/model_metrics.py +160 -0
  216. sagemaker/core/model_monitor/__init__.py +66 -0
  217. sagemaker/core/model_monitor/clarify_model_monitoring.py +1497 -0
  218. sagemaker/core/model_monitor/cron_expression_generator.py +82 -0
  219. sagemaker/core/model_monitor/data_capture_config.py +115 -0
  220. sagemaker/core/model_monitor/data_quality_monitoring_config.py +66 -0
  221. sagemaker/core/model_monitor/dataset_format.py +102 -0
  222. sagemaker/core/model_monitor/model_monitoring.py +4266 -0
  223. sagemaker/core/model_monitor/monitoring_alert.py +76 -0
  224. sagemaker/core/model_monitor/monitoring_files.py +506 -0
  225. sagemaker/core/model_monitor/utils.py +793 -0
  226. sagemaker/core/model_registry.py +480 -0
  227. sagemaker/core/model_uris.py +97 -0
  228. sagemaker/core/modules/__init__.py +19 -0
  229. sagemaker/core/modules/configs.py +239 -0
  230. sagemaker/core/modules/constants.py +37 -0
  231. sagemaker/core/modules/distributed.py +182 -0
  232. sagemaker/core/modules/local_core/local_container.py +605 -0
  233. sagemaker/core/modules/templates.py +83 -0
  234. sagemaker/core/modules/train/__init__.py +14 -0
  235. sagemaker/core/modules/train/container_drivers/__init__.py +14 -0
  236. sagemaker/core/modules/train/container_drivers/common/__init__.py +14 -0
  237. sagemaker/core/modules/train/container_drivers/common/utils.py +205 -0
  238. sagemaker/core/modules/train/container_drivers/distributed_drivers/__init__.py +14 -0
  239. sagemaker/core/modules/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
  240. sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_driver.py +123 -0
  241. sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
  242. sagemaker/core/modules/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
  243. sagemaker/core/modules/train/container_drivers/scripts/__init__.py +14 -0
  244. sagemaker/core/modules/train/container_drivers/scripts/environment.py +305 -0
  245. sagemaker/core/modules/train/sm_recipes/__init__.py +0 -0
  246. sagemaker/core/modules/train/sm_recipes/utils.py +330 -0
  247. sagemaker/core/modules/types.py +19 -0
  248. sagemaker/core/modules/utils.py +194 -0
  249. sagemaker/core/network.py +185 -0
  250. sagemaker/core/parameter.py +173 -0
  251. sagemaker/core/payloads.py +185 -0
  252. sagemaker/core/processing.py +1599 -0
  253. sagemaker/core/remote_function/__init__.py +19 -0
  254. sagemaker/core/remote_function/checkpoint_location.py +47 -0
  255. sagemaker/core/remote_function/client.py +1310 -0
  256. sagemaker/core/remote_function/core/__init__.py +0 -0
  257. sagemaker/core/remote_function/core/_custom_dispatch_table.py +72 -0
  258. sagemaker/core/remote_function/core/pipeline_variables.py +347 -0
  259. sagemaker/core/remote_function/core/serialization.py +410 -0
  260. sagemaker/core/remote_function/core/stored_function.py +223 -0
  261. sagemaker/core/remote_function/custom_file_filter.py +128 -0
  262. sagemaker/core/remote_function/errors.py +102 -0
  263. sagemaker/core/remote_function/invoke_function.py +167 -0
  264. sagemaker/core/remote_function/job.py +2121 -0
  265. sagemaker/core/remote_function/logging_config.py +38 -0
  266. sagemaker/core/remote_function/runtime_environment/__init__.py +14 -0
  267. sagemaker/core/remote_function/runtime_environment/bootstrap_runtime_environment.py +605 -0
  268. sagemaker/core/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
  269. sagemaker/core/remote_function/runtime_environment/runtime_environment_manager.py +554 -0
  270. sagemaker/core/remote_function/runtime_environment/spark_app.py +18 -0
  271. sagemaker/core/remote_function/spark_config.py +149 -0
  272. sagemaker/core/resource_requirements.py +168 -0
  273. {sagemaker_core/main → sagemaker/core}/resources.py +19098 -10895
  274. sagemaker/core/s3/__init__.py +41 -0
  275. sagemaker/core/s3/client.py +367 -0
  276. sagemaker/core/s3/utils.py +175 -0
  277. sagemaker/core/script_uris.py +93 -0
  278. sagemaker/core/serializers/__init__.py +11 -0
  279. sagemaker/core/serializers/base.py +510 -0
  280. sagemaker/core/serializers/implementations.py +159 -0
  281. sagemaker/core/serializers/utils.py +223 -0
  282. sagemaker/core/serverless_inference_config.py +63 -0
  283. sagemaker/core/session_settings.py +55 -0
  284. sagemaker/core/shapes/__init__.py +3 -0
  285. sagemaker/core/shapes/model_card_shapes.py +159 -0
  286. {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +5810 -1806
  287. sagemaker/core/spark/__init__.py +16 -0
  288. sagemaker/core/spark/defaults.py +16 -0
  289. sagemaker/core/spark/processing.py +1380 -0
  290. sagemaker/core/telemetry/__init__.py +23 -0
  291. sagemaker/core/telemetry/constants.py +82 -0
  292. sagemaker/core/telemetry/telemetry_logging.py +285 -0
  293. sagemaker/core/tools/__init__.py +1 -0
  294. {sagemaker_core → sagemaker/core}/tools/codegen.py +4 -4
  295. {sagemaker_core → sagemaker/core}/tools/constants.py +23 -15
  296. {sagemaker_core → sagemaker/core}/tools/data_extractor.py +1 -1
  297. {sagemaker_core → sagemaker/core}/tools/method.py +1 -1
  298. sagemaker/core/tools/model_card/generate_model_card_from_schema.py +562 -0
  299. {sagemaker_core → sagemaker/core}/tools/resources_codegen.py +165 -98
  300. {sagemaker_core → sagemaker/core}/tools/resources_extractor.py +5 -13
  301. {sagemaker_core → sagemaker/core}/tools/shapes_codegen.py +16 -17
  302. {sagemaker_core → sagemaker/core}/tools/shapes_extractor.py +29 -67
  303. {sagemaker_core → sagemaker/core}/tools/templates.py +39 -17
  304. sagemaker/core/training/__init__.py +14 -0
  305. sagemaker/core/training/configs.py +345 -0
  306. sagemaker/core/training/constants.py +37 -0
  307. sagemaker/core/training/utils.py +77 -0
  308. sagemaker/core/training_compiler/__init__.py +16 -0
  309. sagemaker/core/training_compiler/config.py +197 -0
  310. sagemaker/core/training_compiler_config.py +197 -0
  311. sagemaker/core/transformer.py +793 -0
  312. sagemaker/core/user_agent.py +76 -0
  313. sagemaker/core/utilities/__init__.py +24 -0
  314. sagemaker/core/utilities/cache.py +169 -0
  315. sagemaker/core/utilities/search_expression.py +133 -0
  316. sagemaker/core/utils/__init__.py +48 -0
  317. sagemaker/core/utils/code_injection/__init__.py +0 -0
  318. {sagemaker_core/main → sagemaker/core/utils}/code_injection/codec.py +2 -2
  319. {sagemaker_core/main → sagemaker/core/utils}/code_injection/shape_dag.py +5979 -176
  320. {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
  321. sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
  322. {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
  323. {sagemaker_core/main → sagemaker/core/utils}/utils.py +27 -22
  324. sagemaker/core/workflow/__init__.py +152 -0
  325. sagemaker/core/workflow/conditions.py +313 -0
  326. sagemaker/core/workflow/entities.py +58 -0
  327. sagemaker/core/workflow/execution_variables.py +89 -0
  328. sagemaker/core/workflow/functions.py +193 -0
  329. sagemaker/core/workflow/parameters.py +222 -0
  330. sagemaker/core/workflow/pipeline_context.py +394 -0
  331. sagemaker/core/workflow/pipeline_definition_config.py +31 -0
  332. sagemaker/core/workflow/properties.py +285 -0
  333. sagemaker/core/workflow/step_outputs.py +65 -0
  334. sagemaker/core/workflow/utilities.py +514 -0
  335. sagemaker/lineage/__init__.py +33 -0
  336. sagemaker/lineage/action.py +28 -0
  337. sagemaker/lineage/artifact.py +28 -0
  338. sagemaker/lineage/context.py +28 -0
  339. sagemaker/lineage/lineage_trial_component.py +28 -0
  340. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/METADATA +28 -9
  341. sagemaker_core-2.3.1.dist-info/RECORD +351 -0
  342. sagemaker_core-2.3.1.dist-info/top_level.txt +1 -0
  343. sagemaker_core/_version.py +0 -3
  344. sagemaker_core/helper/session_helper.py +0 -769
  345. sagemaker_core/resources/__init__.py +0 -1
  346. sagemaker_core/shapes/__init__.py +0 -1
  347. sagemaker_core/tools/__init__.py +0 -1
  348. sagemaker_core-1.0.62.dist-info/RECORD +0 -35
  349. sagemaker_core-1.0.62.dist-info/top_level.txt +0 -1
  350. {sagemaker_core → sagemaker/core/helper}/__init__.py +0 -0
  351. {sagemaker_core/helper → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
  352. {sagemaker_core/main → sagemaker/core/jumpstart/hub}/__init__.py +0 -0
  353. {sagemaker_core/main/code_injection → sagemaker/core/modules/local_core}/__init__.py +0 -0
  354. {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
  355. {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
  356. {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
  357. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/WHEEL +0 -0
  358. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,793 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """Placeholder docstring"""
14
+ from __future__ import absolute_import, annotations, print_function
15
+
16
+ import json
17
+ from typing import Dict, Optional
18
+
19
+ from sagemaker.core._studio import _append_project_tags
20
+ from sagemaker.core.config.config_schema import (
21
+ MONITORING_JOB_ENVIRONMENT_PATH,
22
+ MONITORING_JOB_ROLE_ARN_PATH,
23
+ MONITORING_JOB_VOLUME_KMS_KEY_ID_PATH,
24
+ MONITORING_JOB_NETWORK_CONFIG_PATH,
25
+ MONITORING_JOB_OUTPUT_KMS_KEY_ID_PATH,
26
+ MONITORING_SCHEDULE,
27
+ MONITORING_SCHEDULE_INTER_CONTAINER_ENCRYPTION_PATH,
28
+ KMS_KEY_ID,
29
+ SAGEMAKER,
30
+ TAGS,
31
+ )
32
+ from sagemaker.core.common_utils import (
33
+ resolve_value_from_config,
34
+ resolve_nested_dict_value_from_config,
35
+ update_nested_dictionary_with_values_from_config,
36
+ format_tags,
37
+ )
38
+ from sagemaker.core.config.config_utils import _append_sagemaker_config_tags
39
+ import logging
40
+
41
+ # Setting LOGGER for backward compatibility, in case users import it...
42
+ logger = LOGGER = logging.getLogger("sagemaker")
43
+
44
+ MODEL_MONITOR_ONE_TIME_SCHEDULE = "NOW"
45
+
46
+
47
+ def boto_create_monitoring_schedule(
48
+ sagemaker_session,
49
+ monitoring_schedule_name,
50
+ schedule_expression,
51
+ statistics_s3_uri,
52
+ constraints_s3_uri,
53
+ monitoring_inputs,
54
+ monitoring_output_config,
55
+ instance_count,
56
+ instance_type,
57
+ volume_size_in_gb,
58
+ volume_kms_key=None,
59
+ image_uri=None,
60
+ entrypoint=None,
61
+ arguments=None,
62
+ record_preprocessor_source_uri=None,
63
+ post_analytics_processor_source_uri=None,
64
+ max_runtime_in_seconds=None,
65
+ environment=None,
66
+ network_config=None,
67
+ role_arn=None,
68
+ tags=None,
69
+ data_analysis_start_time=None,
70
+ data_analysis_end_time=None,
71
+ ):
72
+ """Create an Amazon SageMaker monitoring schedule.
73
+
74
+ Args:
75
+ monitoring_schedule_name (str): The name of the monitoring schedule. The name must be
76
+ unique within an AWS Region in an AWS account. Names should have a minimum length
77
+ of 1 and a maximum length of 63 characters.
78
+ schedule_expression (str): The cron expression that dictates the monitoring execution
79
+ schedule.
80
+ statistics_s3_uri (str): The S3 uri of the statistics file to use.
81
+ constraints_s3_uri (str): The S3 uri of the constraints file to use.
82
+ monitoring_inputs ([dict]): List of MonitoringInput dictionaries.
83
+ monitoring_output_config (dict): A config dictionary, which contains a list of
84
+ MonitoringOutput dictionaries, as well as an optional KMS key ID.
85
+ instance_count (int): The number of instances to run.
86
+ instance_type (str): The type of instance to run.
87
+ volume_size_in_gb (int): Size of the volume in GB.
88
+ volume_kms_key (str): KMS key to use when encrypting the volume.
89
+ image_uri (str): The image uri to use for monitoring executions.
90
+ entrypoint (str): The entrypoint to the monitoring execution image.
91
+ arguments (str): The arguments to pass to the monitoring execution image.
92
+ record_preprocessor_source_uri (str or None): The S3 uri that points to the script that
93
+ pre-processes the dataset (only applicable to first-party images).
94
+ post_analytics_processor_source_uri (str or None): The S3 uri that points to the script
95
+ that post-processes the dataset (only applicable to first-party images).
96
+ max_runtime_in_seconds (int): Specifies a limit to how long
97
+ the processing job can run, in seconds.
98
+ environment (dict): Environment variables to start the monitoring execution
99
+ container with.
100
+ network_config (dict): Specifies networking options, such as network
101
+ traffic encryption between processing containers, whether to allow
102
+ inbound and outbound network calls to and from processing containers,
103
+ and VPC subnets and security groups to use for VPC-enabled processing
104
+ jobs.
105
+ role_arn (str): The Amazon Resource Name (ARN) of an IAM role that
106
+ Amazon SageMaker can assume to perform tasks on your behalf.
107
+ tags (Optional[Tags]): A list of dictionaries containing key-value
108
+ pairs.
109
+ data_analysis_start_time (str): Start time for the data analysis window
110
+ for the one time monitoring schedule (NOW), e.g. "-PT1H"
111
+ data_analysis_end_time (str): End time for the data analysis window
112
+ for the one time monitoring schedule (NOW), e.g. "-PT1H"
113
+ """
114
+ role_arn = resolve_value_from_config(
115
+ role_arn, MONITORING_JOB_ROLE_ARN_PATH, sagemaker_session=sagemaker_session
116
+ )
117
+ volume_kms_key = resolve_value_from_config(
118
+ volume_kms_key, MONITORING_JOB_VOLUME_KMS_KEY_ID_PATH, sagemaker_session=sagemaker_session
119
+ )
120
+ inferred_network_config_from_config = update_nested_dictionary_with_values_from_config(
121
+ network_config, MONITORING_JOB_NETWORK_CONFIG_PATH, sagemaker_session=sagemaker_session
122
+ )
123
+ environment = resolve_value_from_config(
124
+ direct_input=environment,
125
+ config_path=MONITORING_JOB_ENVIRONMENT_PATH,
126
+ default_value=None,
127
+ sagemaker_session=sagemaker_session,
128
+ )
129
+ monitoring_schedule_request = {
130
+ "MonitoringScheduleName": monitoring_schedule_name,
131
+ "MonitoringScheduleConfig": {
132
+ "MonitoringJobDefinition": {
133
+ "Environment": environment,
134
+ "MonitoringInputs": monitoring_inputs,
135
+ "MonitoringResources": {
136
+ "ClusterConfig": {
137
+ "InstanceCount": instance_count,
138
+ "InstanceType": instance_type,
139
+ "VolumeSizeInGB": volume_size_in_gb,
140
+ }
141
+ },
142
+ "MonitoringAppSpecification": {"ImageUri": image_uri},
143
+ "RoleArn": role_arn,
144
+ }
145
+ },
146
+ }
147
+
148
+ if schedule_expression is not None:
149
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"] = {
150
+ "ScheduleExpression": schedule_expression,
151
+ }
152
+ if data_analysis_start_time is not None:
153
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"][
154
+ "DataAnalysisStartTime"
155
+ ] = data_analysis_start_time
156
+
157
+ if data_analysis_end_time is not None:
158
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"][
159
+ "DataAnalysisEndTime"
160
+ ] = data_analysis_end_time
161
+
162
+ if monitoring_output_config is not None:
163
+ kms_key_from_config = resolve_value_from_config(
164
+ config_path=MONITORING_JOB_OUTPUT_KMS_KEY_ID_PATH, sagemaker_session=sagemaker_session
165
+ )
166
+ if KMS_KEY_ID not in monitoring_output_config and kms_key_from_config:
167
+ monitoring_output_config[KMS_KEY_ID] = kms_key_from_config
168
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
169
+ "MonitoringOutputConfig"
170
+ ] = monitoring_output_config
171
+
172
+ if statistics_s3_uri is not None or constraints_s3_uri is not None:
173
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
174
+ "BaselineConfig"
175
+ ] = {}
176
+
177
+ if statistics_s3_uri is not None:
178
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
179
+ "BaselineConfig"
180
+ ]["StatisticsResource"] = {"S3Uri": statistics_s3_uri}
181
+
182
+ if constraints_s3_uri is not None:
183
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
184
+ "BaselineConfig"
185
+ ]["ConstraintsResource"] = {"S3Uri": constraints_s3_uri}
186
+
187
+ if record_preprocessor_source_uri is not None:
188
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
189
+ "MonitoringAppSpecification"
190
+ ]["RecordPreprocessorSourceUri"] = record_preprocessor_source_uri
191
+
192
+ if post_analytics_processor_source_uri is not None:
193
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
194
+ "MonitoringAppSpecification"
195
+ ]["PostAnalyticsProcessorSourceUri"] = post_analytics_processor_source_uri
196
+
197
+ if entrypoint is not None:
198
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
199
+ "MonitoringAppSpecification"
200
+ ]["ContainerEntrypoint"] = entrypoint
201
+
202
+ if arguments is not None:
203
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
204
+ "MonitoringAppSpecification"
205
+ ]["ContainerArguments"] = arguments
206
+
207
+ if volume_kms_key is not None:
208
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
209
+ "MonitoringResources"
210
+ ]["ClusterConfig"]["VolumeKmsKeyId"] = volume_kms_key
211
+
212
+ if max_runtime_in_seconds is not None:
213
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
214
+ "StoppingCondition"
215
+ ] = {"MaxRuntimeInSeconds": max_runtime_in_seconds}
216
+
217
+ if environment is not None:
218
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
219
+ "Environment"
220
+ ] = environment
221
+
222
+ if inferred_network_config_from_config is not None:
223
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
224
+ "NetworkConfig"
225
+ ] = inferred_network_config_from_config
226
+
227
+ tags = _append_project_tags(format_tags(tags))
228
+ tags = _append_sagemaker_config_tags(
229
+ sagemaker_session, tags, "{}.{}.{}".format(SAGEMAKER, MONITORING_SCHEDULE, TAGS)
230
+ )
231
+
232
+ if tags is not None:
233
+ monitoring_schedule_request["Tags"] = tags
234
+
235
+ logger.info("Creating monitoring schedule name %s.", monitoring_schedule_name)
236
+ logger.debug(
237
+ "monitoring_schedule_request= %s", json.dumps(monitoring_schedule_request, indent=4)
238
+ )
239
+ sagemaker_session.sagemaker_client.create_monitoring_schedule(**monitoring_schedule_request)
240
+
241
+
242
+ def boto_update_monitoring_schedule(
243
+ sagemaker_session,
244
+ monitoring_schedule_name,
245
+ schedule_expression=None,
246
+ statistics_s3_uri=None,
247
+ constraints_s3_uri=None,
248
+ monitoring_inputs=None,
249
+ monitoring_output_config=None,
250
+ instance_count=None,
251
+ instance_type=None,
252
+ volume_size_in_gb=None,
253
+ volume_kms_key=None,
254
+ image_uri=None,
255
+ entrypoint=None,
256
+ arguments=None,
257
+ record_preprocessor_source_uri=None,
258
+ post_analytics_processor_source_uri=None,
259
+ max_runtime_in_seconds=None,
260
+ environment=None,
261
+ network_config=None,
262
+ role_arn=None,
263
+ data_analysis_start_time=None,
264
+ data_analysis_end_time=None,
265
+ ):
266
+ """Update an Amazon SageMaker monitoring schedule.
267
+
268
+ Args:
269
+ monitoring_schedule_name (str): The name of the monitoring schedule. The name must be
270
+ unique within an AWS Region in an AWS account. Names should have a minimum length
271
+ of 1 and a maximum length of 63 characters.
272
+ schedule_expression (str): The cron expression that dictates the monitoring execution
273
+ schedule.
274
+ statistics_s3_uri (str): The S3 uri of the statistics file to use.
275
+ constraints_s3_uri (str): The S3 uri of the constraints file to use.
276
+ monitoring_inputs ([dict]): List of MonitoringInput dictionaries.
277
+ monitoring_output_config (dict): A config dictionary, which contains a list of
278
+ MonitoringOutput dictionaries, as well as an optional KMS key ID.
279
+ instance_count (int): The number of instances to run.
280
+ instance_type (str): The type of instance to run.
281
+ volume_size_in_gb (int): Size of the volume in GB.
282
+ volume_kms_key (str): KMS key to use when encrypting the volume.
283
+ image_uri (str): The image uri to use for monitoring executions.
284
+ entrypoint (str): The entrypoint to the monitoring execution image.
285
+ arguments (str): The arguments to pass to the monitoring execution image.
286
+ record_preprocessor_source_uri (str or None): The S3 uri that points to the script that
287
+ pre-processes the dataset (only applicable to first-party images).
288
+ post_analytics_processor_source_uri (str or None): The S3 uri that points to the script
289
+ that post-processes the dataset (only applicable to first-party images).
290
+ max_runtime_in_seconds (int): Specifies a limit to how long
291
+ the processing job can run, in seconds.
292
+ environment (dict): Environment variables to start the monitoring execution
293
+ container with.
294
+ network_config (dict): Specifies networking options, such as network
295
+ traffic encryption between processing containers, whether to allow
296
+ inbound and outbound network calls to and from processing containers,
297
+ and VPC subnets and security groups to use for VPC-enabled processing
298
+ jobs.
299
+ role_arn (str): The Amazon Resource Name (ARN) of an IAM role that
300
+ Amazon SageMaker can assume to perform tasks on your behalf.
301
+ tags ([dict[str,str]]): A list of dictionaries containing key-value
302
+ pairs.
303
+ data_analysis_start_time (str): Start time for the data analysis window
304
+ for the one time monitoring schedule (NOW), e.g. "-PT1H"
305
+ data_analysis_end_time (str): End time for the data analysis window
306
+ for the one time monitoring schedule (NOW), e.g. "-PT1H"
307
+ """
308
+ existing_desc = sagemaker_session.sagemaker_client.describe_monitoring_schedule(
309
+ MonitoringScheduleName=monitoring_schedule_name
310
+ )
311
+
312
+ existing_schedule_config = None
313
+ existing_data_analysis_start_time = None
314
+ existing_data_analysis_end_time = None
315
+
316
+ if (
317
+ existing_desc.get("MonitoringScheduleConfig") is not None
318
+ and existing_desc["MonitoringScheduleConfig"].get("ScheduleConfig") is not None
319
+ and existing_desc["MonitoringScheduleConfig"]["ScheduleConfig"]["ScheduleExpression"]
320
+ is not None
321
+ ):
322
+ existing_schedule_config = existing_desc["MonitoringScheduleConfig"]["ScheduleConfig"][
323
+ "ScheduleExpression"
324
+ ]
325
+ if (
326
+ existing_desc["MonitoringScheduleConfig"]["ScheduleConfig"].get("DataAnalysisStartTime")
327
+ is not None
328
+ ):
329
+ existing_data_analysis_start_time = existing_desc["MonitoringScheduleConfig"][
330
+ "ScheduleConfig"
331
+ ]["DataAnalysisStartTime"]
332
+ if (
333
+ existing_desc["MonitoringScheduleConfig"]["ScheduleConfig"].get("DataAnalysisEndTime")
334
+ is not None
335
+ ):
336
+ existing_data_analysis_end_time = existing_desc["MonitoringScheduleConfig"][
337
+ "ScheduleConfig"
338
+ ]["DataAnalysisEndTime"]
339
+
340
+ request_schedule_expression = schedule_expression or existing_schedule_config
341
+ request_data_analysis_start_time = data_analysis_start_time or existing_data_analysis_start_time
342
+ request_data_analysis_end_time = data_analysis_end_time or existing_data_analysis_end_time
343
+
344
+ if request_schedule_expression == MODEL_MONITOR_ONE_TIME_SCHEDULE and (
345
+ request_data_analysis_start_time is None or request_data_analysis_end_time is None
346
+ ):
347
+ message = (
348
+ "Both data_analysis_start_time and data_analysis_end_time are required "
349
+ "for one time monitoring schedule "
350
+ )
351
+ LOGGER.error(message)
352
+ raise ValueError(message)
353
+
354
+ request_monitoring_inputs = (
355
+ monitoring_inputs
356
+ or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"]["MonitoringInputs"]
357
+ )
358
+ request_instance_count = (
359
+ instance_count
360
+ or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
361
+ "MonitoringResources"
362
+ ]["ClusterConfig"]["InstanceCount"]
363
+ )
364
+ request_instance_type = (
365
+ instance_type
366
+ or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
367
+ "MonitoringResources"
368
+ ]["ClusterConfig"]["InstanceType"]
369
+ )
370
+ request_volume_size_in_gb = (
371
+ volume_size_in_gb
372
+ or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
373
+ "MonitoringResources"
374
+ ]["ClusterConfig"]["VolumeSizeInGB"]
375
+ )
376
+ request_image_uri = (
377
+ image_uri
378
+ or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
379
+ "MonitoringAppSpecification"
380
+ ]["ImageUri"]
381
+ )
382
+ request_role_arn = (
383
+ role_arn or existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"]["RoleArn"]
384
+ )
385
+
386
+ monitoring_schedule_request = {
387
+ "MonitoringScheduleName": monitoring_schedule_name,
388
+ "MonitoringScheduleConfig": {
389
+ "MonitoringJobDefinition": {
390
+ "MonitoringInputs": request_monitoring_inputs,
391
+ "MonitoringResources": {
392
+ "ClusterConfig": {
393
+ "InstanceCount": request_instance_count,
394
+ "InstanceType": request_instance_type,
395
+ "VolumeSizeInGB": request_volume_size_in_gb,
396
+ }
397
+ },
398
+ "MonitoringAppSpecification": {"ImageUri": request_image_uri},
399
+ "RoleArn": request_role_arn,
400
+ }
401
+ },
402
+ }
403
+
404
+ if existing_schedule_config is not None:
405
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"] = {
406
+ "ScheduleExpression": request_schedule_expression,
407
+ }
408
+
409
+ if request_data_analysis_start_time is not None:
410
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"][
411
+ "DataAnalysisStartTime"
412
+ ] = request_data_analysis_start_time
413
+
414
+ if request_data_analysis_end_time is not None:
415
+ monitoring_schedule_request["MonitoringScheduleConfig"]["ScheduleConfig"][
416
+ "DataAnalysisEndTime"
417
+ ] = request_data_analysis_end_time
418
+
419
+ existing_monitoring_output_config = existing_desc["MonitoringScheduleConfig"][
420
+ "MonitoringJobDefinition"
421
+ ].get("MonitoringOutputConfig")
422
+ if monitoring_output_config is not None or existing_monitoring_output_config is not None:
423
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
424
+ "MonitoringOutputConfig"
425
+ ] = (monitoring_output_config or existing_monitoring_output_config)
426
+
427
+ existing_statistics_s3_uri = None
428
+ existing_constraints_s3_uri = None
429
+ if (
430
+ existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"].get("BaselineConfig")
431
+ is not None
432
+ ):
433
+ if (
434
+ existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
435
+ "BaselineConfig"
436
+ ].get("StatisticsResource")
437
+ is not None
438
+ ):
439
+ existing_statistics_s3_uri = existing_desc["MonitoringScheduleConfig"][
440
+ "MonitoringJobDefinition"
441
+ ]["BaselineConfig"]["StatisticsResource"]["S3Uri"]
442
+
443
+ if (
444
+ existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
445
+ "BaselineConfig"
446
+ ].get("ConstraintsResource")
447
+ is not None
448
+ ):
449
+ existing_statistics_s3_uri = existing_desc["MonitoringScheduleConfig"][
450
+ "MonitoringJobDefinition"
451
+ ]["BaselineConfig"]["ConstraintsResource"]["S3Uri"]
452
+
453
+ if (
454
+ statistics_s3_uri is not None
455
+ or constraints_s3_uri is not None
456
+ or existing_statistics_s3_uri is not None
457
+ or existing_constraints_s3_uri is not None
458
+ ):
459
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
460
+ "BaselineConfig"
461
+ ] = {}
462
+
463
+ if statistics_s3_uri is not None or existing_statistics_s3_uri is not None:
464
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
465
+ "BaselineConfig"
466
+ ]["StatisticsResource"] = {"S3Uri": statistics_s3_uri or existing_statistics_s3_uri}
467
+
468
+ if constraints_s3_uri is not None or existing_constraints_s3_uri is not None:
469
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
470
+ "BaselineConfig"
471
+ ]["ConstraintsResource"] = {"S3Uri": constraints_s3_uri or existing_constraints_s3_uri}
472
+
473
+ existing_record_preprocessor_source_uri = existing_desc["MonitoringScheduleConfig"][
474
+ "MonitoringJobDefinition"
475
+ ]["MonitoringAppSpecification"].get("RecordPreprocessorSourceUri")
476
+ if (
477
+ record_preprocessor_source_uri is not None
478
+ or existing_record_preprocessor_source_uri is not None
479
+ ):
480
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
481
+ "MonitoringAppSpecification"
482
+ ]["RecordPreprocessorSourceUri"] = (
483
+ record_preprocessor_source_uri or existing_record_preprocessor_source_uri
484
+ )
485
+
486
+ existing_post_analytics_processor_source_uri = existing_desc["MonitoringScheduleConfig"][
487
+ "MonitoringJobDefinition"
488
+ ]["MonitoringAppSpecification"].get("PostAnalyticsProcessorSourceUri")
489
+ if (
490
+ post_analytics_processor_source_uri is not None
491
+ or existing_post_analytics_processor_source_uri is not None
492
+ ):
493
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
494
+ "MonitoringAppSpecification"
495
+ ]["PostAnalyticsProcessorSourceUri"] = (
496
+ post_analytics_processor_source_uri or existing_post_analytics_processor_source_uri
497
+ )
498
+
499
+ existing_entrypoint = existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
500
+ "MonitoringAppSpecification"
501
+ ].get("ContainerEntrypoint")
502
+ if entrypoint is not None or existing_entrypoint is not None:
503
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
504
+ "MonitoringAppSpecification"
505
+ ]["ContainerEntrypoint"] = (entrypoint or existing_entrypoint)
506
+
507
+ existing_arguments = existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
508
+ "MonitoringAppSpecification"
509
+ ].get("ContainerArguments")
510
+ if arguments is not None or existing_arguments is not None:
511
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
512
+ "MonitoringAppSpecification"
513
+ ]["ContainerArguments"] = (arguments or existing_arguments)
514
+
515
+ existing_volume_kms_key = existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
516
+ "MonitoringResources"
517
+ ]["ClusterConfig"].get("VolumeKmsKeyId")
518
+
519
+ if volume_kms_key is not None or existing_volume_kms_key is not None:
520
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
521
+ "MonitoringResources"
522
+ ]["ClusterConfig"]["VolumeKmsKeyId"] = (volume_kms_key or existing_volume_kms_key)
523
+
524
+ existing_max_runtime_in_seconds = None
525
+ if existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"].get(
526
+ "StoppingCondition"
527
+ ):
528
+ existing_max_runtime_in_seconds = existing_desc["MonitoringScheduleConfig"][
529
+ "MonitoringJobDefinition"
530
+ ]["StoppingCondition"].get("MaxRuntimeInSeconds")
531
+
532
+ if max_runtime_in_seconds is not None or existing_max_runtime_in_seconds is not None:
533
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
534
+ "StoppingCondition"
535
+ ] = {"MaxRuntimeInSeconds": max_runtime_in_seconds or existing_max_runtime_in_seconds}
536
+
537
+ existing_environment = existing_desc["MonitoringScheduleConfig"]["MonitoringJobDefinition"].get(
538
+ "Environment"
539
+ )
540
+ if environment is not None or existing_environment is not None:
541
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
542
+ "Environment"
543
+ ] = (environment or existing_environment)
544
+
545
+ existing_network_config = existing_desc["MonitoringScheduleConfig"][
546
+ "MonitoringJobDefinition"
547
+ ].get("NetworkConfig")
548
+
549
+ _network_config = network_config or existing_network_config
550
+ _network_config = resolve_nested_dict_value_from_config(
551
+ _network_config,
552
+ ["EnableInterContainerTrafficEncryption"],
553
+ MONITORING_SCHEDULE_INTER_CONTAINER_ENCRYPTION_PATH,
554
+ sagemaker_session=sagemaker_session,
555
+ )
556
+ if _network_config is not None:
557
+ monitoring_schedule_request["MonitoringScheduleConfig"]["MonitoringJobDefinition"][
558
+ "NetworkConfig"
559
+ ] = _network_config
560
+
561
+ logger.info("Updating monitoring schedule with name: %s .", monitoring_schedule_name)
562
+ logger.debug(
563
+ "monitoring_schedule_request= %s", json.dumps(monitoring_schedule_request, indent=4)
564
+ )
565
+ sagemaker_session.sagemaker_client.update_monitoring_schedule(**monitoring_schedule_request)
566
+
567
+
568
+ def boto_start_monitoring_schedule(sagemaker_session, monitoring_schedule_name):
569
+ """Starts a monitoring schedule.
570
+
571
+ Args:
572
+ monitoring_schedule_name (str): The name of the Amazon SageMaker Monitoring
573
+ Schedule to start.
574
+ """
575
+ logger.info("Starting Monitoring Schedule with name: %s", monitoring_schedule_name)
576
+ sagemaker_session.sagemaker_client.start_monitoring_schedule(
577
+ MonitoringScheduleName=monitoring_schedule_name
578
+ )
579
+
580
+
581
+ def boto_stop_monitoring_schedule(sagemaker_session, monitoring_schedule_name):
582
+ """Stops a monitoring schedule.
583
+
584
+ Args:
585
+ monitoring_schedule_name (str): The name of the Amazon SageMaker Monitoring
586
+ Schedule to stop.
587
+ """
588
+ logger.info("Stopping Monitoring Schedule with name: %s", monitoring_schedule_name)
589
+ sagemaker_session.sagemaker_client.stop_monitoring_schedule(
590
+ MonitoringScheduleName=monitoring_schedule_name
591
+ )
592
+
593
+
594
+ def boto_delete_monitoring_schedule(sagemaker_session, monitoring_schedule_name):
595
+ """Deletes a monitoring schedule.
596
+
597
+ Args:
598
+ monitoring_schedule_name (str): The name of the Amazon SageMaker Monitoring
599
+ Schedule to delete.
600
+ """
601
+ logger.info("Deleting Monitoring Schedule with name: %s", monitoring_schedule_name)
602
+ sagemaker_session.sagemaker_client.delete_monitoring_schedule(
603
+ MonitoringScheduleName=monitoring_schedule_name
604
+ )
605
+
606
+
607
+ def boto_describe_monitoring_schedule(sagemaker_session, monitoring_schedule_name):
608
+ """Calls the DescribeMonitoringSchedule API for given name and returns the response.
609
+
610
+ Args:
611
+ monitoring_schedule_name (str): The name of the processing job to describe.
612
+
613
+ Returns:
614
+ dict: A dictionary response with the processing job description.
615
+ """
616
+ return sagemaker_session.sagemaker_client.describe_monitoring_schedule(
617
+ MonitoringScheduleName=monitoring_schedule_name
618
+ )
619
+
620
+
621
+ def boto_list_monitoring_executions(
622
+ sagemaker_session,
623
+ monitoring_schedule_name,
624
+ sort_by="ScheduledTime",
625
+ sort_order="Descending",
626
+ max_results=100,
627
+ ):
628
+ """Lists the monitoring executions associated with the given monitoring_schedule_name.
629
+
630
+ Args:
631
+ monitoring_schedule_name (str): The monitoring_schedule_name for which to retrieve the
632
+ monitoring executions.
633
+ sort_by (str): The field to sort by. Can be one of: "CreationTime", "ScheduledTime",
634
+ "Status". Default: "ScheduledTime".
635
+ sort_order (str): The sort order. Can be one of: "Ascending", "Descending".
636
+ Default: "Descending".
637
+ max_results (int): The maximum number of results to return. Must be between 1 and 100.
638
+
639
+ Returns:
640
+ dict: Dictionary of monitoring schedule executions.
641
+ """
642
+ response = sagemaker_session.sagemaker_client.list_monitoring_executions(
643
+ MonitoringScheduleName=monitoring_schedule_name,
644
+ SortBy=sort_by,
645
+ SortOrder=sort_order,
646
+ MaxResults=max_results,
647
+ )
648
+ return response
649
+
650
+
651
+ def boto_list_monitoring_schedules(
652
+ sagemaker_session,
653
+ endpoint_name=None,
654
+ sort_by="CreationTime",
655
+ sort_order="Descending",
656
+ max_results=100,
657
+ ):
658
+ """Lists the monitoring executions associated with the given monitoring_schedule_name.
659
+
660
+ Args:
661
+ endpoint_name (str): The name of the endpoint to filter on. If not provided, does not
662
+ filter on it. Default: None.
663
+ sort_by (str): The field to sort by. Can be one of: "Name", "CreationTime", "Status".
664
+ Default: "CreationTime".
665
+ sort_order (str): The sort order. Can be one of: "Ascending", "Descending".
666
+ Default: "Descending".
667
+ max_results (int): The maximum number of results to return. Must be between 1 and 100.
668
+
669
+ Returns:
670
+ dict: Dictionary of monitoring schedule executions.
671
+ """
672
+ if endpoint_name is not None:
673
+ response = sagemaker_session.sagemaker_client.list_monitoring_schedules(
674
+ EndpointName=endpoint_name,
675
+ SortBy=sort_by,
676
+ SortOrder=sort_order,
677
+ MaxResults=max_results,
678
+ )
679
+ else:
680
+ response = sagemaker_session.sagemaker_client.list_monitoring_schedules(
681
+ SortBy=sort_by, SortOrder=sort_order, MaxResults=max_results
682
+ )
683
+
684
+ return response
685
+
686
+
687
+ def boto_update_monitoring_alert(
688
+ sagemaker_session,
689
+ monitoring_schedule_name: str,
690
+ monitoring_alert_name: str,
691
+ data_points_to_alert: int,
692
+ evaluation_period: int,
693
+ ):
694
+ """Update the monitoring alerts associated with the given schedule_name and alert_name
695
+
696
+ Args:
697
+ monitoring_schedule_name (str): The name of the monitoring schedule to update.
698
+ monitoring_alert_name (str): The name of the monitoring alert to update.
699
+ data_points_to_alert (int): The data point to alert.
700
+ evaluation_period (int): The period to evaluate the alert status.
701
+
702
+ Returns:
703
+ dict: A dict represents the update alert response.
704
+ """
705
+ return sagemaker_session.sagemaker_client.update_monitoring_alert(
706
+ MonitoringScheduleName=monitoring_schedule_name,
707
+ MonitoringAlertName=monitoring_alert_name,
708
+ DatapointsToAlert=data_points_to_alert,
709
+ EvaluationPeriod=evaluation_period,
710
+ )
711
+
712
+
713
+ def boto_list_monitoring_alerts(
714
+ sagemaker_session,
715
+ monitoring_schedule_name: str,
716
+ next_token: Optional[str] = None,
717
+ max_results: Optional[int] = 10,
718
+ ) -> Dict:
719
+ """Lists the monitoring alerts associated with the given monitoring_schedule_name.
720
+
721
+ Args:
722
+ monitoring_schedule_name (str): The name of the monitoring schedule to filter on.
723
+ If not provided, does not filter on it.
724
+ next_token (Optional[str]): The pagination token. Default: None
725
+ max_results (Optional[int]): The maximum number of results to return.
726
+ Must be between 1 and 100. Default: 10
727
+
728
+ Returns:
729
+ dict: list of monitoring alerts.
730
+ """
731
+ params = {
732
+ "MonitoringScheduleName": monitoring_schedule_name,
733
+ "MaxResults": max_results,
734
+ }
735
+ if next_token:
736
+ params.update({"NextToken": next_token})
737
+
738
+ return sagemaker_session.sagemaker_client.list_monitoring_alerts(**params)
739
+
740
+
741
+ def boto_list_monitoring_alert_history(
742
+ sagemaker_session,
743
+ monitoring_schedule_name: Optional[str] = None,
744
+ monitoring_alert_name: Optional[str] = None,
745
+ sort_by: Optional[str] = "CreationTime",
746
+ sort_order: Optional[str] = "Descending",
747
+ next_token: Optional[str] = None,
748
+ max_results: Optional[int] = 10,
749
+ creation_time_before: Optional[str] = None,
750
+ creation_time_after: Optional[str] = None,
751
+ status_equals: Optional[str] = None,
752
+ ) -> Dict:
753
+ """Lists the alert history associated with the given schedule_name and alert_name.
754
+
755
+ Args:
756
+ monitoring_schedule_name (Optional[str]): The name of the monitoring_schedule_name
757
+ to filter on. If not provided, does not filter on it. Default: None.
758
+ monitoring_alert_name (Optional[str]): The name of the monitoring_alert_name
759
+ to filter on. If not provided, does not filter on it. Default: None.
760
+ sort_by (Optional[str]): sort_by (str): The field to sort by.
761
+ Can be one of: "Name", "CreationTime" Default: "CreationTime".
762
+ sort_order (Optional[str]): The sort order. Can be one of: "Ascending", "Descending".
763
+ Default: "Descending".
764
+ next_token (Optional[str]): The pagination token. Default: None
765
+ max_results (Optional[int]): The maximum number of results to return.
766
+ Must be between 1 and 100. Default: 10.
767
+ creation_time_before (Optional[str]): A filter to filter alert history before a time
768
+ creation_time_after (Optional[str]): A filter to filter alert history after a time
769
+ Default: None.
770
+ status_equals (Optional[str]): A filter to filter alert history by status
771
+ Default: None.
772
+
773
+ Returns:
774
+ dict: list of monitoring alert history.
775
+ """
776
+ params = {
777
+ "MonitoringScheduleName": monitoring_schedule_name,
778
+ "SortBy": sort_by,
779
+ "SortOrder": sort_order,
780
+ "MaxResults": max_results,
781
+ }
782
+ if monitoring_alert_name:
783
+ params.update({"MonitoringAlertName": monitoring_alert_name})
784
+ if creation_time_before:
785
+ params.update({"CreationTimeBefore": creation_time_before})
786
+ if creation_time_after:
787
+ params.update({"CreationTimeAfter": creation_time_after})
788
+ if status_equals:
789
+ params.update({"StatusEquals": status_equals})
790
+ if next_token:
791
+ params.update({"NextToken": next_token})
792
+
793
+ return sagemaker_session.sagemaker_client.list_monitoring_alert_history(**params)