Read configured saved credentials in generated Python clients - #47
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 configuration schema, generated runtime resolver, sync and async client wiring, fallback handling, and existing generator coverage. I found no concrete correctness, compatibility, security, or performance issue in the diff. LGTM.
|
🎉 PR #47 has been merged—thank you, @glenn-jocher, for this valuable contribution!
This work brings together configurable saved-credential support, shared sync and async API-key resolution, explicit and environment-key precedence, and safe fallback handling—allowing generated Python SDKs to reuse |
Generated Python clients currently resolve explicit and environment API keys, so a user logged in through
yolo loginstill has to supply credentials again to the standalone SDK. Add optional consumer configuration for reading that existing JSON settings key in the shared runtime used by both sync and async clients.Resolution is explicit key → environment → saved key; an explicit empty string disables authentication. Reads preserve the settings writer's OS directory and fallback selection, never modify settings, and tolerate absent or malformed files. The SDK remains independent of the ML package and Torch. All behavior lives in the generator, so downstream regeneration retains it.
The new configuration is necessary to describe a consumer-owned credential file without hardcoding Ultralytics into the generic generator. The implementation extends the existing runtime and replaces the two client-level resolvers; no additional runtime files or credential stores.
Validation: 19 generator tests, typecheck, lint, unused-code check, generated Python Ruff, SDK tests on Python 3.11/3.14, and actual installed
yolo login/logoutwith both SDK clients against a local HTTP server using isolated settings and dummy credentials. The HTTP validation also covers explicit/environment precedence, empty-string opt-out, malformed settings, unchanged files, and no ML imports.Consumer configuration and automatic SDK-only release versioning follow in
ultralytics/sdk; no API contract change is required.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Generated Python SDK clients now optionally read saved JSON credentials through generator configuration, preserving explicit and environment key precedence while allowing
yolo logincredentials to be reused.📊 Key Changes
apiKey.settingsconfiguration for the settings directory, environment override, filename, and JSON key.🎯 Purpose & Impact