sagemaker-core 1.0.62__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 +408 -3
- sagemaker/core/constants.py +73 -0
- sagemaker/core/content_types.py +137 -0
- sagemaker/core/debugger/__init__.py +39 -0
- sagemaker/core/debugger/debugger.py +945 -0
- sagemaker/core/debugger/framework_profile.py +292 -0
- sagemaker/core/debugger/metrics_config.py +468 -0
- sagemaker/core/debugger/profiler.py +42 -0
- sagemaker/core/debugger/profiler_config.py +190 -0
- sagemaker/core/debugger/profiler_constants.py +40 -0
- sagemaker/core/debugger/utils.py +148 -0
- sagemaker/core/deprecations.py +254 -0
- sagemaker/core/deserializers/__init__.py +10 -0
- sagemaker/core/deserializers/base.py +424 -0
- sagemaker/core/deserializers/implementations.py +157 -0
- sagemaker/core/drift_check_baselines.py +106 -0
- sagemaker/core/enums.py +51 -0
- sagemaker/core/environment_variables.py +101 -0
- sagemaker/core/exceptions.py +108 -0
- sagemaker/core/experiments/__init__.py +53 -0
- sagemaker/core/experiments/_api_types.py +251 -0
- sagemaker/core/experiments/_environment.py +124 -0
- sagemaker/core/experiments/_helper.py +294 -0
- sagemaker/core/experiments/_metrics.py +333 -0
- sagemaker/core/experiments/_run_context.py +58 -0
- sagemaker/core/experiments/_utils.py +216 -0
- sagemaker/core/experiments/experiment.py +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/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 +19098 -10895
- sagemaker/core/s3/__init__.py +41 -0
- sagemaker/core/s3/client.py +367 -0
- sagemaker/core/s3/utils.py +175 -0
- sagemaker/core/script_uris.py +93 -0
- sagemaker/core/serializers/__init__.py +11 -0
- sagemaker/core/serializers/base.py +510 -0
- sagemaker/core/serializers/implementations.py +159 -0
- sagemaker/core/serializers/utils.py +223 -0
- sagemaker/core/serverless_inference_config.py +63 -0
- sagemaker/core/session_settings.py +55 -0
- sagemaker/core/shapes/__init__.py +3 -0
- sagemaker/core/shapes/model_card_shapes.py +159 -0
- {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +5810 -1806
- sagemaker/core/spark/__init__.py +16 -0
- sagemaker/core/spark/defaults.py +16 -0
- sagemaker/core/spark/processing.py +1380 -0
- sagemaker/core/telemetry/__init__.py +23 -0
- sagemaker/core/telemetry/constants.py +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 +5979 -176
- {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
- sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
- {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
- {sagemaker_core/main → sagemaker/core/utils}/utils.py +27 -22
- sagemaker/core/workflow/__init__.py +152 -0
- sagemaker/core/workflow/conditions.py +313 -0
- sagemaker/core/workflow/entities.py +58 -0
- sagemaker/core/workflow/execution_variables.py +89 -0
- sagemaker/core/workflow/functions.py +193 -0
- sagemaker/core/workflow/parameters.py +222 -0
- sagemaker/core/workflow/pipeline_context.py +394 -0
- sagemaker/core/workflow/pipeline_definition_config.py +31 -0
- sagemaker/core/workflow/properties.py +285 -0
- sagemaker/core/workflow/step_outputs.py +65 -0
- sagemaker/core/workflow/utilities.py +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.62.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/_version.py +0 -3
- sagemaker_core/helper/session_helper.py +0 -769
- sagemaker_core/resources/__init__.py +0 -1
- sagemaker_core/shapes/__init__.py +0 -1
- sagemaker_core/tools/__init__.py +0 -1
- sagemaker_core-1.0.62.dist-info/RECORD +0 -35
- sagemaker_core-1.0.62.dist-info/top_level.txt +0 -1
- {sagemaker_core → sagemaker/core/helper}/__init__.py +0 -0
- {sagemaker_core/helper → sagemaker/core/huggingface/training_compiler}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
- {sagemaker_core/main/code_injection → sagemaker/core/jumpstart/hub}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.1.1.dist-info}/WHEEL +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.1.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
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
|
+
"""Contains the Trial class."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from botocore.exceptions import ClientError
|
|
17
|
+
|
|
18
|
+
from sagemaker.core.apiutils import _base_types
|
|
19
|
+
import sagemaker.core.experiments._api_types as _api_types
|
|
20
|
+
from sagemaker.core.experiments.trial_component import _TrialComponent
|
|
21
|
+
from sagemaker.core.common_utils import format_tags
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _Trial(_base_types.Record):
|
|
25
|
+
"""An execution of a data-science workflow with an experiment.
|
|
26
|
+
|
|
27
|
+
Consists of a list of trial component objects, which document individual
|
|
28
|
+
activities within the workflow.
|
|
29
|
+
|
|
30
|
+
Attributes:
|
|
31
|
+
trial_name (str): The name of the trial.
|
|
32
|
+
experiment_name (str): The name of the trial's experiment.
|
|
33
|
+
display_name (str): The name of the trial that will appear in UI,
|
|
34
|
+
such as SageMaker Studio.
|
|
35
|
+
tags (List[Dict[str, str]]): A list of tags to associate with the trial.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
trial_name = None
|
|
39
|
+
experiment_name = None
|
|
40
|
+
display_name = None
|
|
41
|
+
tags = None
|
|
42
|
+
|
|
43
|
+
_boto_create_method = "create_trial"
|
|
44
|
+
_boto_load_method = "describe_trial"
|
|
45
|
+
_boto_delete_method = "delete_trial"
|
|
46
|
+
_boto_update_method = "update_trial"
|
|
47
|
+
|
|
48
|
+
_boto_update_members = ["trial_name", "display_name"]
|
|
49
|
+
_boto_delete_members = ["trial_name"]
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def _boto_ignore(cls):
|
|
53
|
+
"""Response fields to ignore by default."""
|
|
54
|
+
return super(_Trial, cls)._boto_ignore() + ["CreatedBy"]
|
|
55
|
+
|
|
56
|
+
def save(self):
|
|
57
|
+
"""Save the state of this Trial to SageMaker.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
dict: Update trial response.
|
|
61
|
+
"""
|
|
62
|
+
return self._invoke_api(self._boto_update_method, self._boto_update_members)
|
|
63
|
+
|
|
64
|
+
def delete(self):
|
|
65
|
+
"""Delete this Trial from SageMaker.
|
|
66
|
+
|
|
67
|
+
Does not delete associated Trial Components.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
dict: Delete trial response.
|
|
71
|
+
"""
|
|
72
|
+
return self._invoke_api(self._boto_delete_method, self._boto_delete_members)
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def load(cls, trial_name, sagemaker_session=None):
|
|
76
|
+
"""Load an existing trial and return a `_Trial` object.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
trial_name: (str): Name of the Trial.
|
|
80
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
81
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
82
|
+
AWS services needed. If not specified, one is created using the
|
|
83
|
+
default AWS configuration chain.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
experiments.trial._Trial: A SageMaker `_Trial` object
|
|
87
|
+
"""
|
|
88
|
+
return super(_Trial, cls)._construct(
|
|
89
|
+
cls._boto_load_method,
|
|
90
|
+
trial_name=trial_name,
|
|
91
|
+
sagemaker_session=sagemaker_session,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
@classmethod
|
|
95
|
+
def create(
|
|
96
|
+
cls, experiment_name, trial_name, display_name=None, tags=None, sagemaker_session=None
|
|
97
|
+
):
|
|
98
|
+
"""Create a new trial and return a `_Trial` object.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
experiment_name: (str): Name of the experiment to create this trial in.
|
|
102
|
+
trial_name: (str): Name of the Trial.
|
|
103
|
+
display_name (str): Name of the trial that will appear in UI,
|
|
104
|
+
such as SageMaker Studio (default: None).
|
|
105
|
+
tags (Optional[Tags]): A list of tags to associate with the trial (default: None).
|
|
106
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
107
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
108
|
+
AWS services needed. If not specified, one is created using the
|
|
109
|
+
default AWS configuration chain.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
experiments.trial._Trial: A SageMaker `_Trial` object
|
|
113
|
+
"""
|
|
114
|
+
trial = super(_Trial, cls)._construct(
|
|
115
|
+
cls._boto_create_method,
|
|
116
|
+
trial_name=trial_name,
|
|
117
|
+
experiment_name=experiment_name,
|
|
118
|
+
display_name=display_name,
|
|
119
|
+
tags=format_tags(tags),
|
|
120
|
+
sagemaker_session=sagemaker_session,
|
|
121
|
+
)
|
|
122
|
+
return trial
|
|
123
|
+
|
|
124
|
+
@classmethod
|
|
125
|
+
def list(
|
|
126
|
+
cls,
|
|
127
|
+
experiment_name=None,
|
|
128
|
+
trial_component_name=None,
|
|
129
|
+
created_before=None,
|
|
130
|
+
created_after=None,
|
|
131
|
+
sort_by=None,
|
|
132
|
+
sort_order=None,
|
|
133
|
+
sagemaker_session=None,
|
|
134
|
+
):
|
|
135
|
+
"""List all trials matching the specified criteria.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
experiment_name (str): Name of the experiment. If specified, only trials in
|
|
139
|
+
the experiment will be returned (default: None).
|
|
140
|
+
trial_component_name (str): Name of the trial component. If specified, only
|
|
141
|
+
trials with this trial component name will be returned (default: None).
|
|
142
|
+
created_before (datetime.datetime): Return trials created before this instant
|
|
143
|
+
(default: None).
|
|
144
|
+
created_after (datetime.datetime): Return trials created after this instant
|
|
145
|
+
(default: None).
|
|
146
|
+
sort_by (str): Which property to sort results by. One of 'Name', 'CreationTime'
|
|
147
|
+
(default: None).
|
|
148
|
+
sort_order (str): One of 'Ascending', or 'Descending' (default: None).
|
|
149
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
150
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
151
|
+
AWS services needed. If not specified, one is created using the
|
|
152
|
+
default AWS configuration chain.
|
|
153
|
+
Returns:
|
|
154
|
+
collections.Iterator[experiments._api_types.TrialSummary]: An iterator over trials
|
|
155
|
+
matching the specified criteria.
|
|
156
|
+
"""
|
|
157
|
+
return super(_Trial, cls)._list(
|
|
158
|
+
"list_trials",
|
|
159
|
+
_api_types.TrialSummary.from_boto,
|
|
160
|
+
"TrialSummaries",
|
|
161
|
+
experiment_name=experiment_name,
|
|
162
|
+
trial_component_name=trial_component_name,
|
|
163
|
+
created_before=created_before,
|
|
164
|
+
created_after=created_after,
|
|
165
|
+
sort_by=sort_by,
|
|
166
|
+
sort_order=sort_order,
|
|
167
|
+
sagemaker_session=sagemaker_session,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def add_trial_component(self, trial_component):
|
|
171
|
+
"""Add the specified trial component to this trial.
|
|
172
|
+
|
|
173
|
+
A trial component may belong to many trials and a trial may have many trial components.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
trial_component (str or _TrialComponent): The trial component to add.
|
|
177
|
+
Can be one of a _TrialComponent instance, or a string containing
|
|
178
|
+
the name of the trial component to add.
|
|
179
|
+
"""
|
|
180
|
+
if isinstance(trial_component, _TrialComponent):
|
|
181
|
+
trial_component_name = trial_component.trial_component_name
|
|
182
|
+
elif isinstance(trial_component, str):
|
|
183
|
+
trial_component_name = trial_component
|
|
184
|
+
else:
|
|
185
|
+
raise TypeError(
|
|
186
|
+
"Unsupported type of trail component {}. "
|
|
187
|
+
"It has to be one type of _TrialComponent or str".format(trial_component)
|
|
188
|
+
)
|
|
189
|
+
self.sagemaker_session.sagemaker_client.associate_trial_component(
|
|
190
|
+
TrialName=self.trial_name, TrialComponentName=trial_component_name
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def remove_trial_component(self, trial_component):
|
|
194
|
+
"""Remove the specified trial component from this trial.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
trial_component (str or _TrialComponent): The trial component to add.
|
|
198
|
+
Can be one of a _TrialComponent instance, or a string containing
|
|
199
|
+
the name of the trial component to add.
|
|
200
|
+
"""
|
|
201
|
+
if isinstance(trial_component, _TrialComponent):
|
|
202
|
+
trial_component_name = trial_component.trial_component_name
|
|
203
|
+
elif isinstance(trial_component, str):
|
|
204
|
+
trial_component_name = trial_component
|
|
205
|
+
else:
|
|
206
|
+
raise TypeError(
|
|
207
|
+
"Unsupported type of trail component {}. "
|
|
208
|
+
"It has to be one type of _TrialComponent or str".format(trial_component)
|
|
209
|
+
)
|
|
210
|
+
self.sagemaker_session.sagemaker_client.disassociate_trial_component(
|
|
211
|
+
TrialName=self.trial_name, TrialComponentName=trial_component_name
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
def list_trial_components(
|
|
215
|
+
self,
|
|
216
|
+
created_before=None,
|
|
217
|
+
created_after=None,
|
|
218
|
+
sort_by=None,
|
|
219
|
+
sort_order=None,
|
|
220
|
+
max_results=None,
|
|
221
|
+
next_token=None,
|
|
222
|
+
):
|
|
223
|
+
"""List trial components in this trial matching the specified criteria.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
created_before (datetime.datetime): Return trials created before this instant
|
|
227
|
+
(default: None).
|
|
228
|
+
created_after (datetime.datetime): Return trials created after this instant
|
|
229
|
+
(default: None).
|
|
230
|
+
sort_by (str): Which property to sort results by. One of 'Name',
|
|
231
|
+
'CreationTime' (default: None).
|
|
232
|
+
sort_order (str): One of 'Ascending', or 'Descending' (default: None).
|
|
233
|
+
max_results (int): maximum number of trial components to retrieve (default: None).
|
|
234
|
+
next_token (str): token for next page of results (default: None).
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
collections.Iterator[experiments._api_types.TrialComponentSummary] : An iterator over
|
|
238
|
+
trials matching the criteria.
|
|
239
|
+
"""
|
|
240
|
+
return _TrialComponent.list(
|
|
241
|
+
trial_name=self.trial_name,
|
|
242
|
+
created_before=created_before,
|
|
243
|
+
created_after=created_after,
|
|
244
|
+
sort_by=sort_by,
|
|
245
|
+
sort_order=sort_order,
|
|
246
|
+
max_results=max_results,
|
|
247
|
+
next_token=next_token,
|
|
248
|
+
sagemaker_session=self.sagemaker_session,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
@classmethod
|
|
252
|
+
def _load_or_create(
|
|
253
|
+
cls, experiment_name, trial_name, display_name=None, tags=None, sagemaker_session=None
|
|
254
|
+
):
|
|
255
|
+
"""Load a trial by name and create a new one if it does not exist.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
experiment_name: (str): Name of the experiment to create this trial in.
|
|
259
|
+
trial_name: (str): Name of the Trial.
|
|
260
|
+
display_name (str): Name of the trial that will appear in UI,
|
|
261
|
+
such as SageMaker Studio (default: None). This is used only when the given
|
|
262
|
+
`trial_name` does not exist and a new trial has to be created.
|
|
263
|
+
tags (Optional[Tags]): A list of tags to associate with the trial (default: None).
|
|
264
|
+
This is used only when the given `trial_name` does not exist and
|
|
265
|
+
a new trial has to be created.
|
|
266
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
267
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
268
|
+
AWS services needed. If not specified, one is created using the
|
|
269
|
+
default AWS configuration chain.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
experiments.trial._Trial: A SageMaker `_Trial` object
|
|
273
|
+
"""
|
|
274
|
+
try:
|
|
275
|
+
trial = _Trial.create(
|
|
276
|
+
experiment_name=experiment_name,
|
|
277
|
+
trial_name=trial_name,
|
|
278
|
+
display_name=display_name,
|
|
279
|
+
tags=format_tags(tags),
|
|
280
|
+
sagemaker_session=sagemaker_session,
|
|
281
|
+
)
|
|
282
|
+
except ClientError as ce:
|
|
283
|
+
error_code = ce.response["Error"]["Code"]
|
|
284
|
+
error_message = ce.response["Error"]["Message"]
|
|
285
|
+
if not (error_code == "ValidationException" and "already exists" in error_message):
|
|
286
|
+
raise ce
|
|
287
|
+
# already exists
|
|
288
|
+
trial = _Trial.load(trial_name, sagemaker_session)
|
|
289
|
+
if trial.experiment_name != experiment_name: # pylint: disable=no-member
|
|
290
|
+
raise ValueError(
|
|
291
|
+
"The given experiment_name {} ".format(experiment_name)
|
|
292
|
+
+ "does not match that in the loaded trial {}".format(
|
|
293
|
+
trial.experiment_name # pylint: disable=no-member
|
|
294
|
+
)
|
|
295
|
+
)
|
|
296
|
+
return trial
|
|
@@ -0,0 +1,387 @@
|
|
|
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
|
+
"""Contains the TrialComponent class."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import time
|
|
17
|
+
|
|
18
|
+
from botocore.exceptions import ClientError
|
|
19
|
+
|
|
20
|
+
from sagemaker.core.apiutils import _base_types
|
|
21
|
+
import sagemaker.core.experiments._api_types as _api_types
|
|
22
|
+
from sagemaker.core.experiments._api_types import TrialComponentSearchResult
|
|
23
|
+
from sagemaker.core.common_utils import format_tags
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _TrialComponent(_base_types.Record):
|
|
27
|
+
"""This class represents a SageMaker trial component object.
|
|
28
|
+
|
|
29
|
+
A trial component is a stage in a trial.
|
|
30
|
+
Trial components are created automatically within the SageMaker runtime and
|
|
31
|
+
may not be created directly. To automatically associate trial components with
|
|
32
|
+
a trial and experiment, supply an experiment config when creating a job.
|
|
33
|
+
For example: https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTrainingJob.html
|
|
34
|
+
|
|
35
|
+
Attributes:
|
|
36
|
+
trial_component_name (str): The name of the trial component. Generated by SageMaker
|
|
37
|
+
from the name of the source job with a suffix specific to the type of source job.
|
|
38
|
+
trial_component_arn (str): The ARN of the trial component.
|
|
39
|
+
display_name (str): The name of the trial component that will appear in UI,
|
|
40
|
+
such as SageMaker Studio.
|
|
41
|
+
source (TrialComponentSource): A TrialComponentSource object with a source_arn attribute.
|
|
42
|
+
status (str): Status of the source job.
|
|
43
|
+
start_time (datetime): When the source job started.
|
|
44
|
+
end_time (datetime): When the source job ended.
|
|
45
|
+
creation_time (datetime): When the source job was created.
|
|
46
|
+
created_by (obj): Contextual info on which account created the trial component.
|
|
47
|
+
last_modified_time (datetime): When the trial component was last modified.
|
|
48
|
+
last_modified_by (obj): Contextual info on which account last modified the trial component.
|
|
49
|
+
parameters (dict): Dictionary of parameters to the source job.
|
|
50
|
+
input_artifacts (dict): Dictionary of input artifacts.
|
|
51
|
+
output_artifacts (dict): Dictionary of output artifacts.
|
|
52
|
+
metrics (obj): Aggregated metrics for the job.
|
|
53
|
+
parameters_to_remove (list): The hyperparameters to remove from the component.
|
|
54
|
+
input_artifacts_to_remove (list): The input artifacts to remove from the component.
|
|
55
|
+
output_artifacts_to_remove (list): The output artifacts to remove from the component.
|
|
56
|
+
tags (List[Dict[str, str]]): A list of tags to associate with the trial component.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
trial_component_name = None
|
|
60
|
+
trial_component_arn = None
|
|
61
|
+
display_name = None
|
|
62
|
+
source = None
|
|
63
|
+
status = None
|
|
64
|
+
start_time = None
|
|
65
|
+
end_time = None
|
|
66
|
+
creation_time = None
|
|
67
|
+
created_by = None
|
|
68
|
+
last_modified_time = None
|
|
69
|
+
last_modified_by = None
|
|
70
|
+
parameters = None
|
|
71
|
+
input_artifacts = None
|
|
72
|
+
output_artifacts = None
|
|
73
|
+
metrics = None
|
|
74
|
+
parameters_to_remove = None
|
|
75
|
+
input_artifacts_to_remove = None
|
|
76
|
+
output_artifacts_to_remove = None
|
|
77
|
+
tags = None
|
|
78
|
+
|
|
79
|
+
_boto_load_method = "describe_trial_component"
|
|
80
|
+
_boto_create_method = "create_trial_component"
|
|
81
|
+
_boto_update_method = "update_trial_component"
|
|
82
|
+
_boto_delete_method = "delete_trial_component"
|
|
83
|
+
|
|
84
|
+
_custom_boto_types = {
|
|
85
|
+
"source": (_api_types.TrialComponentSource, False),
|
|
86
|
+
"status": (_api_types.TrialComponentStatus, False),
|
|
87
|
+
"parameters": (_api_types.TrialComponentParameters, False),
|
|
88
|
+
"input_artifacts": (_api_types.TrialComponentArtifact, True),
|
|
89
|
+
"output_artifacts": (_api_types.TrialComponentArtifact, True),
|
|
90
|
+
"metrics": (_api_types.TrialComponentMetricSummary, True),
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_boto_update_members = [
|
|
94
|
+
"trial_component_name",
|
|
95
|
+
"display_name",
|
|
96
|
+
"status",
|
|
97
|
+
"start_time",
|
|
98
|
+
"end_time",
|
|
99
|
+
"parameters",
|
|
100
|
+
"input_artifacts",
|
|
101
|
+
"output_artifacts",
|
|
102
|
+
"parameters_to_remove",
|
|
103
|
+
"input_artifacts_to_remove",
|
|
104
|
+
"output_artifacts_to_remove",
|
|
105
|
+
]
|
|
106
|
+
_boto_delete_members = ["trial_component_name"]
|
|
107
|
+
|
|
108
|
+
def __init__(self, sagemaker_session=None, **kwargs):
|
|
109
|
+
"""Init for _TrialComponent"""
|
|
110
|
+
super().__init__(sagemaker_session, **kwargs)
|
|
111
|
+
self.parameters = self.parameters or {}
|
|
112
|
+
self.input_artifacts = self.input_artifacts or {}
|
|
113
|
+
self.output_artifacts = self.output_artifacts or {}
|
|
114
|
+
|
|
115
|
+
@classmethod
|
|
116
|
+
def _boto_ignore(cls):
|
|
117
|
+
"""Response fields to ignore by default."""
|
|
118
|
+
return super(_TrialComponent, cls)._boto_ignore() + ["CreatedBy"]
|
|
119
|
+
|
|
120
|
+
def save(self):
|
|
121
|
+
"""Save the state of this TrialComponent to SageMaker."""
|
|
122
|
+
return self._invoke_api(self._boto_update_method, self._boto_update_members)
|
|
123
|
+
|
|
124
|
+
def delete(self, force_disassociate=False):
|
|
125
|
+
"""Delete this TrialComponent from SageMaker.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
force_disassociate (boolean): Indicates whether to force disassociate the
|
|
129
|
+
trial component with the trials before deletion (default: False).
|
|
130
|
+
If set to true, force disassociate the trial component with associated trials
|
|
131
|
+
first, then delete the trial component.
|
|
132
|
+
If it's not set or set to false, it will delete the trial component directory
|
|
133
|
+
without disassociation.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
dict: Delete trial component response.
|
|
137
|
+
"""
|
|
138
|
+
if force_disassociate:
|
|
139
|
+
next_token = None
|
|
140
|
+
|
|
141
|
+
while True:
|
|
142
|
+
if next_token:
|
|
143
|
+
list_trials_response = self.sagemaker_session.sagemaker_client.list_trials(
|
|
144
|
+
TrialComponentName=self.trial_component_name, NextToken=next_token
|
|
145
|
+
)
|
|
146
|
+
else:
|
|
147
|
+
list_trials_response = self.sagemaker_session.sagemaker_client.list_trials(
|
|
148
|
+
TrialComponentName=self.trial_component_name
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Disassociate the trials and trial components
|
|
152
|
+
for per_trial in list_trials_response["TrialSummaries"]:
|
|
153
|
+
# to prevent DisassociateTrialComponent throttling
|
|
154
|
+
time.sleep(1.2)
|
|
155
|
+
self.sagemaker_session.sagemaker_client.disassociate_trial_component(
|
|
156
|
+
TrialName=per_trial["TrialName"],
|
|
157
|
+
TrialComponentName=self.trial_component_name,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
if "NextToken" in list_trials_response:
|
|
161
|
+
next_token = list_trials_response["NextToken"]
|
|
162
|
+
else:
|
|
163
|
+
break
|
|
164
|
+
|
|
165
|
+
return self._invoke_api(self._boto_delete_method, self._boto_delete_members)
|
|
166
|
+
|
|
167
|
+
@classmethod
|
|
168
|
+
def load(cls, trial_component_name, sagemaker_session=None):
|
|
169
|
+
"""Load an existing trial component and return an `_TrialComponent` object representing it.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
trial_component_name (str): Name of the trial component
|
|
173
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
174
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
175
|
+
AWS services needed. If not specified, one is created using the
|
|
176
|
+
default AWS configuration chain.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
experiments.trial_component._TrialComponent: A SageMaker `_TrialComponent` object
|
|
180
|
+
"""
|
|
181
|
+
trial_component = cls._construct(
|
|
182
|
+
cls._boto_load_method,
|
|
183
|
+
trial_component_name=trial_component_name,
|
|
184
|
+
sagemaker_session=sagemaker_session,
|
|
185
|
+
)
|
|
186
|
+
return trial_component
|
|
187
|
+
|
|
188
|
+
@classmethod
|
|
189
|
+
def create(cls, trial_component_name, display_name=None, tags=None, sagemaker_session=None):
|
|
190
|
+
"""Create a trial component and return a `_TrialComponent` object representing it.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
trial_component_name (str): The name of the trial component.
|
|
194
|
+
display_name (str): Display name of the trial component used by Studio (default: None).
|
|
195
|
+
tags (Optional[Tags]): Tags to add to the trial component (default: None).
|
|
196
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
197
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
198
|
+
AWS services needed. If not specified, one is created using the
|
|
199
|
+
default AWS configuration chain.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
experiments.trial_component._TrialComponent: A SageMaker `_TrialComponent` object.
|
|
203
|
+
"""
|
|
204
|
+
return super(_TrialComponent, cls)._construct(
|
|
205
|
+
cls._boto_create_method,
|
|
206
|
+
trial_component_name=trial_component_name,
|
|
207
|
+
display_name=display_name,
|
|
208
|
+
tags=format_tags(tags),
|
|
209
|
+
sagemaker_session=sagemaker_session,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
@classmethod
|
|
213
|
+
def list(
|
|
214
|
+
cls,
|
|
215
|
+
source_arn=None,
|
|
216
|
+
created_before=None,
|
|
217
|
+
created_after=None,
|
|
218
|
+
sort_by=None,
|
|
219
|
+
sort_order=None,
|
|
220
|
+
sagemaker_session=None,
|
|
221
|
+
trial_name=None,
|
|
222
|
+
experiment_name=None,
|
|
223
|
+
max_results=None,
|
|
224
|
+
next_token=None,
|
|
225
|
+
):
|
|
226
|
+
"""Return a list of trial component summaries.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
source_arn (str): A SageMaker Training or Processing Job ARN (default: None).
|
|
230
|
+
created_before (datetime.datetime): Return trial components created before this instant
|
|
231
|
+
(default: None).
|
|
232
|
+
created_after (datetime.datetime): Return trial components created after this instant
|
|
233
|
+
(default: None).
|
|
234
|
+
sort_by (str): Which property to sort results by. One of 'Name', 'CreationTime'
|
|
235
|
+
(default: None).
|
|
236
|
+
sort_order (str): One of 'Ascending', or 'Descending' (default: None).
|
|
237
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
238
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
239
|
+
AWS services needed. If not specified, one is created using the
|
|
240
|
+
default AWS configuration chain.
|
|
241
|
+
trial_name (str): If provided only trial components related to the trial are returned
|
|
242
|
+
(default: None).
|
|
243
|
+
experiment_name (str): If provided only trial components related to the experiment are
|
|
244
|
+
returned (default: None).
|
|
245
|
+
max_results (int): maximum number of trial components to retrieve (default: None).
|
|
246
|
+
next_token (str): token for next page of results (default: None).
|
|
247
|
+
Returns:
|
|
248
|
+
collections.Iterator[experiments._api_types.TrialComponentSummary]: An iterator
|
|
249
|
+
over `TrialComponentSummary` objects.
|
|
250
|
+
"""
|
|
251
|
+
return super(_TrialComponent, cls)._list(
|
|
252
|
+
"list_trial_components",
|
|
253
|
+
_api_types.TrialComponentSummary.from_boto,
|
|
254
|
+
"TrialComponentSummaries",
|
|
255
|
+
source_arn=source_arn,
|
|
256
|
+
created_before=created_before,
|
|
257
|
+
created_after=created_after,
|
|
258
|
+
sort_by=sort_by,
|
|
259
|
+
sort_order=sort_order,
|
|
260
|
+
sagemaker_session=sagemaker_session,
|
|
261
|
+
trial_name=trial_name,
|
|
262
|
+
experiment_name=experiment_name,
|
|
263
|
+
max_results=max_results,
|
|
264
|
+
next_token=next_token,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
@classmethod
|
|
268
|
+
def search(
|
|
269
|
+
cls,
|
|
270
|
+
search_expression=None,
|
|
271
|
+
sort_by=None,
|
|
272
|
+
sort_order=None,
|
|
273
|
+
max_results=None,
|
|
274
|
+
sagemaker_session=None,
|
|
275
|
+
):
|
|
276
|
+
"""Search Experiment Trail Component.
|
|
277
|
+
|
|
278
|
+
Returns SearchResults in the account matching the search criteria.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
search_expression: (SearchExpression): A Boolean conditional statement (default: None).
|
|
282
|
+
Resource objects must satisfy this condition to be included in search results.
|
|
283
|
+
You must provide at least one subexpression, filter, or nested filter.
|
|
284
|
+
sort_by (str): The name of the resource property used to sort the SearchResults
|
|
285
|
+
(default: None).
|
|
286
|
+
sort_order (str): How SearchResults are ordered. Valid values are Ascending or
|
|
287
|
+
Descending (default: None).
|
|
288
|
+
max_results (int): The maximum number of results to return in a SearchResponse
|
|
289
|
+
(default: None).
|
|
290
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
291
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
292
|
+
AWS services needed. If not specified, one is created using the
|
|
293
|
+
default AWS configuration chain.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
collections.Iterator[SearchResult] : An iterator over search results matching the
|
|
297
|
+
search criteria.
|
|
298
|
+
"""
|
|
299
|
+
return super(_TrialComponent, cls)._search(
|
|
300
|
+
search_resource="ExperimentTrialComponent",
|
|
301
|
+
search_item_factory=TrialComponentSearchResult.from_boto,
|
|
302
|
+
search_expression=None if search_expression is None else search_expression.to_boto(),
|
|
303
|
+
sort_by=sort_by,
|
|
304
|
+
sort_order=sort_order,
|
|
305
|
+
max_results=max_results,
|
|
306
|
+
sagemaker_session=sagemaker_session,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
@classmethod
|
|
310
|
+
def _load_or_create(
|
|
311
|
+
cls, trial_component_name, display_name=None, tags=None, sagemaker_session=None
|
|
312
|
+
):
|
|
313
|
+
"""Load a trial component by name and create a new one if it does not exist.
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
trial_component_name (str): The name of the trial component.
|
|
317
|
+
display_name (str): Display name of the trial component used by Studio (default: None).
|
|
318
|
+
This is used only when the given `trial_component_name` does not
|
|
319
|
+
exist and a new trial component has to be created.
|
|
320
|
+
tags (Optional[Tags]): Tags to add to the trial component (default: None).
|
|
321
|
+
This is used only when the given `trial_component_name` does not
|
|
322
|
+
exist and a new trial component has to be created.
|
|
323
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
324
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
325
|
+
AWS services needed. If not specified, one is created using the
|
|
326
|
+
default AWS configuration chain.
|
|
327
|
+
|
|
328
|
+
Returns:
|
|
329
|
+
experiments.trial_component._TrialComponent: A SageMaker `_TrialComponent` object.
|
|
330
|
+
bool: A boolean variable indicating whether the trail component already exists
|
|
331
|
+
"""
|
|
332
|
+
is_existed = False
|
|
333
|
+
try:
|
|
334
|
+
run_tc = _TrialComponent.create(
|
|
335
|
+
trial_component_name=trial_component_name,
|
|
336
|
+
display_name=display_name,
|
|
337
|
+
tags=format_tags(tags),
|
|
338
|
+
sagemaker_session=sagemaker_session,
|
|
339
|
+
)
|
|
340
|
+
except ClientError as ce:
|
|
341
|
+
error_code = ce.response["Error"]["Code"]
|
|
342
|
+
error_message = ce.response["Error"]["Message"]
|
|
343
|
+
if not (error_code == "ValidationException" and "already exists" in error_message):
|
|
344
|
+
raise ce
|
|
345
|
+
# already exists
|
|
346
|
+
run_tc = _TrialComponent.load(trial_component_name, sagemaker_session)
|
|
347
|
+
is_existed = True
|
|
348
|
+
return run_tc, is_existed
|
|
349
|
+
|
|
350
|
+
@classmethod
|
|
351
|
+
def _trial_component_is_associated_to_trial(
|
|
352
|
+
cls, trial_component_name, trial_name=None, sagemaker_session=None
|
|
353
|
+
):
|
|
354
|
+
"""Returns a bool based on if trial_component is already associated with the trial.
|
|
355
|
+
|
|
356
|
+
Args:
|
|
357
|
+
trial_component_name (str): The name of the trial component.
|
|
358
|
+
trial_name: (str): The name of the trial.
|
|
359
|
+
sagemaker_session (sagemaker.core.helper.session_helper.Session): Session object which
|
|
360
|
+
manages interactions with Amazon SageMaker APIs and any other
|
|
361
|
+
AWS services needed.
|
|
362
|
+
|
|
363
|
+
Returns:
|
|
364
|
+
bool: A boolean variable indicating whether the trial component is already
|
|
365
|
+
associated with the trial.
|
|
366
|
+
|
|
367
|
+
"""
|
|
368
|
+
search_results = sagemaker_session.sagemaker_client.search(
|
|
369
|
+
Resource="ExperimentTrialComponent",
|
|
370
|
+
SearchExpression={
|
|
371
|
+
"Filters": [
|
|
372
|
+
{
|
|
373
|
+
"Name": "TrialComponentName",
|
|
374
|
+
"Operator": "Equals",
|
|
375
|
+
"Value": str(trial_component_name),
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"Name": "Parents.TrialName",
|
|
379
|
+
"Operator": "Equals",
|
|
380
|
+
"Value": str(trial_name),
|
|
381
|
+
},
|
|
382
|
+
]
|
|
383
|
+
},
|
|
384
|
+
)
|
|
385
|
+
if search_results["Results"]:
|
|
386
|
+
return True
|
|
387
|
+
return False
|