Keep OpenAPI application-agnostic and move credential policy to consumers - #48
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, Python generator, tests, README, and product-boundary guidance. The provider fallback and package inclusion are otherwise consistent with the requested design, but invalid provider paths can now delete existing generated output before generation fails.
💬 Posted 1 inline comment
- 💡 MEDIUM
lib/generators/python.ts:865The provider file is read lazily insideBun.write, butoutputhas already been recursively deleted at line 857. IfauthProvideris missing, unreadable, or otherwise invalid, generation rejects only after removing the previous generated package and may leave a partial output. Read and validate the provider source beforerm(output, ...), then write the already-read contents.
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
Review 2: the previous output-deletion issue is addressed by reading the configured provider before removing the output directory. The auth-provider hook, path resolution, and generated credential fallback are consistent with the requested design, with no new concrete regressions found. LGTM.
|
🎉 PR #48 has been merged—thank you, @glenn-jocher!
This change keeps generated Python clients application-agnostic by delegating optional credential discovery to consumer-provided providers, while preserving explicit credentials and environment-variable fallback. |
The saved-settings resolver introduced in #47 embeds one consumer's credential discovery policy in a general OpenAPI-to-SDK converter. Delete that policy from the generator and replace it with optional
python.authProvider: a consumer-owned Python module exportingget_api_key() -> str | None, copied into the generated package. Default clients continue to resolve explicit and environment credentials; an opted-in provider supplies the final fallback.ultralytics/sdkowns its own provider, including every Ultralytics settings path and fallback rule. Any independent API provider can supply different credential discovery without changing this converter. The hook is language-scoped and does not inspect or modify the API contract.Add a critical product-boundary section to
AGENTS.md: OpenAPI is a standalone general-purpose SDK/docs product competing with Stainless and Scalar, must remain usable by third parties, and must never inherit ML-package or Platform-specific behavior. Product naming configuration is explicitly insufficient to justify application-specific policy.The generator change deletes more code than it adds and reuses the existing consumer-source inclusion pattern used for package READMEs. No plugin framework or application dependency is introduced.
Validation: 19 existing generator tests including configured source inclusion, typecheck, lint, unused-code check, and regeneration of all 86 Platform operations with the SDK-owned provider. SDK integration changes remain on ultralytics/sdk#56.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
The OpenAPI generator now delegates optional Python credential discovery to a consumer-provided provider instead of embedding saved-settings policy, keeping the converter application-agnostic.
📊 Key Changes
apiKey.settingswith optionalpython.authProvider, which points to a consumer-owned Python module exportingget_api_key()._auth.pyand uses it as the final credential fallback after explicit credentials and the configured environment variable.AGENTS.mdrequiring application-specific SDK behavior to remain in consumer repositories such asultralytics/sdk.🎯 Purpose & Impact
python.authProvider, credentials resolve from the explicit argument or environment variable only.get_api_key()result is used once during client initialization as the final fallback, while an explicit empty string still disables authentication.