Repository navigation
Wake the local On Premise worker from every SDK client - #132
Conversation
|
👋 Hello @glenn-jocher, thank you for submitting a
For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Reviewed the hook integration, CLI migration, generated client changes, and tests. The default-client path appears correct, but custom HTTP clients bypass the wake hooks, leaving a gap in the SDK-wide behavior.
💬 Posted 1 inline comment
- 💡 MEDIUM
sdk/python/src/ultralytics_platform/_client.py:130When callers providehttp_client, this branch uses it unchanged, soresponse_hookis never registered; the async branch has the same behavior. Successful ingest or training requests through the supported custom-client path therefore do not wake the local worker. Preserve any existing hooks while registering the wake hook on supplied clients too, so the feature coversPlatformandAsyncPlatforminstances that use custom clients.
|
🎉 Thanks @glenn-jocher for merging this PR! Default
A small, shared SDK hook makes that worker wake-up available beyond the CLI. |
Summary
#131 made the
ulCLI wake a local On Premise worker (GET http://127.0.0.1:8765/wake) after it creates an ingest or training job. This moves that wake into the generated SDK through ultralytics/openapi#60'spython.hooksProvider, soPlatformandAsyncPlatformusers get instant pickup too, and the CLI keeps it with no code of its own.hooks.py(new, hand-written, copied to_hooks.py):response_hookand an async twinasync_response_hook.POSTending in/ingestor/training/start.trust_env=False, everyhttpx.HTTPErrorsuppressed. Neither hook can raise.Originis the scheme and host of the request that created the job, which is exactly what the worker checks, including forPlatform(base_url=...)users.cli.py: deleteswake_workerand the CLI's ownhttpx.Client;dispatch()uses the generatedPlatform, whose client carries the hook.openapi.config.json:"hooksProvider": "hooks.py".main(3aba4be) and synced; the drift check is clean. CI, AGENTS.md and README listhooks.pynext toauth.py.No version bump.
Validation
pytest tests -v: 7 passed. The CLI wire test still sees exactly 2 wakes, now through the generated hook. The new async test runsAsyncPlatformagainst a loopback fake API with a listener on 8765: a GET, a failed ingest, a training start and an ingest give exactly 2 wakes with the rightOrigin. Stubbing the async hook fails it.ruff format --checkandruff checkare clean onsdk/python,tests,cli.py,auth.pyandhooks.py.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Added response hooks to the generated Python SDK clients so successful ingest and training-start requests wake a local On Premise worker, while the CLI now uses the same SDK behavior.
📊 Key Changes
POSTrequests to paths ending in/ingestor/training/start.http://127.0.0.1:8765/wake, uses the originating request’s scheme and host in itsOriginheader, and has a 0.5-second timeout.python.hooksProviderand attached them to SDK-created HTTP clients.Platformclient now provides the behavior.🎯 Purpose & Impact
PlatformandAsyncPlatformclients can trigger the local worker without using the CLI.