68 lines
1.1 KiB
Markdown
68 lines
1.1 KiB
Markdown
# Hello, World! 套件示例
|
|
|
|
一个最简单的套件,演示 workflow.yaml 和脚本结构。
|
|
|
|
## 文件结构
|
|
|
|
```
|
|
hello-world/
|
|
├── workflow.yaml
|
|
└── scripts/
|
|
└── run.py
|
|
```
|
|
|
|
## workflow.yaml
|
|
|
|
```yaml
|
|
name: Hello World
|
|
description: 首个 AgentGIS 套件,接收一条消息并打印
|
|
version: 1.0.0
|
|
author: SuiteForge
|
|
platform: all
|
|
tags: [示例, 入门]
|
|
|
|
params:
|
|
message:
|
|
type: string
|
|
required: true
|
|
desc: 要打印的消息
|
|
|
|
base_image: gis-base:latest
|
|
|
|
steps:
|
|
- id: hello
|
|
name: 打印消息
|
|
runtime: python3
|
|
script_id: run
|
|
params:
|
|
message: $params.message
|
|
```
|
|
|
|
## scripts/run.py
|
|
|
|
```python
|
|
#!/usr/bin/env python3
|
|
import sys, json
|
|
|
|
def run(params):
|
|
message = params.get("message", "Hello, AgentGIS!")
|
|
print(f"📢 {message}")
|
|
return {
|
|
"status": "completed",
|
|
"message": message,
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
params = json.loads(sys.argv[1]) if len(sys.argv) > 1 else {}
|
|
result = run(params)
|
|
print(json.dumps(result, ensure_ascii=False))
|
|
```
|
|
|
|
## 执行
|
|
|
|
```bash
|
|
agc run /tmp/hello-output \
|
|
--suite-id <your-suite-id> \
|
|
--input message="你好,AgentGIS!"
|
|
```
|