Algorithm Plugin SDK
算法侧最小接口
from algorithm_plugin_sdk import Algorithm
class MyAlgorithm(Algorithm):
@classmethod
def metadata(cls): ...
def execute(self, request, context): ...
算法包需要声明 algorithm_plugin_sdk.algorithms entry point。
单次运行
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,不要手动编辑或提交它们。
通过目标仓库的虚拟环境执行:
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。
确认输出后执行:
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
/srv/camera-space-mano/.venv/bin/algorithm-plugin serve \
--config /srv/camera-space-mano/algorithm-plugin.json
安装与测试
python -m pip install .
python -m unittest discover -s tests -v
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 ls_algorithm_plugin_sdk-0.3.1.tar.gz.
File metadata
- Download URL: ls_algorithm_plugin_sdk-0.3.1.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb15438b0a54ca6d6ea45bec36ee91640df8d78ad5fba46cf65405995a136677
|
|
| MD5 |
178dca0cc1dc6b5799621ada9eae2bd8
|
|
| BLAKE2b-256 |
0d85dbabb7658f34798dad44ac84cef9a776b581c7daa444de4943fe4fdcd081
|
File details
Details for the file ls_algorithm_plugin_sdk-0.3.1-py3-none-any.whl.
File metadata
- Download URL: ls_algorithm_plugin_sdk-0.3.1-py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d64c707318abc062ebd24b5abb975f2a598d4876b0384150c0637be6093c506
|
|
| MD5 |
3336f1ca09d4b3f624547280dcebfea2
|
|
| BLAKE2b-256 |
595ab1c7702b7e99f7856b661fd2371fbe613845e59aca5c4b2debed51f63b74
|