ASF (AI Service Framework) 开发脚手架 —— 一键创建/校验 SU 模块
Project description
ASF Scaffold
ASF (AI Service Framework) 开发脚手架 —— 一键创建、列表、校验 SU (Service Unit) 模块。
安装
pip install asf-scaffold
本地开发安装:
cd tools/cli
pip install -e .
依赖
- Python >= 3.8
- click >= 8.0
- jinja2 >= 3.0
命令一览
| 命令 | 说明 | 示例 |
|---|---|---|
create <category> <name> |
创建新 SU 模块 | asf create ai my_service |
list [category] |
列出所有 SU(扫描文件系统) | asf list / asf list ai |
validate <category> <name> |
校验 SU 结构 | asf validate ai sample |
使用流程
1. 创建新 SU 模块
# 创建
asf create ai my_service
# 强制覆盖已存在的模块
asf create ai my_service --force
CLI 不会修改 modules.conf,需手动注册。
创建后自动生成以下文件结构:
server/app/ai/my_service/
├── __init__.py # APIRouter 聚合
├── api.py # API 端点
├── README.md # 模块文档
├── requirements.txt # Python 依赖
├── Dockerfile # 容器构建
├── docker-compose.yml # 容器编排
├── logger.yaml # 日志配置
├── errors/
│ ├── __init__.py
│ └── error_codes.py # 错误码定义 (ASF_ 前缀)
└── nginx/
└── default.conf # Nginx 反向代理
2. 查看已有模块
# 列出所有(扫描 server/app/ 文件系统)
asf list
# 按分类过滤
asf list ai
# 详细信息(含关键文件校验)
asf list --detail
3. 校验模块结构
asf validate ai my_service
# 自动补全缺失文件
asf validate ai my_service --repair
模板变量
模板文件位于 src/asf_scaffold/templates/su_template/,使用 Jinja2 语法,可用变量:
| 变量 | 示例值 (ai/my_service) |
|---|---|
{{category}} |
ai |
{{name}} |
my_service |
{{class_name}} |
AiMyService |
{{error_prefix}} |
AI_MY_SERVICE |
{{category_title}} |
Ai |
{{name_title}} |
MyService |
{{log_path}} |
logs/ai/my_service/my_service.log |
{{image_tag}} |
registry.inspures.com/ai_su/my_service:latest |
项目结构
tools/cli/
├── pyproject.toml # 包配置
├── README.md # 本文档
├── LICENSE # MIT 许可证
├── src/
│ └── asf_scaffold/ # 主包目录
│ ├── __init__.py # 包初始化
│ ├── cli.py # CLI 主入口
│ └── templates/ # SU 模块模板
├── tests/ # 测试目录
└── docs/ # 文档目录
发布到 PyPI
查看 PyPI 发布流程文档 了解详细的发布步骤。
许可证
MIT License
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
asf_scaffold-0.1.0.tar.gz
(15.0 kB
view details)
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 asf_scaffold-0.1.0.tar.gz.
File metadata
- Download URL: asf_scaffold-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f17a83d7e3818b2ad52b6100dd3d8eae84d7a0d6529ccc4c1e54245df0eadc6f
|
|
| MD5 |
66fb9000195c1759436cdc213ce4cda1
|
|
| BLAKE2b-256 |
0866447853deaaf07fb2172120a84a35f9b0b271e64484d2494e086546030002
|
File details
Details for the file asf_scaffold-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asf_scaffold-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
816085f922fe4a2485c708efd4b43026c1d98eab241aa762e3a21145f374c886
|
|
| MD5 |
414a71d345aa9f0deb0feb17c190cf23
|
|
| BLAKE2b-256 |
5df43166c64e0cc9a976f0223bc8e8920b6ce6f95ce43b34665b9f1aff3b9205
|