CLI and TUI for submitting and monitoring Amazon SageMaker Processing Jobs and Pipelines.
Project description
SageMaker Ops CLI
smops 是一个面向 SageMaker Processing Job 和 SageMaker Pipeline 的命令行工具:
- 提交 SageMaker Processing Job
- 启动 SageMaker Pipeline execution
- 用 TUI 查看正在运行的 Processing Jobs
- 用 TUI 查看正在运行和最近结束的 Pipeline executions、steps 状态和失败 step 的 CloudWatch 日志尾部
- 支持单个、多个或所有 AWS profiles
安装
python -m venv .venv
source .venv/bin/activate
pip install -e .
从 GitHub 直接安装:
pip install git+https://github.com/southpolemonkey/smops.git
从本地 wheel 安装:
pip install dist/sagemaker_ops_cli-0.1.0-py3-none-any.whl
如果要读取 YAML 配置:
pip install -e '.[yaml]'
构建 Python 包
pip install -e '.[dev]'
python -m build
构建产物会输出到 dist/:
sagemaker_ops_cli-0.1.0-py3-none-any.whlsagemaker_ops_cli-0.1.0.tar.gz
提交 Processing Job
配置文件直接使用 boto3 create_processing_job 的参数结构。
smops processing submit \
--profile dev \
--region us-east-1 \
--config examples/processing-job.json
只检查请求内容,不提交:
smops processing submit --config examples/processing-job.json --dry-run
启动 Pipeline
smops pipeline start \
--profile dev \
--region us-east-1 \
--name my-pipeline \
--display-name manual-run-001 \
--parameter InputDate=2026-06-30 \
--parameter Mode=prod
TUI 查看 Processing Jobs
smops tui processing --profile dev --region us-east-1
多个 profile:
smops tui processing --profile dev --profile prod --region us-east-1
所有 profile:
smops tui processing --all-profiles
快捷键:
↑/↓或←/→切换 jobr刷新q退出
TUI 查看 Pipelines
smops tui pipelines --profile dev --region us-east-1
只看某个 pipeline:
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline
默认会显示正在运行的 executions,以及最近 3 小时内结束的 executions,方便查看成功/失败结果。可以用 --hours 调整窗口:
smops tui pipelines --profile dev --region us-east-1 --name my-pipeline --hours 6
快捷键:
←/→在 executions 和 steps 面板之间切换↑/↓移动当前面板选中行l加载选中失败 step 的 CloudWatch 日志尾部r刷新q退出
目前自动支持这些 step 的日志定位:
- ProcessingJob:
/aws/sagemaker/ProcessingJobs - TrainingJob:
/aws/sagemaker/TrainingJobs - TransformJob:
/aws/sagemaker/TransformJobs
非交互式查看
smops processing list --profile dev --region us-east-1
smops pipeline list --profile dev --region us-east-1
smops pipeline list --profile dev --region us-east-1 --name my-pipeline --hours 6
smops pipeline steps --profile dev --region us-east-1 --execution-arn arn:aws:sagemaker:...
processing list 默认每页读取 20 个 running jobs。输出 Next token 时,用它继续翻页:
smops processing list --profile dev --region us-east-1 --max-results 20
smops processing list --profile dev --region us-east-1 --max-results 20 --next-token '<token>'
pipeline list 不传 --name 时默认每页只扫描 10 个 pipelines,避免真实账号里 pipelines 很多时卡住。输出 Next token 时,用它继续翻页:
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10
smops pipeline list --profile dev --region us-east-1 --pipeline-page-size 10 --next-token '<token>'
AWS 权限
运行账号需要至少具备这些权限:
sagemaker:CreateProcessingJobsagemaker:StartPipelineExecutionsagemaker:ListProcessingJobssagemaker:DescribeProcessingJobsagemaker:ListPipelinessagemaker:ListPipelineExecutionssagemaker:DescribePipelineExecutionsagemaker:ListPipelineExecutionStepslogs:DescribeLogStreamslogs:GetLogEvents
Mock AWS Profile
仓库里提供了一套 mock AWS 配置,方便本地演示 profile 切换和 CLI 参数解析,不会写入真实 ~/.aws:
export AWS_CONFIG_FILE=examples/aws/config
export AWS_SHARED_CREDENTIALS_FILE=examples/aws/credentials
export AWS_PROFILE=mock-dev
export AWS_DEFAULT_REGION=us-east-1
也可以直接加载样例环境变量:
set -a
source examples/aws/mock.env
set +a
然后运行:
smops processing submit --config examples/processing-job.json --dry-run
smops processing list --profile mock-dev
smops tui processing --profile mock-dev
注意:这套 credentials 是 dummy 值,只适合 dry-run、mock、本地端点或配合 botocore Stubber/moto 使用;直接访问真实 AWS 会认证失败。
E2E 测试
测试使用 moto 模拟 AWS SageMaker 和 CloudWatch Logs,不会访问真实 AWS:
pip install -e '.[dev]'
pytest
覆盖范围包括:
- Processing Job 提交和 running job 分页列表
- Pipeline execution 启动和 active/recent execution 列表
- Pipeline steps 状态展示
- 失败 step 的 CloudWatch Logs tail
- Processing Job TUI 的上下左右键导航
- Pipeline TUI 的 executions、steps 和失败日志加载
- 多 AWS profile 解析
Moto 目前还没有实现 list_pipeline_execution_steps,测试里对这一个 paginator 做了内存 fake,其余 SageMaker/Logs 调用都在 moto 环境中执行。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sagemaker_ops_cli-0.1.0.tar.gz.
File metadata
- Download URL: sagemaker_ops_cli-0.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e469ce11e7caed12509ca7eece57030a1adffc44aa2fe3d1ff052c53d96140e0
|
|
| MD5 |
d8984d7b9999151080d7113ded39ce99
|
|
| BLAKE2b-256 |
3b996389b758e6442b8f49075d52ea44c7c8deb1a3844a9ae8d0b628e4dcd1c9
|
File details
Details for the file sagemaker_ops_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sagemaker_ops_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6ccb66a6f5ff0718eaf7f73f70bdf7d12cbcd00f24e64e36e34edb6edbd947e
|
|
| MD5 |
144acfd73722793b0c51a94ba4d15aa6
|
|
| BLAKE2b-256 |
ce680af0f5a47700515ad588892fbb651e1dc6b89e8bd9d95b8e14bc474e1dcf
|