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
|
@@ -15,11 +15,11 @@ from functools import lru_cache
|
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
17
|
import json
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
18
|
+
from sagemaker.core.utils.code_injection.codec import pascal_to_snake
|
|
19
|
+
from sagemaker.core.config_schema import SAGEMAKER_PYTHON_SDK_CONFIG_SCHEMA
|
|
20
|
+
from sagemaker.core.utils.exceptions import IntelligentDefaultsError
|
|
21
|
+
from sagemaker.core.utils.utils import get_textual_rich_logger
|
|
22
|
+
from sagemaker.core.tools.constants import (
|
|
23
23
|
BASIC_RETURN_TYPES,
|
|
24
24
|
GENERATED_CLASSES_LOCATION,
|
|
25
25
|
RESOURCES_CODEGEN_FILE_NAME,
|
|
@@ -31,17 +31,17 @@ from sagemaker_core.tools.constants import (
|
|
|
31
31
|
CONFIGURABLE_ATTRIBUTE_SUBSTRINGS,
|
|
32
32
|
RESOURCE_WITH_LOGS,
|
|
33
33
|
)
|
|
34
|
-
from
|
|
35
|
-
from
|
|
34
|
+
from sagemaker.core.tools.method import Method, MethodType
|
|
35
|
+
from sagemaker.core.utils.utils import (
|
|
36
36
|
add_indent,
|
|
37
37
|
convert_to_snake_case,
|
|
38
38
|
snake_to_pascal,
|
|
39
39
|
remove_html_tags,
|
|
40
40
|
escape_special_rst_characters,
|
|
41
41
|
)
|
|
42
|
-
from
|
|
43
|
-
from
|
|
44
|
-
from
|
|
42
|
+
from sagemaker.core.tools.resources_extractor import ResourcesExtractor
|
|
43
|
+
from sagemaker.core.tools.shapes_extractor import ShapesExtractor
|
|
44
|
+
from sagemaker.core.tools.templates import (
|
|
45
45
|
CALL_OPERATION_API_NO_ARG_TEMPLATE,
|
|
46
46
|
CALL_OPERATION_API_TEMPLATE,
|
|
47
47
|
CREATE_METHOD_TEMPLATE,
|
|
@@ -74,8 +74,10 @@ from sagemaker_core.tools.templates import (
|
|
|
74
74
|
RESOURCE_METHOD_EXCEPTION_DOCSTRING,
|
|
75
75
|
INIT_WAIT_LOGS_TEMPLATE,
|
|
76
76
|
PRINT_WAIT_LOGS,
|
|
77
|
+
SERIALIZE_INPUT_ENDPOINT_TEMPLATE,
|
|
78
|
+
DESERIALIZE_RESPONSE_ENDPOINT_TEMPLATE,
|
|
77
79
|
)
|
|
78
|
-
from
|
|
80
|
+
from sagemaker.core.tools.data_extractor import (
|
|
79
81
|
load_combined_shapes_data,
|
|
80
82
|
load_combined_operations_data,
|
|
81
83
|
)
|
|
@@ -177,7 +179,7 @@ class ResourcesCodeGen:
|
|
|
177
179
|
"import datetime",
|
|
178
180
|
"import time",
|
|
179
181
|
"import functools",
|
|
180
|
-
"from pydantic import validate_call
|
|
182
|
+
"from pydantic import validate_call",
|
|
181
183
|
"from typing import Dict, List, Literal, Optional, Union, Any\n"
|
|
182
184
|
"from boto3.session import Session",
|
|
183
185
|
"from rich.console import Group",
|
|
@@ -186,14 +188,18 @@ class ResourcesCodeGen:
|
|
|
186
188
|
"from rich.progress import Progress, SpinnerColumn, TextColumn, TimeElapsedColumn",
|
|
187
189
|
"from rich.status import Status",
|
|
188
190
|
"from rich.style import Style",
|
|
189
|
-
"from
|
|
190
|
-
"from
|
|
191
|
-
"from
|
|
191
|
+
"from sagemaker.core.shapes import *",
|
|
192
|
+
"from sagemaker.core.helper.pipeline_variable import StrPipeVar",
|
|
193
|
+
"from sagemaker.core.utils.code_injection.codec import transform",
|
|
194
|
+
"from sagemaker.core.utils.code_injection.constants import Color",
|
|
195
|
+
"from sagemaker.core.utils.utils import SageMakerClient, ResourceIterator, Unassigned, get_textual_rich_logger, "
|
|
192
196
|
"snake_to_pascal, pascal_to_snake, is_not_primitive, is_not_str_dict, is_primitive_list, serialize",
|
|
193
|
-
"from
|
|
194
|
-
"from
|
|
195
|
-
"from
|
|
196
|
-
"
|
|
197
|
+
"from sagemaker.core.config.config_manager import SageMakerConfig",
|
|
198
|
+
"from sagemaker.core.utils.logs import MultiLogStreamHandler",
|
|
199
|
+
"from sagemaker.core.utils.exceptions import *",
|
|
200
|
+
"from typing import ClassVar",
|
|
201
|
+
"from sagemaker.core.serializers.base import BaseSerializer",
|
|
202
|
+
"from sagemaker.core.deserializers.base import BaseDeserializer",
|
|
197
203
|
]
|
|
198
204
|
|
|
199
205
|
formated_imports = "\n".join(imports)
|
|
@@ -339,11 +345,8 @@ class ResourcesCodeGen:
|
|
|
339
345
|
str: The formatted resource class.
|
|
340
346
|
|
|
341
347
|
"""
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
basic_class_content = resource_class + add_indent(
|
|
345
|
-
f'"""\n{class_documentation_string}\n"""\n', 4
|
|
346
|
-
)
|
|
348
|
+
# Initialize an empty string for the resource class
|
|
349
|
+
resource_class = ""
|
|
347
350
|
|
|
348
351
|
# _get_class_attributes will return value only if the resource has get or get_all method
|
|
349
352
|
if class_attribute_info := self._get_class_attributes(resource_name, class_methods):
|
|
@@ -351,7 +354,11 @@ class ResourcesCodeGen:
|
|
|
351
354
|
class_attribute_info
|
|
352
355
|
)
|
|
353
356
|
|
|
354
|
-
|
|
357
|
+
# Start defining the class
|
|
358
|
+
resource_class = f"class {resource_name}(Base):\n"
|
|
359
|
+
|
|
360
|
+
class_documentation_string = f"Class representing resource {resource_name}\n\n"
|
|
361
|
+
class_documentation_string += f"Attributes:\n"
|
|
355
362
|
class_documentation_string += self._get_shape_attr_documentation_string(
|
|
356
363
|
attributes_and_documentation
|
|
357
364
|
)
|
|
@@ -418,6 +425,11 @@ class ResourcesCodeGen:
|
|
|
418
425
|
):
|
|
419
426
|
resource_class += add_indent(delete_method, 4)
|
|
420
427
|
|
|
428
|
+
if start_method := self._evaluate_method(
|
|
429
|
+
resource_name, "start", object_methods, resource_attributes=resource_attributes
|
|
430
|
+
):
|
|
431
|
+
resource_class += add_indent(start_method, 4)
|
|
432
|
+
|
|
421
433
|
if stop_method := self._evaluate_method(resource_name, "stop", object_methods):
|
|
422
434
|
resource_class += add_indent(stop_method, 4)
|
|
423
435
|
|
|
@@ -443,12 +455,9 @@ class ResourcesCodeGen:
|
|
|
443
455
|
else:
|
|
444
456
|
# If there's no 'get' or 'list' or 'create' method, generate a class with no attributes
|
|
445
457
|
resource_attributes = []
|
|
446
|
-
resource_class =
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
# class need not be generated
|
|
450
|
-
if resource_name not in self.resource_methods:
|
|
451
|
-
return ""
|
|
458
|
+
resource_class = f"class {resource_name}(Base):\n"
|
|
459
|
+
class_documentation_string = f"Class representing resource {resource_name}\n"
|
|
460
|
+
resource_class += add_indent(f'"""\n{class_documentation_string}\n"""\n', 4)
|
|
452
461
|
|
|
453
462
|
if resource_name in self.resource_methods:
|
|
454
463
|
# TODO: use resource_methods for all methods
|
|
@@ -496,17 +505,17 @@ class ResourcesCodeGen:
|
|
|
496
505
|
# These resources take in the main identifier in the create and get methods , but is not present in the describe response output
|
|
497
506
|
# Hence for consistent behaviour of functions such as refresh and delete, the identifiers are hardcoded
|
|
498
507
|
if resource_name == "ImageVersion":
|
|
499
|
-
class_attributes["image_name"] = "
|
|
500
|
-
class_attributes_string = "image_name:
|
|
508
|
+
class_attributes["image_name"] = "StrPipeVar"
|
|
509
|
+
class_attributes_string = "image_name: StrPipeVar\n" + class_attributes_string
|
|
501
510
|
if resource_name == "Workteam":
|
|
502
|
-
class_attributes["workteam_name"] = "
|
|
503
|
-
class_attributes_string = "workteam_name:
|
|
511
|
+
class_attributes["workteam_name"] = "StrPipeVar"
|
|
512
|
+
class_attributes_string = "workteam_name: StrPipeVar\n" + class_attributes_string
|
|
504
513
|
if resource_name == "Workforce":
|
|
505
|
-
class_attributes["workforce_name"] = "
|
|
506
|
-
class_attributes_string = "workforce_name:
|
|
514
|
+
class_attributes["workforce_name"] = "StrPipeVar"
|
|
515
|
+
class_attributes_string = "workforce_name: StrPipeVar\n" + class_attributes_string
|
|
507
516
|
if resource_name == "SubscribedWorkteam":
|
|
508
|
-
class_attributes["workteam_arn"] = "
|
|
509
|
-
class_attributes_string = "workteam_arn:
|
|
517
|
+
class_attributes["workteam_arn"] = "StrPipeVar"
|
|
518
|
+
class_attributes_string = "workteam_arn: StrPipeVar\n" + class_attributes_string
|
|
510
519
|
|
|
511
520
|
if resource_name == "HubContent":
|
|
512
521
|
class_attributes["hub_name"] = "Optional[str] = Unassigned()"
|
|
@@ -514,6 +523,21 @@ class ResourcesCodeGen:
|
|
|
514
523
|
class_attributes_string = (
|
|
515
524
|
class_attributes_string + "hub_name: Optional[str] = Unassigned()"
|
|
516
525
|
)
|
|
526
|
+
if resource_name == "Endpoint":
|
|
527
|
+
class_attributes["serializer"] = "Optional[BaseSerializer] = None"
|
|
528
|
+
class_attributes_string = class_attributes_string.replace(
|
|
529
|
+
"serializer: BaseSerializer", ""
|
|
530
|
+
)
|
|
531
|
+
class_attributes_string = (
|
|
532
|
+
class_attributes_string + "serializer: Optional[BaseSerializer] = None\n"
|
|
533
|
+
)
|
|
534
|
+
class_attributes["deserializer"] = "Optional[BaseDeserializer] = None"
|
|
535
|
+
class_attributes_string = class_attributes_string.replace(
|
|
536
|
+
"deserializer: BaseDeserializer", ""
|
|
537
|
+
)
|
|
538
|
+
class_attributes_string = (
|
|
539
|
+
class_attributes_string + "deserializer: Optional[BaseDeserializer] = None\n"
|
|
540
|
+
)
|
|
517
541
|
|
|
518
542
|
return class_attributes, class_attributes_string, attributes_and_documentation
|
|
519
543
|
elif "get_all" in class_methods:
|
|
@@ -583,9 +607,11 @@ class ResourcesCodeGen:
|
|
|
583
607
|
and snake_to_pascal(attr[: -len("_name")]) in resource_names
|
|
584
608
|
):
|
|
585
609
|
if value.startswith("Optional"):
|
|
586
|
-
init_data_body +=
|
|
610
|
+
init_data_body += (
|
|
611
|
+
f"{attr}: Optional[Union[StrPipeVar, object]] = Unassigned()\n"
|
|
612
|
+
)
|
|
587
613
|
else:
|
|
588
|
-
init_data_body += f"{attr}: Union[
|
|
614
|
+
init_data_body += f"{attr}: Union[StrPipeVar, object]\n"
|
|
589
615
|
elif attr == "lambda":
|
|
590
616
|
init_data_body += f"# {attr}: {value}\n"
|
|
591
617
|
else:
|
|
@@ -649,9 +675,9 @@ class ResourcesCodeGen:
|
|
|
649
675
|
and snake_to_pascal(attr[: -len("_name")]) in self.resource_names
|
|
650
676
|
):
|
|
651
677
|
if attr_type.startswith("Optional"):
|
|
652
|
-
method_args += f"{attr}: Optional[Union[
|
|
678
|
+
method_args += f"{attr}: Optional[Union[StrPipeVar, object]] = Unassigned(),"
|
|
653
679
|
else:
|
|
654
|
-
method_args += f"{attr}: Union[
|
|
680
|
+
method_args += f"{attr}: Union[StrPipeVar, object],"
|
|
655
681
|
else:
|
|
656
682
|
method_args += f"{attr}: {method_parameter_type},"
|
|
657
683
|
if attr != last_key:
|
|
@@ -861,7 +887,7 @@ class ResourcesCodeGen:
|
|
|
861
887
|
operation_input_shape_name=operation_input_shape_name,
|
|
862
888
|
include_session_region=True,
|
|
863
889
|
include_return_resource_docstring=True,
|
|
864
|
-
|
|
890
|
+
include_intelligent_defaults_errors=True,
|
|
865
891
|
)
|
|
866
892
|
|
|
867
893
|
if "Describe" + resource_name in self.operations:
|
|
@@ -910,11 +936,18 @@ class ResourcesCodeGen:
|
|
|
910
936
|
deserialize_response = DESERIALIZE_INPUT_AND_RESPONSE_TO_CLS_TEMPLATE.format(
|
|
911
937
|
operation_output_shape=operation_output_shape_name
|
|
912
938
|
)
|
|
939
|
+
method_args = (
|
|
940
|
+
add_indent("cls,\n", 4)
|
|
941
|
+
+ create_args
|
|
942
|
+
+ "\n"
|
|
943
|
+
+ add_indent("session: Optional[Session] = None,\n", 4)
|
|
944
|
+
+ add_indent("region: Optional[str] = None,", 4)
|
|
945
|
+
)
|
|
913
946
|
formatted_method = GENERIC_METHOD_TEMPLATE.format(
|
|
914
947
|
docstring=docstring,
|
|
915
948
|
decorator=decorator,
|
|
916
949
|
method_name="create",
|
|
917
|
-
method_args=
|
|
950
|
+
method_args=method_args,
|
|
918
951
|
return_type=f'Optional["{resource_name}"]',
|
|
919
952
|
serialize_operation_input=serialize_operation_input,
|
|
920
953
|
initialize_client=initialize_client,
|
|
@@ -958,7 +991,7 @@ class ResourcesCodeGen:
|
|
|
958
991
|
include_session_region: bool = False,
|
|
959
992
|
include_return_resource_docstring: bool = False,
|
|
960
993
|
return_string: str = None,
|
|
961
|
-
|
|
994
|
+
include_intelligent_defaults_errors: bool = False,
|
|
962
995
|
exclude_resource_attrs: list = None,
|
|
963
996
|
) -> str:
|
|
964
997
|
"""
|
|
@@ -972,13 +1005,14 @@ class ResourcesCodeGen:
|
|
|
972
1005
|
include_session_region (bool): Whether to include session and region documentation.
|
|
973
1006
|
include_return_resource_docstring (bool): Whether to include resource-specific documentation.
|
|
974
1007
|
return_string (str): The return string.
|
|
975
|
-
|
|
1008
|
+
include_intelligent_defaults_errors (bool): Whether to include intelligent defaults errors.
|
|
976
1009
|
exclude_resource_attrs (list): A list of attributes to exclude from the docstring.
|
|
977
1010
|
|
|
978
1011
|
Returns:
|
|
979
1012
|
str: The generated docstring for the IMPORT method.
|
|
980
1013
|
"""
|
|
981
1014
|
docstring = f"{title}\n"
|
|
1015
|
+
_shape_attr_documentation_string = ""
|
|
982
1016
|
if operation_input_shape_name:
|
|
983
1017
|
_shape_attr_documentation_string = self._get_shape_attr_documentation_string(
|
|
984
1018
|
self.shapes_extractor.fetch_shape_members_and_doc_strings(
|
|
@@ -1002,8 +1036,8 @@ class ResourcesCodeGen:
|
|
|
1002
1036
|
|
|
1003
1037
|
docstring += self._exception_docstring(operation_name)
|
|
1004
1038
|
|
|
1005
|
-
if
|
|
1006
|
-
subclasses = set(
|
|
1039
|
+
if include_intelligent_defaults_errors:
|
|
1040
|
+
subclasses = set(IntelligentDefaultsError.__subclasses__())
|
|
1007
1041
|
_id_exception_docstrings = [
|
|
1008
1042
|
f"\n {subclass.__name__}: {subclass.__doc__}" for subclass in subclasses
|
|
1009
1043
|
]
|
|
@@ -1291,6 +1325,63 @@ class ResourcesCodeGen:
|
|
|
1291
1325
|
)
|
|
1292
1326
|
return formatted_method
|
|
1293
1327
|
|
|
1328
|
+
def generate_start_method(self, resource_name: str, **kwargs) -> str:
|
|
1329
|
+
"""Auto-Generate 'start' object Method [delete API] for a resource.
|
|
1330
|
+
|
|
1331
|
+
Args:
|
|
1332
|
+
resource_name (str): The resource name.
|
|
1333
|
+
|
|
1334
|
+
Returns:
|
|
1335
|
+
str: The formatted stop Method template.
|
|
1336
|
+
"""
|
|
1337
|
+
operation_name = "Start" + resource_name
|
|
1338
|
+
operation_metadata = self.operations[operation_name]
|
|
1339
|
+
operation_input_shape_name = operation_metadata["input"]["shape"]
|
|
1340
|
+
resource_attributes = kwargs["resource_attributes"]
|
|
1341
|
+
|
|
1342
|
+
method_args = add_indent("self,\n", 4)
|
|
1343
|
+
method_args += (
|
|
1344
|
+
self._generate_method_args(operation_input_shape_name, resource_attributes) + "\n"
|
|
1345
|
+
)
|
|
1346
|
+
operation_input_args = self._generate_operation_input_args_updated(
|
|
1347
|
+
operation_metadata, False, resource_attributes
|
|
1348
|
+
)
|
|
1349
|
+
exclude_resource_attrs = resource_attributes
|
|
1350
|
+
method_args += add_indent("session: Optional[Session] = None,\n", 4)
|
|
1351
|
+
method_args += add_indent("region: Optional[str] = None,", 4)
|
|
1352
|
+
|
|
1353
|
+
serialize_operation_input = SERIALIZE_INPUT_TEMPLATE.format(
|
|
1354
|
+
operation_input_args=operation_input_args
|
|
1355
|
+
)
|
|
1356
|
+
call_operation_api = CALL_OPERATION_API_TEMPLATE.format(
|
|
1357
|
+
operation=convert_to_snake_case(operation_name)
|
|
1358
|
+
)
|
|
1359
|
+
|
|
1360
|
+
# generate docstring
|
|
1361
|
+
docstring = self._generate_docstring(
|
|
1362
|
+
title=f"Start a {resource_name} resource",
|
|
1363
|
+
operation_name=operation_name,
|
|
1364
|
+
resource_name=resource_name,
|
|
1365
|
+
include_session_region=True,
|
|
1366
|
+
include_return_resource_docstring=False,
|
|
1367
|
+
exclude_resource_attrs=exclude_resource_attrs,
|
|
1368
|
+
)
|
|
1369
|
+
|
|
1370
|
+
initialize_client = INITIALIZE_CLIENT_TEMPLATE.format(service_name="sagemaker")
|
|
1371
|
+
|
|
1372
|
+
formatted_method = GENERIC_METHOD_TEMPLATE.format(
|
|
1373
|
+
docstring=docstring,
|
|
1374
|
+
decorator="",
|
|
1375
|
+
method_name="start",
|
|
1376
|
+
method_args=method_args,
|
|
1377
|
+
return_type="None",
|
|
1378
|
+
serialize_operation_input=serialize_operation_input,
|
|
1379
|
+
initialize_client=initialize_client,
|
|
1380
|
+
call_operation_api=call_operation_api,
|
|
1381
|
+
deserialize_response="",
|
|
1382
|
+
)
|
|
1383
|
+
return formatted_method
|
|
1384
|
+
|
|
1294
1385
|
def generate_stop_method(self, resource_name: str) -> str:
|
|
1295
1386
|
"""Auto-Generate 'stop' object Method [delete API] for a resource.
|
|
1296
1387
|
|
|
@@ -1390,12 +1481,9 @@ class ResourcesCodeGen:
|
|
|
1390
1481
|
return_type_conversion = "cls"
|
|
1391
1482
|
return_string = f"Returns:\n" f" {method.resource_name}\n"
|
|
1392
1483
|
else:
|
|
1484
|
+
return_type = f"Optional[{method.return_type}]"
|
|
1393
1485
|
return_type_conversion = method.return_type
|
|
1394
|
-
|
|
1395
|
-
return_type_conversion = f"shapes.{method.return_type}"
|
|
1396
|
-
return_type = f"Optional[{return_type_conversion}]"
|
|
1397
|
-
|
|
1398
|
-
return_string = f"Returns:\n" f" {return_type_conversion}\n"
|
|
1486
|
+
return_string = f"Returns:\n" f" {method.return_type}\n"
|
|
1399
1487
|
operation_output_shape = operation_metadata["output"]["shape"]
|
|
1400
1488
|
deserialize_response = DESERIALIZE_RESPONSE_TEMPLATE.format(
|
|
1401
1489
|
operation_output_shape=operation_output_shape,
|
|
@@ -1405,9 +1493,21 @@ class ResourcesCodeGen:
|
|
|
1405
1493
|
initialize_client = INITIALIZE_CLIENT_TEMPLATE.format(service_name=method.service_name)
|
|
1406
1494
|
if len(self.shapes[operation_input_shape_name]["members"]) != 0:
|
|
1407
1495
|
# the method has input arguments
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1496
|
+
if method.resource_name == "Endpoint" and method.method_name == "invoke":
|
|
1497
|
+
serialize_operation_input = SERIALIZE_INPUT_ENDPOINT_TEMPLATE.format(
|
|
1498
|
+
operation_input_args=operation_input_args
|
|
1499
|
+
)
|
|
1500
|
+
return_type_conversion = method.return_type
|
|
1501
|
+
operation_output_shape = operation_metadata["output"]["shape"]
|
|
1502
|
+
deserialize_response = DESERIALIZE_RESPONSE_ENDPOINT_TEMPLATE.format(
|
|
1503
|
+
operation_output_shape=operation_output_shape,
|
|
1504
|
+
return_type_conversion=return_type_conversion,
|
|
1505
|
+
)
|
|
1506
|
+
|
|
1507
|
+
else:
|
|
1508
|
+
serialize_operation_input = SERIALIZE_INPUT_TEMPLATE.format(
|
|
1509
|
+
operation_input_args=operation_input_args
|
|
1510
|
+
)
|
|
1411
1511
|
call_operation_api = CALL_OPERATION_API_TEMPLATE.format(
|
|
1412
1512
|
operation=convert_to_snake_case(method.operation_name)
|
|
1413
1513
|
)
|
|
@@ -1476,14 +1576,10 @@ class ResourcesCodeGen:
|
|
|
1476
1576
|
method_args += add_indent("session: Optional[Session] = None,\n", 4)
|
|
1477
1577
|
method_args += add_indent("region: Optional[str] = None,", 4)
|
|
1478
1578
|
|
|
1479
|
-
iterator_return_type = method.return_type
|
|
1480
|
-
if method.resource_name != method.return_type and method.return_type in self.shapes:
|
|
1481
|
-
iterator_return_type = f"shapes.{method.return_type}"
|
|
1482
|
-
|
|
1483
1579
|
if method.return_type == method.resource_name:
|
|
1484
|
-
|
|
1580
|
+
return_type = f'ResourceIterator["{method.resource_name}"]'
|
|
1485
1581
|
else:
|
|
1486
|
-
|
|
1582
|
+
return_type = f"ResourceIterator[{method.return_type}]"
|
|
1487
1583
|
return_string = f"Returns:\n" f" Iterator for listed {method.return_type}.\n"
|
|
1488
1584
|
|
|
1489
1585
|
get_list_operation_output_shape = operation_metadata["output"]["shape"]
|
|
@@ -1506,7 +1602,7 @@ class ResourcesCodeGen:
|
|
|
1506
1602
|
f"list_method='{list_method}'",
|
|
1507
1603
|
f"summaries_key='{summaries_key}'",
|
|
1508
1604
|
f"summary_name='{summary_name}'",
|
|
1509
|
-
f"resource_cls={
|
|
1605
|
+
f"resource_cls={method.return_type}",
|
|
1510
1606
|
"list_method_kwargs=operation_input_args",
|
|
1511
1607
|
]
|
|
1512
1608
|
|
|
@@ -1536,7 +1632,7 @@ class ResourcesCodeGen:
|
|
|
1536
1632
|
decorator=decorator,
|
|
1537
1633
|
method_name=method.method_name,
|
|
1538
1634
|
method_args=method_args,
|
|
1539
|
-
return_type=
|
|
1635
|
+
return_type=return_type,
|
|
1540
1636
|
serialize_operation_input=serialize_operation_input,
|
|
1541
1637
|
initialize_client=initialize_client,
|
|
1542
1638
|
call_operation_api="",
|
|
@@ -1756,27 +1852,14 @@ class ResourcesCodeGen:
|
|
|
1756
1852
|
get_operation_required_input = []
|
|
1757
1853
|
|
|
1758
1854
|
custom_key_mapping_str = ""
|
|
1759
|
-
custom_key_mapping = {}
|
|
1760
|
-
extract_name_mapping_str = ""
|
|
1761
|
-
extract_name_mapping = {}
|
|
1762
1855
|
if any(member not in summary_members for member in get_operation_required_input):
|
|
1763
|
-
if
|
|
1856
|
+
if "MonitoringJobDefinitionSummary" == summary_name:
|
|
1764
1857
|
custom_key_mapping = {
|
|
1765
1858
|
"monitoring_job_definition_name": "job_definition_name",
|
|
1766
1859
|
"monitoring_job_definition_arn": "job_definition_arn",
|
|
1767
1860
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
# {source key from input: (target label in arn, target key in output)}
|
|
1771
|
-
extract_name_mapping = {
|
|
1772
|
-
"hub_content_arn": ("hub-content/", "hub_name"),
|
|
1773
|
-
}
|
|
1774
|
-
elif summary_name == "ImageVersion":
|
|
1775
|
-
# ImageVersionArn -- arn:aws:sagemaker:<region>:<account>:image-version/<image-name>/<version-number>
|
|
1776
|
-
# {source key from input: (target label in arn, target key in output)}
|
|
1777
|
-
extract_name_mapping = {
|
|
1778
|
-
"image_version_arn": ("image-version/", "image_name"),
|
|
1779
|
-
}
|
|
1861
|
+
custom_key_mapping_str = f"custom_key_mapping = {json.dumps(custom_key_mapping)}"
|
|
1862
|
+
custom_key_mapping_str = add_indent(custom_key_mapping_str, 4)
|
|
1780
1863
|
else:
|
|
1781
1864
|
log.warning(
|
|
1782
1865
|
f"Resource {resource_name} summaries do not have required members to create object instance. Resource may require custom key mapping for get_all().\n"
|
|
@@ -1784,15 +1867,6 @@ class ResourcesCodeGen:
|
|
|
1784
1867
|
)
|
|
1785
1868
|
return ""
|
|
1786
1869
|
|
|
1787
|
-
if custom_key_mapping:
|
|
1788
|
-
custom_key_mapping_str = add_indent(
|
|
1789
|
-
f"custom_key_mapping = {json.dumps(custom_key_mapping)}", 4
|
|
1790
|
-
)
|
|
1791
|
-
if extract_name_mapping:
|
|
1792
|
-
extract_name_mapping_str = add_indent(
|
|
1793
|
-
f"extract_name_mapping = {json.dumps(extract_name_mapping)}", 4
|
|
1794
|
-
)
|
|
1795
|
-
|
|
1796
1870
|
resource_iterator_args_list = [
|
|
1797
1871
|
"client=client",
|
|
1798
1872
|
f"list_method='{operation}'",
|
|
@@ -1804,9 +1878,6 @@ class ResourcesCodeGen:
|
|
|
1804
1878
|
if custom_key_mapping_str:
|
|
1805
1879
|
resource_iterator_args_list.append(f"custom_key_mapping=custom_key_mapping")
|
|
1806
1880
|
|
|
1807
|
-
if extract_name_mapping_str:
|
|
1808
|
-
resource_iterator_args_list.append(f"extract_name_mapping=extract_name_mapping")
|
|
1809
|
-
|
|
1810
1881
|
exclude_list = ["next_token", "max_results"]
|
|
1811
1882
|
get_all_args = self._generate_method_args(operation_input_shape_name, exclude_list)
|
|
1812
1883
|
|
|
@@ -1819,7 +1890,6 @@ class ResourcesCodeGen:
|
|
|
1819
1890
|
resource=resource_name,
|
|
1820
1891
|
operation=operation,
|
|
1821
1892
|
custom_key_mapping=custom_key_mapping_str,
|
|
1822
|
-
extract_name_mapping=extract_name_mapping_str,
|
|
1823
1893
|
resource_iterator_args=resource_iterator_args,
|
|
1824
1894
|
)
|
|
1825
1895
|
return formatted_method
|
|
@@ -1850,7 +1920,6 @@ class ResourcesCodeGen:
|
|
|
1850
1920
|
get_all_args=get_all_args,
|
|
1851
1921
|
operation_input_args=operation_input_args,
|
|
1852
1922
|
custom_key_mapping=custom_key_mapping_str,
|
|
1853
|
-
extract_name_mapping=extract_name_mapping_str,
|
|
1854
1923
|
resource_iterator_args=resource_iterator_args,
|
|
1855
1924
|
)
|
|
1856
1925
|
return formatted_method
|
|
@@ -1937,8 +2006,6 @@ class ResourcesCodeGen:
|
|
|
1937
2006
|
new_val = value.split("=")[0].strip()
|
|
1938
2007
|
if new_val.startswith("Optional"):
|
|
1939
2008
|
new_val = new_val.replace("Optional[", "")[:-1]
|
|
1940
|
-
if new_val.startswith("shapes."):
|
|
1941
|
-
new_val = new_val.replace("shapes.", "")
|
|
1942
2009
|
cleaned_class_attributes[key] = new_val
|
|
1943
2010
|
return cleaned_class_attributes
|
|
1944
2011
|
|
|
@@ -1953,7 +2020,7 @@ class ResourcesCodeGen:
|
|
|
1953
2020
|
Dict with attributes that can be configurable
|
|
1954
2021
|
|
|
1955
2022
|
"""
|
|
1956
|
-
PYTHON_TYPES = ["
|
|
2023
|
+
PYTHON_TYPES = ["StrPipeVar", "datetime.datetime", "bool", "int", "float"]
|
|
1957
2024
|
default_attributes = {}
|
|
1958
2025
|
for key, value in class_attributes.items():
|
|
1959
2026
|
if value in PYTHON_TYPES or value.startswith("List"):
|
|
@@ -15,14 +15,14 @@ from typing import Optional
|
|
|
15
15
|
|
|
16
16
|
import pandas as pd
|
|
17
17
|
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
18
|
+
from sagemaker.core.utils.utils import get_textual_rich_logger
|
|
19
|
+
from sagemaker.core.tools.constants import CLASS_METHODS, OBJECT_METHODS
|
|
20
|
+
from sagemaker.core.tools.data_extractor import (
|
|
21
21
|
load_additional_operations_data,
|
|
22
22
|
load_combined_operations_data,
|
|
23
23
|
load_combined_shapes_data,
|
|
24
24
|
)
|
|
25
|
-
from
|
|
25
|
+
from sagemaker.core.tools.method import Method
|
|
26
26
|
|
|
27
27
|
log = get_textual_rich_logger(__name__)
|
|
28
28
|
"""
|
|
@@ -311,15 +311,7 @@ class ResourcesExtractor:
|
|
|
311
311
|
):
|
|
312
312
|
chain_resource_names.add(chain_resource_name)
|
|
313
313
|
action_split = action_low.split(resource_low)
|
|
314
|
-
if action_split[0]
|
|
315
|
-
if not action_split[1]:
|
|
316
|
-
invoke_method = "invoke"
|
|
317
|
-
elif action_split[1] == "async":
|
|
318
|
-
invoke_method = "invoke_async"
|
|
319
|
-
else:
|
|
320
|
-
invoke_method = "invoke_with_response_stream"
|
|
321
|
-
object_methods.add(invoke_method)
|
|
322
|
-
elif action_split[0] in CLASS_METHODS:
|
|
314
|
+
if action_split[0] in CLASS_METHODS:
|
|
323
315
|
if action_low.split(resource_low)[0] == "list":
|
|
324
316
|
class_methods.add("get_all")
|
|
325
317
|
else:
|
|
@@ -17,22 +17,21 @@ export PYTHONPATH=<sagemaker-code-gen repo directory>:$PYTHONPATH
|
|
|
17
17
|
"""
|
|
18
18
|
import os
|
|
19
19
|
|
|
20
|
-
from
|
|
21
|
-
from
|
|
20
|
+
from sagemaker.core.utils.code_injection.codec import pascal_to_snake
|
|
21
|
+
from sagemaker.core.tools.constants import (
|
|
22
22
|
LICENCES_STRING,
|
|
23
23
|
GENERATED_CLASSES_LOCATION,
|
|
24
24
|
SHAPES_CODEGEN_FILE_NAME,
|
|
25
|
-
SHAPES_WITH_JSON_FIELD_ALIAS,
|
|
26
25
|
)
|
|
27
|
-
from
|
|
28
|
-
from
|
|
26
|
+
from sagemaker.core.tools.shapes_extractor import ShapesExtractor
|
|
27
|
+
from sagemaker.core.utils.utils import (
|
|
29
28
|
add_indent,
|
|
30
29
|
convert_to_snake_case,
|
|
31
30
|
remove_html_tags,
|
|
32
31
|
escape_special_rst_characters,
|
|
33
32
|
)
|
|
34
|
-
from
|
|
35
|
-
from
|
|
33
|
+
from sagemaker.core.tools.templates import SHAPE_CLASS_TEMPLATE, SHAPE_BASE_CLASS_TEMPLATE
|
|
34
|
+
from sagemaker.core.tools.data_extractor import (
|
|
36
35
|
load_combined_shapes_data,
|
|
37
36
|
load_combined_operations_data,
|
|
38
37
|
)
|
|
@@ -149,8 +148,9 @@ class ShapesCodeGen:
|
|
|
149
148
|
"""
|
|
150
149
|
class_name = shape
|
|
151
150
|
init_data = self.shapes_extractor.generate_data_shape_string_body(
|
|
152
|
-
shape, self.resources_plan
|
|
151
|
+
shape, self.resources_plan
|
|
153
152
|
)
|
|
153
|
+
|
|
154
154
|
try:
|
|
155
155
|
data_class_members = add_indent(init_data, 4)
|
|
156
156
|
except Exception:
|
|
@@ -181,13 +181,7 @@ class ShapesCodeGen:
|
|
|
181
181
|
|
|
182
182
|
if "members" in shape_dict:
|
|
183
183
|
for member, member_attributes in shape_dict["members"].items():
|
|
184
|
-
|
|
185
|
-
if shape in SHAPES_WITH_JSON_FIELD_ALIAS and member == "Json":
|
|
186
|
-
updated_member = "JsonFormat"
|
|
187
|
-
docstring += f"\n{convert_to_snake_case(updated_member)}"
|
|
188
|
-
else:
|
|
189
|
-
docstring += f"\n{convert_to_snake_case(member)}"
|
|
190
|
-
|
|
184
|
+
docstring += f"\n{convert_to_snake_case(member)}"
|
|
191
185
|
if "documentation" in member_attributes:
|
|
192
186
|
docstring += f": {member_attributes['documentation']}"
|
|
193
187
|
|
|
@@ -210,10 +204,15 @@ class ShapesCodeGen:
|
|
|
210
204
|
:return: The generated import statements as a string.
|
|
211
205
|
"""
|
|
212
206
|
imports = "import datetime\n"
|
|
207
|
+
imports += "import warnings\n"
|
|
213
208
|
imports += "\n"
|
|
214
|
-
imports += "from pydantic import BaseModel, ConfigDict
|
|
209
|
+
imports += "from pydantic import BaseModel, ConfigDict\n"
|
|
215
210
|
imports += "from typing import List, Dict, Optional, Any, Union\n"
|
|
216
|
-
imports += "from
|
|
211
|
+
imports += "from sagemaker.core.utils.utils import Unassigned\n"
|
|
212
|
+
imports += "from sagemaker.core.helper.pipeline_variable import StrPipeVar\n"
|
|
213
|
+
imports += "\n"
|
|
214
|
+
imports += "# Suppress Pydantic warnings about field names shadowing parent attributes\n"
|
|
215
|
+
imports += "warnings.filterwarnings('ignore', message='.*shadows an attribute.*')\n"
|
|
217
216
|
imports += "\n"
|
|
218
217
|
return imports
|
|
219
218
|
|