Metadata-Version: 2.4
Name: ls-algorithm-plugin-sdk
Version: 0.3.1
Summary: Protocol-independent runtime SDK for dataset algorithms
Author: Ling Robotics
License: Proprietary
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: service
Requires-Dist: fastapi<1,>=0.110; extra == "service"
Requires-Dist: pydantic<3,>=2.0; extra == "service"
Requires-Dist: uvicorn[standard]<1,>=0.29; extra == "service"
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"

# Algorithm Plugin SDK

## 算法侧最小接口

```python
from algorithm_plugin_sdk import Algorithm

class MyAlgorithm(Algorithm):
    @classmethod
    def metadata(cls): ...
    def execute(self, request, context): ...
```

算法包需要声明 `algorithm_plugin_sdk.algorithms` entry point。

## 单次运行

```bash
algorithm-plugin run camera-space-mano \
  --input '{"input_dataset":"/data/input1","output":"/data/output1"}' \
  --input '{"input_dataset":"/data/input2","output":"/data/output2"}' \
  --gpu-ids 0 \
  --parameters '{"batch_size":16}'
```

`--gpu-ids` 和 `--parameters` 可省略，也可用 `--request-file` 读取完整请求 JSON。

## 配置现有仓库

目标算法仓库必须满足：

- 仓库本身是 Git 工作树根目录。
- 仓库包含自己的 `.venv`。
- `<repository>/.venv/bin/algorithm-plugin` 存在且可执行。

建议将生成的 `release-manifest.json` 和 `algorithm-plugin.json` 加入算法仓库的
`.gitignore`，不要手动编辑或提交它们。

通过目标仓库的虚拟环境执行：

```bash
sudo /srv/camera-space-mano/.venv/bin/algorithm-plugin configure \
  --repository /srv/camera-space-mano \
  --compute-url http://compute:5180 \
  --api-key "$LDP_INTERNAL_API_KEY" \
  --port 9030 \
  --cluster production \
  --gpu-ids 0,1
```

重复执行 configure 需要显式提供 `--force`。

确认输出后执行：

```bash
sudo systemctl daemon-reload
sudo systemctl enable camera-space-mano.service
sudo systemctl restart camera-space-mano.service
sudo systemctl status camera-space-mano.service --no-pager
```

## serve

```bash
/srv/camera-space-mano/.venv/bin/algorithm-plugin serve \
  --config /srv/camera-space-mano/algorithm-plugin.json
```

## 安装与测试

```bash
python -m pip install .
python -m unittest discover -s tests -v
```
