Skip to content

feat(python): add dfget Python SDK (#4421) - #93

Closed
DoubleCore wants to merge 2 commits into
dragonflyoss:mainfrom
DoubleCore:issue-4421-dfget-py-sdk
Closed

DoubleCore wants to merge 2 commits into
dragonflyoss:mainfrom
DoubleCore:issue-4421-dfget-py-sdk

Conversation

@DoubleCore

@DoubleCore DoubleCore commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Adds a self-contained, zero-runtime-dependency Python SDK for the dfget CLI under python/dfget_sdk/ (implements dragonflyoss/dragonfly#4421).

This is the CLI-wrapper approach: the SDK shells out to a locally installed dfget binary via subprocess / asyncio.subprocess, so it needs no gRPC stack and no protobuf codegen. It is deliberately complementary to #87 (which talks to dfdaemon over gRPC) — the two packages cover different deployment shapes.

API

  • DfgetClient.download(url, output, *, ...) -> DownloadResult (task id, raw stdout/stderr, duration, parsed downloaded size, progress lines)
  • DfgetClient.adownload(...) -> asyncio-native twin
  • DfgetClient.version(), DfgetClient.health() (+ async twins)
  • DfgetConfig (explicit > DFGET_BIN > PATH; DFDAEMON_ENDPOINT, DFGET_TIMEOUT, DFGET_LOG_LEVEL)
  • Errors: DfgetError, DfgetNotFoundError, DfgetTimeoutError, DfgetCommandError
  • dfget-sdk console script with download | version | health subcommands and --json output

Tests

All subprocess calls are mocked (both subprocess.run and asyncio.create_subprocess_exec), so no real dfget binary, Dragonfly cluster, or network is required:

cd python/dfget_sdk
.venv/Scripts/python.exe -m pytest -q
# 80 passed

Notes

  • Mirrors the layout of the sibling python/dfcache_sdk/ package (feat(python): add dfcache Python SDK (#4422) #92), so the two SDKs stay consistent.
  • Does not touch CI workflows or any other package under python/.
  • Commits are Signed-off-by (DCO green).

….replace()


Signed-off-by: DoubleCore <851678303@qq.com>
Signed-off-by: DoubleCore <851678303@qq.com>
@DoubleCore

Copy link
Copy Markdown
Author

The PR labels need the enhancement label for the 'Classify PR' check. Issue #4421 carries the enhancement label per the issue description, but non-maintainers cannot add labels via CLI. Maintainer attention needed for label application.

@DoubleCore DoubleCore closed this Nov 4, 2026
@DoubleCore
DoubleCore force-pushed the issue-4421-dfget-py-sdk branch from a3bb716 to 55d32a4 Compare November 4, 2026 03:07
@DoubleCore

Copy link
Copy Markdown
Author

Re-pushed with Signed-off-by trailers on both commits, so the DCO check is now green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants