sagemaker-core 1.0.47__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sagemaker/core/__init__.py +16 -0
- sagemaker/core/_studio.py +116 -0
- sagemaker/core/_version.py +11 -0
- sagemaker/core/accept_types.py +131 -0
- sagemaker/core/analytics.py +744 -0
- sagemaker/core/apiutils/__init__.py +13 -0
- sagemaker/core/apiutils/_base_types.py +228 -0
- sagemaker/core/apiutils/_boto_functions.py +130 -0
- sagemaker/core/apiutils/_utils.py +34 -0
- sagemaker/core/base_deserializers.py +35 -0
- sagemaker/core/base_serializers.py +35 -0
- sagemaker/core/clarify/__init__.py +2898 -0
- sagemaker/core/collection.py +467 -0
- sagemaker/core/common_utils.py +2281 -0
- sagemaker/core/compute_resource_requirements/__init__.py +18 -0
- sagemaker/core/compute_resource_requirements/resource_requirements.py +94 -0
- sagemaker/core/config/__init__.py +181 -0
- sagemaker/core/config/config.py +238 -0
- sagemaker/core/config/config_manager.py +595 -0
- sagemaker/core/config/config_schema.py +1220 -0
- sagemaker/core/config/config_utils.py +297 -0
- {sagemaker_core/main → sagemaker/core}/config_schema.py +410 -4
- sagemaker/core/constants.py +73 -0
- sagemaker/core/content_types.py +137 -0
- sagemaker/core/debugger/__init__.py +39 -0
- sagemaker/core/debugger/debugger.py +945 -0
- sagemaker/core/debugger/framework_profile.py +292 -0
- sagemaker/core/debugger/metrics_config.py +468 -0
- sagemaker/core/debugger/profiler.py +42 -0
- sagemaker/core/debugger/profiler_config.py +190 -0
- sagemaker/core/debugger/profiler_constants.py +40 -0
- sagemaker/core/debugger/utils.py +148 -0
- sagemaker/core/deprecations.py +254 -0
- sagemaker/core/deserializers/__init__.py +10 -0
- sagemaker/core/deserializers/base.py +424 -0
- sagemaker/core/deserializers/implementations.py +157 -0
- sagemaker/core/drift_check_baselines.py +106 -0
- sagemaker/core/enums.py +51 -0
- sagemaker/core/environment_variables.py +101 -0
- sagemaker/core/exceptions.py +108 -0
- sagemaker/core/experiments/__init__.py +53 -0
- sagemaker/core/experiments/_api_types.py +251 -0
- sagemaker/core/experiments/_environment.py +124 -0
- sagemaker/core/experiments/_helper.py +294 -0
- sagemaker/core/experiments/_metrics.py +333 -0
- sagemaker/core/experiments/_run_context.py +58 -0
- sagemaker/core/experiments/_utils.py +216 -0
- sagemaker/core/experiments/experiment.py +244 -0
- sagemaker/core/experiments/run.py +970 -0
- sagemaker/core/experiments/trial.py +296 -0
- sagemaker/core/experiments/trial_component.py +387 -0
- sagemaker/core/explainer/__init__.py +24 -0
- sagemaker/core/explainer/clarify_explainer_config.py +298 -0
- sagemaker/core/explainer/explainer_config.py +44 -0
- sagemaker/core/fw_utils.py +1176 -0
- sagemaker/core/git_utils.py +349 -0
- sagemaker/core/helper/pipeline_variable.py +82 -0
- sagemaker/core/helper/session_helper.py +2965 -0
- sagemaker/core/huggingface/__init__.py +29 -0
- sagemaker/core/huggingface/llm_utils.py +150 -0
- sagemaker/core/huggingface/processing.py +139 -0
- sagemaker/core/huggingface/training_compiler/config.py +167 -0
- sagemaker/core/hyperparameters.py +172 -0
- sagemaker/core/image_retriever/__init__.py +3 -0
- sagemaker/core/image_retriever/image_retriever.py +640 -0
- sagemaker/core/image_retriever/image_retriever_utils.py +511 -0
- sagemaker/core/image_retriever/test.py +7 -0
- sagemaker/core/image_uri_config/__init__.py +13 -0
- sagemaker/core/image_uri_config/autogluon.json +1335 -0
- sagemaker/core/image_uri_config/blazingtext.json +50 -0
- sagemaker/core/image_uri_config/chainer.json +104 -0
- sagemaker/core/image_uri_config/clarify.json +39 -0
- sagemaker/core/image_uri_config/coach-mxnet.json +70 -0
- sagemaker/core/image_uri_config/coach-tensorflow.json +186 -0
- sagemaker/core/image_uri_config/data-wrangler.json +91 -0
- sagemaker/core/image_uri_config/debugger.json +34 -0
- sagemaker/core/image_uri_config/detailed-profiler.json +18 -0
- sagemaker/core/image_uri_config/djl-deepspeed.json +385 -0
- sagemaker/core/image_uri_config/djl-fastertransformer.json +167 -0
- sagemaker/core/image_uri_config/djl-lmi.json +136 -0
- sagemaker/core/image_uri_config/djl-neuronx.json +258 -0
- sagemaker/core/image_uri_config/djl-tensorrtllm.json +262 -0
- sagemaker/core/image_uri_config/factorization-machines.json +50 -0
- sagemaker/core/image_uri_config/forecasting-deepar.json +50 -0
- sagemaker/core/image_uri_config/huggingface-llm-neuronx.json +660 -0
- sagemaker/core/image_uri_config/huggingface-llm.json +1158 -0
- sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
- sagemaker/core/image_uri_config/huggingface-neuronx.json +510 -0
- sagemaker/core/image_uri_config/huggingface-tei-cpu.json +298 -0
- sagemaker/core/image_uri_config/huggingface-tei.json +298 -0
- sagemaker/core/image_uri_config/huggingface-training-compiler.json +195 -0
- sagemaker/core/image_uri_config/huggingface.json +2138 -0
- sagemaker/core/image_uri_config/hyperpod-recipes-neuron.json +52 -0
- sagemaker/core/image_uri_config/image-classification-neo.json +43 -0
- sagemaker/core/image_uri_config/image-classification.json +50 -0
- sagemaker/core/image_uri_config/inferentia-mxnet.json +88 -0
- sagemaker/core/image_uri_config/inferentia-pytorch.json +127 -0
- sagemaker/core/image_uri_config/inferentia-tensorflow.json +88 -0
- sagemaker/core/image_uri_config/instance_gpu_info.json +782 -0
- sagemaker/core/image_uri_config/ipinsights.json +50 -0
- sagemaker/core/image_uri_config/kmeans.json +50 -0
- sagemaker/core/image_uri_config/knn.json +50 -0
- sagemaker/core/image_uri_config/lda.json +26 -0
- sagemaker/core/image_uri_config/linear-learner.json +50 -0
- sagemaker/core/image_uri_config/model-monitor.json +42 -0
- sagemaker/core/image_uri_config/mxnet.json +1154 -0
- sagemaker/core/image_uri_config/neo-mxnet.json +64 -0
- sagemaker/core/image_uri_config/neo-pytorch.json +341 -0
- sagemaker/core/image_uri_config/neo-tensorflow.json +109 -0
- sagemaker/core/image_uri_config/ntm.json +50 -0
- sagemaker/core/image_uri_config/object-detection.json +50 -0
- sagemaker/core/image_uri_config/object2vec.json +50 -0
- sagemaker/core/image_uri_config/pca.json +50 -0
- sagemaker/core/image_uri_config/pytorch-neuron.json +43 -0
- sagemaker/core/image_uri_config/pytorch-smp.json +218 -0
- sagemaker/core/image_uri_config/pytorch-training-compiler.json +80 -0
- sagemaker/core/image_uri_config/pytorch.json +3101 -0
- sagemaker/core/image_uri_config/randomcutforest.json +50 -0
- sagemaker/core/image_uri_config/ray-pytorch.json +46 -0
- sagemaker/core/image_uri_config/ray-tensorflow.json +194 -0
- sagemaker/core/image_uri_config/sagemaker-base-python.json +46 -0
- sagemaker/core/image_uri_config/sagemaker-distribution.json +37 -0
- sagemaker/core/image_uri_config/sagemaker-geospatial.json +13 -0
- sagemaker/core/image_uri_config/sagemaker-tritonserver.json +212 -0
- sagemaker/core/image_uri_config/semantic-segmentation.json +50 -0
- sagemaker/core/image_uri_config/seq2seq.json +50 -0
- sagemaker/core/image_uri_config/sklearn.json +446 -0
- sagemaker/core/image_uri_config/spark.json +280 -0
- sagemaker/core/image_uri_config/sparkml-serving.json +97 -0
- sagemaker/core/image_uri_config/stabilityai.json +53 -0
- sagemaker/core/image_uri_config/tensorflow.json +5086 -0
- sagemaker/core/image_uri_config/vw.json +25 -0
- sagemaker/core/image_uri_config/xgboost-neo.json +43 -0
- sagemaker/core/image_uri_config/xgboost.json +888 -0
- sagemaker/core/image_uris.py +810 -0
- sagemaker/core/inference_config.py +144 -0
- sagemaker/core/inference_recommender/__init__.py +18 -0
- sagemaker/core/inference_recommender/inference_recommender_mixin.py +622 -0
- sagemaker/core/inputs.py +366 -0
- sagemaker/core/instance_group.py +61 -0
- sagemaker/core/instance_types.py +164 -0
- sagemaker/core/instance_types_gpu_info.py +43 -0
- sagemaker/core/interactive_apps/__init__.py +41 -0
- sagemaker/core/interactive_apps/base_interactive_app.py +204 -0
- sagemaker/core/interactive_apps/detail_profiler_app.py +139 -0
- sagemaker/core/interactive_apps/tensorboard.py +149 -0
- sagemaker/core/iterators.py +186 -0
- sagemaker/core/job.py +380 -0
- sagemaker/core/jumpstart/__init__.py +156 -0
- sagemaker/core/jumpstart/accessors.py +390 -0
- sagemaker/core/jumpstart/artifacts/__init__.py +69 -0
- sagemaker/core/jumpstart/artifacts/environment_variables.py +252 -0
- sagemaker/core/jumpstart/artifacts/hyperparameters.py +120 -0
- sagemaker/core/jumpstart/artifacts/image_uris.py +139 -0
- sagemaker/core/jumpstart/artifacts/incremental_training.py +87 -0
- sagemaker/core/jumpstart/artifacts/instance_types.py +223 -0
- sagemaker/core/jumpstart/artifacts/kwargs.py +289 -0
- sagemaker/core/jumpstart/artifacts/metric_definitions.py +117 -0
- sagemaker/core/jumpstart/artifacts/model_packages.py +202 -0
- sagemaker/core/jumpstart/artifacts/model_uris.py +252 -0
- sagemaker/core/jumpstart/artifacts/payloads.py +96 -0
- sagemaker/core/jumpstart/artifacts/predictors.py +540 -0
- sagemaker/core/jumpstart/artifacts/resource_names.py +86 -0
- sagemaker/core/jumpstart/artifacts/resource_requirements.py +162 -0
- sagemaker/core/jumpstart/artifacts/script_uris.py +172 -0
- sagemaker/core/jumpstart/cache.py +663 -0
- sagemaker/core/jumpstart/configs.py +50 -0
- sagemaker/core/jumpstart/constants.py +198 -0
- sagemaker/core/jumpstart/deserializers.py +81 -0
- sagemaker/core/jumpstart/document.py +76 -0
- sagemaker/core/jumpstart/enums.py +168 -0
- sagemaker/core/jumpstart/exceptions.py +236 -0
- sagemaker/core/jumpstart/factory/utils.py +833 -0
- sagemaker/core/jumpstart/filters.py +597 -0
- sagemaker/core/jumpstart/hub/__init__.py +0 -0
- sagemaker/core/jumpstart/hub/constants.py +16 -0
- sagemaker/core/jumpstart/hub/hub.py +291 -0
- sagemaker/core/jumpstart/hub/interfaces.py +936 -0
- sagemaker/core/jumpstart/hub/parser_utils.py +70 -0
- sagemaker/core/jumpstart/hub/parsers.py +288 -0
- sagemaker/core/jumpstart/hub/types.py +35 -0
- sagemaker/core/jumpstart/hub/utils.py +260 -0
- sagemaker/core/jumpstart/models.py +499 -0
- sagemaker/core/jumpstart/notebook_utils.py +575 -0
- sagemaker/core/jumpstart/parameters.py +20 -0
- sagemaker/core/jumpstart/payload_utils.py +239 -0
- sagemaker/core/jumpstart/region_config.json +163 -0
- sagemaker/core/jumpstart/search.py +171 -0
- sagemaker/core/jumpstart/serializers.py +81 -0
- sagemaker/core/jumpstart/session_utils.py +234 -0
- sagemaker/core/jumpstart/types.py +3044 -0
- sagemaker/core/jumpstart/utils.py +1731 -0
- sagemaker/core/jumpstart/validators.py +257 -0
- sagemaker/core/lambda_helper.py +312 -0
- sagemaker/core/lineage/__init__.py +42 -0
- sagemaker/core/lineage/_api_types.py +239 -0
- sagemaker/core/lineage/_utils.py +49 -0
- sagemaker/core/lineage/action.py +345 -0
- sagemaker/core/lineage/artifact.py +646 -0
- sagemaker/core/lineage/association.py +190 -0
- sagemaker/core/lineage/context.py +505 -0
- sagemaker/core/lineage/lineage_trial_component.py +191 -0
- sagemaker/core/lineage/query.py +732 -0
- sagemaker/core/lineage/visualizer.py +346 -0
- sagemaker/core/local/__init__.py +18 -0
- sagemaker/core/local/data.py +413 -0
- sagemaker/core/local/entities.py +678 -0
- sagemaker/core/local/exceptions.py +17 -0
- sagemaker/core/local/image.py +1243 -0
- sagemaker/core/local/local_session.py +739 -0
- sagemaker/core/local/utils.py +245 -0
- sagemaker/core/logs.py +181 -0
- sagemaker/core/metadata_properties.py +56 -0
- sagemaker/core/metric_definitions.py +91 -0
- sagemaker/core/mlflow/__init__.py +38 -0
- sagemaker/core/mlflow/forward_sagemaker_metrics.py +44 -0
- sagemaker/core/model_card/__init__.py +26 -0
- sagemaker/core/model_life_cycle.py +51 -0
- sagemaker/core/model_metrics.py +160 -0
- sagemaker/core/model_monitor/__init__.py +66 -0
- sagemaker/core/model_monitor/clarify_model_monitoring.py +1495 -0
- sagemaker/core/model_monitor/cron_expression_generator.py +82 -0
- sagemaker/core/model_monitor/data_capture_config.py +115 -0
- sagemaker/core/model_monitor/data_quality_monitoring_config.py +66 -0
- sagemaker/core/model_monitor/dataset_format.py +102 -0
- sagemaker/core/model_monitor/model_monitoring.py +4266 -0
- sagemaker/core/model_monitor/monitoring_alert.py +76 -0
- sagemaker/core/model_monitor/monitoring_files.py +506 -0
- sagemaker/core/model_monitor/utils.py +793 -0
- sagemaker/core/model_registry.py +480 -0
- sagemaker/core/model_uris.py +97 -0
- sagemaker/core/modules/__init__.py +19 -0
- sagemaker/core/modules/configs.py +226 -0
- sagemaker/core/modules/constants.py +37 -0
- sagemaker/core/modules/distributed.py +182 -0
- sagemaker/core/modules/local_core/__init__.py +0 -0
- sagemaker/core/modules/local_core/local_container.py +605 -0
- sagemaker/core/modules/templates.py +83 -0
- sagemaker/core/modules/train/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/common/utils.py +213 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_driver.py +123 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
- sagemaker/core/modules/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
- sagemaker/core/modules/train/container_drivers/scripts/__init__.py +14 -0
- sagemaker/core/modules/train/container_drivers/scripts/environment.py +305 -0
- sagemaker/core/modules/train/sm_recipes/__init__.py +0 -0
- sagemaker/core/modules/train/sm_recipes/utils.py +330 -0
- sagemaker/core/modules/types.py +19 -0
- sagemaker/core/modules/utils.py +194 -0
- sagemaker/core/network.py +185 -0
- sagemaker/core/parameter.py +173 -0
- sagemaker/core/payloads.py +185 -0
- sagemaker/core/processing.py +1597 -0
- sagemaker/core/remote_function/__init__.py +19 -0
- sagemaker/core/remote_function/checkpoint_location.py +47 -0
- sagemaker/core/remote_function/client.py +1285 -0
- sagemaker/core/remote_function/core/__init__.py +0 -0
- sagemaker/core/remote_function/core/_custom_dispatch_table.py +72 -0
- sagemaker/core/remote_function/core/pipeline_variables.py +353 -0
- sagemaker/core/remote_function/core/serialization.py +422 -0
- sagemaker/core/remote_function/core/stored_function.py +226 -0
- sagemaker/core/remote_function/custom_file_filter.py +128 -0
- sagemaker/core/remote_function/errors.py +104 -0
- sagemaker/core/remote_function/invoke_function.py +172 -0
- sagemaker/core/remote_function/job.py +2140 -0
- sagemaker/core/remote_function/logging_config.py +38 -0
- sagemaker/core/remote_function/runtime_environment/__init__.py +14 -0
- sagemaker/core/remote_function/runtime_environment/bootstrap_runtime_environment.py +605 -0
- sagemaker/core/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
- sagemaker/core/remote_function/runtime_environment/runtime_environment_manager.py +554 -0
- sagemaker/core/remote_function/runtime_environment/spark_app.py +18 -0
- sagemaker/core/remote_function/spark_config.py +149 -0
- sagemaker/core/resource_requirements.py +168 -0
- {sagemaker_core/main → sagemaker/core}/resources.py +20121 -11728
- sagemaker/core/s3/__init__.py +41 -0
- sagemaker/core/s3/client.py +367 -0
- sagemaker/core/s3/utils.py +175 -0
- sagemaker/core/script_uris.py +93 -0
- sagemaker/core/serializers/__init__.py +11 -0
- sagemaker/core/serializers/base.py +510 -0
- sagemaker/core/serializers/implementations.py +159 -0
- sagemaker/core/serializers/utils.py +223 -0
- sagemaker/core/serverless_inference_config.py +63 -0
- sagemaker/core/session_settings.py +55 -0
- sagemaker/core/shapes/__init__.py +3 -0
- sagemaker/core/shapes/model_card_shapes.py +159 -0
- {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +6384 -1865
- sagemaker/core/spark/__init__.py +16 -0
- sagemaker/core/spark/defaults.py +16 -0
- sagemaker/core/spark/processing.py +1380 -0
- sagemaker/core/telemetry/__init__.py +23 -0
- sagemaker/core/telemetry/constants.py +84 -0
- sagemaker/core/telemetry/telemetry_logging.py +284 -0
- sagemaker/core/tools/__init__.py +1 -0
- {sagemaker_core → sagemaker/core}/tools/codegen.py +4 -4
- {sagemaker_core → sagemaker/core}/tools/constants.py +23 -15
- {sagemaker_core → sagemaker/core}/tools/data_extractor.py +1 -1
- {sagemaker_core → sagemaker/core}/tools/method.py +1 -1
- sagemaker/core/tools/model_card/generate_model_card_from_schema.py +562 -0
- {sagemaker_core → sagemaker/core}/tools/resources_codegen.py +165 -98
- {sagemaker_core → sagemaker/core}/tools/resources_extractor.py +5 -13
- {sagemaker_core → sagemaker/core}/tools/shapes_codegen.py +16 -17
- {sagemaker_core → sagemaker/core}/tools/shapes_extractor.py +29 -67
- {sagemaker_core → sagemaker/core}/tools/templates.py +39 -17
- sagemaker/core/training/__init__.py +14 -0
- sagemaker/core/training/configs.py +333 -0
- sagemaker/core/training/constants.py +37 -0
- sagemaker/core/training/utils.py +77 -0
- sagemaker/core/training_compiler/__init__.py +16 -0
- sagemaker/core/training_compiler/config.py +197 -0
- sagemaker/core/training_compiler_config.py +197 -0
- sagemaker/core/transformer.py +793 -0
- sagemaker/core/user_agent.py +76 -0
- sagemaker/core/utilities/__init__.py +24 -0
- sagemaker/core/utilities/cache.py +169 -0
- sagemaker/core/utilities/search_expression.py +133 -0
- sagemaker/core/utils/__init__.py +48 -0
- sagemaker/core/utils/code_injection/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/codec.py +2 -2
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/shape_dag.py +6479 -136
- {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
- sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
- {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
- {sagemaker_core/main → sagemaker/core/utils}/utils.py +25 -20
- sagemaker/core/workflow/__init__.py +152 -0
- sagemaker/core/workflow/conditions.py +313 -0
- sagemaker/core/workflow/entities.py +58 -0
- sagemaker/core/workflow/execution_variables.py +89 -0
- sagemaker/core/workflow/functions.py +193 -0
- sagemaker/core/workflow/parameters.py +222 -0
- sagemaker/core/workflow/pipeline_context.py +394 -0
- sagemaker/core/workflow/pipeline_definition_config.py +31 -0
- sagemaker/core/workflow/properties.py +285 -0
- sagemaker/core/workflow/step_outputs.py +65 -0
- sagemaker/core/workflow/utilities.py +507 -0
- sagemaker/lineage/__init__.py +33 -0
- sagemaker/lineage/action.py +28 -0
- sagemaker/lineage/artifact.py +28 -0
- sagemaker/lineage/context.py +28 -0
- sagemaker/lineage/lineage_trial_component.py +28 -0
- {sagemaker_core-1.0.47.dist-info → sagemaker_core-2.1.1.dist-info}/METADATA +28 -9
- sagemaker_core-2.1.1.dist-info/RECORD +355 -0
- sagemaker_core-2.1.1.dist-info/top_level.txt +1 -0
- sagemaker_core/__init__.py +0 -4
- sagemaker_core/_version.py +0 -3
- sagemaker_core/helper/session_helper.py +0 -769
- sagemaker_core/resources/__init__.py +0 -1
- sagemaker_core/shapes/__init__.py +0 -1
- sagemaker_core/tools/__init__.py +0 -1
- sagemaker_core-1.0.47.dist-info/RECORD +0 -35
- sagemaker_core-1.0.47.dist-info/top_level.txt +0 -1
- {sagemaker_core → sagemaker/core}/helper/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/huggingface/training_compiler}/__init__.py +0 -0
- {sagemaker_core/main/code_injection → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
- {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
- {sagemaker_core-1.0.47.dist-info → sagemaker_core-2.1.1.dist-info}/WHEEL +0 -0
- {sagemaker_core-1.0.47.dist-info → sagemaker_core-2.1.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -91,21 +91,21 @@ class TimeoutExceededError(WaiterError):
|
|
|
91
91
|
super().__init__(resource_type=resource_type, status=status, reason=reason)
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
###
|
|
95
|
-
class
|
|
96
|
-
"""Raised when an error occurs in the
|
|
94
|
+
### Intelligent Defaults Errors
|
|
95
|
+
class IntelligentDefaultsError(SageMakerCoreError):
|
|
96
|
+
"""Raised when an error occurs in the Intelligent Defaults"""
|
|
97
97
|
|
|
98
|
-
fmt = "An error occurred while loading Default
|
|
98
|
+
fmt = "An error occurred while loading Intelligent Default. {message}"
|
|
99
99
|
|
|
100
100
|
def __init__(self, message="", **kwargs):
|
|
101
|
-
"""Initialize an
|
|
101
|
+
"""Initialize an IntelligentDefaultsError exception.
|
|
102
102
|
Args:
|
|
103
103
|
message (str): A message describing the error.
|
|
104
104
|
"""
|
|
105
105
|
super().__init__(message=message, **kwargs)
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
class LocalConfigNotFoundError(
|
|
108
|
+
class LocalConfigNotFoundError(IntelligentDefaultsError):
|
|
109
109
|
"""Raised when a configuration file is not found in local file system"""
|
|
110
110
|
|
|
111
111
|
fmt = "Failed to load configuration file from location: {file_path}. {message}"
|
|
@@ -119,7 +119,7 @@ class LocalConfigNotFoundError(DefaultConfigsError):
|
|
|
119
119
|
super().__init__(file_path=file_path, message=message)
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
class S3ConfigNotFoundError(
|
|
122
|
+
class S3ConfigNotFoundError(IntelligentDefaultsError):
|
|
123
123
|
"""Raised when a configuration file is not found in S3"""
|
|
124
124
|
|
|
125
125
|
fmt = "Failed to load configuration file from S3 location: {s3_uri}. {message}"
|
|
@@ -133,7 +133,7 @@ class S3ConfigNotFoundError(DefaultConfigsError):
|
|
|
133
133
|
super().__init__(s3_uri=s3_uri, message=message)
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
class ConfigSchemaValidationError(
|
|
136
|
+
class ConfigSchemaValidationError(IntelligentDefaultsError, ValidationError):
|
|
137
137
|
"""Raised when a configuration file does not adhere to the schema"""
|
|
138
138
|
|
|
139
139
|
fmt = "Failed to validate configuration file from location: {file_path}. {message}"
|
sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py
RENAMED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
|
12
12
|
# language governing permissions and limitations under the License.
|
|
13
13
|
|
|
14
|
-
import logging
|
|
15
14
|
|
|
16
15
|
import os
|
|
17
16
|
import jsonschema
|
|
@@ -25,14 +24,14 @@ from platformdirs import site_config_dir, user_config_dir
|
|
|
25
24
|
|
|
26
25
|
from botocore.utils import merge_dicts
|
|
27
26
|
from six.moves.urllib.parse import urlparse
|
|
28
|
-
from
|
|
29
|
-
from
|
|
27
|
+
from sagemaker.core.config_schema import SAGEMAKER_PYTHON_SDK_CONFIG_SCHEMA
|
|
28
|
+
from sagemaker.core.utils.exceptions import (
|
|
30
29
|
LocalConfigNotFoundError,
|
|
31
30
|
S3ConfigNotFoundError,
|
|
32
|
-
|
|
31
|
+
IntelligentDefaultsError,
|
|
33
32
|
ConfigSchemaValidationError,
|
|
34
33
|
)
|
|
35
|
-
from
|
|
34
|
+
from sagemaker.core.utils.utils import get_textual_rich_logger
|
|
36
35
|
|
|
37
36
|
logger = get_textual_rich_logger(__name__)
|
|
38
37
|
|
|
@@ -116,7 +115,7 @@ def _load_config_from_s3(s3_uri, s3_resource_for_config) -> dict:
|
|
|
116
115
|
boto_session = boto3.DEFAULT_SESSION or boto3.Session()
|
|
117
116
|
boto_region_name = boto_session.region_name
|
|
118
117
|
if boto_region_name is None:
|
|
119
|
-
raise
|
|
118
|
+
raise IntelligentDefaultsError(
|
|
120
119
|
message=(
|
|
121
120
|
"Valid region is not provided in the Boto3 session."
|
|
122
121
|
+ "Setup local AWS configuration with a valid region supported by SageMaker."
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import boto3
|
|
2
1
|
import botocore
|
|
3
2
|
|
|
4
3
|
from boto3.session import Session
|
|
5
4
|
import botocore.client
|
|
6
5
|
from botocore.config import Config
|
|
7
6
|
from typing import Generator, Tuple, List
|
|
8
|
-
from
|
|
7
|
+
from sagemaker.core.utils.utils import SingletonMeta
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
class CloudWatchLogsClient(metaclass=SingletonMeta):
|
|
@@ -26,9 +26,9 @@ from rich.style import Style
|
|
|
26
26
|
from rich.theme import Theme
|
|
27
27
|
from rich.traceback import install
|
|
28
28
|
from typing import Any, Dict, List, TypeVar, Generic, Type
|
|
29
|
-
from
|
|
30
|
-
from
|
|
31
|
-
from
|
|
29
|
+
from sagemaker.core.utils.code_injection.codec import transform
|
|
30
|
+
from sagemaker.core.utils.code_injection.constants import Color
|
|
31
|
+
from sagemaker.core.utils.user_agent import get_user_agent_extra_suffix
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def add_indent(text, num_spaces=4):
|
|
@@ -182,11 +182,8 @@ def get_textual_rich_logger(name: str, log_level: str = "INFO") -> logging.Logge
|
|
|
182
182
|
"""
|
|
183
183
|
enable_textual_rich_console_and_traceback()
|
|
184
184
|
handler = get_rich_handler()
|
|
185
|
+
logging.basicConfig(level=getattr(logging, log_level), handlers=[handler])
|
|
185
186
|
logger = logging.getLogger(name)
|
|
186
|
-
for handler in logger.handlers:
|
|
187
|
-
logger.removeHandler(handler)
|
|
188
|
-
logger.addHandler(handler)
|
|
189
|
-
logger.setLevel(getattr(logging, log_level))
|
|
190
187
|
|
|
191
188
|
return logger
|
|
192
189
|
|
|
@@ -336,7 +333,7 @@ class SageMakerClient(metaclass=SingletonMeta):
|
|
|
336
333
|
Creates a boto3 client using the provided session, region, and service.
|
|
337
334
|
"""
|
|
338
335
|
if session is None:
|
|
339
|
-
logger.
|
|
336
|
+
logger.debug("No boto3 session provided. Creating a new session.")
|
|
340
337
|
session = Session(region_name=region_name)
|
|
341
338
|
|
|
342
339
|
if region_name is None:
|
|
@@ -344,13 +341,25 @@ class SageMakerClient(metaclass=SingletonMeta):
|
|
|
344
341
|
region_name = session.region_name
|
|
345
342
|
|
|
346
343
|
if config is None:
|
|
347
|
-
logger.
|
|
344
|
+
logger.debug("No config provided. Using default config.")
|
|
348
345
|
config = Config(retries={"max_attempts": 10, "mode": "standard"})
|
|
349
346
|
|
|
350
347
|
self.config = Config(user_agent_extra=get_user_agent_extra_suffix())
|
|
351
348
|
self.session = session
|
|
352
349
|
self.region_name = region_name
|
|
353
|
-
|
|
350
|
+
# Read region from environment variable, default to us-west-2
|
|
351
|
+
import os
|
|
352
|
+
env_region = os.environ.get('SAGEMAKER_REGION', region_name)
|
|
353
|
+
env_stage = os.environ.get('SAGEMAKER_STAGE', 'prod') # default to gamma
|
|
354
|
+
logger.info(f"Runs on sagemaker {env_stage}, region:{env_region}")
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
self.sagemaker_client = session.client(
|
|
358
|
+
"sagemaker",
|
|
359
|
+
region_name=env_region,
|
|
360
|
+
config=self.config,
|
|
361
|
+
)
|
|
362
|
+
|
|
354
363
|
self.sagemaker_runtime_client = session.client(
|
|
355
364
|
"sagemaker-runtime", region_name, config=self.config
|
|
356
365
|
)
|
|
@@ -387,7 +396,6 @@ class ResourceIterator(Generic[T]):
|
|
|
387
396
|
list_method: str,
|
|
388
397
|
list_method_kwargs: dict = {},
|
|
389
398
|
custom_key_mapping: dict = None,
|
|
390
|
-
extract_name_mapping: dict = None,
|
|
391
399
|
):
|
|
392
400
|
"""Initialize a ResourceIterator object
|
|
393
401
|
|
|
@@ -399,7 +407,6 @@ class ResourceIterator(Generic[T]):
|
|
|
399
407
|
list_method (str): The list method string used to make list calls to the client.
|
|
400
408
|
list_method_kwargs (dict, optional): The kwargs used to make list method calls. Defaults to {}.
|
|
401
409
|
custom_key_mapping (dict, optional): The custom key mapping used to map keys from summary object to those expected from resource object during initialization. Defaults to None.
|
|
402
|
-
extract_name_mapping (dict, optional): The extract name mapping used to extract names from arn in summary object and map to those expected from resource object during initialization. Defaults to None.
|
|
403
410
|
"""
|
|
404
411
|
self.summaries_key = summaries_key
|
|
405
412
|
self.summary_name = summary_name
|
|
@@ -407,7 +414,6 @@ class ResourceIterator(Generic[T]):
|
|
|
407
414
|
self.list_method = list_method
|
|
408
415
|
self.list_method_kwargs = list_method_kwargs
|
|
409
416
|
self.custom_key_mapping = custom_key_mapping
|
|
410
|
-
self.extract_name_mapping = extract_name_mapping
|
|
411
417
|
|
|
412
418
|
self.resource_cls = resource_cls
|
|
413
419
|
self.index = 0
|
|
@@ -436,12 +442,6 @@ class ResourceIterator(Generic[T]):
|
|
|
436
442
|
if self.custom_key_mapping:
|
|
437
443
|
init_data = {self.custom_key_mapping.get(k, k): v for k, v in init_data.items()}
|
|
438
444
|
|
|
439
|
-
# Extract name from arn. Currently implemented for HubContent and ImageVersion
|
|
440
|
-
if self.extract_name_mapping:
|
|
441
|
-
for arn, target in self.extract_name_mapping.items():
|
|
442
|
-
name = init_data[arn].split(target[0])[1].split("/")[0]
|
|
443
|
-
init_data.update({target[1]: name})
|
|
444
|
-
|
|
445
445
|
# Filter out the fields that are not in the resource class
|
|
446
446
|
fields = self.resource_cls.__annotations__
|
|
447
447
|
init_data = {k: v for k, v in init_data.items() if k in fields}
|
|
@@ -491,8 +491,13 @@ def serialize(value: Any) -> Any:
|
|
|
491
491
|
Returns:
|
|
492
492
|
Any: The serialized object
|
|
493
493
|
"""
|
|
494
|
-
|
|
494
|
+
from sagemaker.core.helper.pipeline_variable import PipelineVariable
|
|
495
|
+
|
|
496
|
+
if value is None or isinstance(value, type(Unassigned())):
|
|
495
497
|
return None
|
|
498
|
+
elif isinstance(value, PipelineVariable):
|
|
499
|
+
# Return PipelineVariables as-is (Join, ExecutionVariables, etc.)
|
|
500
|
+
return value
|
|
496
501
|
elif isinstance(value, Dict):
|
|
497
502
|
# if the value is a dict, use _serialize_dict() to serialize it recursively
|
|
498
503
|
return _serialize_dict(value)
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
"""Workflow primitives for SageMaker pipelines.
|
|
14
|
+
|
|
15
|
+
This module contains the foundation types and primitives used by workflow orchestration.
|
|
16
|
+
These primitives can be used by Train, Serve, and MLOps packages without creating
|
|
17
|
+
circular dependencies.
|
|
18
|
+
|
|
19
|
+
For pipeline and step orchestration classes (Pipeline, TrainingStep, etc.),
|
|
20
|
+
import from sagemaker.mlops.workflow instead.
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import absolute_import
|
|
23
|
+
|
|
24
|
+
from sagemaker.core.helper.pipeline_variable import PipelineVariable
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def is_pipeline_variable(var: object) -> bool:
|
|
28
|
+
"""Check if the variable is a pipeline variable
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
var (object): The variable to be verified.
|
|
32
|
+
Returns:
|
|
33
|
+
bool: True if it is, False otherwise.
|
|
34
|
+
"""
|
|
35
|
+
return isinstance(var, PipelineVariable)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def is_pipeline_parameter_string(var: object) -> bool:
|
|
39
|
+
"""Check if the variable is a pipeline parameter string
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
var (object): The variable to be verified.
|
|
43
|
+
Returns:
|
|
44
|
+
bool: True if it is, False otherwise.
|
|
45
|
+
"""
|
|
46
|
+
from sagemaker.core.workflow.parameters import ParameterString
|
|
47
|
+
|
|
48
|
+
return isinstance(var, ParameterString)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Entities
|
|
52
|
+
from sagemaker.core.workflow.entities import (
|
|
53
|
+
DefaultEnumMeta,
|
|
54
|
+
Entity,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Execution Variables
|
|
58
|
+
from sagemaker.core.workflow.execution_variables import (
|
|
59
|
+
ExecutionVariable,
|
|
60
|
+
ExecutionVariables,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Functions
|
|
64
|
+
from sagemaker.core.workflow.functions import (
|
|
65
|
+
Join,
|
|
66
|
+
JsonGet,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Parameters
|
|
70
|
+
from sagemaker.core.workflow.parameters import (
|
|
71
|
+
Parameter,
|
|
72
|
+
ParameterBoolean,
|
|
73
|
+
ParameterFloat,
|
|
74
|
+
ParameterInteger,
|
|
75
|
+
ParameterString,
|
|
76
|
+
ParameterTypeEnum,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Properties
|
|
80
|
+
from sagemaker.core.workflow.properties import (
|
|
81
|
+
Properties,
|
|
82
|
+
PropertiesList,
|
|
83
|
+
PropertiesMap,
|
|
84
|
+
PropertyFile,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Step Outputs (primitive - used by properties)
|
|
88
|
+
from sagemaker.core.workflow.step_outputs import (
|
|
89
|
+
StepOutput,
|
|
90
|
+
get_step,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Conditions (primitive)
|
|
94
|
+
from sagemaker.core.workflow.conditions import (
|
|
95
|
+
Condition,
|
|
96
|
+
ConditionComparison,
|
|
97
|
+
ConditionEquals,
|
|
98
|
+
ConditionGreaterThan,
|
|
99
|
+
ConditionGreaterThanOrEqualTo,
|
|
100
|
+
ConditionIn,
|
|
101
|
+
ConditionLessThan,
|
|
102
|
+
ConditionLessThanOrEqualTo,
|
|
103
|
+
ConditionNot,
|
|
104
|
+
ConditionOr,
|
|
105
|
+
ConditionTypeEnum,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# NOTE: Orchestration classes (Pipeline, TrainingStep, ProcessingStep, etc.) have moved
|
|
109
|
+
# to sagemaker.mlops.workflow. Import them from there instead:
|
|
110
|
+
# from sagemaker.mlops.workflow import Pipeline, TrainingStep, ProcessingStep
|
|
111
|
+
|
|
112
|
+
__all__ = [
|
|
113
|
+
# Helper functions
|
|
114
|
+
"is_pipeline_variable",
|
|
115
|
+
"is_pipeline_parameter_string",
|
|
116
|
+
# Entities (primitives)
|
|
117
|
+
"DefaultEnumMeta",
|
|
118
|
+
"Entity",
|
|
119
|
+
# Execution Variables (primitives)
|
|
120
|
+
"ExecutionVariable",
|
|
121
|
+
"ExecutionVariables",
|
|
122
|
+
# Functions (primitives)
|
|
123
|
+
"Join",
|
|
124
|
+
"JsonGet",
|
|
125
|
+
# Parameters (primitives)
|
|
126
|
+
"Parameter",
|
|
127
|
+
"ParameterBoolean",
|
|
128
|
+
"ParameterFloat",
|
|
129
|
+
"ParameterInteger",
|
|
130
|
+
"ParameterString",
|
|
131
|
+
"ParameterTypeEnum",
|
|
132
|
+
# Properties (primitives)
|
|
133
|
+
"Properties",
|
|
134
|
+
"PropertiesList",
|
|
135
|
+
"PropertiesMap",
|
|
136
|
+
"PropertyFile",
|
|
137
|
+
# Step Outputs (primitives)
|
|
138
|
+
"StepOutput",
|
|
139
|
+
"get_step",
|
|
140
|
+
# Conditions (primitives)
|
|
141
|
+
"Condition",
|
|
142
|
+
"ConditionComparison",
|
|
143
|
+
"ConditionEquals",
|
|
144
|
+
"ConditionGreaterThan",
|
|
145
|
+
"ConditionGreaterThanOrEqualTo",
|
|
146
|
+
"ConditionIn",
|
|
147
|
+
"ConditionLessThan",
|
|
148
|
+
"ConditionLessThanOrEqualTo",
|
|
149
|
+
"ConditionNot",
|
|
150
|
+
"ConditionOr",
|
|
151
|
+
"ConditionTypeEnum",
|
|
152
|
+
]
|
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
"""Conditions for condition steps.
|
|
14
|
+
|
|
15
|
+
Ideally, some of these comparison conditions would be implemented as "partial classes",
|
|
16
|
+
but use of functools.partial doesn't set correct metadata/type information.
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import absolute_import
|
|
19
|
+
|
|
20
|
+
import abc
|
|
21
|
+
|
|
22
|
+
from enum import Enum
|
|
23
|
+
from typing import Dict, List, Union
|
|
24
|
+
|
|
25
|
+
import attr
|
|
26
|
+
|
|
27
|
+
from sagemaker.core.workflow import is_pipeline_variable
|
|
28
|
+
from sagemaker.core.workflow.entities import (
|
|
29
|
+
DefaultEnumMeta,
|
|
30
|
+
Entity,
|
|
31
|
+
)
|
|
32
|
+
from sagemaker.core.helper.pipeline_variable import (
|
|
33
|
+
PrimitiveType,
|
|
34
|
+
RequestType,
|
|
35
|
+
PipelineVariable,
|
|
36
|
+
)
|
|
37
|
+
from sagemaker.core.workflow.execution_variables import ExecutionVariable
|
|
38
|
+
from sagemaker.core.workflow.parameters import Parameter
|
|
39
|
+
from sagemaker.core.workflow.properties import Properties
|
|
40
|
+
|
|
41
|
+
# TODO: consider base class for those with an expr method, rather than defining a type here
|
|
42
|
+
from sagemaker.core.workflow.step_outputs import StepOutput
|
|
43
|
+
|
|
44
|
+
ConditionValueType = Union[ExecutionVariable, Parameter, Properties, StepOutput]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ConditionTypeEnum(Enum, metaclass=DefaultEnumMeta):
|
|
48
|
+
"""Condition type enum."""
|
|
49
|
+
|
|
50
|
+
EQ = "Equals"
|
|
51
|
+
GT = "GreaterThan"
|
|
52
|
+
GTE = "GreaterThanOrEqualTo"
|
|
53
|
+
IN = "In"
|
|
54
|
+
LT = "LessThan"
|
|
55
|
+
LTE = "LessThanOrEqualTo"
|
|
56
|
+
NOT = "Not"
|
|
57
|
+
OR = "Or"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@attr.s
|
|
61
|
+
class Condition(Entity):
|
|
62
|
+
"""Abstract Condition entity.
|
|
63
|
+
|
|
64
|
+
Attributes:
|
|
65
|
+
condition_type (ConditionTypeEnum): The type of condition.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
condition_type: ConditionTypeEnum = attr.ib(factory=ConditionTypeEnum.factory)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
@abc.abstractmethod
|
|
72
|
+
def _referenced_steps(self) -> List[str]:
|
|
73
|
+
"""List of step names that this function depends on."""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@attr.s
|
|
77
|
+
class ConditionComparison(Condition):
|
|
78
|
+
"""Generic comparison condition that can be used to derive specific condition comparisons.
|
|
79
|
+
|
|
80
|
+
Attributes:
|
|
81
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable, parameter,
|
|
82
|
+
property, step output or Python primitive value to use in the comparison.
|
|
83
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
84
|
+
parameter, property, step output or Python primitive value to compare to.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
left: Union[ConditionValueType, PrimitiveType] = attr.ib(default=None)
|
|
88
|
+
right: Union[ConditionValueType, PrimitiveType] = attr.ib(default=None)
|
|
89
|
+
|
|
90
|
+
def to_request(self) -> RequestType:
|
|
91
|
+
"""Get the request structure for workflow service calls."""
|
|
92
|
+
return {
|
|
93
|
+
"Type": self.condition_type.value,
|
|
94
|
+
"LeftValue": self.left,
|
|
95
|
+
"RightValue": self.right,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def _referenced_steps(self) -> List[str]:
|
|
100
|
+
"""List of step names that this function depends on."""
|
|
101
|
+
steps = []
|
|
102
|
+
if isinstance(self.left, PipelineVariable):
|
|
103
|
+
steps.extend(self.left._referenced_steps)
|
|
104
|
+
if isinstance(self.right, PipelineVariable):
|
|
105
|
+
steps.extend(self.right._referenced_steps)
|
|
106
|
+
return steps
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ConditionEquals(ConditionComparison):
|
|
110
|
+
"""A condition for equality comparisons."""
|
|
111
|
+
|
|
112
|
+
def __init__(
|
|
113
|
+
self,
|
|
114
|
+
left: Union[ConditionValueType, PrimitiveType],
|
|
115
|
+
right: Union[ConditionValueType, PrimitiveType],
|
|
116
|
+
):
|
|
117
|
+
"""Construct A condition for equality comparisons.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
121
|
+
parameter, property, or Python primitive value to use in the comparison.
|
|
122
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution
|
|
123
|
+
variable, parameter, property, or Python primitive value to compare to.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
super(ConditionEquals, self).__init__(ConditionTypeEnum.EQ, left, right)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class ConditionGreaterThan(ConditionComparison):
|
|
130
|
+
"""A condition for greater than comparisons."""
|
|
131
|
+
|
|
132
|
+
def __init__(
|
|
133
|
+
self,
|
|
134
|
+
left: Union[ConditionValueType, PrimitiveType],
|
|
135
|
+
right: Union[ConditionValueType, PrimitiveType],
|
|
136
|
+
):
|
|
137
|
+
"""Construct an instance of ConditionGreaterThan for greater than comparisons.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
141
|
+
parameter, property, or Python primitive value to use in the comparison.
|
|
142
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution
|
|
143
|
+
variable, parameter, property, or Python primitive value to compare to.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
super(ConditionGreaterThan, self).__init__(ConditionTypeEnum.GT, left, right)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ConditionGreaterThanOrEqualTo(ConditionComparison):
|
|
150
|
+
"""A condition for greater than or equal to comparisons."""
|
|
151
|
+
|
|
152
|
+
def __init__(
|
|
153
|
+
self,
|
|
154
|
+
left: Union[ConditionValueType, PrimitiveType],
|
|
155
|
+
right: Union[ConditionValueType, PrimitiveType],
|
|
156
|
+
):
|
|
157
|
+
"""Construct of ConditionGreaterThanOrEqualTo for greater than or equal to comparisons.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
161
|
+
parameter, property, or Python primitive value to use in the comparison.
|
|
162
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution
|
|
163
|
+
variable, parameter, property, or Python primitive value to compare to.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
super(ConditionGreaterThanOrEqualTo, self).__init__(ConditionTypeEnum.GTE, left, right)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class ConditionLessThan(ConditionComparison):
|
|
170
|
+
"""A condition for less than comparisons."""
|
|
171
|
+
|
|
172
|
+
def __init__(
|
|
173
|
+
self,
|
|
174
|
+
left: Union[ConditionValueType, PrimitiveType],
|
|
175
|
+
right: Union[ConditionValueType, PrimitiveType],
|
|
176
|
+
):
|
|
177
|
+
"""Construct an instance of ConditionLessThan for less than comparisons.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
181
|
+
parameter, property, or Python primitive value to use in the comparison.
|
|
182
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution
|
|
183
|
+
variable, parameter, property, or Python primitive value to compare to.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
super(ConditionLessThan, self).__init__(ConditionTypeEnum.LT, left, right)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class ConditionLessThanOrEqualTo(ConditionComparison):
|
|
190
|
+
"""A condition for less than or equal to comparisons."""
|
|
191
|
+
|
|
192
|
+
def __init__(
|
|
193
|
+
self,
|
|
194
|
+
left: Union[ConditionValueType, PrimitiveType],
|
|
195
|
+
right: Union[ConditionValueType, PrimitiveType],
|
|
196
|
+
):
|
|
197
|
+
"""Construct ConditionLessThanOrEqualTo for less than or equal to comparisons.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
201
|
+
parameter, property, or Python primitive value to use in the comparison.
|
|
202
|
+
right (Union[ConditionValueType, PrimitiveType]): The execution
|
|
203
|
+
variable, parameter, property, or Python primitive value to compare to.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
super(ConditionLessThanOrEqualTo, self).__init__(ConditionTypeEnum.LTE, left, right)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class ConditionIn(Condition):
|
|
210
|
+
"""A condition to check membership."""
|
|
211
|
+
|
|
212
|
+
def __init__(
|
|
213
|
+
self,
|
|
214
|
+
value: Union[ConditionValueType, PrimitiveType],
|
|
215
|
+
in_values: List[Union[ConditionValueType, PrimitiveType]],
|
|
216
|
+
):
|
|
217
|
+
"""Construct a `ConditionIn` condition to check membership.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
value (Union[ConditionValueType, PrimitiveType]): The execution variable,
|
|
221
|
+
parameter, property or primitive value to check for membership.
|
|
222
|
+
in_values (List[Union[ConditionValueType, PrimitiveType]]): The list
|
|
223
|
+
of values to check for membership in.
|
|
224
|
+
"""
|
|
225
|
+
super(ConditionIn, self).__init__(ConditionTypeEnum.IN)
|
|
226
|
+
self.value = value
|
|
227
|
+
self.in_values = in_values
|
|
228
|
+
|
|
229
|
+
def to_request(self) -> RequestType:
|
|
230
|
+
"""Get the request structure for workflow service calls."""
|
|
231
|
+
return {
|
|
232
|
+
"Type": self.condition_type.value,
|
|
233
|
+
"QueryValue": self.value,
|
|
234
|
+
"Values": self.in_values,
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@property
|
|
238
|
+
def _referenced_steps(self) -> List[str]:
|
|
239
|
+
"""List of step names that this function depends on."""
|
|
240
|
+
steps = []
|
|
241
|
+
if isinstance(self.value, PipelineVariable):
|
|
242
|
+
steps.extend(self.value._referenced_steps)
|
|
243
|
+
for in_value in self.in_values:
|
|
244
|
+
if isinstance(in_value, PipelineVariable):
|
|
245
|
+
steps.extend(in_value._referenced_steps)
|
|
246
|
+
return steps
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class ConditionNot(Condition):
|
|
250
|
+
"""A condition for negating another `Condition`."""
|
|
251
|
+
|
|
252
|
+
def __init__(self, expression: Condition):
|
|
253
|
+
"""Construct a `ConditionNot` condition for negating another `Condition`.
|
|
254
|
+
|
|
255
|
+
Attributes:
|
|
256
|
+
expression (Condition): A `Condition` to take the negation of.
|
|
257
|
+
"""
|
|
258
|
+
super(ConditionNot, self).__init__(ConditionTypeEnum.NOT)
|
|
259
|
+
self.expression = expression
|
|
260
|
+
|
|
261
|
+
def to_request(self) -> RequestType:
|
|
262
|
+
"""Get the request structure for workflow service calls."""
|
|
263
|
+
return {"Type": self.condition_type.value, "Condition": self.expression.to_request()}
|
|
264
|
+
|
|
265
|
+
@property
|
|
266
|
+
def _referenced_steps(self) -> List[str]:
|
|
267
|
+
"""List of step names that this function depends on."""
|
|
268
|
+
return self.expression._referenced_steps
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class ConditionOr(Condition):
|
|
272
|
+
"""A condition for taking the logical OR of a list of `Condition` instances."""
|
|
273
|
+
|
|
274
|
+
def __init__(self, conditions: List[Condition] = None):
|
|
275
|
+
"""Construct a `ConditionOr` condition.
|
|
276
|
+
|
|
277
|
+
Attributes:
|
|
278
|
+
conditions (List[Condition]): A list of `Condition` instances to logically OR.
|
|
279
|
+
"""
|
|
280
|
+
super(ConditionOr, self).__init__(ConditionTypeEnum.OR)
|
|
281
|
+
self.conditions = conditions or []
|
|
282
|
+
|
|
283
|
+
def to_request(self) -> RequestType:
|
|
284
|
+
"""Get the request structure for workflow service calls."""
|
|
285
|
+
return {
|
|
286
|
+
"Type": self.condition_type.value,
|
|
287
|
+
"Conditions": [condition.to_request() for condition in self.conditions],
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@property
|
|
291
|
+
def _referenced_steps(self) -> List[str]:
|
|
292
|
+
"""List of step names that this function depends on."""
|
|
293
|
+
steps = []
|
|
294
|
+
for condition in self.conditions:
|
|
295
|
+
steps.extend(condition._referenced_steps)
|
|
296
|
+
return steps
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def primitive_or_expr(
|
|
300
|
+
value: Union[
|
|
301
|
+
ExecutionVariable, PipelineVariable, PrimitiveType, Parameter, Properties, StepOutput
|
|
302
|
+
],
|
|
303
|
+
) -> Union[Dict[str, str], PrimitiveType]:
|
|
304
|
+
"""Provide the expression of the value or return value if it is a primitive.
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
value (Union[ConditionValueType, PrimitiveType]): The value to evaluate.
|
|
308
|
+
Returns:
|
|
309
|
+
Either the expression of the value or the primitive value.
|
|
310
|
+
"""
|
|
311
|
+
if is_pipeline_variable(value):
|
|
312
|
+
return value.expr
|
|
313
|
+
return value
|