sagemaker-mlops 1.0__tar.gz
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_mlops-1.0/PKG-INFO +143 -0
- sagemaker_mlops-1.0/README.md +112 -0
- sagemaker_mlops-1.0/VERSION +1 -0
- sagemaker_mlops-1.0/pyproject.toml +81 -0
- sagemaker_mlops-1.0/setup.cfg +4 -0
- sagemaker_mlops-1.0/src/sagemaker/__init__.py +2 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/__init__.py +33 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/local/__init__.py +24 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/local/exceptions.py +29 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/local/local_pipeline_session.py +154 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/local/pipeline.py +563 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/local/pipeline_entities.py +363 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/__init__.py +121 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/_event_bridge_client_helper.py +106 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/_repack_model.py +204 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/_steps_compiler.py +402 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/_utils.py +300 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/automl_step.py +184 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/callback_step.py +143 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/check_job_config.py +170 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/clarify_check_step.py +521 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/condition_step.py +91 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/emr_step.py +253 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/fail_step.py +73 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/function_step.py +618 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/lambda_step.py +166 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/model_step.py +303 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/monitor_batch_transform_step.py +157 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/notebook_job_step.py +598 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/parallelism_config.py +34 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/pipeline.py +1165 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/pipeline_experiment_config.py +94 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/quality_check_step.py +534 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/retry.py +212 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/selective_execution_config.py +64 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/step_collections.py +49 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/steps.py +788 -0
- sagemaker_mlops-1.0/src/sagemaker/mlops/workflow/triggers.py +165 -0
- sagemaker_mlops-1.0/src/sagemaker_mlops.egg-info/PKG-INFO +143 -0
- sagemaker_mlops-1.0/src/sagemaker_mlops.egg-info/SOURCES.txt +41 -0
- sagemaker_mlops-1.0/src/sagemaker_mlops.egg-info/dependency_links.txt +1 -0
- sagemaker_mlops-1.0/src/sagemaker_mlops.egg-info/requires.txt +17 -0
- sagemaker_mlops-1.0/src/sagemaker_mlops.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sagemaker-mlops
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: SageMaker MLOps package for workflow orchestration and model building
|
|
5
|
+
Author: Amazon Web Services
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: sagemaker-core>=2.0.0
|
|
17
|
+
Requires-Dist: sagemaker-train>=0.1.0
|
|
18
|
+
Requires-Dist: sagemaker-serve>=0.1.0
|
|
19
|
+
Requires-Dist: boto3<2.0,>=1.35.75
|
|
20
|
+
Requires-Dist: botocore<2.0,>=1.35.75
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest; extra == "test"
|
|
23
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
24
|
+
Requires-Dist: mock; extra == "test"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
28
|
+
Requires-Dist: mock; extra == "dev"
|
|
29
|
+
Requires-Dist: black; extra == "dev"
|
|
30
|
+
Requires-Dist: flake8; extra == "dev"
|
|
31
|
+
|
|
32
|
+
# SageMaker MLOps Package
|
|
33
|
+
|
|
34
|
+
The `sagemaker-mlops` package provides high-level orchestration capabilities for Amazon SageMaker workflows, including pipeline definitions, step implementations, and model building utilities.
|
|
35
|
+
|
|
36
|
+
## Purpose
|
|
37
|
+
|
|
38
|
+
This package sits at the top of the SageMaker SDK dependency hierarchy and orchestrates components from the Core, Train, and Serve packages. It resolves architectural violations by providing a dedicated home for workflow orchestration logic that needs to import from multiple lower-level packages.
|
|
39
|
+
|
|
40
|
+
## Architecture
|
|
41
|
+
|
|
42
|
+
The SageMaker SDK follows a clean 4-package architecture:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
46
|
+
│ Package Architecture │
|
|
47
|
+
└─────────────────────────────────────────────────────────────┘
|
|
48
|
+
|
|
49
|
+
MLOps (orchestration)
|
|
50
|
+
↙ ↓ ↘
|
|
51
|
+
Train Core Serve
|
|
52
|
+
↘ ↓ ↙
|
|
53
|
+
Core
|
|
54
|
+
|
|
55
|
+
Dependency Rules:
|
|
56
|
+
✓ Core → nothing (foundation layer)
|
|
57
|
+
✓ Train → Core only
|
|
58
|
+
✓ Serve → Core only
|
|
59
|
+
✓ MLOps → Train, Serve, Core (orchestration layer)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Package Responsibilities
|
|
63
|
+
|
|
64
|
+
- **sagemaker-core**: Foundation primitives (entities, parameters, functions, conditions, properties)
|
|
65
|
+
- **sagemaker-train**: Training functionality (estimators, processors, tuners)
|
|
66
|
+
- **sagemaker-serve**: Serving functionality (models, predictors, endpoints)
|
|
67
|
+
- **sagemaker-mlops**: Workflow orchestration (pipelines, steps, model building)
|
|
68
|
+
|
|
69
|
+
## What's in This Package
|
|
70
|
+
|
|
71
|
+
### Workflow Orchestration (from Core)
|
|
72
|
+
|
|
73
|
+
The following files were moved from `sagemaker-core/src/sagemaker/core/workflow/` to establish clean architectural boundaries:
|
|
74
|
+
|
|
75
|
+
**Core Orchestration (2 files):**
|
|
76
|
+
- `pipeline.py` - Pipeline class for workflow definition
|
|
77
|
+
- `steps.py` - Base Step class and common step logic
|
|
78
|
+
|
|
79
|
+
**Step Implementations (13 files):**
|
|
80
|
+
- `automl_step.py` - AutoML training steps
|
|
81
|
+
- `model_step.py` - Model creation and registration steps
|
|
82
|
+
- `callback_step.py` - Callback steps for custom logic
|
|
83
|
+
- `clarify_check_step.py` - Model bias and explainability checks
|
|
84
|
+
- `condition_step.py` - Conditional execution steps
|
|
85
|
+
- `emr_step.py` - EMR cluster steps
|
|
86
|
+
- `fail_step.py` - Explicit failure steps
|
|
87
|
+
- `function_step.py` - Lambda function steps
|
|
88
|
+
- `lambda_step.py` - AWS Lambda invocation steps
|
|
89
|
+
- `monitor_batch_transform_step.py` - Batch transform monitoring
|
|
90
|
+
- `notebook_job_step.py` - Notebook execution steps
|
|
91
|
+
- `quality_check_step.py` - Model quality checks
|
|
92
|
+
- `step_collections.py` - Step collection utilities
|
|
93
|
+
- `step_outputs.py` - Step output handling
|
|
94
|
+
|
|
95
|
+
**Utilities (6 files):**
|
|
96
|
+
- `_utils.py` - Internal utilities
|
|
97
|
+
- `_steps_compiler.py` - Step compilation logic
|
|
98
|
+
- `_repack_model.py` - Model repackaging utilities
|
|
99
|
+
- `_event_bridge_client_helper.py` - EventBridge integration
|
|
100
|
+
- `triggers.py` - Pipeline triggers
|
|
101
|
+
- `utilities.py` - Public utility functions
|
|
102
|
+
|
|
103
|
+
**Configuration (6 files):**
|
|
104
|
+
- `check_job_config.py` - Quality check configuration
|
|
105
|
+
- `parallelism_config.py` - Parallel execution configuration
|
|
106
|
+
- `pipeline_definition_config.py` - Pipeline definition settings
|
|
107
|
+
- `pipeline_experiment_config.py` - Experiment tracking configuration
|
|
108
|
+
- `retry.py` - Retry policies
|
|
109
|
+
- `selective_execution_config.py` - Selective execution settings
|
|
110
|
+
|
|
111
|
+
### Model Building
|
|
112
|
+
|
|
113
|
+
ModelBuilder is now located in the `sagemaker-serve` package but is re-exported from MLOps for convenience.
|
|
114
|
+
|
|
115
|
+
### What Stayed in Core
|
|
116
|
+
|
|
117
|
+
The following primitive files remain in `sagemaker-core/src/sagemaker/core/workflow/`:
|
|
118
|
+
|
|
119
|
+
- `entities.py` - Base Entity and PipelineVariable classes
|
|
120
|
+
- `parameters.py` - Parameter type definitions
|
|
121
|
+
- `functions.py` - Pipeline functions (Join, JsonGet)
|
|
122
|
+
- `execution_variables.py` - ExecutionVariable
|
|
123
|
+
- `conditions.py` - Condition primitives
|
|
124
|
+
- `properties.py` - Property definitions
|
|
125
|
+
- `pipeline_context.py` - PipelineSession (refactored to remove Train/Serve imports)
|
|
126
|
+
- `__init__.py` - Package initialization
|
|
127
|
+
|
|
128
|
+
## Installation
|
|
129
|
+
|
|
130
|
+
Install the package in editable mode for development:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install -e sagemaker-mlops
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or install all SageMaker packages together:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pip install -e sagemaker-core
|
|
140
|
+
pip install -e sagemaker-train
|
|
141
|
+
pip install -e sagemaker-serve
|
|
142
|
+
pip install -e sagemaker-mlops
|
|
143
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# SageMaker MLOps Package
|
|
2
|
+
|
|
3
|
+
The `sagemaker-mlops` package provides high-level orchestration capabilities for Amazon SageMaker workflows, including pipeline definitions, step implementations, and model building utilities.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package sits at the top of the SageMaker SDK dependency hierarchy and orchestrates components from the Core, Train, and Serve packages. It resolves architectural violations by providing a dedicated home for workflow orchestration logic that needs to import from multiple lower-level packages.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
The SageMaker SDK follows a clean 4-package architecture:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
15
|
+
│ Package Architecture │
|
|
16
|
+
└─────────────────────────────────────────────────────────────┘
|
|
17
|
+
|
|
18
|
+
MLOps (orchestration)
|
|
19
|
+
↙ ↓ ↘
|
|
20
|
+
Train Core Serve
|
|
21
|
+
↘ ↓ ↙
|
|
22
|
+
Core
|
|
23
|
+
|
|
24
|
+
Dependency Rules:
|
|
25
|
+
✓ Core → nothing (foundation layer)
|
|
26
|
+
✓ Train → Core only
|
|
27
|
+
✓ Serve → Core only
|
|
28
|
+
✓ MLOps → Train, Serve, Core (orchestration layer)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Package Responsibilities
|
|
32
|
+
|
|
33
|
+
- **sagemaker-core**: Foundation primitives (entities, parameters, functions, conditions, properties)
|
|
34
|
+
- **sagemaker-train**: Training functionality (estimators, processors, tuners)
|
|
35
|
+
- **sagemaker-serve**: Serving functionality (models, predictors, endpoints)
|
|
36
|
+
- **sagemaker-mlops**: Workflow orchestration (pipelines, steps, model building)
|
|
37
|
+
|
|
38
|
+
## What's in This Package
|
|
39
|
+
|
|
40
|
+
### Workflow Orchestration (from Core)
|
|
41
|
+
|
|
42
|
+
The following files were moved from `sagemaker-core/src/sagemaker/core/workflow/` to establish clean architectural boundaries:
|
|
43
|
+
|
|
44
|
+
**Core Orchestration (2 files):**
|
|
45
|
+
- `pipeline.py` - Pipeline class for workflow definition
|
|
46
|
+
- `steps.py` - Base Step class and common step logic
|
|
47
|
+
|
|
48
|
+
**Step Implementations (13 files):**
|
|
49
|
+
- `automl_step.py` - AutoML training steps
|
|
50
|
+
- `model_step.py` - Model creation and registration steps
|
|
51
|
+
- `callback_step.py` - Callback steps for custom logic
|
|
52
|
+
- `clarify_check_step.py` - Model bias and explainability checks
|
|
53
|
+
- `condition_step.py` - Conditional execution steps
|
|
54
|
+
- `emr_step.py` - EMR cluster steps
|
|
55
|
+
- `fail_step.py` - Explicit failure steps
|
|
56
|
+
- `function_step.py` - Lambda function steps
|
|
57
|
+
- `lambda_step.py` - AWS Lambda invocation steps
|
|
58
|
+
- `monitor_batch_transform_step.py` - Batch transform monitoring
|
|
59
|
+
- `notebook_job_step.py` - Notebook execution steps
|
|
60
|
+
- `quality_check_step.py` - Model quality checks
|
|
61
|
+
- `step_collections.py` - Step collection utilities
|
|
62
|
+
- `step_outputs.py` - Step output handling
|
|
63
|
+
|
|
64
|
+
**Utilities (6 files):**
|
|
65
|
+
- `_utils.py` - Internal utilities
|
|
66
|
+
- `_steps_compiler.py` - Step compilation logic
|
|
67
|
+
- `_repack_model.py` - Model repackaging utilities
|
|
68
|
+
- `_event_bridge_client_helper.py` - EventBridge integration
|
|
69
|
+
- `triggers.py` - Pipeline triggers
|
|
70
|
+
- `utilities.py` - Public utility functions
|
|
71
|
+
|
|
72
|
+
**Configuration (6 files):**
|
|
73
|
+
- `check_job_config.py` - Quality check configuration
|
|
74
|
+
- `parallelism_config.py` - Parallel execution configuration
|
|
75
|
+
- `pipeline_definition_config.py` - Pipeline definition settings
|
|
76
|
+
- `pipeline_experiment_config.py` - Experiment tracking configuration
|
|
77
|
+
- `retry.py` - Retry policies
|
|
78
|
+
- `selective_execution_config.py` - Selective execution settings
|
|
79
|
+
|
|
80
|
+
### Model Building
|
|
81
|
+
|
|
82
|
+
ModelBuilder is now located in the `sagemaker-serve` package but is re-exported from MLOps for convenience.
|
|
83
|
+
|
|
84
|
+
### What Stayed in Core
|
|
85
|
+
|
|
86
|
+
The following primitive files remain in `sagemaker-core/src/sagemaker/core/workflow/`:
|
|
87
|
+
|
|
88
|
+
- `entities.py` - Base Entity and PipelineVariable classes
|
|
89
|
+
- `parameters.py` - Parameter type definitions
|
|
90
|
+
- `functions.py` - Pipeline functions (Join, JsonGet)
|
|
91
|
+
- `execution_variables.py` - ExecutionVariable
|
|
92
|
+
- `conditions.py` - Condition primitives
|
|
93
|
+
- `properties.py` - Property definitions
|
|
94
|
+
- `pipeline_context.py` - PipelineSession (refactored to remove Train/Serve imports)
|
|
95
|
+
- `__init__.py` - Package initialization
|
|
96
|
+
|
|
97
|
+
## Installation
|
|
98
|
+
|
|
99
|
+
Install the package in editable mode for development:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install -e sagemaker-mlops
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or install all SageMaker packages together:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install -e sagemaker-core
|
|
109
|
+
pip install -e sagemaker-train
|
|
110
|
+
pip install -e sagemaker-serve
|
|
111
|
+
pip install -e sagemaker-mlops
|
|
112
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sagemaker-mlops"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "SageMaker MLOps package for workflow orchestration and model building"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Amazon Web Services"},
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"sagemaker-core>=2.0.0",
|
|
26
|
+
"sagemaker-train>=0.1.0",
|
|
27
|
+
"sagemaker-serve>=0.1.0",
|
|
28
|
+
"boto3>=1.35.75,<2.0",
|
|
29
|
+
"botocore>=1.35.75,<2.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
test = [
|
|
34
|
+
"pytest",
|
|
35
|
+
"pytest-cov",
|
|
36
|
+
"mock",
|
|
37
|
+
]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest",
|
|
40
|
+
"pytest-cov",
|
|
41
|
+
"mock",
|
|
42
|
+
"black",
|
|
43
|
+
"flake8",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools]
|
|
47
|
+
package-dir = {"" = "src"}
|
|
48
|
+
include-package-data = true
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.dynamic]
|
|
51
|
+
version = { file = "VERSION"}
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
include = ["sagemaker*"]
|
|
56
|
+
namespaces = true
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
python_files = ["test_*.py"]
|
|
61
|
+
python_classes = ["Test*"]
|
|
62
|
+
python_functions = ["test_*"]
|
|
63
|
+
addopts = "-v --tb=short"
|
|
64
|
+
|
|
65
|
+
[tool.black]
|
|
66
|
+
line-length = 100
|
|
67
|
+
target-version = ['py38']
|
|
68
|
+
include = '\.pyi?$'
|
|
69
|
+
extend-exclude = '''
|
|
70
|
+
/(
|
|
71
|
+
# directories
|
|
72
|
+
\.eggs
|
|
73
|
+
| \.git
|
|
74
|
+
| \.hg
|
|
75
|
+
| \.mypy_cache
|
|
76
|
+
| \.tox
|
|
77
|
+
| \.venv
|
|
78
|
+
| build
|
|
79
|
+
| dist
|
|
80
|
+
)/
|
|
81
|
+
'''
|
|
@@ -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)
|