fix(#8): 快速开始 — 替换 agc publish/suites list 和双花括号语法
This commit is contained in:
+17
-82
@@ -1,97 +1,32 @@
|
||||
# 快速开始 — 开发第一个套件
|
||||
# 快速开始
|
||||
|
||||
## 什么是套件
|
||||
|
||||
套件(Suite)是平台的可执行单元。一个套件包含:
|
||||
- **workflow.yaml**:步骤定义(核心)
|
||||
- **scripts/run.py**:执行脚本
|
||||
|
||||
## 第一步:创建套件目录
|
||||
## 安装 gis-actions
|
||||
|
||||
```bash
|
||||
mkdir my-first-suite
|
||||
cd my-first-suite
|
||||
# 下载
|
||||
curl -sLO https://git.mercator.cn/api/packages/SuiteHub/generic/gis-actions/3.0.1/gis-actions_3.0.1_all.deb
|
||||
|
||||
# 安装
|
||||
sudo dpkg -i gis-actions_3.0.1_all.deb
|
||||
```
|
||||
|
||||
## 第二步:编写 workflow.yaml
|
||||
|
||||
```yaml
|
||||
name: hello-world
|
||||
description: 最小示例套件 — 输出用户输入的文本
|
||||
version: 1.0.0
|
||||
category: utility
|
||||
|
||||
params:
|
||||
type: object
|
||||
required:
|
||||
- message
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: 要输出的文本
|
||||
|
||||
steps:
|
||||
- id: say-hello
|
||||
name: 输出信息
|
||||
script: run
|
||||
params:
|
||||
message: $params.message
|
||||
|
||||
resolved_params:
|
||||
- step_index: 0
|
||||
step_name: 输出信息
|
||||
params:
|
||||
message: "Hello, AgentGIS!"
|
||||
```
|
||||
|
||||
## 第三步:编写脚本
|
||||
## 浏览套件
|
||||
|
||||
```bash
|
||||
mkdir scripts
|
||||
curl -s https://suites.mercator.cn/api/v1/suites | python3 -m json.tool
|
||||
```
|
||||
|
||||
`scripts/run.py`:
|
||||
## 执行套件
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import json, os
|
||||
|
||||
params_file = os.environ.get("PARAMS_FILE", "/tmp/params.json")
|
||||
with open(params_file) as f:
|
||||
params = json.load(f)
|
||||
|
||||
message = params.get("message", "Hello!")
|
||||
result = {"output": message, "length": len(message)}
|
||||
print(json.dumps(result))
|
||||
```
|
||||
|
||||
## 第四步:测试
|
||||
选择一个套件 ID,在本地执行:
|
||||
|
||||
```bash
|
||||
agc run /tmp/output --suite-id <suite-id> --input key=val
|
||||
agc run /tmp/my-output \
|
||||
--suite-id 2c99a1cb-84a5-42dd-9147-1c8e8f7f2941 \
|
||||
--input bid_xls=/path/to/标段清单.xls \
|
||||
--input points_shp=/path/to/点状工程.shp
|
||||
```
|
||||
|
||||
或直接提交任务到 API:
|
||||
## 发布套件
|
||||
|
||||
```bash
|
||||
curl -X POST https://suites.mercator.cn/api/v1/task \
|
||||
-H "Authorization: Bearer mk_xxxx" \
|
||||
-d '{"suite_id": "...", "inputs": {"message": "测试"}}'
|
||||
```
|
||||
|
||||
## 第五步:发布
|
||||
|
||||
```bash
|
||||
curl -X POST https://suites.mercator.cn/api/v1/publish \
|
||||
-H "Authorization: Bearer mk_xxxx" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "my-first-suite", "version": "1.0.0", "description": "我的第一个套件", "workflow_yaml": "...", "scripts": {"run.py": "..."}}'
|
||||
```
|
||||
|
||||
发布后套件会在市场中展示,其他用户可以搜索和使用。
|
||||
|
||||
## 查看已发布的套件
|
||||
|
||||
```bash
|
||||
curl -s https://suites.mercator.cn/api/v1/suites | jq '.[] | {name, version, description}'
|
||||
```
|
||||
套件通过 Gitea 仓库 + 发布 API 发布,详见 [套件发布指南](../开发者指南/套件发布指南.md)。
|
||||
|
||||
Reference in New Issue
Block a user