sd-helper
华为云服务交付工程师的命令行工具,用于简化日常运维操作。
快速开始
安装后生成配置文件,填写凭据即可使用:
sd-helper init # 生成 ~/.sd-helper.yaml
安装
在线安装:
pip install sd-helper-cli
离线安装(服务器无外网):
在有网络的机器上下载依赖包:
# 默认 ARM64 / Python 3.9,可通过参数调整
bash scripts/download_wheels.sh
bash scripts/download_wheels.sh --platform manylinux2014_x86_64 --python-version 3.10
# 将生成的 sd-helper-offline.tar.gz 传输到服务器
scp sd-helper-offline.tar.gz user@server:/tmp/
在服务器上安装到 virtualenv:
bash install.sh --archive /tmp/sd-helper-offline.tar.gz
source ~/.venv/sd-helper/bin/activate
sd-helper --version
功能模块
IAM 认证
# 配置凭据
sd-helper iam configure
# 获取 token
sd-helper iam token
# 查看已配置的 profile
sd-helper iam list-profiles
# 设置默认 profile
sd-helper iam set-default <profile>
LLM 对话
与 ModelArts / 盘古大模型进行对话。
# 添加模型配置
sd-helper llm add <model-name> --endpoint <url> --type modelarts
# 查看已配置的模型
sd-helper llm list
# 单次对话
sd-helper llm chat "你好"
# 携带文件上下文
sd-helper llm chat -f code.py "解释这段代码"
# 视觉模型(图片输入)
sd-helper llm chat -i image.jpg "描述这张图片"
# 交互式对话(进入 TUI 界面)
sd-helper llm chat
# OCR:识别图片中的手写数字(短码 + 长码)
sd-helper llm ocr image.jpg
sd-helper llm ocr *.jpg
输出为 JSON 数组,每张图片对应一条记录:
[
{
"short_code": "36 202",
"long_code": "269202",
"file": "image.jpg"
}
]
OCR 提示词默认内置,也可在模型配置中自定义:
llm:
models:
qwen3-vl-32b:
endpoint: https://...
type: vl
ocr_prompt: "识别图片中的文字,只返回 JSON:{\"result\": \"...\"}"
Nisco OCR
从 Nisco 系统下载图片并调用多模态大模型进行 OCR 识别,结果写入 Excel。
下载图片并生成 Excel:
# 下载指定日期范围内 result_sta=否 的记录,图片嵌入 Excel
sd-helper nisco ocr image-download --start 2026-03-01 --end 2026-03-02
# 指定输出文件和图片目录
sd-helper nisco ocr image-download --start 2026-03-01 --end 2026-03-31 -o march.xlsx -i ./march_images
生成的 Excel 包含所有原始字段,以及:
image_file_name— 保存到磁盘的图片文件名image— 嵌入的图片预览(512px)
对已下载的图片运行 OCR:
# 使用默认模型和提示词
sd-helper nisco ocr run nisco_ocr.xlsx
# 指定模型
sd-helper nisco ocr run nisco_ocr.xlsx -m qwen3-vl-32b
# 自定义提示词
sd-helper nisco ocr run nisco_ocr.xlsx --prompt "识别图片中的炉号,只返回JSON: {\"result\": \"...\", \"reason\": \"...\"}"
# 从文件读取提示词
sd-helper nisco ocr run nisco_ocr.xlsx --prompt-file my_prompt.txt
OCR 结果写回原 Excel,新增三列:
ocr_raw— 模型原始返回内容ocr_result— 解析后的识别结果ocr_reason— 模型说明
Docker 镜像管理
批量加载并推送镜像到 SWR,支持断点续传。
前提条件: 环境已安装 docker,并完成 SWR 登录。
# 校验资产清单中的文件是否完整
sd-helper docker upload-images --config config.yaml --dir /path/to/files --validate
# 试运行(只打印命令,不执行)
sd-helper docker upload-images --config config.yaml --dir /path/to/files --dry-run
# 正式上传
sd-helper docker upload-images --config config.yaml --dir /path/to/files
# 重置所有进度(重新上传)
sd-helper docker upload-images --reset-all
# 重置指定镜像的进度
sd-helper docker upload-images --reset "name:tag"
配置文件示例(config.yaml):
assets_file: 资产清单.txt # 资产清单文件,只处理其中的 镜像 分区
swr:
endpoint: swr.cn-north-4.myhuaweicloud.com
org: com-huaweicloud-dataengineering
cleanup_after_push: false # 设为 true 可在推送后删除本地镜像
后台运行:
nohup sd-helper docker upload-images --config config.yaml --dir /path/to/files > upload.log 2>&1 &
echo $! # 记录 PID
tail -f upload.log # 查看实时日志
cat .progress.json # 查看每个镜像的上传状态
数据管理
离线收集和同步数据。
# 采集数据
sd-helper data collect --name <name>
# 查看已采集的数据
sd-helper data list
# 使用模板批量执行请求
sd-helper data run <template.yaml>
独立脚本
scripts/upload_images.py 是一个独立版本的镜像上传脚本,仅依赖 pyyaml,可直接复制到目标节点使用:
python upload_images.py --config config.yaml --dir /path/to/files
后台运行:
nohup python upload_images.py --config config.yaml --dir /path/to/files > upload.log 2>&1 &
echo $! # 记录 PID
tail -f upload.log # 查看实时日志
cat .progress.json # 查看每个镜像的上传状态
Metadata
Release files for sd-helper-cli 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sd_helper_cli-0.1.7.tar.gz | 12.0 MB | Without provenance | Details for sd_helper_cli-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sd_helper_cli-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for sd_helper_cli-0.1.7-py3-none-any.whl |
Total release size: 12.1 MB
Release files / sd_helper_cli-0.1.7.tar.gz
| Download URL | sd_helper_cli-0.1.7.tar.gz |
|---|---|
| Size | 12.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7558f516058d605db62b9106423a6532b535f84a556548a61a6447080578b497
|
|
BLAKE2b-256 checksum How to use checksums |
de04351d99b2064133f6c154d6aa36e42b56dbd31b996c1398edf2fd2efd7a9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / sd_helper_cli-0.1.7-py3-none-any.whl
| Download URL | sd_helper_cli-0.1.7-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19739067cfcc28659da325aad48d908b171177c96608c916fb7cd68616fcb838
|
|
BLAKE2b-256 checksum How to use checksums |
d4ec13bc3a3e2babd1fcceee8a80030ea882c837c71bcfee599f94aa08113e99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for sd-helper-cli 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.