sagemaker-ops-cli 0.1.0__tar.gz → 0.2.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_ops_cli-0.2.0/PKG-INFO +336 -0
- sagemaker_ops_cli-0.2.0/README.md +316 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/pyproject.toml +1 -1
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops/__init__.py +1 -1
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops/aws.py +180 -13
- sagemaker_ops_cli-0.2.0/sagemaker_ops/cli.py +586 -0
- sagemaker_ops_cli-0.2.0/sagemaker_ops/config.py +57 -0
- sagemaker_ops_cli-0.2.0/sagemaker_ops/tui.py +882 -0
- sagemaker_ops_cli-0.2.0/sagemaker_ops_cli.egg-info/PKG-INFO +336 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops_cli.egg-info/SOURCES.txt +1 -0
- sagemaker_ops_cli-0.2.0/tests/test_e2e_moto.py +711 -0
- sagemaker_ops_cli-0.1.0/PKG-INFO +0 -241
- sagemaker_ops_cli-0.1.0/README.md +0 -221
- sagemaker_ops_cli-0.1.0/sagemaker_ops/cli.py +0 -262
- sagemaker_ops_cli-0.1.0/sagemaker_ops/tui.py +0 -458
- sagemaker_ops_cli-0.1.0/sagemaker_ops_cli.egg-info/PKG-INFO +0 -241
- sagemaker_ops_cli-0.1.0/tests/test_e2e_moto.py +0 -298
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops_cli.egg-info/dependency_links.txt +0 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops_cli.egg-info/entry_points.txt +0 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops_cli.egg-info/requires.txt +0 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/sagemaker_ops_cli.egg-info/top_level.txt +0 -0
- {sagemaker_ops_cli-0.1.0 → sagemaker_ops_cli-0.2.0}/setup.cfg +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sagemaker-ops-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: CLI and TUI for submitting and monitoring Amazon SageMaker Processing Jobs and Pipelines.
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: boto3>=1.34.0
|
|
8
|
+
Requires-Dist: botocore>=1.34.0
|
|
9
|
+
Requires-Dist: rich>=13.7.0
|
|
10
|
+
Requires-Dist: typer>=0.12.0
|
|
11
|
+
Requires-Dist: textual>=0.58.0
|
|
12
|
+
Provides-Extra: yaml
|
|
13
|
+
Requires-Dist: PyYAML>=6.0.0; extra == "yaml"
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
16
|
+
Requires-Dist: moto[logs,sagemaker]>=5.0.0; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.5.0; extra == "dev"
|
|
19
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
20
|
+
|
|
21
|
+
# SageMaker Ops CLI
|
|
22
|
+
|
|
23
|
+
`smops` is a command-line tool for operating Amazon SageMaker Processing Jobs and SageMaker Pipelines.
|
|
24
|
+
|
|
25
|
+
It can:
|
|
26
|
+
|
|
27
|
+
- Submit SageMaker Processing Jobs
|
|
28
|
+
- Start SageMaker Pipeline executions
|
|
29
|
+
- Show running Processing Jobs in an interactive TUI
|
|
30
|
+
- Show running and recently completed Pipeline executions in an interactive TUI
|
|
31
|
+
- Inspect Pipeline step status and failed step CloudWatch logs
|
|
32
|
+
- Work with one, many, or all configured AWS profiles
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install from PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install sagemaker-ops-cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The installed command is:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
smops --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Install from GitHub:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install git+https://github.com/southpolemonkey/smops.git
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Install from a local wheel:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install dist/sagemaker_ops_cli-0.2.0-py3-none-any.whl
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Install with Homebrew:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
brew tap southpolemonkey/smops https://github.com/southpolemonkey/smops
|
|
64
|
+
brew install sagemaker-ops-cli
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If the formula is later moved into a dedicated `southpolemonkey/homebrew-smops` tap repository, users can use the shorter command:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
brew tap southpolemonkey/smops
|
|
71
|
+
brew install sagemaker-ops-cli
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For local development:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python -m venv .venv
|
|
78
|
+
source .venv/bin/activate
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
To enable YAML config files:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install -e '.[yaml]'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Defaults
|
|
89
|
+
|
|
90
|
+
Set a default AWS region once so you do not need to pass `--region` on every command:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
smops config set-region ap-southeast-2
|
|
94
|
+
smops config get-region
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The config file is stored at `~/.config/smops/config.json` by default. You can inspect it with:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
smops config show
|
|
101
|
+
smops config path
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Region resolution order is:
|
|
105
|
+
|
|
106
|
+
1. `--region`
|
|
107
|
+
2. `SMOPS_DEFAULT_REGION`
|
|
108
|
+
3. `smops config set-region ...`
|
|
109
|
+
4. Region configured on the selected AWS profile
|
|
110
|
+
|
|
111
|
+
## Build The Python Package
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install -e '.[dev]'
|
|
115
|
+
python -m build
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Build artifacts are written to `dist/`:
|
|
119
|
+
|
|
120
|
+
- `sagemaker_ops_cli-0.2.0-py3-none-any.whl`
|
|
121
|
+
- `sagemaker_ops_cli-0.2.0.tar.gz`
|
|
122
|
+
|
|
123
|
+
## Submit A Processing Job
|
|
124
|
+
|
|
125
|
+
The config file uses the same parameter structure as boto3 `create_processing_job`.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
smops processing submit \
|
|
129
|
+
--profile dev \
|
|
130
|
+
--region us-east-1 \
|
|
131
|
+
--config examples/processing-job.json
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Validate the request without submitting it:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
smops processing submit --config examples/processing-job.json --dry-run
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Start A Pipeline Execution
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
smops pipeline start \
|
|
144
|
+
--profile dev \
|
|
145
|
+
--region us-east-1 \
|
|
146
|
+
--name my-pipeline \
|
|
147
|
+
--display-name manual-run-001 \
|
|
148
|
+
--parameter InputDate=2026-06-30 \
|
|
149
|
+
--parameter Mode=prod
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Interactive TUI
|
|
153
|
+
|
|
154
|
+
Open the TUI selector and choose between Pipelines and Processing Jobs:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
smops tui --profile dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Inside the TUI:
|
|
161
|
+
|
|
162
|
+
- `p` / `P`: switch to the next AWS profile from your local AWS config
|
|
163
|
+
- `s`: start a pipeline or submit a processing job from the current TUI
|
|
164
|
+
- `r`: refresh
|
|
165
|
+
- `q`: quit
|
|
166
|
+
|
|
167
|
+
For pipeline starts, enter the pipeline name, optional display name, and optional comma-separated parameters such as `InputDate=2026-07-01,Mode=test`. For processing job submits, enter the path to a JSON/YAML config file using the same structure as boto3 `create_processing_job`.
|
|
168
|
+
|
|
169
|
+
## Processing Jobs TUI
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
smops tui processing --profile dev --region us-east-1
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Multiple profiles:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
smops tui processing --profile dev --profile prod --region us-east-1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
All profiles:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
smops tui processing --all-profiles
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Keyboard shortcuts:
|
|
188
|
+
|
|
189
|
+
- `Up` / `Down` or `Left` / `Right`: switch jobs
|
|
190
|
+
- `p` / `P`: switch to the next AWS profile
|
|
191
|
+
- `s`: submit a Processing Job from a JSON/YAML config file
|
|
192
|
+
- `r`: refresh
|
|
193
|
+
- `q`: quit
|
|
194
|
+
|
|
195
|
+
## Pipelines TUI
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
smops tui pipelines --profile dev --region us-east-1
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Filter to one pipeline:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
By default, the TUI shows running executions plus executions completed within the last 3 hours, so you can inspect recent success and failure results. Use `--hours` to adjust the time window:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline --hours 6
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Keyboard shortcuts:
|
|
214
|
+
|
|
215
|
+
- `Left` / `Right`: switch focus between the executions and steps panels
|
|
216
|
+
- `Up` / `Down`: move within the focused panel
|
|
217
|
+
- `p` / `P`: switch to the next AWS profile
|
|
218
|
+
- `s`: start a Pipeline execution
|
|
219
|
+
- `l`: load the CloudWatch log tail for the selected failed step
|
|
220
|
+
- `r`: refresh
|
|
221
|
+
- `q`: quit
|
|
222
|
+
|
|
223
|
+
Log discovery is currently supported for these step job types:
|
|
224
|
+
|
|
225
|
+
- ProcessingJob: `/aws/sagemaker/ProcessingJobs`
|
|
226
|
+
- TrainingJob: `/aws/sagemaker/TrainingJobs`
|
|
227
|
+
- TransformJob: `/aws/sagemaker/TransformJobs`
|
|
228
|
+
|
|
229
|
+
## Non-Interactive Commands
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
smops processing list --profile dev --region us-east-1
|
|
233
|
+
smops processing wait --profile dev --region us-east-1 --name my-processing-job
|
|
234
|
+
smops pipeline list --profile dev --region us-east-1
|
|
235
|
+
smops pipeline list --profile dev --region us-east-1 --name my-pipeline --hours 6
|
|
236
|
+
smops pipeline steps --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
237
|
+
smops pipeline wait --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
238
|
+
smops pipeline inspect --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
239
|
+
smops pipeline diagnose --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Most non-interactive commands support `--json` for agents and automation:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
smops processing list --profile dev --region us-east-1 --json
|
|
246
|
+
smops processing wait --profile dev --region us-east-1 --name my-processing-job --json
|
|
247
|
+
smops pipeline start --profile dev --region us-east-1 --name my-pipeline --json
|
|
248
|
+
smops pipeline list --profile dev --region us-east-1 --json
|
|
249
|
+
smops pipeline steps --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
250
|
+
smops pipeline wait --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
251
|
+
smops pipeline inspect --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
252
|
+
smops pipeline diagnose --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
JSON responses use a stable envelope. Successful commands return `status: "ok"`; errors return `status: "error"` and a user-facing `error` message. List commands return `items`, `count`, and `next_token`.
|
|
256
|
+
|
|
257
|
+
`pipeline inspect` returns execution details, all steps, and failed steps. `pipeline diagnose` extends that with the first failed step, inferred SageMaker job type/name, CloudWatch log group and stream prefix, log tail, and suggested next actions.
|
|
258
|
+
|
|
259
|
+
`processing list` reads 20 running jobs per page by default. If the output includes `Next token`, pass it to fetch the next page:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
smops processing list --profile dev --region us-east-1 --max-results 20
|
|
263
|
+
smops processing list --profile dev --region us-east-1 --max-results 20 --next-token '<token>'
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
When `pipeline list` is used without `--name`, it scans 10 pipelines per page by default. This avoids long hangs in AWS accounts with many pipelines. If the output includes `Next token`, pass it to continue scanning:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10
|
|
270
|
+
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10 --next-token '<token>'
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## AWS Permissions
|
|
274
|
+
|
|
275
|
+
The AWS identity used by `smops` needs at least these permissions:
|
|
276
|
+
|
|
277
|
+
- `sagemaker:CreateProcessingJob`
|
|
278
|
+
- `sagemaker:StartPipelineExecution`
|
|
279
|
+
- `sagemaker:ListProcessingJobs`
|
|
280
|
+
- `sagemaker:DescribeProcessingJob`
|
|
281
|
+
- `sagemaker:ListPipelines`
|
|
282
|
+
- `sagemaker:ListPipelineExecutions`
|
|
283
|
+
- `sagemaker:DescribePipelineExecution`
|
|
284
|
+
- `sagemaker:ListPipelineExecutionSteps`
|
|
285
|
+
- `logs:DescribeLogStreams`
|
|
286
|
+
- `logs:GetLogEvents`
|
|
287
|
+
|
|
288
|
+
## Mock AWS Profile
|
|
289
|
+
|
|
290
|
+
This repository includes mock AWS config files for local demos of profile switching and CLI argument parsing. They do not write to your real `~/.aws` files:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
export AWS_CONFIG_FILE=examples/aws/config
|
|
294
|
+
export AWS_SHARED_CREDENTIALS_FILE=examples/aws/credentials
|
|
295
|
+
export AWS_PROFILE=mock-dev
|
|
296
|
+
export AWS_DEFAULT_REGION=us-east-1
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
You can also load the sample environment file directly:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
set -a
|
|
303
|
+
source examples/aws/mock.env
|
|
304
|
+
set +a
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Then run:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
smops processing submit --config examples/processing-job.json --dry-run
|
|
311
|
+
smops processing list --profile mock-dev
|
|
312
|
+
smops tui processing --profile mock-dev
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The bundled credentials are dummy values. They are only intended for dry runs, mock environments, local endpoints, or tests that use botocore Stubber/moto. They will not authenticate against real AWS.
|
|
316
|
+
|
|
317
|
+
## E2E Tests
|
|
318
|
+
|
|
319
|
+
The tests use `moto` to simulate AWS SageMaker and CloudWatch Logs. They do not call real AWS services:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
pip install -e '.[dev]'
|
|
323
|
+
pytest
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Coverage includes:
|
|
327
|
+
|
|
328
|
+
- Processing Job submission and paginated running job lists
|
|
329
|
+
- Pipeline execution start and active/recent execution lists
|
|
330
|
+
- Pipeline step status display
|
|
331
|
+
- Failed step CloudWatch Logs tailing
|
|
332
|
+
- Processing Job TUI keyboard navigation with up, down, left, and right
|
|
333
|
+
- Pipeline TUI execution, step, and failed log loading
|
|
334
|
+
- Multiple AWS profile resolution
|
|
335
|
+
|
|
336
|
+
Moto does not currently implement `list_pipeline_execution_steps`, so that paginator is faked in memory in the tests. The other SageMaker and CloudWatch Logs calls run inside the moto environment.
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# SageMaker Ops CLI
|
|
2
|
+
|
|
3
|
+
`smops` is a command-line tool for operating Amazon SageMaker Processing Jobs and SageMaker Pipelines.
|
|
4
|
+
|
|
5
|
+
It can:
|
|
6
|
+
|
|
7
|
+
- Submit SageMaker Processing Jobs
|
|
8
|
+
- Start SageMaker Pipeline executions
|
|
9
|
+
- Show running Processing Jobs in an interactive TUI
|
|
10
|
+
- Show running and recently completed Pipeline executions in an interactive TUI
|
|
11
|
+
- Inspect Pipeline step status and failed step CloudWatch logs
|
|
12
|
+
- Work with one, many, or all configured AWS profiles
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Install from PyPI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install sagemaker-ops-cli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The installed command is:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
smops --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Install from GitHub:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install git+https://github.com/southpolemonkey/smops.git
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Install from a local wheel:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install dist/sagemaker_ops_cli-0.2.0-py3-none-any.whl
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Install with Homebrew:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
brew tap southpolemonkey/smops https://github.com/southpolemonkey/smops
|
|
44
|
+
brew install sagemaker-ops-cli
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the formula is later moved into a dedicated `southpolemonkey/homebrew-smops` tap repository, users can use the shorter command:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
brew tap southpolemonkey/smops
|
|
51
|
+
brew install sagemaker-ops-cli
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For local development:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python -m venv .venv
|
|
58
|
+
source .venv/bin/activate
|
|
59
|
+
pip install -e .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To enable YAML config files:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -e '.[yaml]'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Defaults
|
|
69
|
+
|
|
70
|
+
Set a default AWS region once so you do not need to pass `--region` on every command:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
smops config set-region ap-southeast-2
|
|
74
|
+
smops config get-region
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The config file is stored at `~/.config/smops/config.json` by default. You can inspect it with:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
smops config show
|
|
81
|
+
smops config path
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Region resolution order is:
|
|
85
|
+
|
|
86
|
+
1. `--region`
|
|
87
|
+
2. `SMOPS_DEFAULT_REGION`
|
|
88
|
+
3. `smops config set-region ...`
|
|
89
|
+
4. Region configured on the selected AWS profile
|
|
90
|
+
|
|
91
|
+
## Build The Python Package
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install -e '.[dev]'
|
|
95
|
+
python -m build
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Build artifacts are written to `dist/`:
|
|
99
|
+
|
|
100
|
+
- `sagemaker_ops_cli-0.2.0-py3-none-any.whl`
|
|
101
|
+
- `sagemaker_ops_cli-0.2.0.tar.gz`
|
|
102
|
+
|
|
103
|
+
## Submit A Processing Job
|
|
104
|
+
|
|
105
|
+
The config file uses the same parameter structure as boto3 `create_processing_job`.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
smops processing submit \
|
|
109
|
+
--profile dev \
|
|
110
|
+
--region us-east-1 \
|
|
111
|
+
--config examples/processing-job.json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Validate the request without submitting it:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
smops processing submit --config examples/processing-job.json --dry-run
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Start A Pipeline Execution
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
smops pipeline start \
|
|
124
|
+
--profile dev \
|
|
125
|
+
--region us-east-1 \
|
|
126
|
+
--name my-pipeline \
|
|
127
|
+
--display-name manual-run-001 \
|
|
128
|
+
--parameter InputDate=2026-06-30 \
|
|
129
|
+
--parameter Mode=prod
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Interactive TUI
|
|
133
|
+
|
|
134
|
+
Open the TUI selector and choose between Pipelines and Processing Jobs:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
smops tui --profile dev
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Inside the TUI:
|
|
141
|
+
|
|
142
|
+
- `p` / `P`: switch to the next AWS profile from your local AWS config
|
|
143
|
+
- `s`: start a pipeline or submit a processing job from the current TUI
|
|
144
|
+
- `r`: refresh
|
|
145
|
+
- `q`: quit
|
|
146
|
+
|
|
147
|
+
For pipeline starts, enter the pipeline name, optional display name, and optional comma-separated parameters such as `InputDate=2026-07-01,Mode=test`. For processing job submits, enter the path to a JSON/YAML config file using the same structure as boto3 `create_processing_job`.
|
|
148
|
+
|
|
149
|
+
## Processing Jobs TUI
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
smops tui processing --profile dev --region us-east-1
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Multiple profiles:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
smops tui processing --profile dev --profile prod --region us-east-1
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
All profiles:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
smops tui processing --all-profiles
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Keyboard shortcuts:
|
|
168
|
+
|
|
169
|
+
- `Up` / `Down` or `Left` / `Right`: switch jobs
|
|
170
|
+
- `p` / `P`: switch to the next AWS profile
|
|
171
|
+
- `s`: submit a Processing Job from a JSON/YAML config file
|
|
172
|
+
- `r`: refresh
|
|
173
|
+
- `q`: quit
|
|
174
|
+
|
|
175
|
+
## Pipelines TUI
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
smops tui pipelines --profile dev --region us-east-1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Filter to one pipeline:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
By default, the TUI shows running executions plus executions completed within the last 3 hours, so you can inspect recent success and failure results. Use `--hours` to adjust the time window:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline --hours 6
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Keyboard shortcuts:
|
|
194
|
+
|
|
195
|
+
- `Left` / `Right`: switch focus between the executions and steps panels
|
|
196
|
+
- `Up` / `Down`: move within the focused panel
|
|
197
|
+
- `p` / `P`: switch to the next AWS profile
|
|
198
|
+
- `s`: start a Pipeline execution
|
|
199
|
+
- `l`: load the CloudWatch log tail for the selected failed step
|
|
200
|
+
- `r`: refresh
|
|
201
|
+
- `q`: quit
|
|
202
|
+
|
|
203
|
+
Log discovery is currently supported for these step job types:
|
|
204
|
+
|
|
205
|
+
- ProcessingJob: `/aws/sagemaker/ProcessingJobs`
|
|
206
|
+
- TrainingJob: `/aws/sagemaker/TrainingJobs`
|
|
207
|
+
- TransformJob: `/aws/sagemaker/TransformJobs`
|
|
208
|
+
|
|
209
|
+
## Non-Interactive Commands
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
smops processing list --profile dev --region us-east-1
|
|
213
|
+
smops processing wait --profile dev --region us-east-1 --name my-processing-job
|
|
214
|
+
smops pipeline list --profile dev --region us-east-1
|
|
215
|
+
smops pipeline list --profile dev --region us-east-1 --name my-pipeline --hours 6
|
|
216
|
+
smops pipeline steps --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
217
|
+
smops pipeline wait --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
218
|
+
smops pipeline inspect --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
219
|
+
smops pipeline diagnose --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Most non-interactive commands support `--json` for agents and automation:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
smops processing list --profile dev --region us-east-1 --json
|
|
226
|
+
smops processing wait --profile dev --region us-east-1 --name my-processing-job --json
|
|
227
|
+
smops pipeline start --profile dev --region us-east-1 --name my-pipeline --json
|
|
228
|
+
smops pipeline list --profile dev --region us-east-1 --json
|
|
229
|
+
smops pipeline steps --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
230
|
+
smops pipeline wait --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
231
|
+
smops pipeline inspect --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
232
|
+
smops pipeline diagnose --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:... --json
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
JSON responses use a stable envelope. Successful commands return `status: "ok"`; errors return `status: "error"` and a user-facing `error` message. List commands return `items`, `count`, and `next_token`.
|
|
236
|
+
|
|
237
|
+
`pipeline inspect` returns execution details, all steps, and failed steps. `pipeline diagnose` extends that with the first failed step, inferred SageMaker job type/name, CloudWatch log group and stream prefix, log tail, and suggested next actions.
|
|
238
|
+
|
|
239
|
+
`processing list` reads 20 running jobs per page by default. If the output includes `Next token`, pass it to fetch the next page:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
smops processing list --profile dev --region us-east-1 --max-results 20
|
|
243
|
+
smops processing list --profile dev --region us-east-1 --max-results 20 --next-token '<token>'
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
When `pipeline list` is used without `--name`, it scans 10 pipelines per page by default. This avoids long hangs in AWS accounts with many pipelines. If the output includes `Next token`, pass it to continue scanning:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10
|
|
250
|
+
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10 --next-token '<token>'
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## AWS Permissions
|
|
254
|
+
|
|
255
|
+
The AWS identity used by `smops` needs at least these permissions:
|
|
256
|
+
|
|
257
|
+
- `sagemaker:CreateProcessingJob`
|
|
258
|
+
- `sagemaker:StartPipelineExecution`
|
|
259
|
+
- `sagemaker:ListProcessingJobs`
|
|
260
|
+
- `sagemaker:DescribeProcessingJob`
|
|
261
|
+
- `sagemaker:ListPipelines`
|
|
262
|
+
- `sagemaker:ListPipelineExecutions`
|
|
263
|
+
- `sagemaker:DescribePipelineExecution`
|
|
264
|
+
- `sagemaker:ListPipelineExecutionSteps`
|
|
265
|
+
- `logs:DescribeLogStreams`
|
|
266
|
+
- `logs:GetLogEvents`
|
|
267
|
+
|
|
268
|
+
## Mock AWS Profile
|
|
269
|
+
|
|
270
|
+
This repository includes mock AWS config files for local demos of profile switching and CLI argument parsing. They do not write to your real `~/.aws` files:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
export AWS_CONFIG_FILE=examples/aws/config
|
|
274
|
+
export AWS_SHARED_CREDENTIALS_FILE=examples/aws/credentials
|
|
275
|
+
export AWS_PROFILE=mock-dev
|
|
276
|
+
export AWS_DEFAULT_REGION=us-east-1
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
You can also load the sample environment file directly:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
set -a
|
|
283
|
+
source examples/aws/mock.env
|
|
284
|
+
set +a
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Then run:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
smops processing submit --config examples/processing-job.json --dry-run
|
|
291
|
+
smops processing list --profile mock-dev
|
|
292
|
+
smops tui processing --profile mock-dev
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The bundled credentials are dummy values. They are only intended for dry runs, mock environments, local endpoints, or tests that use botocore Stubber/moto. They will not authenticate against real AWS.
|
|
296
|
+
|
|
297
|
+
## E2E Tests
|
|
298
|
+
|
|
299
|
+
The tests use `moto` to simulate AWS SageMaker and CloudWatch Logs. They do not call real AWS services:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
pip install -e '.[dev]'
|
|
303
|
+
pytest
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Coverage includes:
|
|
307
|
+
|
|
308
|
+
- Processing Job submission and paginated running job lists
|
|
309
|
+
- Pipeline execution start and active/recent execution lists
|
|
310
|
+
- Pipeline step status display
|
|
311
|
+
- Failed step CloudWatch Logs tailing
|
|
312
|
+
- Processing Job TUI keyboard navigation with up, down, left, and right
|
|
313
|
+
- Pipeline TUI execution, step, and failed log loading
|
|
314
|
+
- Multiple AWS profile resolution
|
|
315
|
+
|
|
316
|
+
Moto does not currently implement `list_pipeline_execution_steps`, so that paginator is faked in memory in the tests. The other SageMaker and CloudWatch Logs calls run inside the moto environment.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sagemaker-ops-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "CLI and TUI for submitting and monitoring Amazon SageMaker Processing Jobs and Pipelines."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|