Skip to main content

CLI tool for Huawei Cloud Service Delivery Engineers

Project description

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\": \"...\"}"

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        # 查看每个镜像的上传状态

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sd_helper_cli-0.1.4.tar.gz (66.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sd_helper_cli-0.1.4-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file sd_helper_cli-0.1.4.tar.gz.

File metadata

  • Download URL: sd_helper_cli-0.1.4.tar.gz
  • Upload date:
  • Size: 66.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for sd_helper_cli-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a0d72601858617ff25f6536a10494c05f57639f3655a3da52fe9f4869e27bd04
MD5 2752ced858a4e2496a54f037c55caa4a
BLAKE2b-256 d067488c4af5c060168f670b5eef61b9dde93d8e0c37a313cce08d06133668fb

See more details on using hashes here.

File details

Details for the file sd_helper_cli-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sd_helper_cli-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2ebc919a1b389cc6c5fee99e8c33ba083ced973ff46b60d2f0bbb3bc552d42
MD5 0ef77def52945bf87e4602ca9ac44bcd
BLAKE2b-256 c726cc97edc4ae7027cad4585600851b6bebbb33a687dfe18d5db5c23ef42b43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page