sagemaker-core 1.0.62__py3-none-any.whl → 2.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sagemaker/__init__.py +2 -0
- sagemaker/core/__init__.py +16 -0
- sagemaker/core/_studio.py +116 -0
- sagemaker/core/_version.py +11 -0
- sagemaker/core/accept_types.py +131 -0
- sagemaker/core/analytics.py +744 -0
- sagemaker/core/apiutils/__init__.py +13 -0
- sagemaker/core/apiutils/_base_types.py +228 -0
- sagemaker/core/apiutils/_boto_functions.py +130 -0
- sagemaker/core/apiutils/_utils.py +34 -0
- sagemaker/core/base_deserializers.py +35 -0
- sagemaker/core/base_serializers.py +35 -0
- sagemaker/core/clarify/__init__.py +2898 -0
- sagemaker/core/collection.py +467 -0
- sagemaker/core/common_utils.py +2399 -0
- sagemaker/core/compute_resource_requirements/__init__.py +18 -0
- sagemaker/core/compute_resource_requirements/resource_requirements.py +94 -0
- sagemaker/core/config/__init__.py +181 -0
- sagemaker/core/config/config.py +238 -0
- sagemaker/core/config/config_manager.py +595 -0
- sagemaker/core/config/config_schema.py +1220 -0
- sagemaker/core/config/config_utils.py +297 -0
- {sagemaker_core/main → sagemaker/core}/config_schema.py +408 -3
- sagemaker/core/constants.py +73 -0
- sagemaker/core/content_types.py +137 -0
- sagemaker/core/debugger/__init__.py +39 -0
- sagemaker/core/debugger/debugger.py +945 -0
- sagemaker/core/debugger/framework_profile.py +292 -0
- sagemaker/core/debugger/metrics_config.py +468 -0
- sagemaker/core/debugger/profiler.py +42 -0
- sagemaker/core/debugger/profiler_config.py +190 -0
- sagemaker/core/debugger/profiler_constants.py +40 -0
- sagemaker/core/debugger/utils.py +148 -0
- sagemaker/core/deprecations.py +254 -0
- sagemaker/core/deserializers/__init__.py +10 -0
- sagemaker/core/deserializers/base.py +424 -0
- sagemaker/core/deserializers/implementations.py +157 -0
- sagemaker/core/drift_check_baselines.py +106 -0
- sagemaker/core/enums.py +51 -0
- sagemaker/core/environment_variables.py +101 -0
- sagemaker/core/exceptions.py +108 -0
- sagemaker/core/experiments/__init__.py +53 -0
- sagemaker/core/experiments/_api_types.py +251 -0
- sagemaker/core/experiments/_environment.py +124 -0
- sagemaker/core/experiments/_helper.py +294 -0
- sagemaker/core/experiments/_metrics.py +333 -0
- sagemaker/core/experiments/_run_context.py +58 -0
- sagemaker/core/experiments/_utils.py +216 -0
- sagemaker/core/experiments/experiment.py +247 -0
- sagemaker/core/experiments/run.py +970 -0
- sagemaker/core/experiments/trial.py +296 -0
- sagemaker/core/experiments/trial_component.py +387 -0
- sagemaker/core/explainer/__init__.py +24 -0
- sagemaker/core/explainer/clarify_explainer_config.py +298 -0
- sagemaker/core/explainer/explainer_config.py +44 -0
- sagemaker/core/fw_utils.py +1220 -0
- sagemaker/core/git_utils.py +415 -0
- sagemaker/core/helper/pipeline_variable.py +82 -0
- sagemaker/core/helper/session_helper.py +2977 -0
- sagemaker/core/hyperparameters.py +172 -0
- sagemaker/core/image_retriever/__init__.py +3 -0
- sagemaker/core/image_retriever/image_retriever.py +640 -0
- sagemaker/core/image_retriever/image_retriever_utils.py +509 -0
- sagemaker/core/image_retriever/test.py +7 -0
- sagemaker/core/image_uri_config/autogluon.json +1335 -0
- sagemaker/core/image_uri_config/blazingtext.json +50 -0
- sagemaker/core/image_uri_config/chainer.json +104 -0
- sagemaker/core/image_uri_config/clarify.json +39 -0
- sagemaker/core/image_uri_config/coach-mxnet.json +70 -0
- sagemaker/core/image_uri_config/coach-tensorflow.json +186 -0
- sagemaker/core/image_uri_config/data-wrangler.json +91 -0
- sagemaker/core/image_uri_config/debugger.json +34 -0
- sagemaker/core/image_uri_config/detailed-profiler.json +18 -0
- sagemaker/core/image_uri_config/djl-deepspeed.json +385 -0
- sagemaker/core/image_uri_config/djl-fastertransformer.json +167 -0
- sagemaker/core/image_uri_config/djl-lmi.json +136 -0
- sagemaker/core/image_uri_config/djl-neuronx.json +258 -0
- sagemaker/core/image_uri_config/djl-tensorrtllm.json +262 -0
- sagemaker/core/image_uri_config/factorization-machines.json +50 -0
- sagemaker/core/image_uri_config/forecasting-deepar.json +50 -0
- sagemaker/core/image_uri_config/huggingface-llm-neuronx.json +770 -0
- sagemaker/core/image_uri_config/huggingface-llm.json +1267 -0
- sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
- sagemaker/core/image_uri_config/huggingface-neuronx.json +686 -0
- sagemaker/core/image_uri_config/huggingface-tei-cpu.json +298 -0
- sagemaker/core/image_uri_config/huggingface-tei.json +298 -0
- sagemaker/core/image_uri_config/huggingface-training-compiler.json +195 -0
- sagemaker/core/image_uri_config/huggingface-vllm-neuronx.json +38 -0
- sagemaker/core/image_uri_config/huggingface.json +2287 -0
- sagemaker/core/image_uri_config/hyperpod-recipes-neuron.json +52 -0
- sagemaker/core/image_uri_config/image-classification-neo.json +43 -0
- sagemaker/core/image_uri_config/image-classification.json +50 -0
- sagemaker/core/image_uri_config/inferentia-mxnet.json +88 -0
- sagemaker/core/image_uri_config/inferentia-pytorch.json +127 -0
- sagemaker/core/image_uri_config/inferentia-tensorflow.json +88 -0
- sagemaker/core/image_uri_config/instance_gpu_info.json +782 -0
- sagemaker/core/image_uri_config/ipinsights.json +50 -0
- sagemaker/core/image_uri_config/kmeans.json +50 -0
- sagemaker/core/image_uri_config/knn.json +50 -0
- sagemaker/core/image_uri_config/lda.json +26 -0
- sagemaker/core/image_uri_config/linear-learner.json +50 -0
- sagemaker/core/image_uri_config/model-monitor.json +42 -0
- sagemaker/core/image_uri_config/mxnet.json +1154 -0
- sagemaker/core/image_uri_config/neo-mxnet.json +64 -0
- sagemaker/core/image_uri_config/neo-pytorch.json +341 -0
- sagemaker/core/image_uri_config/neo-tensorflow.json +109 -0
- sagemaker/core/image_uri_config/ntm.json +50 -0
- sagemaker/core/image_uri_config/object-detection.json +50 -0
- sagemaker/core/image_uri_config/object2vec.json +50 -0
- sagemaker/core/image_uri_config/pca.json +50 -0
- sagemaker/core/image_uri_config/pytorch-neuron.json +43 -0
- sagemaker/core/image_uri_config/pytorch-smp.json +218 -0
- sagemaker/core/image_uri_config/pytorch-training-compiler.json +80 -0
- sagemaker/core/image_uri_config/pytorch.json +3101 -0
- sagemaker/core/image_uri_config/randomcutforest.json +50 -0
- sagemaker/core/image_uri_config/ray-pytorch.json +46 -0
- sagemaker/core/image_uri_config/ray-tensorflow.json +194 -0
- sagemaker/core/image_uri_config/sagemaker-base-python.json +46 -0
- sagemaker/core/image_uri_config/sagemaker-distribution.json +37 -0
- sagemaker/core/image_uri_config/sagemaker-geospatial.json +13 -0
- sagemaker/core/image_uri_config/sagemaker-tritonserver.json +252 -0
- sagemaker/core/image_uri_config/semantic-segmentation.json +50 -0
- sagemaker/core/image_uri_config/seq2seq.json +50 -0
- sagemaker/core/image_uri_config/sklearn.json +494 -0
- sagemaker/core/image_uri_config/spark.json +280 -0
- sagemaker/core/image_uri_config/sparkml-serving.json +97 -0
- sagemaker/core/image_uri_config/stabilityai.json +53 -0
- sagemaker/core/image_uri_config/tensorflow.json +5086 -0
- sagemaker/core/image_uri_config/vw.json +25 -0
- sagemaker/core/image_uri_config/xgboost-neo.json +43 -0
- sagemaker/core/image_uri_config/xgboost.json +972 -0
- sagemaker/core/image_uris.py +816 -0
- sagemaker/core/inference_config.py +144 -0
- sagemaker/core/inference_recommender/__init__.py +18 -0
- sagemaker/core/inference_recommender/inference_recommender_mixin.py +622 -0
- sagemaker/core/inputs.py +366 -0
- sagemaker/core/instance_group.py +61 -0
- sagemaker/core/instance_types.py +164 -0
- sagemaker/core/instance_types_gpu_info.py +43 -0
- sagemaker/core/interactive_apps/__init__.py +41 -0
- sagemaker/core/interactive_apps/base_interactive_app.py +204 -0
- sagemaker/core/interactive_apps/detail_profiler_app.py +139 -0
- sagemaker/core/interactive_apps/tensorboard.py +149 -0
- sagemaker/core/iterators.py +197 -0
- sagemaker/core/job.py +380 -0
- sagemaker/core/jumpstart/__init__.py +156 -0
- sagemaker/core/jumpstart/accessors.py +390 -0
- sagemaker/core/jumpstart/artifacts/__init__.py +69 -0
- sagemaker/core/jumpstart/artifacts/environment_variables.py +252 -0
- sagemaker/core/jumpstart/artifacts/hyperparameters.py +120 -0
- sagemaker/core/jumpstart/artifacts/image_uris.py +139 -0
- sagemaker/core/jumpstart/artifacts/incremental_training.py +87 -0
- sagemaker/core/jumpstart/artifacts/instance_types.py +223 -0
- sagemaker/core/jumpstart/artifacts/kwargs.py +289 -0
- sagemaker/core/jumpstart/artifacts/metric_definitions.py +117 -0
- sagemaker/core/jumpstart/artifacts/model_packages.py +202 -0
- sagemaker/core/jumpstart/artifacts/model_uris.py +252 -0
- sagemaker/core/jumpstart/artifacts/payloads.py +96 -0
- sagemaker/core/jumpstart/artifacts/predictors.py +540 -0
- sagemaker/core/jumpstart/artifacts/resource_names.py +86 -0
- sagemaker/core/jumpstart/artifacts/resource_requirements.py +162 -0
- sagemaker/core/jumpstart/artifacts/script_uris.py +172 -0
- sagemaker/core/jumpstart/cache.py +663 -0
- sagemaker/core/jumpstart/configs.py +50 -0
- sagemaker/core/jumpstart/constants.py +198 -0
- sagemaker/core/jumpstart/deserializers.py +81 -0
- sagemaker/core/jumpstart/document.py +76 -0
- sagemaker/core/jumpstart/enums.py +168 -0
- sagemaker/core/jumpstart/exceptions.py +236 -0
- sagemaker/core/jumpstart/factory/utils.py +833 -0
- sagemaker/core/jumpstart/filters.py +597 -0
- sagemaker/core/jumpstart/hub/constants.py +16 -0
- sagemaker/core/jumpstart/hub/hub.py +291 -0
- sagemaker/core/jumpstart/hub/interfaces.py +936 -0
- sagemaker/core/jumpstart/hub/parser_utils.py +70 -0
- sagemaker/core/jumpstart/hub/parsers.py +288 -0
- sagemaker/core/jumpstart/hub/types.py +35 -0
- sagemaker/core/jumpstart/hub/utils.py +260 -0
- sagemaker/core/jumpstart/models.py +501 -0
- sagemaker/core/jumpstart/notebook_utils.py +575 -0
- sagemaker/core/jumpstart/parameters.py +20 -0
- sagemaker/core/jumpstart/payload_utils.py +239 -0
- sagemaker/core/jumpstart/region_config.json +171 -0
- sagemaker/core/jumpstart/search.py +171 -0
- sagemaker/core/jumpstart/serializers.py +81 -0
- sagemaker/core/jumpstart/session_utils.py +234 -0
- sagemaker/core/jumpstart/types.py +3044 -0
- sagemaker/core/jumpstart/utils.py +1731 -0
- sagemaker/core/jumpstart/validators.py +257 -0
- sagemaker/core/lambda_helper.py +312 -0
- sagemaker/core/lineage/__init__.py +42 -0
- sagemaker/core/lineage/_api_types.py +239 -0
- sagemaker/core/lineage/_utils.py +49 -0
- sagemaker/core/lineage/action.py +345 -0
- sagemaker/core/lineage/artifact.py +646 -0
- sagemaker/core/lineage/association.py +190 -0
- sagemaker/core/lineage/context.py +505 -0
- sagemaker/core/lineage/lineage_trial_component.py +191 -0
- sagemaker/core/lineage/query.py +732 -0
- sagemaker/core/lineage/visualizer.py +346 -0
- sagemaker/core/local/__init__.py +18 -0
- sagemaker/core/local/data.py +423 -0
- sagemaker/core/local/entities.py +678 -0
- sagemaker/core/local/exceptions.py +17 -0
- sagemaker/core/local/image.py +1243 -0
- sagemaker/core/local/local_session.py +739 -0
- sagemaker/core/local/utils.py +246 -0
- sagemaker/core/logs.py +181 -0
- sagemaker/core/metadata_properties.py +56 -0
- sagemaker/core/metric_definitions.py +91 -0
- sagemaker/core/mlflow/__init__.py +38 -0
- sagemaker/core/mlflow/forward_sagemaker_metrics.py +44 -0
- sagemaker/core/model_card/__init__.py +26 -0
- sagemaker/core/model_life_cycle.py +51 -0
- sagemaker/core/model_metrics.py +160 -0
- sagemaker/core/model_monitor/__init__.py +66 -0
- sagemaker/core/model_monitor/clarify_model_monitoring.py +1497 -0
- sagemaker/core/model_monitor/cron_expression_generator.py +82 -0
- sagemaker/core/model_monitor/data_capture_config.py +115 -0
- sagemaker/core/model_monitor/data_quality_monitoring_config.py +66 -0
- sagemaker/core/model_monitor/dataset_format.py +102 -0
- sagemaker/core/model_monitor/model_monitoring.py +4266 -0
- sagemaker/core/model_monitor/monitoring_alert.py +76 -0
- sagemaker/core/model_monitor/monitoring_files.py +506 -0
- sagemaker/core/model_monitor/utils.py +793 -0
- sagemaker/core/model_registry.py +480 -0
- sagemaker/core/model_uris.py +97 -0
- sagemaker/core/modules/__init__.py +19 -0
- sagemaker/core/modules/configs.py +239 -0
- sagemaker/core/modules/constants.py +37 -0
- sagemaker/core/modules/distributed.py +182 -0
- sagemaker/core/modules/local_core/local_container.py +605 -0
- sagemaker/core/modules/templates.py +83 -0
- sagemaker/core/modules/train/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/utils.py +205 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_driver.py +123 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
- sagemaker/core/modules/train/container_drivers/scripts/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/scripts/environment.py +305 -0
- sagemaker/core/modules/train/sm_recipes/__init__.py +0 -0
- sagemaker/core/modules/train/sm_recipes/utils.py +330 -0
- sagemaker/core/modules/types.py +19 -0
- sagemaker/core/modules/utils.py +194 -0
- sagemaker/core/network.py +185 -0
- sagemaker/core/parameter.py +173 -0
- sagemaker/core/payloads.py +185 -0
- sagemaker/core/processing.py +1599 -0
- sagemaker/core/remote_function/__init__.py +19 -0
- sagemaker/core/remote_function/checkpoint_location.py +47 -0
- sagemaker/core/remote_function/client.py +1310 -0
- sagemaker/core/remote_function/core/__init__.py +0 -0
- sagemaker/core/remote_function/core/_custom_dispatch_table.py +72 -0
- sagemaker/core/remote_function/core/pipeline_variables.py +347 -0
- sagemaker/core/remote_function/core/serialization.py +410 -0
- sagemaker/core/remote_function/core/stored_function.py +223 -0
- sagemaker/core/remote_function/custom_file_filter.py +128 -0
- sagemaker/core/remote_function/errors.py +102 -0
- sagemaker/core/remote_function/invoke_function.py +167 -0
- sagemaker/core/remote_function/job.py +2121 -0
- sagemaker/core/remote_function/logging_config.py +38 -0
- sagemaker/core/remote_function/runtime_environment/__init__.py +14 -0
- sagemaker/core/remote_function/runtime_environment/bootstrap_runtime_environment.py +605 -0
- sagemaker/core/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
- sagemaker/core/remote_function/runtime_environment/runtime_environment_manager.py +554 -0
- sagemaker/core/remote_function/runtime_environment/spark_app.py +18 -0
- sagemaker/core/remote_function/spark_config.py +149 -0
- sagemaker/core/resource_requirements.py +168 -0
- {sagemaker_core/main → sagemaker/core}/resources.py +19098 -10895
- sagemaker/core/s3/__init__.py +41 -0
- sagemaker/core/s3/client.py +367 -0
- sagemaker/core/s3/utils.py +175 -0
- sagemaker/core/script_uris.py +93 -0
- sagemaker/core/serializers/__init__.py +11 -0
- sagemaker/core/serializers/base.py +510 -0
- sagemaker/core/serializers/implementations.py +159 -0
- sagemaker/core/serializers/utils.py +223 -0
- sagemaker/core/serverless_inference_config.py +63 -0
- sagemaker/core/session_settings.py +55 -0
- sagemaker/core/shapes/__init__.py +3 -0
- sagemaker/core/shapes/model_card_shapes.py +159 -0
- {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +5810 -1806
- sagemaker/core/spark/__init__.py +16 -0
- sagemaker/core/spark/defaults.py +16 -0
- sagemaker/core/spark/processing.py +1380 -0
- sagemaker/core/telemetry/__init__.py +23 -0
- sagemaker/core/telemetry/constants.py +82 -0
- sagemaker/core/telemetry/telemetry_logging.py +285 -0
- sagemaker/core/tools/__init__.py +1 -0
- {sagemaker_core → sagemaker/core}/tools/codegen.py +4 -4
- {sagemaker_core → sagemaker/core}/tools/constants.py +23 -15
- {sagemaker_core → sagemaker/core}/tools/data_extractor.py +1 -1
- {sagemaker_core → sagemaker/core}/tools/method.py +1 -1
- sagemaker/core/tools/model_card/generate_model_card_from_schema.py +562 -0
- {sagemaker_core → sagemaker/core}/tools/resources_codegen.py +165 -98
- {sagemaker_core → sagemaker/core}/tools/resources_extractor.py +5 -13
- {sagemaker_core → sagemaker/core}/tools/shapes_codegen.py +16 -17
- {sagemaker_core → sagemaker/core}/tools/shapes_extractor.py +29 -67
- {sagemaker_core → sagemaker/core}/tools/templates.py +39 -17
- sagemaker/core/training/__init__.py +14 -0
- sagemaker/core/training/configs.py +345 -0
- sagemaker/core/training/constants.py +37 -0
- sagemaker/core/training/utils.py +77 -0
- sagemaker/core/training_compiler/__init__.py +16 -0
- sagemaker/core/training_compiler/config.py +197 -0
- sagemaker/core/training_compiler_config.py +197 -0
- sagemaker/core/transformer.py +793 -0
- sagemaker/core/user_agent.py +76 -0
- sagemaker/core/utilities/__init__.py +24 -0
- sagemaker/core/utilities/cache.py +169 -0
- sagemaker/core/utilities/search_expression.py +133 -0
- sagemaker/core/utils/__init__.py +48 -0
- sagemaker/core/utils/code_injection/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/codec.py +2 -2
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/shape_dag.py +5979 -176
- {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
- sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
- {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
- {sagemaker_core/main → sagemaker/core/utils}/utils.py +27 -22
- sagemaker/core/workflow/__init__.py +152 -0
- sagemaker/core/workflow/conditions.py +313 -0
- sagemaker/core/workflow/entities.py +58 -0
- sagemaker/core/workflow/execution_variables.py +89 -0
- sagemaker/core/workflow/functions.py +193 -0
- sagemaker/core/workflow/parameters.py +222 -0
- sagemaker/core/workflow/pipeline_context.py +394 -0
- sagemaker/core/workflow/pipeline_definition_config.py +31 -0
- sagemaker/core/workflow/properties.py +285 -0
- sagemaker/core/workflow/step_outputs.py +65 -0
- sagemaker/core/workflow/utilities.py +514 -0
- sagemaker/lineage/__init__.py +33 -0
- sagemaker/lineage/action.py +28 -0
- sagemaker/lineage/artifact.py +28 -0
- sagemaker/lineage/context.py +28 -0
- sagemaker/lineage/lineage_trial_component.py +28 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/METADATA +28 -9
- sagemaker_core-2.3.1.dist-info/RECORD +351 -0
- sagemaker_core-2.3.1.dist-info/top_level.txt +1 -0
- sagemaker_core/_version.py +0 -3
- sagemaker_core/helper/session_helper.py +0 -769
- sagemaker_core/resources/__init__.py +0 -1
- sagemaker_core/shapes/__init__.py +0 -1
- sagemaker_core/tools/__init__.py +0 -1
- sagemaker_core-1.0.62.dist-info/RECORD +0 -35
- sagemaker_core-1.0.62.dist-info/top_level.txt +0 -1
- {sagemaker_core → sagemaker/core/helper}/__init__.py +0 -0
- {sagemaker_core/helper → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/jumpstart/hub}/__init__.py +0 -0
- {sagemaker_core/main/code_injection → sagemaker/core/modules/local_core}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/WHEEL +0 -0
- {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
"""Defines the base entities used in workflow."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import abc
|
|
17
|
+
|
|
18
|
+
from enum import EnumMeta
|
|
19
|
+
from typing import Any, Dict, List, Union, TYPE_CHECKING
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
from pydantic_core import core_schema
|
|
23
|
+
except ImportError:
|
|
24
|
+
core_schema = None
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
# Import PipelineVariable from the migrated location
|
|
30
|
+
from sagemaker.core.helper.pipeline_variable import PipelineVariable # noqa: F401
|
|
31
|
+
|
|
32
|
+
PrimitiveType = Union[str, int, bool, float, None]
|
|
33
|
+
RequestType = Union[Dict[str, Any], List[Dict[str, Any]]]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Entity(abc.ABC):
|
|
37
|
+
"""Base object for workflow entities.
|
|
38
|
+
|
|
39
|
+
Entities must implement the to_request method.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
@abc.abstractmethod
|
|
43
|
+
def to_request(self) -> RequestType:
|
|
44
|
+
"""Get the request structure for workflow service calls."""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class DefaultEnumMeta(EnumMeta):
|
|
48
|
+
"""An EnumMeta which defaults to the first value in the Enum list."""
|
|
49
|
+
|
|
50
|
+
default = object()
|
|
51
|
+
|
|
52
|
+
def __call__(cls, *args, value=default, **kwargs):
|
|
53
|
+
"""Defaults to the first value in the Enum list."""
|
|
54
|
+
if value is DefaultEnumMeta.default:
|
|
55
|
+
return next(iter(cls))
|
|
56
|
+
return super().__call__(value, *args, **kwargs)
|
|
57
|
+
|
|
58
|
+
factory = __call__
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
"""Pipeline parameters and conditions for workflow."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from typing import List, TYPE_CHECKING
|
|
17
|
+
from sagemaker.core.helper.pipeline_variable import (
|
|
18
|
+
RequestType,
|
|
19
|
+
PipelineVariable,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from sagemaker.mlops.workflow.steps import Step
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ExecutionVariable(PipelineVariable):
|
|
27
|
+
"""Pipeline execution variables for workflow."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, name: str):
|
|
30
|
+
"""Create a pipeline execution variable.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
name (str): The name of the execution variable.
|
|
34
|
+
"""
|
|
35
|
+
self.name = name
|
|
36
|
+
|
|
37
|
+
def __eq__(self, other):
|
|
38
|
+
"""Override default equals method"""
|
|
39
|
+
if not isinstance(other, ExecutionVariable):
|
|
40
|
+
return NotImplemented
|
|
41
|
+
return self.name == other.name
|
|
42
|
+
|
|
43
|
+
def to_string(self) -> PipelineVariable:
|
|
44
|
+
"""Prompt the pipeline to convert the pipeline variable to String in runtime
|
|
45
|
+
|
|
46
|
+
As ExecutionVariable is treated as String in runtime, no extra actions are needed.
|
|
47
|
+
"""
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def expr(self) -> RequestType:
|
|
52
|
+
"""The 'Get' expression dict for an `ExecutionVariable`."""
|
|
53
|
+
return {"Get": f"Execution.{self.name}"}
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def _pickleable(self):
|
|
57
|
+
"""The pickleable object that can be passed to a remote function invocation."""
|
|
58
|
+
|
|
59
|
+
from sagemaker.core.remote_function.core.pipeline_variables import _ExecutionVariable
|
|
60
|
+
|
|
61
|
+
return _ExecutionVariable(name=self.name)
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def _referenced_steps(self) -> List["Step"]:
|
|
65
|
+
"""List of step that this function depends on."""
|
|
66
|
+
return []
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ExecutionVariables:
|
|
70
|
+
"""Provide access to all available execution variables:
|
|
71
|
+
|
|
72
|
+
- ExecutionVariables.START_DATETIME
|
|
73
|
+
- ExecutionVariables.CURRENT_DATETIME
|
|
74
|
+
- ExecutionVariables.PIPELINE_NAME
|
|
75
|
+
- ExecutionVariables.PIPELINE_ARN
|
|
76
|
+
- ExecutionVariables.PIPELINE_EXECUTION_ID
|
|
77
|
+
- ExecutionVariables.PIPELINE_EXECUTION_ARN
|
|
78
|
+
- ExecutionVariables.TRAINING_JOB_NAME
|
|
79
|
+
- ExecutionVariables.PROCESSING_JOB_NAME
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
START_DATETIME = ExecutionVariable("StartDateTime")
|
|
83
|
+
CURRENT_DATETIME = ExecutionVariable("CurrentDateTime")
|
|
84
|
+
PIPELINE_NAME = ExecutionVariable("PipelineName")
|
|
85
|
+
PIPELINE_ARN = ExecutionVariable("PipelineArn")
|
|
86
|
+
PIPELINE_EXECUTION_ID = ExecutionVariable("PipelineExecutionId")
|
|
87
|
+
PIPELINE_EXECUTION_ARN = ExecutionVariable("PipelineExecutionArn")
|
|
88
|
+
TRAINING_JOB_NAME = ExecutionVariable("TrainingJobName")
|
|
89
|
+
PROCESSING_JOB_NAME = ExecutionVariable("ProcessingJobName")
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
"""The step definitions for workflow."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from typing import List, Union, Optional, TYPE_CHECKING
|
|
17
|
+
|
|
18
|
+
import attr
|
|
19
|
+
|
|
20
|
+
from sagemaker.core.helper.pipeline_variable import PipelineVariable
|
|
21
|
+
from sagemaker.core.workflow.execution_variables import ExecutionVariable
|
|
22
|
+
from sagemaker.core.workflow.parameters import Parameter
|
|
23
|
+
from sagemaker.core.workflow.properties import PropertyFile, Properties
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def is_pipeline_variable(var: object) -> bool:
|
|
27
|
+
"""Check if the variable is a pipeline variable
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
var (object): The variable to be verified.
|
|
31
|
+
Returns:
|
|
32
|
+
bool: True if it is, False otherwise.
|
|
33
|
+
"""
|
|
34
|
+
return isinstance(var, PipelineVariable)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if TYPE_CHECKING:
|
|
38
|
+
from sagemaker.mlops.workflow.steps import Step
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@attr.s
|
|
42
|
+
class Join(PipelineVariable):
|
|
43
|
+
"""Join together properties.
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
Build a Amazon S3 Uri with bucket name parameter and pipeline execution Id and use it
|
|
47
|
+
as training input::
|
|
48
|
+
|
|
49
|
+
bucket = ParameterString('bucket', default_value='my-bucket')
|
|
50
|
+
|
|
51
|
+
TrainingInput(
|
|
52
|
+
s3_data=Join(
|
|
53
|
+
on='/',
|
|
54
|
+
values=['s3:/', bucket, ExecutionVariables.PIPELINE_EXECUTION_ID]
|
|
55
|
+
),
|
|
56
|
+
content_type="text/csv")
|
|
57
|
+
|
|
58
|
+
Attributes:
|
|
59
|
+
values (List[Union[PrimitiveType, Parameter, PipelineVariable]]):
|
|
60
|
+
The primitive type values, parameters, step properties, expressions to join.
|
|
61
|
+
on (str): The string to join the values on (Defaults to "").
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
on: str = attr.ib(factory=str)
|
|
65
|
+
values: List = attr.ib(factory=list)
|
|
66
|
+
|
|
67
|
+
def to_string(self) -> PipelineVariable:
|
|
68
|
+
"""Prompt the pipeline to convert the pipeline variable to String in runtime
|
|
69
|
+
|
|
70
|
+
As Join is treated as String in runtime, no extra actions are needed.
|
|
71
|
+
"""
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def expr(self):
|
|
76
|
+
"""The expression dict for a `Join` function."""
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
"Std:Join": {
|
|
80
|
+
"On": self.on,
|
|
81
|
+
"Values": [
|
|
82
|
+
value.expr if hasattr(value, "expr") else value for value in self.values
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def _referenced_steps(self) -> List[Union["Step", str]]:
|
|
89
|
+
"""List of step names that this function depends on."""
|
|
90
|
+
steps = []
|
|
91
|
+
for value in self.values:
|
|
92
|
+
if isinstance(value, PipelineVariable):
|
|
93
|
+
steps.extend(value._referenced_steps)
|
|
94
|
+
return steps
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@attr.s
|
|
98
|
+
class JsonGet(PipelineVariable):
|
|
99
|
+
"""Get JSON properties from PropertyFiles or S3 location.
|
|
100
|
+
|
|
101
|
+
Attributes:
|
|
102
|
+
step_name (str): The step name from which to get the property file.
|
|
103
|
+
property_file (Optional[Union[PropertyFile, str]]): Either a PropertyFile instance
|
|
104
|
+
or the name of a property file.
|
|
105
|
+
json_path (str): The JSON path expression to the requested value.
|
|
106
|
+
s3_uri (Optional[sagemaker.workflow.functions.Join]): The S3 location from which to fetch
|
|
107
|
+
a Json file. The Json file is the output of a step defined with ``@step`` decorator.
|
|
108
|
+
step (Step): The upstream step object which the s3_uri is associated to.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
# pylint: disable=W0613
|
|
112
|
+
def _check_property_file_s3_uri(self, attribute, value):
|
|
113
|
+
"""Validate mutually exclusive property file / s3uri"""
|
|
114
|
+
if self.property_file and self.s3_uri:
|
|
115
|
+
raise ValueError(
|
|
116
|
+
"Please specify either a property file or s3 uri as an input, but not both."
|
|
117
|
+
)
|
|
118
|
+
if not self.property_file and not self.s3_uri:
|
|
119
|
+
raise ValueError(
|
|
120
|
+
"Missing s3uri or property file as a required input to JsonGet."
|
|
121
|
+
"Please specify either a property file or s3 uri as an input, but not both."
|
|
122
|
+
)
|
|
123
|
+
if self.s3_uri:
|
|
124
|
+
self._validate_json_get_s3_uri()
|
|
125
|
+
|
|
126
|
+
step_name: str = attr.ib(default=None)
|
|
127
|
+
property_file: Optional[Union[PropertyFile, str]] = attr.ib(
|
|
128
|
+
default=None, validator=_check_property_file_s3_uri
|
|
129
|
+
)
|
|
130
|
+
json_path: str = attr.ib(default=None)
|
|
131
|
+
s3_uri: Optional[Join] = attr.ib(default=None, validator=_check_property_file_s3_uri)
|
|
132
|
+
step: "Step" = attr.ib(default=None)
|
|
133
|
+
|
|
134
|
+
# pylint: disable=R1710
|
|
135
|
+
@property
|
|
136
|
+
def expr(self):
|
|
137
|
+
"""The expression dict for a `JsonGet` function."""
|
|
138
|
+
|
|
139
|
+
if self.property_file:
|
|
140
|
+
if not isinstance(self.step_name, str) or not self.step_name:
|
|
141
|
+
raise ValueError("Please give a valid step name as a string.")
|
|
142
|
+
if isinstance(self.property_file, PropertyFile):
|
|
143
|
+
name = self.property_file.name
|
|
144
|
+
else:
|
|
145
|
+
name = self.property_file
|
|
146
|
+
return {
|
|
147
|
+
"Std:JsonGet": {
|
|
148
|
+
"PropertyFile": {"Get": f"Steps.{self.step_name}.PropertyFiles.{name}"},
|
|
149
|
+
"Path": self.json_path,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# ConditionStep uses a JoinFunction to provide this non-static, built s3Uri in
|
|
154
|
+
# the case of Lightsaber steps.
|
|
155
|
+
if self.s3_uri:
|
|
156
|
+
return {
|
|
157
|
+
"Std:JsonGet": {
|
|
158
|
+
"S3Uri": (
|
|
159
|
+
self.s3_uri.expr
|
|
160
|
+
if isinstance(self.s3_uri, PipelineVariable)
|
|
161
|
+
else self.s3_uri
|
|
162
|
+
),
|
|
163
|
+
"Path": self.json_path,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def _referenced_steps(self) -> List[Union["Step", str]]:
|
|
169
|
+
"""List of step that this function depends on."""
|
|
170
|
+
if self.step:
|
|
171
|
+
return [self.step]
|
|
172
|
+
if self.step_name:
|
|
173
|
+
return [self.step_name]
|
|
174
|
+
|
|
175
|
+
return []
|
|
176
|
+
|
|
177
|
+
def _validate_json_get_s3_uri(self):
|
|
178
|
+
"""Validate the s3 uri in JsonGet"""
|
|
179
|
+
s3_uri = self.s3_uri
|
|
180
|
+
if not isinstance(s3_uri, Join):
|
|
181
|
+
raise ValueError(
|
|
182
|
+
f"Invalid JsonGet function {self.expr}. JsonGet "
|
|
183
|
+
"function's s3_uri can only be a sagemaker.workflow.functions.Join object."
|
|
184
|
+
)
|
|
185
|
+
for join_arg in s3_uri.values:
|
|
186
|
+
if not is_pipeline_variable(join_arg):
|
|
187
|
+
continue
|
|
188
|
+
if not isinstance(join_arg, (Parameter, ExecutionVariable, Properties)):
|
|
189
|
+
raise ValueError(
|
|
190
|
+
f"Invalid JsonGet function {self.expr}. "
|
|
191
|
+
f"The Join values in JsonGet's s3_uri can only be a primitive object, "
|
|
192
|
+
f"Parameter, ExecutionVariable or Properties."
|
|
193
|
+
)
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
"""Pipeline parameters and conditions for workflow."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from enum import Enum
|
|
17
|
+
from functools import partial
|
|
18
|
+
from typing import Dict, List, Type
|
|
19
|
+
|
|
20
|
+
import attr
|
|
21
|
+
|
|
22
|
+
from sagemaker.core.workflow.entities import (
|
|
23
|
+
DefaultEnumMeta,
|
|
24
|
+
Entity,
|
|
25
|
+
)
|
|
26
|
+
from sagemaker.core.helper.pipeline_variable import (
|
|
27
|
+
PrimitiveType,
|
|
28
|
+
RequestType,
|
|
29
|
+
PipelineVariable,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ParameterTypeEnum(Enum, metaclass=DefaultEnumMeta):
|
|
34
|
+
"""Parameter type enum."""
|
|
35
|
+
|
|
36
|
+
STRING = "String"
|
|
37
|
+
INTEGER = "Integer"
|
|
38
|
+
BOOLEAN = "Boolean"
|
|
39
|
+
FLOAT = "Float"
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def python_type(self) -> Type:
|
|
43
|
+
"""Provide the Python type of the enum value."""
|
|
44
|
+
mapping = {
|
|
45
|
+
ParameterTypeEnum.STRING: str,
|
|
46
|
+
ParameterTypeEnum.INTEGER: int,
|
|
47
|
+
ParameterTypeEnum.BOOLEAN: bool,
|
|
48
|
+
ParameterTypeEnum.FLOAT: float,
|
|
49
|
+
}
|
|
50
|
+
return mapping[self]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@attr.s
|
|
54
|
+
class Parameter(PipelineVariable, Entity):
|
|
55
|
+
"""Pipeline parameter for workflow.
|
|
56
|
+
|
|
57
|
+
Attributes:
|
|
58
|
+
name (str): The name of the parameter.
|
|
59
|
+
parameter_type (ParameterTypeEnum): The type of the parameter.
|
|
60
|
+
default_value (PrimitiveType): The default value of the parameter.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
name: str = attr.ib(factory=str)
|
|
64
|
+
parameter_type: ParameterTypeEnum = attr.ib(factory=ParameterTypeEnum.factory)
|
|
65
|
+
default_value: PrimitiveType = attr.ib(default=None)
|
|
66
|
+
|
|
67
|
+
@default_value.validator
|
|
68
|
+
def _check_default_value(self, _, value):
|
|
69
|
+
"""Check whether the default value is compatible with the parameter type.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
_: unused argument required by attrs validator decorator.
|
|
73
|
+
value: The value to check the type for.
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
`TypeError` if the value is not compatible with the instance's Python type.
|
|
77
|
+
"""
|
|
78
|
+
self._check_default_value_type(value, self.parameter_type.python_type)
|
|
79
|
+
|
|
80
|
+
def to_request(self) -> RequestType:
|
|
81
|
+
"""Get the request structure for workflow service calls."""
|
|
82
|
+
value = {
|
|
83
|
+
"Name": self.name,
|
|
84
|
+
"Type": self.parameter_type.value,
|
|
85
|
+
}
|
|
86
|
+
if self.default_value is not None:
|
|
87
|
+
value["DefaultValue"] = self.default_value
|
|
88
|
+
return value
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def expr(self) -> Dict[str, str]:
|
|
92
|
+
"""The 'Get' expression dict for a `Parameter`."""
|
|
93
|
+
return Parameter._expr(self.name)
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def _pickleable(self):
|
|
97
|
+
"""The pickleable object that can be passed to a remote function invocation."""
|
|
98
|
+
|
|
99
|
+
from sagemaker.core.remote_function.core.pipeline_variables import (
|
|
100
|
+
_ParameterString,
|
|
101
|
+
_ParameterInteger,
|
|
102
|
+
_ParameterBoolean,
|
|
103
|
+
_ParameterFloat,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
if self.parameter_type == ParameterTypeEnum.STRING:
|
|
107
|
+
return _ParameterString(self.name)
|
|
108
|
+
if self.parameter_type == ParameterTypeEnum.INTEGER:
|
|
109
|
+
return _ParameterInteger(self.name)
|
|
110
|
+
if self.parameter_type == ParameterTypeEnum.BOOLEAN:
|
|
111
|
+
return _ParameterBoolean(self.name)
|
|
112
|
+
if self.parameter_type == ParameterTypeEnum.FLOAT:
|
|
113
|
+
return _ParameterFloat(self.name)
|
|
114
|
+
raise ValueError(f"Unsupported parameter type: {self.parameter_type}")
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def _referenced_steps(self) -> List[str]:
|
|
118
|
+
"""List of step names that this function depends on."""
|
|
119
|
+
return []
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def _expr(cls, name):
|
|
123
|
+
"""An internal classmethod for the 'Get' expression dict for a `Parameter`.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
name (str): The name of the parameter.
|
|
127
|
+
"""
|
|
128
|
+
return {"Get": f"Parameters.{name}"}
|
|
129
|
+
|
|
130
|
+
@classmethod
|
|
131
|
+
def _check_default_value_type(cls, value, python_type):
|
|
132
|
+
"""Check whether the default value is compatible with the parameter type.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
value: The value to check the type for.
|
|
136
|
+
python_type: The type to check the value against.
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
`TypeError` if the value is not compatible with the instance's Python type.
|
|
140
|
+
"""
|
|
141
|
+
if value and not isinstance(value, python_type):
|
|
142
|
+
raise TypeError("The default value specified does not match the Parameter Python type.")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# NOTE: partials do not handle metadata well, but make for at least "partial" syntactic sugar :-P
|
|
146
|
+
# proper implementation postponed, for "reasons": https://bugs.python.org/issue33419
|
|
147
|
+
# NOTE: cannot subclass bool: http://mail.python.org/pipermail/python-dev/2002-March/020822.html
|
|
148
|
+
ParameterBoolean = partial(Parameter, parameter_type=ParameterTypeEnum.BOOLEAN)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class ParameterString(Parameter):
|
|
152
|
+
"""String parameter for pipelines."""
|
|
153
|
+
|
|
154
|
+
def __init__(self, name: str, default_value: str = None, enum_values: List[str] = None):
|
|
155
|
+
"""Create a pipeline string parameter.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
name (str): The name of the parameter.
|
|
159
|
+
default_value (str): The default value of the parameter.
|
|
160
|
+
The default value could be overridden at start of an execution.
|
|
161
|
+
If not set or it is set to None, a value must be provided
|
|
162
|
+
at the start of the execution.
|
|
163
|
+
enum_values (List[str]): Enum values for this parameter.
|
|
164
|
+
"""
|
|
165
|
+
super(ParameterString, self).__init__(
|
|
166
|
+
name=name, parameter_type=ParameterTypeEnum.STRING, default_value=default_value
|
|
167
|
+
)
|
|
168
|
+
self.enum_values = enum_values
|
|
169
|
+
|
|
170
|
+
def __hash__(self):
|
|
171
|
+
"""Hash function for parameter types"""
|
|
172
|
+
return hash(tuple(self.to_request()))
|
|
173
|
+
|
|
174
|
+
def to_string(self) -> PipelineVariable:
|
|
175
|
+
"""Prompt the pipeline to convert the pipeline variable to String in runtime
|
|
176
|
+
|
|
177
|
+
As ParameterString is treated as String in runtime, no extra actions are needed.
|
|
178
|
+
"""
|
|
179
|
+
return self
|
|
180
|
+
|
|
181
|
+
def to_request(self) -> RequestType:
|
|
182
|
+
"""Get the request structure for workflow service calls."""
|
|
183
|
+
request_dict = super(ParameterString, self).to_request()
|
|
184
|
+
if self.enum_values:
|
|
185
|
+
request_dict["EnumValues"] = self.enum_values
|
|
186
|
+
return request_dict
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class ParameterInteger(Parameter):
|
|
190
|
+
"""Integer parameter for pipelines."""
|
|
191
|
+
|
|
192
|
+
def __init__(self, name: str, default_value: int = None):
|
|
193
|
+
"""Create a pipeline integer parameter.
|
|
194
|
+
|
|
195
|
+
Args:
|
|
196
|
+
name (str): The name of the parameter.
|
|
197
|
+
default_value (int): The default value of the parameter.
|
|
198
|
+
The default value could be overridden at start of an execution.
|
|
199
|
+
If not set or it is set to None, a value must be provided
|
|
200
|
+
at the start of the execution.
|
|
201
|
+
"""
|
|
202
|
+
super(ParameterInteger, self).__init__(
|
|
203
|
+
name=name, parameter_type=ParameterTypeEnum.INTEGER, default_value=default_value
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class ParameterFloat(Parameter):
|
|
208
|
+
"""Float parameter for pipelines."""
|
|
209
|
+
|
|
210
|
+
def __init__(self, name: str, default_value: float = None):
|
|
211
|
+
"""Create a pipeline float parameter.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
name (str): The name of the parameter.
|
|
215
|
+
default_value (float): The default value of the parameter.
|
|
216
|
+
The default value could be overridden at start of an execution.
|
|
217
|
+
If not set or it is set to None, a value must be provided
|
|
218
|
+
at the start of the execution.
|
|
219
|
+
"""
|
|
220
|
+
super(ParameterFloat, self).__init__(
|
|
221
|
+
name=name, parameter_type=ParameterTypeEnum.FLOAT, default_value=default_value
|
|
222
|
+
)
|