sagemaker-core 1.0.47__py3-none-any.whl → 2.1.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/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 +2281 -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 +410 -4
- 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 +244 -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 +1176 -0
- sagemaker/core/git_utils.py +349 -0
- sagemaker/core/helper/pipeline_variable.py +82 -0
- sagemaker/core/helper/session_helper.py +2965 -0
- sagemaker/core/huggingface/__init__.py +29 -0
- sagemaker/core/huggingface/llm_utils.py +150 -0
- sagemaker/core/huggingface/processing.py +139 -0
- sagemaker/core/huggingface/training_compiler/config.py +167 -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 +511 -0
- sagemaker/core/image_retriever/test.py +7 -0
- sagemaker/core/image_uri_config/__init__.py +13 -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 +660 -0
- sagemaker/core/image_uri_config/huggingface-llm.json +1158 -0
- sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
- sagemaker/core/image_uri_config/huggingface-neuronx.json +510 -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.json +2138 -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 +212 -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 +446 -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 +888 -0
- sagemaker/core/image_uris.py +810 -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 +186 -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/__init__.py +0 -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 +499 -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 +163 -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 +413 -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 +245 -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 +1495 -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 +226 -0
- sagemaker/core/modules/constants.py +37 -0
- sagemaker/core/modules/distributed.py +182 -0
- sagemaker/core/modules/local_core/__init__.py +0 -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 +213 -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 +1597 -0
- sagemaker/core/remote_function/__init__.py +19 -0
- sagemaker/core/remote_function/checkpoint_location.py +47 -0
- sagemaker/core/remote_function/client.py +1285 -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 +353 -0
- sagemaker/core/remote_function/core/serialization.py +422 -0
- sagemaker/core/remote_function/core/stored_function.py +226 -0
- sagemaker/core/remote_function/custom_file_filter.py +128 -0
- sagemaker/core/remote_function/errors.py +104 -0
- sagemaker/core/remote_function/invoke_function.py +172 -0
- sagemaker/core/remote_function/job.py +2140 -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 +20121 -11728
- 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 +6384 -1865
- 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 +84 -0
- sagemaker/core/telemetry/telemetry_logging.py +284 -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 +333 -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 +6479 -136
- {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 +25 -20
- 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 +507 -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.47.dist-info → sagemaker_core-2.1.1.dist-info}/METADATA +28 -9
- sagemaker_core-2.1.1.dist-info/RECORD +355 -0
- sagemaker_core-2.1.1.dist-info/top_level.txt +1 -0
- sagemaker_core/__init__.py +0 -4
- 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.47.dist-info/RECORD +0 -35
- sagemaker_core-1.0.47.dist-info/top_level.txt +0 -1
- {sagemaker_core → sagemaker/core}/helper/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/huggingface/training_compiler}/__init__.py +0 -0
- {sagemaker_core/main/code_injection → sagemaker/core/jumpstart/factory}/__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.47.dist-info → sagemaker_core-2.1.1.dist-info}/WHEEL +0 -0
- {sagemaker_core-1.0.47.dist-info → sagemaker_core-2.1.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
"""This module contains functions for obtaining JumpStart environment variables."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
from typing import Callable, Dict, Optional, Set
|
|
16
|
+
from sagemaker.core.jumpstart.constants import (
|
|
17
|
+
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
18
|
+
JUMPSTART_LOGGER,
|
|
19
|
+
SAGEMAKER_GATED_MODEL_S3_URI_TRAINING_ENV_VAR_KEY,
|
|
20
|
+
)
|
|
21
|
+
from sagemaker.core.jumpstart.enums import (
|
|
22
|
+
JumpStartModelType,
|
|
23
|
+
JumpStartScriptScope,
|
|
24
|
+
)
|
|
25
|
+
from sagemaker.core.jumpstart.utils import (
|
|
26
|
+
get_jumpstart_gated_content_bucket,
|
|
27
|
+
get_region_fallback,
|
|
28
|
+
verify_model_region_and_return_specs,
|
|
29
|
+
)
|
|
30
|
+
from sagemaker.core.helper.session_helper import Session
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _retrieve_default_environment_variables(
|
|
34
|
+
model_id: str,
|
|
35
|
+
model_version: str,
|
|
36
|
+
hub_arn: Optional[str] = None,
|
|
37
|
+
region: Optional[str] = None,
|
|
38
|
+
tolerate_vulnerable_model: bool = False,
|
|
39
|
+
tolerate_deprecated_model: bool = False,
|
|
40
|
+
include_aws_sdk_env_vars: bool = True,
|
|
41
|
+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
42
|
+
instance_type: Optional[str] = None,
|
|
43
|
+
script: JumpStartScriptScope = JumpStartScriptScope.INFERENCE,
|
|
44
|
+
config_name: Optional[str] = None,
|
|
45
|
+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
|
|
46
|
+
) -> Dict[str, str]:
|
|
47
|
+
"""Retrieves the inference environment variables for the model matching the given arguments.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
model_id (str): JumpStart model ID of the JumpStart model for which to
|
|
51
|
+
retrieve the default environment variables.
|
|
52
|
+
model_version (str): Version of the JumpStart model for which to retrieve the
|
|
53
|
+
default environment variables.
|
|
54
|
+
hub_arn (str): The arn of the SageMaker Hub for which to retrieve
|
|
55
|
+
model details from. (Default: None).
|
|
56
|
+
region (Optional[str]): Region for which to retrieve default environment variables.
|
|
57
|
+
(Default: None).
|
|
58
|
+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
|
|
59
|
+
specifications should be tolerated (exception not raised). If False, raises an
|
|
60
|
+
exception if the script used by this version of the model has dependencies with known
|
|
61
|
+
security vulnerabilities. (Default: False).
|
|
62
|
+
tolerate_deprecated_model (bool): True if deprecated versions of model
|
|
63
|
+
specifications should be tolerated (exception not raised). If False, raises
|
|
64
|
+
an exception if the version of the model is deprecated. (Default: False).
|
|
65
|
+
include_aws_sdk_env_vars (bool): True if environment variables for low-level AWS API call
|
|
66
|
+
should be included. The `Model` class of the SageMaker Python SDK inserts environment
|
|
67
|
+
variables that would be required when making the low-level AWS API call.
|
|
68
|
+
(Default: True).
|
|
69
|
+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
|
|
70
|
+
object, used for SageMaker interactions. If not
|
|
71
|
+
specified, one is created using the default AWS configuration
|
|
72
|
+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
|
|
73
|
+
instance_type (str): An instance type to optionally supply in order to get
|
|
74
|
+
environment variables specific for the instance type.
|
|
75
|
+
script (JumpStartScriptScope): The JumpStart script for which to retrieve
|
|
76
|
+
environment variables.
|
|
77
|
+
config_name (Optional[str]): Name of the JumpStart Model config to apply. (Default: None).
|
|
78
|
+
model_type (JumpStartModelType): The type of the model, can be open weights model
|
|
79
|
+
or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
|
|
80
|
+
Returns:
|
|
81
|
+
dict: the inference environment variables to use for the model.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
region = region or get_region_fallback(
|
|
85
|
+
sagemaker_session=sagemaker_session,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
model_specs = verify_model_region_and_return_specs(
|
|
89
|
+
model_id=model_id,
|
|
90
|
+
version=model_version,
|
|
91
|
+
hub_arn=hub_arn,
|
|
92
|
+
scope=script,
|
|
93
|
+
region=region,
|
|
94
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
95
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
96
|
+
sagemaker_session=sagemaker_session,
|
|
97
|
+
config_name=config_name,
|
|
98
|
+
model_type=model_type,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
default_environment_variables: Dict[str, str] = {}
|
|
102
|
+
if script == JumpStartScriptScope.INFERENCE:
|
|
103
|
+
for environment_variable in model_specs.inference_environment_variables:
|
|
104
|
+
if include_aws_sdk_env_vars or environment_variable.required_for_model_class:
|
|
105
|
+
default_environment_variables[environment_variable.name] = str(
|
|
106
|
+
environment_variable.default
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if instance_type:
|
|
110
|
+
if script == JumpStartScriptScope.INFERENCE and getattr(
|
|
111
|
+
model_specs, "hosting_instance_type_variants", None
|
|
112
|
+
):
|
|
113
|
+
default_environment_variables.update(
|
|
114
|
+
model_specs.hosting_instance_type_variants.get_instance_specific_environment_variables( # noqa E501 # pylint: disable=c0301
|
|
115
|
+
instance_type
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
elif script == JumpStartScriptScope.TRAINING and getattr(
|
|
119
|
+
model_specs, "training_instance_type_variants", None
|
|
120
|
+
):
|
|
121
|
+
instance_specific_environment_variables = model_specs.training_instance_type_variants.get_instance_specific_environment_variables( # noqa E501 # pylint: disable=c0301
|
|
122
|
+
instance_type
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
default_environment_variables.update(instance_specific_environment_variables)
|
|
126
|
+
|
|
127
|
+
retrieve_gated_env_var_for_instance_type: Callable[[str], Optional[str]] = (
|
|
128
|
+
lambda instance_type: _retrieve_gated_model_uri_env_var_value(
|
|
129
|
+
model_id=model_id,
|
|
130
|
+
model_version=model_version,
|
|
131
|
+
hub_arn=hub_arn,
|
|
132
|
+
region=region,
|
|
133
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
134
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
135
|
+
sagemaker_session=sagemaker_session,
|
|
136
|
+
instance_type=instance_type,
|
|
137
|
+
config_name=config_name,
|
|
138
|
+
model_type=model_type,
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
gated_model_env_var: Optional[str] = retrieve_gated_env_var_for_instance_type(
|
|
143
|
+
instance_type
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
if gated_model_env_var is None and model_specs.is_gated_model():
|
|
147
|
+
|
|
148
|
+
possible_env_vars: Set[str] = {
|
|
149
|
+
retrieve_gated_env_var_for_instance_type(instance_type)
|
|
150
|
+
for instance_type in model_specs.supported_training_instance_types
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# If all officially supported instance types have the same underlying artifact,
|
|
154
|
+
# we can use this artifact with high confidence that it'll succeed with
|
|
155
|
+
# an arbitrary instance.
|
|
156
|
+
if len(possible_env_vars) == 1:
|
|
157
|
+
gated_model_env_var = list(possible_env_vars)[0]
|
|
158
|
+
|
|
159
|
+
# If this model does not have 1 artifact for all supported instance types,
|
|
160
|
+
# we cannot determine which artifact to use for an arbitrary instance.
|
|
161
|
+
else:
|
|
162
|
+
log_msg = (
|
|
163
|
+
f"'{model_id}' does not support {instance_type} instance type"
|
|
164
|
+
" for training. Please use one of the following instance types: "
|
|
165
|
+
f"{', '.join(model_specs.supported_training_instance_types)}."
|
|
166
|
+
)
|
|
167
|
+
JUMPSTART_LOGGER.warning(log_msg)
|
|
168
|
+
|
|
169
|
+
if gated_model_env_var is not None:
|
|
170
|
+
default_environment_variables.update(
|
|
171
|
+
{SAGEMAKER_GATED_MODEL_S3_URI_TRAINING_ENV_VAR_KEY: gated_model_env_var}
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
return default_environment_variables
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _retrieve_gated_model_uri_env_var_value(
|
|
178
|
+
model_id: str,
|
|
179
|
+
model_version: str,
|
|
180
|
+
hub_arn: Optional[str] = None,
|
|
181
|
+
region: Optional[str] = None,
|
|
182
|
+
tolerate_vulnerable_model: bool = False,
|
|
183
|
+
tolerate_deprecated_model: bool = False,
|
|
184
|
+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
185
|
+
instance_type: Optional[str] = None,
|
|
186
|
+
config_name: Optional[str] = None,
|
|
187
|
+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
|
|
188
|
+
) -> Optional[str]:
|
|
189
|
+
"""Retrieves the gated model env var URI matching the given arguments.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
model_id (str): JumpStart model ID of the JumpStart model for which to
|
|
193
|
+
retrieve the gated model env var URI.
|
|
194
|
+
model_version (str): Version of the JumpStart model for which to retrieve the
|
|
195
|
+
gated model env var URI.
|
|
196
|
+
hub_arn (str): The arn of the SageMaker Hub for which to retrieve
|
|
197
|
+
model details from. (Default: None).
|
|
198
|
+
region (Optional[str]): Region for which to retrieve the gated model env var URI.
|
|
199
|
+
(Default: None).
|
|
200
|
+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
|
|
201
|
+
specifications should be tolerated (exception not raised). If False, raises an
|
|
202
|
+
exception if the script used by this version of the model has dependencies with known
|
|
203
|
+
security vulnerabilities. (Default: False).
|
|
204
|
+
tolerate_deprecated_model (bool): True if deprecated versions of model
|
|
205
|
+
specifications should be tolerated (exception not raised). If False, raises
|
|
206
|
+
an exception if the version of the model is deprecated. (Default: False).
|
|
207
|
+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
|
|
208
|
+
object, used for SageMaker interactions. If not
|
|
209
|
+
specified, one is created using the default AWS configuration
|
|
210
|
+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
|
|
211
|
+
instance_type (str): An instance type to optionally supply in order to get
|
|
212
|
+
environment variables specific for the instance type.
|
|
213
|
+
config_name (Optional[str]): Name of the JumpStart Model config to apply. (Default: None).
|
|
214
|
+
model_type (JumpStartModelType): The type of the model, can be open weights model
|
|
215
|
+
or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
|
|
216
|
+
Returns:
|
|
217
|
+
Optional[str]: the s3 URI to use for the environment variable, or None if the model does not
|
|
218
|
+
have gated training artifacts.
|
|
219
|
+
|
|
220
|
+
Raises:
|
|
221
|
+
ValueError: If the model specs specified are invalid.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
region = region or get_region_fallback(
|
|
225
|
+
sagemaker_session=sagemaker_session,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
model_specs = verify_model_region_and_return_specs(
|
|
229
|
+
model_id=model_id,
|
|
230
|
+
version=model_version,
|
|
231
|
+
hub_arn=hub_arn,
|
|
232
|
+
scope=JumpStartScriptScope.TRAINING,
|
|
233
|
+
region=region,
|
|
234
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
235
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
236
|
+
sagemaker_session=sagemaker_session,
|
|
237
|
+
config_name=config_name,
|
|
238
|
+
model_type=model_type,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
s3_key: Optional[str] = (
|
|
242
|
+
model_specs.training_instance_type_variants.get_instance_specific_gated_model_key_env_var_value( # noqa E501 # pylint: disable=c0301
|
|
243
|
+
instance_type
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
if s3_key is None:
|
|
247
|
+
return None
|
|
248
|
+
|
|
249
|
+
if hub_arn:
|
|
250
|
+
return s3_key
|
|
251
|
+
|
|
252
|
+
return f"s3://{get_jumpstart_gated_content_bucket(region)}/{s3_key}"
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
"""This module contains functions for obtaining JumpStart hyperparameters."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
from typing import Dict, Optional
|
|
16
|
+
from sagemaker.core.jumpstart.constants import (
|
|
17
|
+
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
18
|
+
)
|
|
19
|
+
from sagemaker.core.jumpstart.enums import (
|
|
20
|
+
JumpStartModelType,
|
|
21
|
+
JumpStartScriptScope,
|
|
22
|
+
VariableScope,
|
|
23
|
+
)
|
|
24
|
+
from sagemaker.core.jumpstart.utils import (
|
|
25
|
+
get_region_fallback,
|
|
26
|
+
verify_model_region_and_return_specs,
|
|
27
|
+
)
|
|
28
|
+
from sagemaker.core.helper.session_helper import Session
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _retrieve_default_hyperparameters(
|
|
32
|
+
model_id: str,
|
|
33
|
+
model_version: str,
|
|
34
|
+
hub_arn: Optional[str] = None,
|
|
35
|
+
region: Optional[str] = None,
|
|
36
|
+
include_container_hyperparameters: bool = False,
|
|
37
|
+
tolerate_vulnerable_model: bool = False,
|
|
38
|
+
tolerate_deprecated_model: bool = False,
|
|
39
|
+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
40
|
+
instance_type: Optional[str] = None,
|
|
41
|
+
config_name: Optional[str] = None,
|
|
42
|
+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
|
|
43
|
+
):
|
|
44
|
+
"""Retrieves the training hyperparameters for the model matching the given arguments.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
model_id (str): JumpStart model ID of the JumpStart model for which to
|
|
48
|
+
retrieve the default hyperparameters.
|
|
49
|
+
model_version (str): Version of the JumpStart model for which to retrieve the
|
|
50
|
+
default hyperparameters.
|
|
51
|
+
hub_arn (str): The arn of the SageMaker Hub for which to retrieve
|
|
52
|
+
model details from. (Default: None).
|
|
53
|
+
region (str): Region for which to retrieve default hyperparameters.
|
|
54
|
+
(Default: None).
|
|
55
|
+
include_container_hyperparameters (bool): True if container hyperparameters
|
|
56
|
+
should be returned as well. Container hyperparameters are not used to tune
|
|
57
|
+
the specific algorithm, but rather by SageMaker Training to setup
|
|
58
|
+
the training container environment. For example, there is a container hyperparameter
|
|
59
|
+
that indicates the entrypoint script to use. These hyperparameters may be required
|
|
60
|
+
when creating a training job with boto3, however the ``Estimator`` classes
|
|
61
|
+
should take care of adding container hyperparameters to the job. (Default: False).
|
|
62
|
+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
|
|
63
|
+
specifications should be tolerated (exception not raised). If False, raises an
|
|
64
|
+
exception if the script used by this version of the model has dependencies with known
|
|
65
|
+
security vulnerabilities. (Default: False).
|
|
66
|
+
tolerate_deprecated_model (bool): True if deprecated versions of model
|
|
67
|
+
specifications should be tolerated (exception not raised). If False, raises
|
|
68
|
+
an exception if the version of the model is deprecated. (Default: False).
|
|
69
|
+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
|
|
70
|
+
object, used for SageMaker interactions. If not
|
|
71
|
+
specified, one is created using the default AWS configuration
|
|
72
|
+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
|
|
73
|
+
instance_type (str): An instance type to optionally supply in order to get hyperparameters
|
|
74
|
+
specific for the instance type.
|
|
75
|
+
config_name (Optional[str]): Name of the JumpStart Model config to apply. (Default: None).
|
|
76
|
+
model_type (JumpStartModelType): The type of the model, can be open weights model
|
|
77
|
+
or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
|
|
78
|
+
Returns:
|
|
79
|
+
dict: the hyperparameters to use for the model.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
region = region or get_region_fallback(
|
|
83
|
+
sagemaker_session=sagemaker_session,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
model_specs = verify_model_region_and_return_specs(
|
|
87
|
+
model_id=model_id,
|
|
88
|
+
version=model_version,
|
|
89
|
+
hub_arn=hub_arn,
|
|
90
|
+
scope=JumpStartScriptScope.TRAINING,
|
|
91
|
+
region=region,
|
|
92
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
93
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
94
|
+
sagemaker_session=sagemaker_session,
|
|
95
|
+
config_name=config_name,
|
|
96
|
+
model_type=model_type,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
default_hyperparameters: Dict[str, str] = {}
|
|
100
|
+
for hyperparameter in model_specs.hyperparameters:
|
|
101
|
+
if (
|
|
102
|
+
include_container_hyperparameters and hyperparameter.scope == VariableScope.CONTAINER
|
|
103
|
+
) or hyperparameter.scope == VariableScope.ALGORITHM:
|
|
104
|
+
default_hyperparameters[hyperparameter.name] = str(hyperparameter.default)
|
|
105
|
+
|
|
106
|
+
instance_specific_hyperparameters = (
|
|
107
|
+
model_specs.training_instance_type_variants.get_instance_specific_hyperparameters(
|
|
108
|
+
instance_type
|
|
109
|
+
)
|
|
110
|
+
if instance_type
|
|
111
|
+
and getattr(model_specs, "training_instance_type_variants", None) is not None
|
|
112
|
+
else []
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
for instance_specific_hyperparameter in instance_specific_hyperparameters:
|
|
116
|
+
default_hyperparameters[instance_specific_hyperparameter.name] = str(
|
|
117
|
+
instance_specific_hyperparameter.default
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return default_hyperparameters
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
"""This module contains functions for obtaining JumpStart image uris."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from typing import Optional
|
|
17
|
+
from sagemaker.core.jumpstart.constants import (
|
|
18
|
+
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
19
|
+
)
|
|
20
|
+
from sagemaker.core.jumpstart.enums import (
|
|
21
|
+
JumpStartModelType,
|
|
22
|
+
JumpStartScriptScope,
|
|
23
|
+
)
|
|
24
|
+
from sagemaker.core.jumpstart.utils import (
|
|
25
|
+
get_region_fallback,
|
|
26
|
+
verify_model_region_and_return_specs,
|
|
27
|
+
)
|
|
28
|
+
from sagemaker.core.helper.session_helper import Session
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _retrieve_image_uri(
|
|
32
|
+
model_id: str,
|
|
33
|
+
model_version: str,
|
|
34
|
+
image_scope: str,
|
|
35
|
+
hub_arn: Optional[str] = None,
|
|
36
|
+
region: Optional[str] = None,
|
|
37
|
+
instance_type: Optional[str] = None,
|
|
38
|
+
tolerate_vulnerable_model: bool = False,
|
|
39
|
+
tolerate_deprecated_model: bool = False,
|
|
40
|
+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
41
|
+
config_name: Optional[str] = None,
|
|
42
|
+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
|
|
43
|
+
):
|
|
44
|
+
"""Retrieves the container image URI for JumpStart models.
|
|
45
|
+
|
|
46
|
+
Only `model_id`, `model_version`, and `image_scope` are required;
|
|
47
|
+
the rest of the fields are auto-populated.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
model_id (str): JumpStart model ID for which to retrieve image URI.
|
|
52
|
+
model_version (str): Version of the JumpStart model for which to retrieve
|
|
53
|
+
the image URI.
|
|
54
|
+
hub_arn (str): The arn of the SageMaker Hub for which to retrieve
|
|
55
|
+
model details from. (Default: None).
|
|
56
|
+
image_scope (str): The image type, i.e. what it is used for.
|
|
57
|
+
Valid values: "training", "inference", "eia". If ``accelerator_type`` is set,
|
|
58
|
+
``image_scope`` is ignored.
|
|
59
|
+
region (str): The AWS region. (Default: None).
|
|
60
|
+
instance_type (str): The SageMaker instance type. For supported types, see
|
|
61
|
+
https://aws.amazon.com/sagemaker/pricing/instance-types. This is required if
|
|
62
|
+
there are different images for different processor types.
|
|
63
|
+
(Default: None).
|
|
64
|
+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
|
|
65
|
+
specifications should be tolerated (exception not raised). If False, raises an
|
|
66
|
+
exception if the script used by this version of the model has dependencies with known
|
|
67
|
+
security vulnerabilities. (Default: False).
|
|
68
|
+
tolerate_deprecated_model (bool): True if deprecated versions of model
|
|
69
|
+
specifications should be tolerated (exception not raised). If False, raises
|
|
70
|
+
an exception if the version of the model is deprecated. (Default: False).
|
|
71
|
+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
|
|
72
|
+
object, used for SageMaker interactions. If not
|
|
73
|
+
specified, one is created using the default AWS configuration
|
|
74
|
+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
|
|
75
|
+
config_name (Optional[str]): Name of the JumpStart Model config to apply. (Default: None).
|
|
76
|
+
model_type (JumpStartModelType): The type of the model, can be open weights model
|
|
77
|
+
or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
|
|
78
|
+
Returns:
|
|
79
|
+
str: the ECR URI for the corresponding SageMaker Docker image.
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
ValueError: If the combination of arguments specified is not supported.
|
|
83
|
+
VulnerableJumpStartModelError: If any of the dependencies required by the script have
|
|
84
|
+
known security vulnerabilities.
|
|
85
|
+
DeprecatedJumpStartModelError: If the version of the model is deprecated.
|
|
86
|
+
"""
|
|
87
|
+
region = region or get_region_fallback(
|
|
88
|
+
sagemaker_session=sagemaker_session,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
model_specs = verify_model_region_and_return_specs(
|
|
92
|
+
model_id=model_id,
|
|
93
|
+
version=model_version,
|
|
94
|
+
hub_arn=hub_arn,
|
|
95
|
+
scope=image_scope,
|
|
96
|
+
region=region,
|
|
97
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
98
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
99
|
+
sagemaker_session=sagemaker_session,
|
|
100
|
+
config_name=config_name,
|
|
101
|
+
model_type=model_type,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if image_scope == JumpStartScriptScope.INFERENCE:
|
|
105
|
+
hosting_instance_type_variants = model_specs.hosting_instance_type_variants
|
|
106
|
+
if hosting_instance_type_variants:
|
|
107
|
+
image_uri = hosting_instance_type_variants.get_image_uri(
|
|
108
|
+
instance_type=instance_type, region=region
|
|
109
|
+
)
|
|
110
|
+
if image_uri is not None:
|
|
111
|
+
return image_uri
|
|
112
|
+
if hub_arn:
|
|
113
|
+
ecr_uri = model_specs.hosting_ecr_uri
|
|
114
|
+
return ecr_uri
|
|
115
|
+
|
|
116
|
+
raise ValueError(
|
|
117
|
+
f"No inference ECR configuration found for JumpStart model ID '{model_id}' "
|
|
118
|
+
f"with {instance_type} instance type in {region}. "
|
|
119
|
+
"Please try another instance type or region."
|
|
120
|
+
)
|
|
121
|
+
if image_scope == JumpStartScriptScope.TRAINING:
|
|
122
|
+
training_instance_type_variants = model_specs.training_instance_type_variants
|
|
123
|
+
if training_instance_type_variants:
|
|
124
|
+
image_uri = training_instance_type_variants.get_image_uri(
|
|
125
|
+
instance_type=instance_type, region=region
|
|
126
|
+
)
|
|
127
|
+
if image_uri is not None:
|
|
128
|
+
return image_uri
|
|
129
|
+
if hub_arn:
|
|
130
|
+
ecr_uri = model_specs.training_ecr_uri
|
|
131
|
+
return ecr_uri
|
|
132
|
+
|
|
133
|
+
raise ValueError(
|
|
134
|
+
f"No training ECR configuration found for JumpStart model ID '{model_id}' "
|
|
135
|
+
f"with {instance_type} instance type in {region}. "
|
|
136
|
+
"Please try another instance type or region."
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
raise ValueError(f"Invalid scope: {image_scope}")
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
"""This module contains functions for obtaining JumpStart incremental training status."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
from typing import Optional
|
|
16
|
+
from sagemaker.core.jumpstart.constants import (
|
|
17
|
+
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
18
|
+
)
|
|
19
|
+
from sagemaker.core.jumpstart.enums import (
|
|
20
|
+
JumpStartModelType,
|
|
21
|
+
JumpStartScriptScope,
|
|
22
|
+
)
|
|
23
|
+
from sagemaker.core.jumpstart.utils import (
|
|
24
|
+
get_region_fallback,
|
|
25
|
+
verify_model_region_and_return_specs,
|
|
26
|
+
)
|
|
27
|
+
from sagemaker.core.helper.session_helper import Session
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _model_supports_incremental_training(
|
|
31
|
+
model_id: str,
|
|
32
|
+
model_version: str,
|
|
33
|
+
region: Optional[str],
|
|
34
|
+
hub_arn: Optional[str] = None,
|
|
35
|
+
tolerate_vulnerable_model: bool = False,
|
|
36
|
+
tolerate_deprecated_model: bool = False,
|
|
37
|
+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
|
|
38
|
+
config_name: Optional[str] = None,
|
|
39
|
+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
|
|
40
|
+
) -> bool:
|
|
41
|
+
"""Returns True if the model supports incremental training.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
model_id (str): JumpStart model ID of the JumpStart model for which to
|
|
45
|
+
retrieve the support status for incremental training.
|
|
46
|
+
model_version (str): Version of the JumpStart model for which to retrieve the
|
|
47
|
+
support status for incremental training.
|
|
48
|
+
region (Optional[str]): Region for which to retrieve the
|
|
49
|
+
support status for incremental training.
|
|
50
|
+
hub_arn (str): The arn of the SageMaker Hub for which to retrieve
|
|
51
|
+
model details from. (Default: None).
|
|
52
|
+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
|
|
53
|
+
specifications should be tolerated (exception not raised). If False, raises an
|
|
54
|
+
exception if the script used by this version of the model has dependencies with known
|
|
55
|
+
security vulnerabilities. (Default: False).
|
|
56
|
+
tolerate_deprecated_model (bool): True if deprecated versions of model
|
|
57
|
+
specifications should be tolerated (exception not raised). If False, raises
|
|
58
|
+
an exception if the version of the model is deprecated. (Default: False).
|
|
59
|
+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
|
|
60
|
+
object, used for SageMaker interactions. If not
|
|
61
|
+
specified, one is created using the default AWS configuration
|
|
62
|
+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
|
|
63
|
+
config_name (Optional[str]): Name of the JumpStart Model config to apply. (Default: None).
|
|
64
|
+
model_type (JumpStartModelType): The type of the model, can be open weights model
|
|
65
|
+
or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
|
|
66
|
+
Returns:
|
|
67
|
+
bool: the support status for incremental training.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
region = region or get_region_fallback(
|
|
71
|
+
sagemaker_session=sagemaker_session,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
model_specs = verify_model_region_and_return_specs(
|
|
75
|
+
model_id=model_id,
|
|
76
|
+
version=model_version,
|
|
77
|
+
hub_arn=hub_arn,
|
|
78
|
+
scope=JumpStartScriptScope.TRAINING,
|
|
79
|
+
region=region,
|
|
80
|
+
tolerate_vulnerable_model=tolerate_vulnerable_model,
|
|
81
|
+
tolerate_deprecated_model=tolerate_deprecated_model,
|
|
82
|
+
sagemaker_session=sagemaker_session,
|
|
83
|
+
config_name=config_name,
|
|
84
|
+
model_type=model_type,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return model_specs.supports_incremental_training()
|