Generate usable Python multipart file samples - #52
Conversation
…ontract, and where-to-look guidance
|
👋 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 AGENTS.md additions against the repository’s package scripts, configuration loader, generator, shared OpenAPI helpers, workflows, and tests. The change is documentation-only and does not alter runtime behavior, but two factual descriptions should be corrected: the generated-package import check and the conditions that prevent request-body flattening.
💬 Posted 2 inline comments
- 📝 LOW
AGENTS.md:47This describes the CI import shape incorrectly. CI imports the configured package (c["package"]) and checks theclientandAsync+clientattributes; it does not import a module named<python.package>.<python.client>. Please make the command comment match.github/workflows/ci.ymlso agents do not try an invalid module import. - 📝 LOW
AGENTS.md:107TheadditionalPropertiesexception is broader than the implementation.sdkArgumentsstill flattens a plain object body with its own object-valuedadditionalProperties; the whole-body fallback only detects object-valuedadditionalPropertiesonallOfbranches (along with the other listed constraints). Please scope this description to the actual behavior.
…f passing the path string
… flattened arguments; keep explicit null
…y properties across schema unions
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
Since the previous review, both AGENTS.md findings are addressed: the CI import description and body-flattening exception now match the implementation. This revision also adds multipart-aware Python samples and coverage. One medium-risk edge case remains: recursive binary detection in samples is broader than the generated client's multipart file handling, so copied samples can be incorrect for union-valued binary fields.
💬 Posted 1 inline comment
- 💡 MEDIUM
lib/openapi.ts:569This recursively classifies a multipart property as a file when any union branch hasformat: "binary", but the Python generator only puts properties with a direct resolvedformat: "binary"intofiles(methodSourceandmultipartBinary). For a schema such asfile: { anyOf: [{ type: "string", format: "binary" }, { type: "null" }] }, the sample emitsopen("path/to/file", "rb")while the generated client passes that value through_form_datainstead of uploading it as a file. Align th…
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 3
Made with ❤️ by Ultralytics Actions
Since review 2, the multipart sample logic now checks direct resolved binary formats, addressing the prior union mismatch. One documentation regression remains: the current diff deletes the existing Architecture and Python Output guidance instead of preserving it as claimed. No other concrete runtime issues found.
💬 Posted 1 inline comment
- 📝 LOW
AGENTS.md:39This replacement removes the existingArchitectureandPython Outputsections, despite the PR description saying those sections are preserved. Agents now lose the documented contract ownership, generated-output rules, API-key handling, client shape, async-client, docstring, and license guidance. Retain those sections while adding the new commands and validation guidance.
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 4
Made with ❤️ by Ultralytics Actions
Since the previous review, the multipart sample logic now matches the Python generator’s direct binary-field classification, and the documentation scope change is settled by the maintainer. The test coverage exercises the generated open(..., "rb") sample. No new concrete runtime, compatibility, security, or maintainability issues found. LGTM.
|
🎉 This PR has been merged—thank you, @glenn-jocher!
This collaboration improves generated Python multipart samples by opening binary files as file handles while preserving non-multipart behavior and generator coverage. Validation also passed 20 tests with 292 assertions, typecheck, lint, and knip. |
Python multipart examples now open binary files instead of passing a literal path string. Match the generator transport's field classification and retain coverage in the existing generator test. Trim AGENTS.md to reusable product boundaries, commands, owner pointers, and pitfalls.
Validation: 20 tests passed (292 assertions), typecheck, lint, and knip passed.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Updated Python multipart code samples to open binary files instead of passing file paths as strings, while refining repository guidance and preserving generator coverage.
📊 Key Changes
open("path/to/file", "rb")expressions.AGENTS.mdby consolidating commands, validation requirements, project boundaries, pointers, and Python output conventions.🎯 Purpose & Impact
multipart/form-datarequests now provide file handles suitable for the SDK’s multipart transport instead of literal path strings.