sagemaker-mlops 1.0__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/mlops/__init__.py +33 -0
- sagemaker/mlops/local/__init__.py +24 -0
- sagemaker/mlops/local/exceptions.py +29 -0
- sagemaker/mlops/local/local_pipeline_session.py +154 -0
- sagemaker/mlops/local/pipeline.py +563 -0
- sagemaker/mlops/local/pipeline_entities.py +363 -0
- sagemaker/mlops/workflow/__init__.py +121 -0
- sagemaker/mlops/workflow/_event_bridge_client_helper.py +106 -0
- sagemaker/mlops/workflow/_repack_model.py +204 -0
- sagemaker/mlops/workflow/_steps_compiler.py +402 -0
- sagemaker/mlops/workflow/_utils.py +300 -0
- sagemaker/mlops/workflow/automl_step.py +184 -0
- sagemaker/mlops/workflow/callback_step.py +143 -0
- sagemaker/mlops/workflow/check_job_config.py +170 -0
- sagemaker/mlops/workflow/clarify_check_step.py +521 -0
- sagemaker/mlops/workflow/condition_step.py +91 -0
- sagemaker/mlops/workflow/emr_step.py +253 -0
- sagemaker/mlops/workflow/fail_step.py +73 -0
- sagemaker/mlops/workflow/function_step.py +618 -0
- sagemaker/mlops/workflow/lambda_step.py +166 -0
- sagemaker/mlops/workflow/model_step.py +303 -0
- sagemaker/mlops/workflow/monitor_batch_transform_step.py +157 -0
- sagemaker/mlops/workflow/notebook_job_step.py +598 -0
- sagemaker/mlops/workflow/parallelism_config.py +34 -0
- sagemaker/mlops/workflow/pipeline.py +1165 -0
- sagemaker/mlops/workflow/pipeline_experiment_config.py +94 -0
- sagemaker/mlops/workflow/quality_check_step.py +534 -0
- sagemaker/mlops/workflow/retry.py +212 -0
- sagemaker/mlops/workflow/selective_execution_config.py +64 -0
- sagemaker/mlops/workflow/step_collections.py +49 -0
- sagemaker/mlops/workflow/steps.py +788 -0
- sagemaker/mlops/workflow/triggers.py +165 -0
- sagemaker_mlops-1.0.dist-info/METADATA +143 -0
- sagemaker_mlops-1.0.dist-info/RECORD +37 -0
- sagemaker_mlops-1.0.dist-info/WHEEL +5 -0
- sagemaker_mlops-1.0.dist-info/top_level.txt +1 -0
sagemaker/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""SageMaker MLOps package for workflow orchestration and model building.
|
|
2
|
+
|
|
3
|
+
This package provides high-level orchestration capabilities for SageMaker workflows,
|
|
4
|
+
including pipeline definitions, step implementations, and model building utilities.
|
|
5
|
+
|
|
6
|
+
The MLOps package sits at the top of the dependency hierarchy and can import from:
|
|
7
|
+
- sagemaker.core (foundation primitives)
|
|
8
|
+
- sagemaker.train (training functionality)
|
|
9
|
+
- sagemaker.serve (serving functionality)
|
|
10
|
+
|
|
11
|
+
Key components:
|
|
12
|
+
- workflow: Pipeline and step orchestration
|
|
13
|
+
- model_builder: Model building and orchestration
|
|
14
|
+
|
|
15
|
+
Example usage:
|
|
16
|
+
from sagemaker.mlops import ModelBuilder
|
|
17
|
+
from sagemaker.mlops.workflow import Pipeline, TrainingStep
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import absolute_import
|
|
20
|
+
|
|
21
|
+
__version__ = "0.1.0"
|
|
22
|
+
|
|
23
|
+
# Model building
|
|
24
|
+
from sagemaker.serve.model_builder import ModelBuilder
|
|
25
|
+
|
|
26
|
+
# Workflow submodule is available via:
|
|
27
|
+
# from sagemaker.mlops import workflow
|
|
28
|
+
# from sagemaker.mlops.workflow import Pipeline, TrainingStep, etc.
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"ModelBuilder",
|
|
32
|
+
"workflow", # Submodule
|
|
33
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
"""Local pipeline execution for SageMaker MLOps."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
from sagemaker.mlops.local.local_pipeline_session import LocalPipelineSession # noqa: F401
|
|
17
|
+
|
|
18
|
+
# Pipeline execution is now in MLOps
|
|
19
|
+
# For backward compatibility, users should update imports:
|
|
20
|
+
# OLD: from sagemaker.core.local import LocalSession
|
|
21
|
+
# NEW: from sagemaker.core.local import LocalSession (for jobs)
|
|
22
|
+
# from sagemaker.mlops.local import LocalPipelineSession (for pipelines)
|
|
23
|
+
|
|
24
|
+
__all__ = ["LocalPipelineSession"]
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
"""Exceptions for local pipeline execution."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class StepExecutionException(Exception):
|
|
18
|
+
"""Exception raised when a pipeline step execution fails in local mode."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, step_name, message):
|
|
21
|
+
"""Initialize StepExecutionException.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
step_name (str): Name of the step that failed
|
|
25
|
+
message (str): Failure message
|
|
26
|
+
"""
|
|
27
|
+
self.step_name = step_name
|
|
28
|
+
self.message = message
|
|
29
|
+
super().__init__(f"Step '{step_name}' failed: {message}")
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
"""Local Pipeline Session - extends LocalSession with pipeline execution capabilities."""
|
|
14
|
+
from __future__ import absolute_import
|
|
15
|
+
|
|
16
|
+
import logging
|
|
17
|
+
from datetime import datetime
|
|
18
|
+
from botocore.exceptions import ClientError
|
|
19
|
+
|
|
20
|
+
from sagemaker.core.local import LocalSession
|
|
21
|
+
from sagemaker.core.telemetry.telemetry_logging import _telemetry_emitter
|
|
22
|
+
from sagemaker.core.telemetry.constants import Feature
|
|
23
|
+
from sagemaker.mlops.local.pipeline_entities import _LocalPipeline
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class LocalPipelineSession(LocalSession):
|
|
29
|
+
"""Extends LocalSession with pipeline execution capabilities.
|
|
30
|
+
|
|
31
|
+
This class provides local pipeline execution functionality that was previously
|
|
32
|
+
in LocalSession. It's now in the MLOps package since pipeline orchestration
|
|
33
|
+
is an MLOps concern.
|
|
34
|
+
|
|
35
|
+
Usage:
|
|
36
|
+
from sagemaker.mlops.local import LocalPipelineSession
|
|
37
|
+
from sagemaker.mlops.workflow import Pipeline
|
|
38
|
+
|
|
39
|
+
session = LocalPipelineSession()
|
|
40
|
+
session.create_pipeline(pipeline, "My pipeline")
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, *args, **kwargs):
|
|
44
|
+
"""Initialize LocalPipelineSession.
|
|
45
|
+
|
|
46
|
+
Accepts the same arguments as LocalSession.
|
|
47
|
+
"""
|
|
48
|
+
super().__init__(*args, **kwargs)
|
|
49
|
+
# Add pipeline storage to the sagemaker_client
|
|
50
|
+
if not hasattr(self.sagemaker_client, '_pipelines'):
|
|
51
|
+
self.sagemaker_client._pipelines = {}
|
|
52
|
+
|
|
53
|
+
@_telemetry_emitter(Feature.LOCAL_MODE, "local_pipeline_session.create_pipeline")
|
|
54
|
+
def create_pipeline(
|
|
55
|
+
self, pipeline, pipeline_description, **kwargs # pylint: disable=unused-argument
|
|
56
|
+
):
|
|
57
|
+
"""Create a local pipeline.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
pipeline (Pipeline): Pipeline object
|
|
61
|
+
pipeline_description (str): Description of the pipeline
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Pipeline metadata (PipelineArn)
|
|
65
|
+
"""
|
|
66
|
+
local_pipeline = _LocalPipeline(
|
|
67
|
+
pipeline=pipeline,
|
|
68
|
+
pipeline_description=pipeline_description,
|
|
69
|
+
local_session=self,
|
|
70
|
+
)
|
|
71
|
+
self.sagemaker_client._pipelines[pipeline.name] = local_pipeline
|
|
72
|
+
return {"PipelineArn": pipeline.name}
|
|
73
|
+
|
|
74
|
+
def update_pipeline(
|
|
75
|
+
self, pipeline, pipeline_description, **kwargs # pylint: disable=unused-argument
|
|
76
|
+
):
|
|
77
|
+
"""Update a local pipeline.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
pipeline (Pipeline): Pipeline object
|
|
81
|
+
pipeline_description (str): Description of the pipeline
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Pipeline metadata (PipelineArn)
|
|
85
|
+
"""
|
|
86
|
+
if pipeline.name not in self.sagemaker_client._pipelines:
|
|
87
|
+
error_response = {
|
|
88
|
+
"Error": {
|
|
89
|
+
"Code": "ResourceNotFound",
|
|
90
|
+
"Message": "Pipeline {} does not exist".format(pipeline.name),
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
raise ClientError(error_response, "update_pipeline")
|
|
94
|
+
self.sagemaker_client._pipelines[pipeline.name].pipeline_description = pipeline_description
|
|
95
|
+
self.sagemaker_client._pipelines[pipeline.name].pipeline = pipeline
|
|
96
|
+
self.sagemaker_client._pipelines[pipeline.name].last_modified_time = (
|
|
97
|
+
datetime.now().timestamp()
|
|
98
|
+
)
|
|
99
|
+
return {"PipelineArn": pipeline.name}
|
|
100
|
+
|
|
101
|
+
def describe_pipeline(self, PipelineName):
|
|
102
|
+
"""Describe the pipeline.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
PipelineName (str): Name of the pipeline
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Pipeline metadata (PipelineArn, PipelineDefinition, LastModifiedTime, etc)
|
|
109
|
+
"""
|
|
110
|
+
if PipelineName not in self.sagemaker_client._pipelines:
|
|
111
|
+
error_response = {
|
|
112
|
+
"Error": {
|
|
113
|
+
"Code": "ResourceNotFound",
|
|
114
|
+
"Message": "Pipeline {} does not exist".format(PipelineName),
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
raise ClientError(error_response, "describe_pipeline")
|
|
118
|
+
return self.sagemaker_client._pipelines[PipelineName].describe()
|
|
119
|
+
|
|
120
|
+
def delete_pipeline(self, PipelineName):
|
|
121
|
+
"""Delete the local pipeline.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
PipelineName (str): Name of the pipeline
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Pipeline metadata (PipelineArn)
|
|
128
|
+
"""
|
|
129
|
+
if PipelineName in self.sagemaker_client._pipelines:
|
|
130
|
+
del self.sagemaker_client._pipelines[PipelineName]
|
|
131
|
+
return {"PipelineArn": PipelineName}
|
|
132
|
+
|
|
133
|
+
def start_pipeline_execution(self, PipelineName, **kwargs):
|
|
134
|
+
"""Start the pipeline.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
PipelineName (str): Name of the pipeline
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
_LocalPipelineExecution object
|
|
141
|
+
"""
|
|
142
|
+
if "ParallelismConfiguration" in kwargs:
|
|
143
|
+
logger.warning("Parallelism configuration is not supported in local mode.")
|
|
144
|
+
if "SelectiveExecutionConfig" in kwargs:
|
|
145
|
+
raise ValueError("SelectiveExecutionConfig is not supported in local mode.")
|
|
146
|
+
if PipelineName not in self.sagemaker_client._pipelines:
|
|
147
|
+
error_response = {
|
|
148
|
+
"Error": {
|
|
149
|
+
"Code": "ResourceNotFound",
|
|
150
|
+
"Message": "Pipeline {} does not exist".format(PipelineName),
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
raise ClientError(error_response, "start_pipeline_execution")
|
|
154
|
+
return self.sagemaker_client._pipelines[PipelineName].start(**kwargs)
|