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.
- sagemaker/__init__.py +2 -0
- sagemaker/core/__init__.py +16 -0
- sagemaker/core/_studio.py +116 -0
- sagemaker/core/_version.py +11 -0
- sagemaker/core/accept_types.py +131 -0
- sagemaker/core/analytics.py +744 -0
- sagemaker/core/apiutils/__init__.py +13 -0
- sagemaker/core/apiutils/_base_types.py +228 -0
- sagemaker/core/apiutils/_boto_functions.py +130 -0
- sagemaker/core/apiutils/_utils.py +34 -0
- sagemaker/core/base_deserializers.py +35 -0
- sagemaker/core/base_serializers.py +35 -0
- sagemaker/core/clarify/__init__.py +2898 -0
- sagemaker/core/collection.py +467 -0
- sagemaker/core/common_utils.py +2399 -0
- sagemaker/core/compute_resource_requirements/__init__.py +18 -0
- sagemaker/core/compute_resource_requirements/resource_requirements.py +94 -0
- sagemaker/core/config/__init__.py +181 -0
- sagemaker/core/config/config.py +238 -0
- sagemaker/core/config/config_manager.py +595 -0
- sagemaker/core/config/config_schema.py +1220 -0
- sagemaker/core/config/config_utils.py +297 -0
- {sagemaker_core/main → sagemaker/core}/config_schema.py +408 -3
- sagemaker/core/constants.py +73 -0
- sagemaker/core/content_types.py +137 -0
- sagemaker/core/debugger/__init__.py +39 -0
- sagemaker/core/debugger/debugger.py +945 -0
- sagemaker/core/debugger/framework_profile.py +292 -0
- sagemaker/core/debugger/metrics_config.py +468 -0
- sagemaker/core/debugger/profiler.py +42 -0
- sagemaker/core/debugger/profiler_config.py +190 -0
- sagemaker/core/debugger/profiler_constants.py +40 -0
- sagemaker/core/debugger/utils.py +148 -0
- sagemaker/core/deprecations.py +254 -0
- sagemaker/core/deserializers/__init__.py +10 -0
- sagemaker/core/deserializers/base.py +424 -0
- sagemaker/core/deserializers/implementations.py +157 -0
- sagemaker/core/drift_check_baselines.py +106 -0
- sagemaker/core/enums.py +51 -0
- sagemaker/core/environment_variables.py +101 -0
- sagemaker/core/exceptions.py +108 -0
- sagemaker/core/experiments/__init__.py +53 -0
- sagemaker/core/experiments/_api_types.py +251 -0
- sagemaker/core/experiments/_environment.py +124 -0
- sagemaker/core/experiments/_helper.py +294 -0
- sagemaker/core/experiments/_metrics.py +333 -0
- sagemaker/core/experiments/_run_context.py +58 -0
- sagemaker/core/experiments/_utils.py +216 -0
- sagemaker/core/experiments/experiment.py +247 -0
- sagemaker/core/experiments/run.py +970 -0
- sagemaker/core/experiments/trial.py +296 -0
- sagemaker/core/experiments/trial_component.py +387 -0
- sagemaker/core/explainer/__init__.py +24 -0
- sagemaker/core/explainer/clarify_explainer_config.py +298 -0
- sagemaker/core/explainer/explainer_config.py +44 -0
- sagemaker/core/fw_utils.py +1220 -0
- sagemaker/core/git_utils.py +415 -0
- sagemaker/core/helper/pipeline_variable.py +82 -0
- sagemaker/core/helper/session_helper.py +2977 -0
- sagemaker/core/hyperparameters.py +172 -0
- sagemaker/core/image_retriever/__init__.py +3 -0
- sagemaker/core/image_retriever/image_retriever.py +640 -0
- sagemaker/core/image_retriever/image_retriever_utils.py +509 -0
- sagemaker/core/image_retriever/test.py +7 -0
- sagemaker/core/image_uri_config/autogluon.json +1335 -0
- sagemaker/core/image_uri_config/blazingtext.json +50 -0
- sagemaker/core/image_uri_config/chainer.json +104 -0
- sagemaker/core/image_uri_config/clarify.json +39 -0
- sagemaker/core/image_uri_config/coach-mxnet.json +70 -0
- sagemaker/core/image_uri_config/coach-tensorflow.json +186 -0
- sagemaker/core/image_uri_config/data-wrangler.json +91 -0
- sagemaker/core/image_uri_config/debugger.json +34 -0
- sagemaker/core/image_uri_config/detailed-profiler.json +18 -0
- sagemaker/core/image_uri_config/djl-deepspeed.json +385 -0
- sagemaker/core/image_uri_config/djl-fastertransformer.json +167 -0
- sagemaker/core/image_uri_config/djl-lmi.json +136 -0
- sagemaker/core/image_uri_config/djl-neuronx.json +258 -0
- sagemaker/core/image_uri_config/djl-tensorrtllm.json +262 -0
- sagemaker/core/image_uri_config/factorization-machines.json +50 -0
- sagemaker/core/image_uri_config/forecasting-deepar.json +50 -0
- sagemaker/core/image_uri_config/huggingface-llm-neuronx.json +770 -0
- sagemaker/core/image_uri_config/huggingface-llm.json +1267 -0
- sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
- sagemaker/core/image_uri_config/huggingface-neuronx.json +686 -0
- sagemaker/core/image_uri_config/huggingface-tei-cpu.json +298 -0
- sagemaker/core/image_uri_config/huggingface-tei.json +298 -0
- sagemaker/core/image_uri_config/huggingface-training-compiler.json +195 -0
- sagemaker/core/image_uri_config/huggingface-vllm-neuronx.json +38 -0
- sagemaker/core/image_uri_config/huggingface.json +2287 -0
- sagemaker/core/image_uri_config/hyperpod-recipes-neuron.json +52 -0
- sagemaker/core/image_uri_config/image-classification-neo.json +43 -0
- sagemaker/core/image_uri_config/image-classification.json +50 -0
- sagemaker/core/image_uri_config/inferentia-mxnet.json +88 -0
- sagemaker/core/image_uri_config/inferentia-pytorch.json +127 -0
- sagemaker/core/image_uri_config/inferentia-tensorflow.json +88 -0
- sagemaker/core/image_uri_config/instance_gpu_info.json +782 -0
- sagemaker/core/image_uri_config/ipinsights.json +50 -0
- sagemaker/core/image_uri_config/kmeans.json +50 -0
- sagemaker/core/image_uri_config/knn.json +50 -0
- sagemaker/core/image_uri_config/lda.json +26 -0
- sagemaker/core/image_uri_config/linear-learner.json +50 -0
- sagemaker/core/image_uri_config/model-monitor.json +42 -0
- sagemaker/core/image_uri_config/mxnet.json +1154 -0
- sagemaker/core/image_uri_config/neo-mxnet.json +64 -0
- sagemaker/core/image_uri_config/neo-pytorch.json +341 -0
- sagemaker/core/image_uri_config/neo-tensorflow.json +109 -0
- sagemaker/core/image_uri_config/ntm.json +50 -0
- sagemaker/core/image_uri_config/object-detection.json +50 -0
- sagemaker/core/image_uri_config/object2vec.json +50 -0
- sagemaker/core/image_uri_config/pca.json +50 -0
- sagemaker/core/image_uri_config/pytorch-neuron.json +43 -0
- sagemaker/core/image_uri_config/pytorch-smp.json +218 -0
- sagemaker/core/image_uri_config/pytorch-training-compiler.json +80 -0
- sagemaker/core/image_uri_config/pytorch.json +3101 -0
- sagemaker/core/image_uri_config/randomcutforest.json +50 -0
- sagemaker/core/image_uri_config/ray-pytorch.json +46 -0
- sagemaker/core/image_uri_config/ray-tensorflow.json +194 -0
- sagemaker/core/image_uri_config/sagemaker-base-python.json +46 -0
- sagemaker/core/image_uri_config/sagemaker-distribution.json +37 -0
- sagemaker/core/image_uri_config/sagemaker-geospatial.json +13 -0
- sagemaker/core/image_uri_config/sagemaker-tritonserver.json +252 -0
- sagemaker/core/image_uri_config/semantic-segmentation.json +50 -0
- sagemaker/core/image_uri_config/seq2seq.json +50 -0
- sagemaker/core/image_uri_config/sklearn.json +494 -0
- sagemaker/core/image_uri_config/spark.json +280 -0
- sagemaker/core/image_uri_config/sparkml-serving.json +97 -0
- sagemaker/core/image_uri_config/stabilityai.json +53 -0
- sagemaker/core/image_uri_config/tensorflow.json +5086 -0
- sagemaker/core/image_uri_config/vw.json +25 -0
- sagemaker/core/image_uri_config/xgboost-neo.json +43 -0
- sagemaker/core/image_uri_config/xgboost.json +972 -0
- sagemaker/core/image_uris.py +816 -0
- sagemaker/core/inference_config.py +144 -0
- sagemaker/core/inference_recommender/__init__.py +18 -0
- sagemaker/core/inference_recommender/inference_recommender_mixin.py +622 -0
- sagemaker/core/inputs.py +366 -0
- sagemaker/core/instance_group.py +61 -0
- sagemaker/core/instance_types.py +164 -0
- sagemaker/core/instance_types_gpu_info.py +43 -0
- sagemaker/core/interactive_apps/__init__.py +41 -0
- sagemaker/core/interactive_apps/base_interactive_app.py +204 -0
- sagemaker/core/interactive_apps/detail_profiler_app.py +139 -0
- sagemaker/core/interactive_apps/tensorboard.py +149 -0
- sagemaker/core/iterators.py +197 -0
- sagemaker/core/job.py +380 -0
- sagemaker/core/jumpstart/__init__.py +156 -0
- sagemaker/core/jumpstart/accessors.py +390 -0
- sagemaker/core/jumpstart/artifacts/__init__.py +69 -0
- sagemaker/core/jumpstart/artifacts/environment_variables.py +252 -0
- sagemaker/core/jumpstart/artifacts/hyperparameters.py +120 -0
- sagemaker/core/jumpstart/artifacts/image_uris.py +139 -0
- sagemaker/core/jumpstart/artifacts/incremental_training.py +87 -0
- sagemaker/core/jumpstart/artifacts/instance_types.py +223 -0
- sagemaker/core/jumpstart/artifacts/kwargs.py +289 -0
- sagemaker/core/jumpstart/artifacts/metric_definitions.py +117 -0
- sagemaker/core/jumpstart/artifacts/model_packages.py +202 -0
- sagemaker/core/jumpstart/artifacts/model_uris.py +252 -0
- sagemaker/core/jumpstart/artifacts/payloads.py +96 -0
- sagemaker/core/jumpstart/artifacts/predictors.py +540 -0
- sagemaker/core/jumpstart/artifacts/resource_names.py +86 -0
- sagemaker/core/jumpstart/artifacts/resource_requirements.py +162 -0
- sagemaker/core/jumpstart/artifacts/script_uris.py +172 -0
- sagemaker/core/jumpstart/cache.py +663 -0
- sagemaker/core/jumpstart/configs.py +50 -0
- sagemaker/core/jumpstart/constants.py +198 -0
- sagemaker/core/jumpstart/deserializers.py +81 -0
- sagemaker/core/jumpstart/document.py +76 -0
- sagemaker/core/jumpstart/enums.py +168 -0
- sagemaker/core/jumpstart/exceptions.py +236 -0
- sagemaker/core/jumpstart/factory/utils.py +833 -0
- sagemaker/core/jumpstart/filters.py +597 -0
- sagemaker/core/jumpstart/hub/constants.py +16 -0
- sagemaker/core/jumpstart/hub/hub.py +291 -0
- sagemaker/core/jumpstart/hub/interfaces.py +936 -0
- sagemaker/core/jumpstart/hub/parser_utils.py +70 -0
- sagemaker/core/jumpstart/hub/parsers.py +288 -0
- sagemaker/core/jumpstart/hub/types.py +35 -0
- sagemaker/core/jumpstart/hub/utils.py +260 -0
- sagemaker/core/jumpstart/models.py +501 -0
- sagemaker/core/jumpstart/notebook_utils.py +575 -0
- sagemaker/core/jumpstart/parameters.py +20 -0
- sagemaker/core/jumpstart/payload_utils.py +239 -0
- sagemaker/core/jumpstart/region_config.json +171 -0
- sagemaker/core/jumpstart/search.py +171 -0
- sagemaker/core/jumpstart/serializers.py +81 -0
- sagemaker/core/jumpstart/session_utils.py +234 -0
- sagemaker/core/jumpstart/types.py +3044 -0
- sagemaker/core/jumpstart/utils.py +1731 -0
- sagemaker/core/jumpstart/validators.py +257 -0
- sagemaker/core/lambda_helper.py +312 -0
- sagemaker/core/lineage/__init__.py +42 -0
- sagemaker/core/lineage/_api_types.py +239 -0
- sagemaker/core/lineage/_utils.py +49 -0
- sagemaker/core/lineage/action.py +345 -0
- sagemaker/core/lineage/artifact.py +646 -0
- sagemaker/core/lineage/association.py +190 -0
- sagemaker/core/lineage/context.py +505 -0
- sagemaker/core/lineage/lineage_trial_component.py +191 -0
- sagemaker/core/lineage/query.py +732 -0
- sagemaker/core/lineage/visualizer.py +346 -0
- sagemaker/core/local/__init__.py +18 -0
- sagemaker/core/local/data.py +423 -0
- sagemaker/core/local/entities.py +678 -0
- sagemaker/core/local/exceptions.py +17 -0
- sagemaker/core/local/image.py +1243 -0
- sagemaker/core/local/local_session.py +739 -0
- sagemaker/core/local/utils.py +246 -0
- sagemaker/core/logs.py +181 -0
- sagemaker/core/metadata_properties.py +56 -0
- sagemaker/core/metric_definitions.py +91 -0
- sagemaker/core/mlflow/__init__.py +38 -0
- sagemaker/core/mlflow/forward_sagemaker_metrics.py +44 -0
- sagemaker/core/model_card/__init__.py +26 -0
- sagemaker/core/model_life_cycle.py +51 -0
- sagemaker/core/model_metrics.py +160 -0
- sagemaker/core/model_monitor/__init__.py +66 -0
- sagemaker/core/model_monitor/clarify_model_monitoring.py +1497 -0
- sagemaker/core/model_monitor/cron_expression_generator.py +82 -0
- sagemaker/core/model_monitor/data_capture_config.py +115 -0
- sagemaker/core/model_monitor/data_quality_monitoring_config.py +66 -0
- sagemaker/core/model_monitor/dataset_format.py +102 -0
- sagemaker/core/model_monitor/model_monitoring.py +4266 -0
- sagemaker/core/model_monitor/monitoring_alert.py +76 -0
- sagemaker/core/model_monitor/monitoring_files.py +506 -0
- sagemaker/core/model_monitor/utils.py +793 -0
- sagemaker/core/model_registry.py +480 -0
- sagemaker/core/model_uris.py +97 -0
- sagemaker/core/modules/__init__.py +19 -0
- sagemaker/core/modules/configs.py +239 -0
- sagemaker/core/modules/constants.py +37 -0
- sagemaker/core/modules/distributed.py +182 -0
- sagemaker/core/modules/local_core/local_container.py +605 -0
- sagemaker/core/modules/templates.py +83 -0
- sagemaker/core/modules/train/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/utils.py +205 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_driver.py +123 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
- sagemaker/core/modules/train/container_drivers/scripts/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/scripts/environment.py +305 -0
- sagemaker/core/modules/train/sm_recipes/__init__.py +0 -0
- sagemaker/core/modules/train/sm_recipes/utils.py +330 -0
- sagemaker/core/modules/types.py +19 -0
- sagemaker/core/modules/utils.py +194 -0
- sagemaker/core/network.py +185 -0
- sagemaker/core/parameter.py +173 -0
- sagemaker/core/payloads.py +185 -0
- sagemaker/core/processing.py +1599 -0
- sagemaker/core/remote_function/__init__.py +19 -0
- sagemaker/core/remote_function/checkpoint_location.py +47 -0
- sagemaker/core/remote_function/client.py +1310 -0
- sagemaker/core/remote_function/core/__init__.py +0 -0
- sagemaker/core/remote_function/core/_custom_dispatch_table.py +72 -0
- sagemaker/core/remote_function/core/pipeline_variables.py +347 -0
- sagemaker/core/remote_function/core/serialization.py +410 -0
- sagemaker/core/remote_function/core/stored_function.py +223 -0
- sagemaker/core/remote_function/custom_file_filter.py +128 -0
- sagemaker/core/remote_function/errors.py +102 -0
- sagemaker/core/remote_function/invoke_function.py +167 -0
- sagemaker/core/remote_function/job.py +2121 -0
- sagemaker/core/remote_function/logging_config.py +38 -0
- sagemaker/core/remote_function/runtime_environment/__init__.py +14 -0
- sagemaker/core/remote_function/runtime_environment/bootstrap_runtime_environment.py +605 -0
- sagemaker/core/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
- sagemaker/core/remote_function/runtime_environment/runtime_environment_manager.py +554 -0
- sagemaker/core/remote_function/runtime_environment/spark_app.py +18 -0
- sagemaker/core/remote_function/spark_config.py +149 -0
- sagemaker/core/resource_requirements.py +168 -0
- {sagemaker_core/main → sagemaker/core}/resources.py +19098 -10895
- sagemaker/core/s3/__init__.py +41 -0
- sagemaker/core/s3/client.py +367 -0
- sagemaker/core/s3/utils.py +175 -0
- sagemaker/core/script_uris.py +93 -0
- sagemaker/core/serializers/__init__.py +11 -0
- sagemaker/core/serializers/base.py +510 -0
- sagemaker/core/serializers/implementations.py +159 -0
- sagemaker/core/serializers/utils.py +223 -0
- sagemaker/core/serverless_inference_config.py +63 -0
- sagemaker/core/session_settings.py +55 -0
- sagemaker/core/shapes/__init__.py +3 -0
- sagemaker/core/shapes/model_card_shapes.py +159 -0
- {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +5810 -1806
- sagemaker/core/spark/__init__.py +16 -0
- sagemaker/core/spark/defaults.py +16 -0
- sagemaker/core/spark/processing.py +1380 -0
- sagemaker/core/telemetry/__init__.py +23 -0
- sagemaker/core/telemetry/constants.py +82 -0
- sagemaker/core/telemetry/telemetry_logging.py +285 -0
- sagemaker/core/tools/__init__.py +1 -0
- {sagemaker_core → sagemaker/core}/tools/codegen.py +4 -4
- {sagemaker_core → sagemaker/core}/tools/constants.py +23 -15
- {sagemaker_core → sagemaker/core}/tools/data_extractor.py +1 -1
- {sagemaker_core → sagemaker/core}/tools/method.py +1 -1
- sagemaker/core/tools/model_card/generate_model_card_from_schema.py +562 -0
- {sagemaker_core → sagemaker/core}/tools/resources_codegen.py +165 -98
- {sagemaker_core → sagemaker/core}/tools/resources_extractor.py +5 -13
- {sagemaker_core → sagemaker/core}/tools/shapes_codegen.py +16 -17
- {sagemaker_core → sagemaker/core}/tools/shapes_extractor.py +29 -67
- {sagemaker_core → sagemaker/core}/tools/templates.py +39 -17
- sagemaker/core/training/__init__.py +14 -0
- sagemaker/core/training/configs.py +345 -0
- sagemaker/core/training/constants.py +37 -0
- sagemaker/core/training/utils.py +77 -0
- sagemaker/core/training_compiler/__init__.py +16 -0
- sagemaker/core/training_compiler/config.py +197 -0
- sagemaker/core/training_compiler_config.py +197 -0
- sagemaker/core/transformer.py +793 -0
- sagemaker/core/user_agent.py +76 -0
- sagemaker/core/utilities/__init__.py +24 -0
- sagemaker/core/utilities/cache.py +169 -0
- sagemaker/core/utilities/search_expression.py +133 -0
- sagemaker/core/utils/__init__.py +48 -0
- sagemaker/core/utils/code_injection/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/codec.py +2 -2
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/shape_dag.py +5979 -176
- {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
- sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
- {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
- {sagemaker_core/main → sagemaker/core/utils}/utils.py +27 -22
- sagemaker/core/workflow/__init__.py +152 -0
- sagemaker/core/workflow/conditions.py +313 -0
- sagemaker/core/workflow/entities.py +58 -0
- sagemaker/core/workflow/execution_variables.py +89 -0
- sagemaker/core/workflow/functions.py +193 -0
- sagemaker/core/workflow/parameters.py +222 -0
- sagemaker/core/workflow/pipeline_context.py +394 -0
- sagemaker/core/workflow/pipeline_definition_config.py +31 -0
- sagemaker/core/workflow/properties.py +285 -0
- sagemaker/core/workflow/step_outputs.py +65 -0
- sagemaker/core/workflow/utilities.py +514 -0
- sagemaker/lineage/__init__.py +33 -0
- sagemaker/lineage/action.py +28 -0
- sagemaker/lineage/artifact.py +28 -0
- sagemaker/lineage/context.py +28 -0
- sagemaker/lineage/lineage_trial_component.py +28 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/METADATA +28 -9
- sagemaker_core-2.3.1.dist-info/RECORD +351 -0
- sagemaker_core-2.3.1.dist-info/top_level.txt +1 -0
- sagemaker_core/_version.py +0 -3
- sagemaker_core/helper/session_helper.py +0 -769
- sagemaker_core/resources/__init__.py +0 -1
- sagemaker_core/shapes/__init__.py +0 -1
- sagemaker_core/tools/__init__.py +0 -1
- sagemaker_core-1.0.62.dist-info/RECORD +0 -35
- sagemaker_core-1.0.62.dist-info/top_level.txt +0 -1
- {sagemaker_core → sagemaker/core/helper}/__init__.py +0 -0
- {sagemaker_core/helper → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/jumpstart/hub}/__init__.py +0 -0
- {sagemaker_core/main/code_injection → sagemaker/core/modules/local_core}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/WHEEL +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
"""Configuration for collecting system and framework metrics in SageMaker training jobs."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import logging
|
|
17
|
+
from typing import Optional, Union
|
|
18
|
+
|
|
19
|
+
from sagemaker.core.debugger.framework_profile import FrameworkProfile
|
|
20
|
+
from sagemaker.core.debugger.profiler import Profiler
|
|
21
|
+
from sagemaker.core.helper.pipeline_variable import PipelineVariable
|
|
22
|
+
from sagemaker.core.deprecations import deprecation_warn_base
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ProfilerConfig(object):
|
|
28
|
+
"""Configuration for collecting system and framework metrics of SageMaker training jobs.
|
|
29
|
+
|
|
30
|
+
SageMaker Debugger collects system and framework profiling
|
|
31
|
+
information of training jobs and identify performance bottlenecks.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
s3_output_path: Optional[Union[str, PipelineVariable]] = None,
|
|
38
|
+
system_monitor_interval_millis: Optional[Union[int, PipelineVariable]] = None,
|
|
39
|
+
framework_profile_params: Optional[FrameworkProfile] = None,
|
|
40
|
+
profile_params: Optional[Profiler] = None,
|
|
41
|
+
disable_profiler: Optional[Union[str, PipelineVariable]] = False,
|
|
42
|
+
):
|
|
43
|
+
"""Initialize a ``ProfilerConfig`` instance.
|
|
44
|
+
|
|
45
|
+
Pass the output of this class
|
|
46
|
+
to the ``profiler_config`` parameter of the generic :class:`~sagemaker.estimator.Estimator`
|
|
47
|
+
class and SageMaker Framework estimators.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
s3_output_path (str or PipelineVariable): The location in Amazon S3 to store
|
|
51
|
+
the output.
|
|
52
|
+
The default Debugger output path for profiling data is created under the
|
|
53
|
+
default output path of the :class:`~sagemaker.estimator.Estimator` class.
|
|
54
|
+
For example,
|
|
55
|
+
s3://sagemaker-<region>-<12digit_account_id>/<training-job-name>/profiler-output/.
|
|
56
|
+
system_monitor_interval_millis (int or PipelineVariable): The time interval in
|
|
57
|
+
milliseconds to collect system metrics. Available values are 100, 200, 500,
|
|
58
|
+
1000 (1 second), 5000 (5 seconds), and 60000 (1 minute) milliseconds.
|
|
59
|
+
The default is 500 milliseconds.
|
|
60
|
+
framework_profile_params (:class:`~sagemaker.debugger.FrameworkProfile`):
|
|
61
|
+
(Deprecated) A parameter object for framework metrics profiling. Configure it using
|
|
62
|
+
the :class:`~sagemaker.debugger.FrameworkProfile` class.
|
|
63
|
+
To use the default framework profile parameters, pass ``FrameworkProfile()``.
|
|
64
|
+
For more information about the default values,
|
|
65
|
+
see :class:`~sagemaker.debugger.FrameworkProfile`.
|
|
66
|
+
disable_profiler (bool): Switch the basic monitoring on or off using this parameter.
|
|
67
|
+
The default is ``False``.
|
|
68
|
+
profile_params (dict or an object of :class:`sagemaker.Profiler`): Pass this parameter
|
|
69
|
+
to activate SageMaker Profiler using the :class:`sagemaker.Profiler` class.
|
|
70
|
+
|
|
71
|
+
**Basic profiling using SageMaker Debugger**
|
|
72
|
+
|
|
73
|
+
By default, if you submit training jobs using SageMaker Python SDK's estimator classes,
|
|
74
|
+
SageMaker runs basic profiling automatically.
|
|
75
|
+
The following example shows the basic profiling configuration
|
|
76
|
+
that you can utilize to update the time interval for collecting system resource utilization.
|
|
77
|
+
|
|
78
|
+
.. code:: python
|
|
79
|
+
|
|
80
|
+
import sagemaker
|
|
81
|
+
from sagemaker.pytorch import PyTorch
|
|
82
|
+
from sagemaker.debugger import ProfilerConfig
|
|
83
|
+
|
|
84
|
+
profiler_config = ProfilerConfig(
|
|
85
|
+
system_monitor_interval_millis = 500
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
estimator = PyTorch(
|
|
89
|
+
framework_version="2.0.0",
|
|
90
|
+
... # Set up other essential parameters for the estimator class
|
|
91
|
+
profiler_config=profiler_config
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
For a complete instruction on activating and using SageMaker Debugger, see
|
|
95
|
+
`Monitor AWS compute resource utilization in Amazon SageMaker Studio
|
|
96
|
+
<https://docs.aws.amazon.com/sagemaker/latest/dg/train-debugger.html>`_.
|
|
97
|
+
|
|
98
|
+
**Deep profiling using SageMaker Profiler**
|
|
99
|
+
|
|
100
|
+
The following example shows an example configration for activating
|
|
101
|
+
SageMaker Profiler.
|
|
102
|
+
|
|
103
|
+
.. code:: python
|
|
104
|
+
|
|
105
|
+
import sagemaker
|
|
106
|
+
from sagemaker.pytorch import PyTorch
|
|
107
|
+
from sagemaker import ProfilerConfig, Profiler
|
|
108
|
+
|
|
109
|
+
profiler_config = ProfilerConfig(
|
|
110
|
+
profiler_params = Profiler(cpu_profiling_duration=3600)
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
estimator = PyTorch(
|
|
114
|
+
framework_version="2.0.0",
|
|
115
|
+
... # Set up other essential parameters for the estimator class
|
|
116
|
+
profiler_config=profiler_config
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
For a complete instruction on activating and using SageMaker Profiler, see
|
|
120
|
+
`Use Amazon SageMaker Profiler to profile activities on AWS compute resources
|
|
121
|
+
<https://docs.aws.amazon.com/sagemaker/latest/dg/train-profile-computational-performance.html>`_.
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
assert framework_profile_params is None or isinstance(
|
|
125
|
+
framework_profile_params, FrameworkProfile
|
|
126
|
+
), "framework_profile_params must be of type FrameworkProfile if specified."
|
|
127
|
+
|
|
128
|
+
assert profile_params is None or isinstance(
|
|
129
|
+
profile_params, Profiler
|
|
130
|
+
), "profile_params must be of type Profiler if specified."
|
|
131
|
+
|
|
132
|
+
if profile_params and framework_profile_params:
|
|
133
|
+
raise ValueError("Profiler will not work when Framework Profiler is ON")
|
|
134
|
+
|
|
135
|
+
self.s3_output_path = s3_output_path
|
|
136
|
+
self.system_monitor_interval_millis = system_monitor_interval_millis
|
|
137
|
+
self.framework_profile_params = framework_profile_params
|
|
138
|
+
self.profile_params = profile_params
|
|
139
|
+
self.disable_profiler = disable_profiler
|
|
140
|
+
|
|
141
|
+
if self.framework_profile_params is not None:
|
|
142
|
+
deprecation_warn_base(
|
|
143
|
+
"Framework profiling will be deprecated from tensorflow 2.12 and pytorch 2.0"
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def _to_request_dict(self):
|
|
147
|
+
"""Generate a request dictionary using the parameters provided when initializing the object.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
dict: An portion of an API request as a dictionary.
|
|
151
|
+
|
|
152
|
+
"""
|
|
153
|
+
profiler_config_request = {}
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
self.s3_output_path is not None
|
|
157
|
+
and self.disable_profiler is not None
|
|
158
|
+
and self.disable_profiler is False
|
|
159
|
+
):
|
|
160
|
+
profiler_config_request["S3OutputPath"] = self.s3_output_path
|
|
161
|
+
|
|
162
|
+
profiler_config_request["DisableProfiler"] = self.disable_profiler
|
|
163
|
+
|
|
164
|
+
if self.system_monitor_interval_millis is not None:
|
|
165
|
+
profiler_config_request["ProfilingIntervalInMilliseconds"] = (
|
|
166
|
+
self.system_monitor_interval_millis
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
if self.framework_profile_params is not None:
|
|
170
|
+
profiler_config_request["ProfilingParameters"] = (
|
|
171
|
+
self.framework_profile_params.profiling_parameters
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
if self.profile_params is not None:
|
|
175
|
+
profiler_config_request["ProfilingParameters"] = (
|
|
176
|
+
self.profile_params.profiling_parameters
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return profiler_config_request
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def _to_profiler_disabled_request_dict(cls):
|
|
183
|
+
"""Generate a request dictionary for updating the training job to disable profiler.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
dict: An portion of an API request as a dictionary.
|
|
187
|
+
|
|
188
|
+
"""
|
|
189
|
+
profiler_config_request = {"DisableProfiler": True}
|
|
190
|
+
return profiler_config_request
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
"""Utils file that contains constants for the profiler."""
|
|
14
|
+
from __future__ import absolute_import # noqa: F401
|
|
15
|
+
|
|
16
|
+
BASE_FOLDER_DEFAULT = "/opt/ml/output/profiler"
|
|
17
|
+
MAX_FILE_SIZE_DEFAULT = 10485760 # default 10MB
|
|
18
|
+
CLOSE_FILE_INTERVAL_DEFAULT = 60 # default 60 seconds
|
|
19
|
+
FILE_OPEN_FAIL_THRESHOLD_DEFAULT = 50
|
|
20
|
+
|
|
21
|
+
DETAILED_PROFILING_CONFIG_NAME = "DetailedProfilingConfig"
|
|
22
|
+
DATALOADER_PROFILING_CONFIG_NAME = "DataloaderProfilingConfig"
|
|
23
|
+
PYTHON_PROFILING_CONFIG_NAME = "PythonProfilingConfig"
|
|
24
|
+
HOROVOD_PROFILING_CONFIG_NAME = "HorovodProfilingConfig"
|
|
25
|
+
SMDATAPARALLEL_PROFILING_CONFIG_NAME = "SMDataParallelProfilingConfig"
|
|
26
|
+
|
|
27
|
+
DETAILED_PROFILING_START_STEP_DEFAULT = 5
|
|
28
|
+
DATALOADER_PROFILING_START_STEP_DEFAULT = 7
|
|
29
|
+
PYTHON_PROFILING_START_STEP_DEFAULT = 9
|
|
30
|
+
HOROVOD_PROFILING_START_STEP_DEFAULT = 13
|
|
31
|
+
SMDATAPARALLEL_PROFILING_START_STEP_DEFAULT = 15
|
|
32
|
+
PROFILING_NUM_STEPS_DEFAULT = 1
|
|
33
|
+
START_STEP_DEFAULT = 0
|
|
34
|
+
PYTHON_PROFILING_NUM_STEPS_DEFAULT = 3
|
|
35
|
+
|
|
36
|
+
# These options are used in detail profiler (NOT framework profile)
|
|
37
|
+
CPU_PROFILING_DURATION = 3600
|
|
38
|
+
FILE_ROTATION_INTERVAL_DEFAULT = 600 # 600 secs
|
|
39
|
+
DETAIL_PROF_PROCESSING_DEFAULT_INSTANCE_TYPE = "ml.m5.4xlarge"
|
|
40
|
+
DETAIL_PROF_PROCESSING_DEFAULT_VOLUME_SIZE = 128
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
"""Utils file that contains util functions for the profiler."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
from datetime import datetime
|
|
18
|
+
from enum import Enum
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _convert_key_and_value(key, value):
|
|
22
|
+
"""Helper function to convert the provided key and value pair (from a dictionary) to a string.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
key (str): The key in the dictionary.
|
|
26
|
+
value: The value for this key.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
str: The provided key value pair as a string.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
updated_key = f'"{key}"' if isinstance(key, str) else key
|
|
33
|
+
updated_value = f'"{value}"' if isinstance(value, str) else value
|
|
34
|
+
|
|
35
|
+
return f"{updated_key}: {updated_value}, "
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def convert_json_config_to_string(config):
|
|
39
|
+
"""Helper function to convert the dictionary config to a string.
|
|
40
|
+
|
|
41
|
+
Calling eval on this string should result in the original dictionary.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
config (dict): The config to be converted to a string.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
str: The config dictionary formatted as a string.
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
json_string = "{"
|
|
51
|
+
for key, value in config.items():
|
|
52
|
+
json_string += _convert_key_and_value(key, value)
|
|
53
|
+
json_string += "}"
|
|
54
|
+
return json_string
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def is_valid_unix_time(unix_time):
|
|
58
|
+
"""Helper function to determine whether the provided UNIX time is valid.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
unix_time (int): The user provided UNIX time.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
bool: Indicates whether the provided UNIX time was valid or not.
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
try:
|
|
68
|
+
datetime.fromtimestamp(unix_time)
|
|
69
|
+
return True
|
|
70
|
+
except (OverflowError, ValueError):
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def is_valid_regex(regex):
|
|
75
|
+
"""Helper function to determine whether the provided regex is valid.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
regex (str): The user provided regex.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
bool: Indicates whether the provided regex was valid or not.
|
|
82
|
+
|
|
83
|
+
"""
|
|
84
|
+
try:
|
|
85
|
+
re.compile(regex)
|
|
86
|
+
return True
|
|
87
|
+
except (re.error, TypeError):
|
|
88
|
+
return False
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class ErrorMessages(Enum):
|
|
92
|
+
"""Enum to store all possible messages during failures in validation of user arguments."""
|
|
93
|
+
|
|
94
|
+
INVALID_LOCAL_PATH = "local_path must be a string!"
|
|
95
|
+
INVALID_FILE_MAX_SIZE = "file_max_size must be an integer greater than 0!"
|
|
96
|
+
INVALID_FILE_CLOSE_INTERVAL = "file_close_interval must be a float/integer greater than 0!"
|
|
97
|
+
INVALID_FILE_OPEN_FAIL_THRESHOLD = "file_open_fail threshold must be an integer greater than 0!"
|
|
98
|
+
INVALID_PROFILE_DEFAULT_STEPS = "profile_default_steps must be a boolean!"
|
|
99
|
+
INVALID_START_STEP = "start_step must be integer greater or equal to 0!"
|
|
100
|
+
INVALID_NUM_STEPS = "num_steps must be integer greater than 0!"
|
|
101
|
+
INVALID_START_UNIX_TIME = "start_unix_time must be valid integer unix time!"
|
|
102
|
+
INVALID_DURATION = "duration must be float greater than 0!"
|
|
103
|
+
FOUND_BOTH_STEP_AND_TIME_FIELDS = (
|
|
104
|
+
"Both step and time fields cannot be specified in the metrics config!"
|
|
105
|
+
)
|
|
106
|
+
INVALID_METRICS_REGEX = "metrics_regex is invalid!"
|
|
107
|
+
INVALID_PYTHON_PROFILER = "python_profiler must be of type PythonProfiler!"
|
|
108
|
+
INVALID_CPROFILE_TIMER = "cprofile_timer must be of type cProfileTimer"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class PythonProfiler(Enum):
|
|
112
|
+
"""Enum to list the Python profiler options for Python profiling.
|
|
113
|
+
|
|
114
|
+
.. py:attribute:: CPROFILE
|
|
115
|
+
|
|
116
|
+
Use to choose ``"cProfile"``.
|
|
117
|
+
|
|
118
|
+
.. py:attribute:: PYINSTRUMENT
|
|
119
|
+
|
|
120
|
+
Use to choose ``"Pyinstrument"``.
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
CPROFILE = "cprofile"
|
|
125
|
+
PYINSTRUMENT = "pyinstrument"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class cProfileTimer(Enum):
|
|
129
|
+
"""Enum to list the possible cProfile timers for Python profiling.
|
|
130
|
+
|
|
131
|
+
.. py:attribute:: TOTAL_TIME
|
|
132
|
+
|
|
133
|
+
Use to choose ``"total_time"``.
|
|
134
|
+
|
|
135
|
+
.. py:attribute:: CPU_TIME
|
|
136
|
+
|
|
137
|
+
Use to choose ``"cpu_time"``.
|
|
138
|
+
|
|
139
|
+
.. py:attribute:: OFF_CPU_TIME
|
|
140
|
+
|
|
141
|
+
Use to choose ``"off_cpu_time"``.
|
|
142
|
+
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
TOTAL_TIME = "total_time"
|
|
146
|
+
CPU_TIME = "cpu_time"
|
|
147
|
+
OFF_CPU_TIME = "off_cpu_time"
|
|
148
|
+
DEFAULT = "default"
|
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
"""Module for deprecation abstractions."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import logging
|
|
17
|
+
import warnings
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
V2_URL = "https://sagemaker.readthedocs.io/en/stable/v2.html"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _warn(msg, sdk_version=None):
|
|
25
|
+
"""Generic warning raiser referencing V2
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
phrase: The phrase to include in the warning.
|
|
29
|
+
sdk_version: the sdk version of removal of support.
|
|
30
|
+
"""
|
|
31
|
+
_sdk_version = sdk_version if sdk_version is not None else "2"
|
|
32
|
+
full_msg = f"{msg} in sagemaker>={_sdk_version}.\nSee: {V2_URL} for details."
|
|
33
|
+
warnings.warn(full_msg, DeprecationWarning, stacklevel=2)
|
|
34
|
+
logger.warning(full_msg)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def removed_warning(phrase, sdk_version=None):
|
|
38
|
+
"""Raise a warning for a no-op in sagemaker>=2
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
phrase: the prefix phrase of the warning message.
|
|
42
|
+
sdk_version: the sdk version of removal of support.
|
|
43
|
+
"""
|
|
44
|
+
_warn(f"{phrase} is a no-op", sdk_version)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def renamed_warning(phrase):
|
|
48
|
+
"""Raise a warning for a rename in sagemaker>=2
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
phrase: the prefix phrase of the warning message.
|
|
52
|
+
"""
|
|
53
|
+
_warn(f"{phrase} has been renamed")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def deprecation_warn(name, date, msg=None):
|
|
57
|
+
"""Raise a warning for soon to be deprecated feature in sagemaker>=2
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
name (str): Name of the feature
|
|
61
|
+
date (str): the date when the feature will be deprecated
|
|
62
|
+
msg (str): the prefix phrase of the warning message.
|
|
63
|
+
"""
|
|
64
|
+
_warn(f"{name} will be deprecated on {date}.{msg}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def deprecation_warn_base(msg):
|
|
68
|
+
"""Raise a warning for soon to be deprecated feature in sagemaker>=2
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
msg (str): the warning message.
|
|
72
|
+
"""
|
|
73
|
+
_warn(msg)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def deprecation_warning(date, msg=None):
|
|
77
|
+
"""Decorator for raising deprecation warning for a feature in sagemaker>=2
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
date (str): the date when the feature will be deprecated
|
|
81
|
+
msg (str): the prefix phrase of the warning message.
|
|
82
|
+
|
|
83
|
+
Usage:
|
|
84
|
+
@deprecation_warning(msg="message", date="date")
|
|
85
|
+
def sample_function():
|
|
86
|
+
print("xxxx....")
|
|
87
|
+
|
|
88
|
+
@deprecation_warning(msg="message", date="date")
|
|
89
|
+
class SampleClass():
|
|
90
|
+
def __init__(self):
|
|
91
|
+
print("xxxx....")
|
|
92
|
+
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
def deprecate(obj):
|
|
96
|
+
def wrapper(*args, **kwargs):
|
|
97
|
+
deprecation_warn(obj.__name__, date, msg)
|
|
98
|
+
return obj(*args, **kwargs)
|
|
99
|
+
|
|
100
|
+
return wrapper
|
|
101
|
+
|
|
102
|
+
return deprecate
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def renamed_kwargs(old_name, new_name, value, kwargs):
|
|
106
|
+
"""Checks if the deprecated argument is in kwargs
|
|
107
|
+
|
|
108
|
+
Raises warning, if present.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
old_name: name of deprecated argument
|
|
112
|
+
new_name: name of the new argument
|
|
113
|
+
value: value associated with new name, if supplied
|
|
114
|
+
kwargs: keyword arguments dict
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
value of the keyword argument, if present
|
|
118
|
+
"""
|
|
119
|
+
if old_name in kwargs:
|
|
120
|
+
value = kwargs.get(old_name, value)
|
|
121
|
+
kwargs[new_name] = value
|
|
122
|
+
renamed_warning(old_name)
|
|
123
|
+
return value
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def removed_arg(name, arg):
|
|
127
|
+
"""Checks if the deprecated argument is populated.
|
|
128
|
+
|
|
129
|
+
Raises warning, if not None.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
name: name of deprecated argument
|
|
133
|
+
arg: the argument to check
|
|
134
|
+
"""
|
|
135
|
+
if arg is not None:
|
|
136
|
+
removed_warning(name)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def removed_kwargs(name, kwargs):
|
|
140
|
+
"""Checks if the deprecated argument is in kwargs
|
|
141
|
+
|
|
142
|
+
Raises warning, if present.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
name: name of deprecated argument
|
|
146
|
+
kwargs: keyword arguments dict
|
|
147
|
+
"""
|
|
148
|
+
if name in kwargs:
|
|
149
|
+
removed_warning(name)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def removed_function(name):
|
|
153
|
+
"""A no-op deprecated function factory."""
|
|
154
|
+
|
|
155
|
+
def func(*args, **kwargs): # pylint: disable=W0613
|
|
156
|
+
removed_warning(f"The function {name}")
|
|
157
|
+
|
|
158
|
+
return func
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def deprecated(sdk_version=None):
|
|
162
|
+
"""Decorator for raising deprecated warning for a feature in sagemaker>=2
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
sdk_version (str): the sdk version of removal of support.
|
|
166
|
+
|
|
167
|
+
Usage:
|
|
168
|
+
@deprecated()
|
|
169
|
+
def sample_function():
|
|
170
|
+
print("xxxx....")
|
|
171
|
+
|
|
172
|
+
@deprecated(sdk_version="2.66")
|
|
173
|
+
class SampleClass():
|
|
174
|
+
def __init__(self):
|
|
175
|
+
print("xxxx....")
|
|
176
|
+
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
def deprecate(obj):
|
|
180
|
+
def wrapper(*args, **kwargs):
|
|
181
|
+
removed_warning(obj.__name__, sdk_version)
|
|
182
|
+
return obj(*args, **kwargs)
|
|
183
|
+
|
|
184
|
+
return wrapper
|
|
185
|
+
|
|
186
|
+
return deprecate
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def deprecated_function(func, name):
|
|
190
|
+
"""Wrap a function with a deprecation warning.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
func: Function to wrap in a deprecation warning.
|
|
194
|
+
name: The name that has been deprecated.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
The modified function
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
def deprecate(*args, **kwargs):
|
|
201
|
+
renamed_warning(f"The {name}")
|
|
202
|
+
return func(*args, **kwargs)
|
|
203
|
+
|
|
204
|
+
return deprecate
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def deprecated_serialize(instance, name):
|
|
208
|
+
"""Modifies a serializer instance serialize method.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
instance: Instance to modify serialize method.
|
|
212
|
+
name: The name that has been deprecated.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
The modified instance
|
|
216
|
+
"""
|
|
217
|
+
instance.serialize = deprecated_function(instance.serialize, name)
|
|
218
|
+
return instance
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def deprecated_deserialize(instance, name):
|
|
222
|
+
"""Modifies a deserializer instance deserialize method.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
instance: Instance to modify deserialize method.
|
|
226
|
+
name: The name that has been deprecated.
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
The modified instance
|
|
230
|
+
"""
|
|
231
|
+
instance.deserialize = deprecated_function(instance.deserialize, name)
|
|
232
|
+
return instance
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def deprecated_class(cls, name):
|
|
236
|
+
"""Returns a class based on super class with a deprecation warning.
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
cls: The class to derive with a deprecation warning on __init__
|
|
240
|
+
name: The name of the class.
|
|
241
|
+
|
|
242
|
+
Returns:
|
|
243
|
+
The modified class.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
class DeprecatedClass(cls):
|
|
247
|
+
"""Provides a warning for the class name."""
|
|
248
|
+
|
|
249
|
+
def __init__(self, *args, **kwargs):
|
|
250
|
+
"""Provides a warning for the class name."""
|
|
251
|
+
renamed_warning(f"The class {name}")
|
|
252
|
+
super(DeprecatedClass, self).__init__(*args, **kwargs)
|
|
253
|
+
|
|
254
|
+
return DeprecatedClass
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Deserializers for SageMaker inference."""
|
|
2
|
+
|
|
3
|
+
from __future__ import absolute_import
|
|
4
|
+
|
|
5
|
+
# Re-export from base
|
|
6
|
+
from sagemaker.core.deserializers.base import * # noqa: F401, F403
|
|
7
|
+
|
|
8
|
+
# Note: implementations is not imported here to avoid circular imports
|
|
9
|
+
# Import explicitly if needed:
|
|
10
|
+
# from sagemaker.core.deserializers.implementations import ...
|