Skip to content

List union body key sets in generated Python docstrings - #55

Merged
glenn-jocher merged 3 commits into
ultralytics:mainfrom
JaviChulvi:JaviChulvi/platform-cli-fewer-turns
Sep 24, 2026
Merged

glenn-jocher merged 3 commits into
ultralytics:mainfrom
JaviChulvi:JaviChulvi/platform-cli-fewer-turns

Conversation

@JaviChulvi

@JaviChulvi JaviChulvi commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

The Platform agent (AutoTrain) runs ul cloud. In chat analytics (2,236 calls, 2026-09-10 to 2026-09-23), about 75 help calls (3.4%) went to operations that take a body= union: datasets create-batch 27, datasets ingest 26, models create 22.

For these arguments the generated docstring, and so CLI help, showed only body (dict[str, Any]). Those help calls taught nothing, and agents guessed bodies. For example, they sent ingest with "split", which the API silently ignores; the real key is targetSplit.

Change

Arguments whose schema is a union of objects now list each accepted object, with ? for optional keys and literal values:

body (dict[str, Any]): Auto-annotate images or preview and apply face blurring
    Valid body objects (? marks an optional key): {modelId, confidence?, iou?, classMapping?, operation?: "annotate", includeAnnotated?} or {operation: "blur", confidence?, boxScale?, preview?, imageId?, previewJobId?}
  • Keys a variant forbids (not: true or an empty not, after resolving $ref) are left out.
  • The union check lives in one helper shared with pythonType.

Evaluation

  • In the replay, agents using the new help sent no bodies with undeclared keys, where the published SDK had 2.
  • Help lists key names, not value formats, so wrong values like modelId: "yolo26s.pt" still need the skill's ul:// example.

Union help also preserves shared properties and required fields declared alongside the union.

@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @JaviChulvi, 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 Python docstring union rendering and shared schema helper/type update. The new filtering can misdocument valid schemas using boolean or referenced not subschemas; otherwise, the change follows the existing union-detection path.

💬 Posted 1 inline comment
  • 📝 LOW lib/generators/python.ts:214 This treats any empty not value as forbidding the key. A valid not: false schema has no enumerable keys but allows the property, so the generated docs omit an accepted field. Conversely, not: { $ref: ... } referencing an empty schema is not resolved here and remains listed even though it forbids all values. Resolve and classify the not subschema—including boolean schemas—before filtering; JsonSchema.not should also allow boolean schemas.

@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 2

Made with ❤️ by Ultralytics Actions

Since review 1, the not filter now handles boolean schemas and resolves referenced schemas, addressing the earlier finding. The Python docstring rendering and shared union detection look correct; no remaining actionable issues. LGTM.

@JaviChulvi
JaviChulvi marked this pull request as ready for review September 23, 2026 20:21

@glenn-jocher glenn-jocher 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.

LGTM at 5f13eab. Cold full-diff review: shared union fields now use the existing object-schema composition owner; no application-specific logic or remaining findings. Verified 20 tests, deterministic regeneration, typecheck, lint, knip, build, Python compilation and Ruff, plus generated Platform body help and a shared-required-field probe.

@glenn-jocher
glenn-jocher merged commit 47bcb99 into ultralytics:main Sep 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants