Skip to content

Read configured saved credentials in generated Python clients - #47

Merged
glenn-jocher merged 1 commit into
mainfrom
feat/shared-platform-auth
Sep 7, 2026
Merged

Read configured saved credentials in generated Python clients#47
glenn-jocher merged 1 commit into
mainfrom
feat/shared-platform-auth

Conversation

@glenn-jocher

@glenn-jocher glenn-jocher commented Sep 7, 2026

Copy link
Copy Markdown
Member

Generated Python clients currently resolve explicit and environment API keys, so a user logged in through yolo login still 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/logout with 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 login credentials to be reused.

📊 Key Changes

  • Added optional apiKey.settings configuration for the settings directory, environment override, filename, and JSON key.
  • Moved API-key resolution into the shared generated runtime used by synchronous and asynchronous clients.
  • Implemented precedence of explicit key, environment variable, then saved settings; an explicit empty string disables authentication.
  • Added OS-specific settings paths, writer-compatible fallback directories, and safe handling for missing, malformed, or unreadable files without modifying them.
  • Updated the Python generator test to verify resolver usage in generated clients and runtime environment-key handling.

🎯 Purpose & Impact

  • Generated SDK users can reuse credentials stored by the configured settings writer without installing or importing the ML package or Torch.
  • Both sync and async clients use the same saved-credential behavior, and regenerated SDKs retain the configuration-driven implementation.

@UltralyticsAssistant UltralyticsAssistant added enhancement New feature or request fixed Bug has been resolved labels Sep 7, 2026
@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/openapi 🚀 PR! This automated message confirms your contribution was received, and an Ultralytics engineer will assist with the review. To ensure a seamless integration of your work, please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/openapi main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

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 UltralyticsAssistant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

@glenn-jocher
glenn-jocher merged commit 41ef1f1 into main Sep 7, 2026
4 checks passed
@glenn-jocher
glenn-jocher deleted the feat/shared-platform-auth branch September 7, 2026 16:31
@UltralyticsAssistant

Copy link
Copy Markdown
Member

🎉 PR #47 has been merged—thank you, @glenn-jocher, for this valuable contribution!

“Great things are done by a series of small things brought together.” — Vincent van Gogh

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 yolo login credentials without requiring the ML package or Torch.

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

Labels

enhancement New feature or request fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants