Skip to main content

Algorithm Plugin SDK

算法仓库只实现一个 Algorithm 类并声明 entry point。SDK 统一提供单次运行、 WebUI、HTTP service、release manifest、compute 注册和心跳。算法仓库不需要 Dockerfile 或 Web 框架代码。

算法侧最小接口

from algorithm_plugin_sdk import Algorithm

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

算法包需要声明 algorithm_plugin_sdk.algorithms entry point。同一个 execute() 会被所有运行方式复用。

单次运行

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 工作树根目录,并且至少有一个 commit。
  • 仓库包含自己的 .venv
  • <repository>/.venv/bin/algorithm-plugin 存在且可执行。
  • 该启动器的 run --helpserve --help 均可正常加载。

建议将生成的 release-manifest.jsonalgorithm-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" \
  --public-url http://10.0.0.4:9000 \
  --input-root /data/jobs/input \
  --workspace-root /data/jobs/workspace \
  --cluster production \
  --namespace camera-space-mano \
  --node-name 10.0.0.4 \
  --gpu-ids 0,1

service name 默认使用仓库目录名,也可以通过 --service-name 指定。 重复执行 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

serve

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

安装与测试

python -m pip install '.[service]'
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

ls_algorithm_plugin_sdk-0.3.0.tar.gz (49.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ls_algorithm_plugin_sdk-0.3.0-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file ls_algorithm_plugin_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: ls_algorithm_plugin_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 49.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for ls_algorithm_plugin_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d08878746a8bf81ef59706f5bef880d4bb0c4326d49b33e0b97e723570f4de93
MD5 177e65c431a5629e755e8515a932e31e
BLAKE2b-256 83b8f17eb472985aec990be36f5583a89b8740fa394ef813407deb9f0c48636e

See more details on using hashes here.

File details

Details for the file ls_algorithm_plugin_sdk-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ls_algorithm_plugin_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2682fd0e22d99adb3de32ab69e215865a61221264569e0408e00e0b4852e544
MD5 556103ee6e83c6319d661d0a1e7c3d4f
BLAKE2b-256 6c037274b24f3de88a67d204700df96ada4cadefe034c15ffde65a56e0c64147

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

2 files

0.3.1

2 files

This release

0.3.0 This release

2 files

0.2.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page