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,394 @@
|
|
|
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
|
+
"""The pipeline context for workflow"""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import warnings
|
|
17
|
+
import inspect
|
|
18
|
+
from functools import wraps
|
|
19
|
+
from typing import Dict, Optional, Callable
|
|
20
|
+
|
|
21
|
+
from sagemaker.core.helper.session_helper import Session, SessionSettings
|
|
22
|
+
from sagemaker.core.local.local_session import LocalSession
|
|
23
|
+
from sagemaker.core.workflow.pipeline_definition_config import PipelineDefinitionConfig
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _StepArguments:
|
|
27
|
+
"""Step arguments entity for `Step`"""
|
|
28
|
+
|
|
29
|
+
# pylint: disable=keyword-arg-before-vararg
|
|
30
|
+
def __init__(self, caller_name: str = None, func: Callable = None, *func_args, **func_kwargs):
|
|
31
|
+
"""Create a `_StepArguments`
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
caller_name (str): The name of the caller function which is intercepted by the
|
|
35
|
+
PipelineSession to get the step arguments.
|
|
36
|
+
func (Callable): The job class function that generates the step arguments used
|
|
37
|
+
when creating the job ( fit() for a training job )
|
|
38
|
+
*func_args: The args for func
|
|
39
|
+
**func_kwargs: The kwargs for func
|
|
40
|
+
"""
|
|
41
|
+
self.caller_name = caller_name
|
|
42
|
+
self.func = func
|
|
43
|
+
self.func_args = func_args
|
|
44
|
+
self.func_kwargs = func_kwargs
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class _JobStepArguments(_StepArguments):
|
|
48
|
+
"""Step arguments entity for job step types
|
|
49
|
+
|
|
50
|
+
Job step types include: TrainingStep, ProcessingStep, TuningStep, TransformStep
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(self, caller_name: str, args: dict):
|
|
54
|
+
"""Create a `_JobStepArguments`
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
caller_name (str): The name of the caller function which is intercepted by the
|
|
58
|
+
PipelineSession to get the step arguments.
|
|
59
|
+
args (dict): The arguments to be used for composing the SageMaker API request.
|
|
60
|
+
"""
|
|
61
|
+
super(_JobStepArguments, self).__init__(caller_name)
|
|
62
|
+
self.args = args
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class _ModelStepArguments(_StepArguments):
|
|
66
|
+
"""Step arguments entity for `ModelStep`"""
|
|
67
|
+
|
|
68
|
+
def __init__(self, model):
|
|
69
|
+
"""Create a `_ModelStepArguments`
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
model (Model or PipelineModel): A `sagemaker.model.Model`
|
|
73
|
+
or `sagemaker.pipeline.PipelineModel` instance
|
|
74
|
+
"""
|
|
75
|
+
super(_ModelStepArguments, self).__init__()
|
|
76
|
+
self.model = model
|
|
77
|
+
self.create_model_package_request = None
|
|
78
|
+
self.create_model_request = None
|
|
79
|
+
self.need_runtime_repack = set()
|
|
80
|
+
self.runtime_repack_output_prefix = None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class _PipelineConfig:
|
|
84
|
+
"""Context for building a step.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
pipeline_name (str): pipeline name
|
|
88
|
+
step_name (str): step name
|
|
89
|
+
sagemaker_session (Session): a SageMaker Session
|
|
90
|
+
code_hash (str): a hash of the code artifact for the particular step
|
|
91
|
+
config_hash (str): a hash of the config artifact for the particular step (Processing)
|
|
92
|
+
pipeline_definition_config (PipelineDefinitionConfig): a configuration used to toggle
|
|
93
|
+
feature flags persistent in a pipeline definition
|
|
94
|
+
upload_runtime_scripts (bool): flag used to manage upload of runtime scripts to s3 for
|
|
95
|
+
a _FunctionStep in pipeline
|
|
96
|
+
upload_workspace (bool): flag used to manage the upload of workspace to s3 for a
|
|
97
|
+
_FunctionStep in pipeline
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def __init__(
|
|
101
|
+
self,
|
|
102
|
+
pipeline_name: str,
|
|
103
|
+
step_name: str,
|
|
104
|
+
sagemaker_session: Session,
|
|
105
|
+
code_hash: str,
|
|
106
|
+
config_hash: str,
|
|
107
|
+
pipeline_definition_config: PipelineDefinitionConfig,
|
|
108
|
+
pipeline_build_time: str = None,
|
|
109
|
+
upload_runtime_scripts: bool = True,
|
|
110
|
+
upload_workspace: bool = True,
|
|
111
|
+
function_step_secret_token: Optional[str] = None,
|
|
112
|
+
):
|
|
113
|
+
self._pipeline_name = pipeline_name
|
|
114
|
+
self._step_name = step_name
|
|
115
|
+
self._sagemaker_session = sagemaker_session
|
|
116
|
+
self.code_hash = code_hash
|
|
117
|
+
self.config_hash = config_hash
|
|
118
|
+
self.pipeline_definition_config = pipeline_definition_config
|
|
119
|
+
self.upload_runtime_scripts = upload_runtime_scripts
|
|
120
|
+
self.upload_workspace = upload_workspace
|
|
121
|
+
self._function_step_secret_token = function_step_secret_token
|
|
122
|
+
self.pipeline_build_time = pipeline_build_time
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def pipeline_name(self):
|
|
126
|
+
"""str: pipeline name"""
|
|
127
|
+
return self._pipeline_name
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def step_name(self):
|
|
131
|
+
"""str: step name"""
|
|
132
|
+
return self._step_name
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def sagemaker_session(self):
|
|
136
|
+
"""Session: a SageMaker Session"""
|
|
137
|
+
return self._sagemaker_session
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def function_step_secret_token(self):
|
|
141
|
+
"""str: a secret token for a function step"""
|
|
142
|
+
return self._function_step_secret_token
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class PipelineSession(Session):
|
|
146
|
+
"""Managing interactions with SageMaker APIs and AWS services needed under Pipeline Context
|
|
147
|
+
|
|
148
|
+
This class inherits the SageMaker session, it provides convenient methods
|
|
149
|
+
for manipulating entities and resources that Amazon SageMaker uses,
|
|
150
|
+
such as training jobs, endpoints, and input datasets in S3. When composing
|
|
151
|
+
SageMaker Model-Building Pipeline, PipelineSession is recommended over
|
|
152
|
+
regular SageMaker Session
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
def __init__(
|
|
156
|
+
self,
|
|
157
|
+
boto_session=None,
|
|
158
|
+
sagemaker_client=None,
|
|
159
|
+
default_bucket=None,
|
|
160
|
+
settings=SessionSettings(),
|
|
161
|
+
sagemaker_config: dict = None,
|
|
162
|
+
default_bucket_prefix: str = None,
|
|
163
|
+
):
|
|
164
|
+
"""Initialize a ``PipelineSession``.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
boto_session (boto3.session.Session): The underlying Boto3 session which AWS service
|
|
168
|
+
calls are delegated to (default: None). If not provided, one is created with
|
|
169
|
+
default AWS configuration chain.
|
|
170
|
+
sagemaker_client (boto3.SageMaker.Client): Client which makes Amazon SageMaker service
|
|
171
|
+
calls other than ``InvokeEndpoint`` (default: None). Estimators created using this
|
|
172
|
+
``Session`` use this client. If not provided, one will be created using this
|
|
173
|
+
instance's ``boto_session``.
|
|
174
|
+
default_bucket (str): The default Amazon S3 bucket to be used by this session.
|
|
175
|
+
This will be created the next time an Amazon S3 bucket is needed (by calling
|
|
176
|
+
:func:`default_bucket`).
|
|
177
|
+
If not provided, a default bucket will be created based on the following format:
|
|
178
|
+
"sagemaker-{region}-{aws-account-id}".
|
|
179
|
+
Example: "sagemaker-my-custom-bucket".
|
|
180
|
+
settings (sagemaker.session_settings.SessionSettings): Optional. Set of optional
|
|
181
|
+
parameters to apply to the session.
|
|
182
|
+
sagemaker_config: A dictionary containing default values for the
|
|
183
|
+
SageMaker Python SDK. (default: None). The dictionary must adhere to the schema
|
|
184
|
+
defined at `~sagemaker.config.config_schema.SAGEMAKER_PYTHON_SDK_CONFIG_SCHEMA`.
|
|
185
|
+
If sagemaker_config is not provided and configuration files exist (at the default
|
|
186
|
+
paths for admins and users, or paths set through the environment variables
|
|
187
|
+
SAGEMAKER_ADMIN_CONFIG_OVERRIDE and SAGEMAKER_USER_CONFIG_OVERRIDE),
|
|
188
|
+
a new dictionary will be generated from those configuration files. Alternatively,
|
|
189
|
+
this dictionary can be generated by calling
|
|
190
|
+
:func:`~sagemaker.config.load_sagemaker_config` and then be provided to the
|
|
191
|
+
Session.
|
|
192
|
+
default_bucket_prefix (str): The default prefix to use for S3 Object Keys. When
|
|
193
|
+
objects are saved to the Session's default_bucket, the Object Key used will
|
|
194
|
+
start with the default_bucket_prefix. If not provided here or within
|
|
195
|
+
sagemaker_config, no additional prefix will be added.
|
|
196
|
+
"""
|
|
197
|
+
super().__init__(
|
|
198
|
+
boto_session=boto_session,
|
|
199
|
+
sagemaker_client=sagemaker_client,
|
|
200
|
+
default_bucket=default_bucket,
|
|
201
|
+
settings=settings,
|
|
202
|
+
sagemaker_config=sagemaker_config,
|
|
203
|
+
default_bucket_prefix=default_bucket_prefix,
|
|
204
|
+
)
|
|
205
|
+
self._context = None
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def context(self):
|
|
209
|
+
"""Hold contextual information useful to the session"""
|
|
210
|
+
return self._context
|
|
211
|
+
|
|
212
|
+
@context.setter
|
|
213
|
+
def context(self, value: Optional[_StepArguments] = None):
|
|
214
|
+
self._context = value
|
|
215
|
+
|
|
216
|
+
def _intercept_create_request(self, request: Dict, create, func_name: str = None):
|
|
217
|
+
"""This function intercepts the create job request
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
request (dict): the create job request
|
|
221
|
+
create (functor): a functor calls the sagemaker client create method
|
|
222
|
+
func_name (str): the name of the function needed intercepting
|
|
223
|
+
"""
|
|
224
|
+
if func_name == "create_model":
|
|
225
|
+
self.context.create_model_request = request
|
|
226
|
+
self.context.caller_name = func_name
|
|
227
|
+
elif func_name == "create_model_package_from_containers":
|
|
228
|
+
self.context.create_model_package_request = request
|
|
229
|
+
self.context.caller_name = func_name
|
|
230
|
+
else:
|
|
231
|
+
self.context = _JobStepArguments(func_name, request)
|
|
232
|
+
|
|
233
|
+
def init_model_step_arguments(self, model):
|
|
234
|
+
"""Create a `_ModelStepArguments` (if not exist) as pipeline context
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
model (Model or PipelineModel): A `sagemaker.model.Model`
|
|
238
|
+
or `sagemaker.pipeline.PipelineModel` instance
|
|
239
|
+
"""
|
|
240
|
+
if not isinstance(self._context, _ModelStepArguments):
|
|
241
|
+
self._context = _ModelStepArguments(model)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class LocalPipelineSession(LocalSession, PipelineSession):
|
|
245
|
+
"""Managing a session that executes Sagemaker pipelines and jobs locally in a pipeline context.
|
|
246
|
+
|
|
247
|
+
This class inherits from the LocalSession and PipelineSession classes.
|
|
248
|
+
When running Sagemaker pipelines locally, this class is preferred over LocalSession.
|
|
249
|
+
"""
|
|
250
|
+
|
|
251
|
+
def __init__(
|
|
252
|
+
self,
|
|
253
|
+
boto_session=None,
|
|
254
|
+
default_bucket=None,
|
|
255
|
+
s3_endpoint_url=None,
|
|
256
|
+
disable_local_code=False,
|
|
257
|
+
default_bucket_prefix=None,
|
|
258
|
+
):
|
|
259
|
+
"""Initialize a ``LocalPipelineSession``.
|
|
260
|
+
|
|
261
|
+
Args:
|
|
262
|
+
boto_session (boto3.session.Session): The underlying Boto3 session which AWS service
|
|
263
|
+
calls are delegated to (default: None). If not provided, one is created with
|
|
264
|
+
default AWS configuration chain.
|
|
265
|
+
default_bucket (str): The default Amazon S3 bucket to be used by this session.
|
|
266
|
+
This will be created the next time an Amazon S3 bucket is needed (by calling
|
|
267
|
+
:func:`default_bucket`).
|
|
268
|
+
If not provided, a default bucket will be created based on the following format:
|
|
269
|
+
"sagemaker-{region}-{aws-account-id}".
|
|
270
|
+
Example: "sagemaker-my-custom-bucket".
|
|
271
|
+
s3_endpoint_url (str): Override the default endpoint URL for Amazon S3,
|
|
272
|
+
if set (default: None).
|
|
273
|
+
disable_local_code (bool): Set to True to override the default AWS configuration chain
|
|
274
|
+
to disable the `local.local_code` setting, which may not be supported for some SDK
|
|
275
|
+
features (default: False).
|
|
276
|
+
default_bucket_prefix (str): The default prefix to use for S3 Object Keys. When
|
|
277
|
+
objects are saved to the Session's default_bucket, the Object Key used will
|
|
278
|
+
start with the default_bucket_prefix. If not provided here or within
|
|
279
|
+
sagemaker_config, no additional prefix will be added.
|
|
280
|
+
"""
|
|
281
|
+
|
|
282
|
+
super().__init__(
|
|
283
|
+
boto_session=boto_session,
|
|
284
|
+
default_bucket=default_bucket,
|
|
285
|
+
s3_endpoint_url=s3_endpoint_url,
|
|
286
|
+
disable_local_code=disable_local_code,
|
|
287
|
+
default_bucket_prefix=default_bucket_prefix,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def runnable_by_pipeline(run_func):
|
|
292
|
+
"""A convenient Decorator
|
|
293
|
+
|
|
294
|
+
This is a decorator designed to annotate, during pipeline session,
|
|
295
|
+
the methods that downstream managed to
|
|
296
|
+
1. preprocess user inputs, outputs, and configurations
|
|
297
|
+
2. generate the create request
|
|
298
|
+
3. start the job.
|
|
299
|
+
For instance, `Processor.run`, `Estimator.fit`, or `Transformer.transform`.
|
|
300
|
+
This decorator will essentially run 1, and capture the request shape from 2,
|
|
301
|
+
then instead of starting a new job in 3, it will return request shape from 2
|
|
302
|
+
to `sagemaker.workflow.steps.Step`. The request shape will be used to construct
|
|
303
|
+
the arguments needed to compose that particular step as part of the pipeline.
|
|
304
|
+
The job will be started during pipeline execution.
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
@wraps(run_func)
|
|
308
|
+
def wrapper(*args, **kwargs):
|
|
309
|
+
self_instance = args[0]
|
|
310
|
+
if isinstance(self_instance.sagemaker_session, PipelineSession):
|
|
311
|
+
run_func_params = inspect.signature(run_func).parameters
|
|
312
|
+
arg_list = list(args)
|
|
313
|
+
|
|
314
|
+
override_wait, override_logs = False, False
|
|
315
|
+
for i, (arg_name, _) in enumerate(run_func_params.items()):
|
|
316
|
+
if i >= len(arg_list):
|
|
317
|
+
break
|
|
318
|
+
if arg_name == "wait":
|
|
319
|
+
override_wait = True
|
|
320
|
+
arg_list[i] = False
|
|
321
|
+
elif arg_name == "logs":
|
|
322
|
+
override_logs = True
|
|
323
|
+
arg_list[i] = False
|
|
324
|
+
|
|
325
|
+
args = tuple(arg_list)
|
|
326
|
+
|
|
327
|
+
if not override_wait and "wait" in run_func_params.keys():
|
|
328
|
+
kwargs["wait"] = False
|
|
329
|
+
if not override_logs and "logs" in run_func_params.keys():
|
|
330
|
+
kwargs["logs"] = False
|
|
331
|
+
|
|
332
|
+
warnings.warn(
|
|
333
|
+
"Running within a PipelineSession, there will be No Wait, "
|
|
334
|
+
"No Logs, and No Job being started.",
|
|
335
|
+
UserWarning,
|
|
336
|
+
)
|
|
337
|
+
if run_func.__name__ in ["register", "build"]:
|
|
338
|
+
self_instance.sagemaker_session.init_model_step_arguments(self_instance)
|
|
339
|
+
run_func(*args, **kwargs)
|
|
340
|
+
context = self_instance.sagemaker_session.context
|
|
341
|
+
self_instance.sagemaker_session.context = None
|
|
342
|
+
return context
|
|
343
|
+
|
|
344
|
+
return _StepArguments(retrieve_caller_name(self_instance), run_func, *args, **kwargs)
|
|
345
|
+
|
|
346
|
+
return run_func(*args, **kwargs)
|
|
347
|
+
|
|
348
|
+
return wrapper
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def retrieve_caller_name(job_instance):
|
|
352
|
+
"""Convenience method for runnable_by_pipeline decorator
|
|
353
|
+
|
|
354
|
+
This function takes an instance of a job class and maps it
|
|
355
|
+
to the pipeline session function that creates the job request.
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
job_instance: A job class instance, one of the following types:
|
|
359
|
+
- Processor (from sagemaker.core.processing)
|
|
360
|
+
- ModelTrainer (from sagemaker.train.model_trainer)
|
|
361
|
+
- Transformer (from sagemaker.core.transformer)
|
|
362
|
+
- HyperparameterTuner (from sagemaker.train.tuner)
|
|
363
|
+
|
|
364
|
+
Note:
|
|
365
|
+
This function uses duck typing to avoid importing from Train package,
|
|
366
|
+
which would create architecture violations (Core should not depend on Train).
|
|
367
|
+
Instead of isinstance checks, we check for characteristic attributes/methods.
|
|
368
|
+
"""
|
|
369
|
+
|
|
370
|
+
from sagemaker.core.processing import Processor
|
|
371
|
+
from sagemaker.core.transformer import Transformer
|
|
372
|
+
|
|
373
|
+
# from sagemaker.utils.automl.automl import AutoML
|
|
374
|
+
|
|
375
|
+
if isinstance(job_instance, Processor):
|
|
376
|
+
return "run"
|
|
377
|
+
|
|
378
|
+
# Duck typing for ModelTrainer: has 'train' method and 'training_image' attribute
|
|
379
|
+
# This avoids importing from sagemaker.train which would violate architecture
|
|
380
|
+
if hasattr(job_instance, "train") and hasattr(job_instance, "training_image"):
|
|
381
|
+
return "train"
|
|
382
|
+
|
|
383
|
+
if isinstance(job_instance, Transformer):
|
|
384
|
+
return "transform"
|
|
385
|
+
|
|
386
|
+
# Duck typing for HyperparameterTuner: has 'tune' method and 'model_trainer' attribute
|
|
387
|
+
# This covers both V2 (fit/best_estimator) and V3 (tune/model_trainer) implementations
|
|
388
|
+
if (hasattr(job_instance, 'fit') and hasattr(job_instance, 'best_estimator')) or \
|
|
389
|
+
(hasattr(job_instance, 'tune') and hasattr(job_instance, 'model_trainer')):
|
|
390
|
+
return "tune"
|
|
391
|
+
# if isinstance(job_instance, AutoML):
|
|
392
|
+
# return "auto_ml"
|
|
393
|
+
|
|
394
|
+
return None
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
"""Pipeline experiment config for SageMaker pipeline."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PipelineDefinitionConfig:
|
|
18
|
+
"""Pipeline Definition Configuration for SageMaker pipeline."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, use_custom_job_prefix: bool):
|
|
21
|
+
"""Create a `PipelineDefinitionConfig`.
|
|
22
|
+
|
|
23
|
+
Examples: Use a `PipelineDefinitionConfig` to turn on custom job prefixing::
|
|
24
|
+
|
|
25
|
+
PipelineDefinitionConfig(use_custom_job_prefix=True)
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
use_custom_job_prefix (bool): A feature flag to toggle on/off custom name prefixing
|
|
29
|
+
during pipeline orchestration.
|
|
30
|
+
"""
|
|
31
|
+
self.use_custom_job_prefix = use_custom_job_prefix
|