Add DiagramsAPI.download_converted_file for diagram convert job downl…#2510
Add DiagramsAPI.download_converted_file for diagram convert job downl…#2510
Conversation
…oads - Add download_converted_file method to download PNG/SVG for a page of a convert job - Support file_id or file_external_id, page, and mime_type parameters - Add unit tests for the new method - Add diagram convert download to API client retryable endpoints - Add verification script for end-to-end testing Made-with: Cursor
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the SDK's capabilities for working with diagram conversion results by providing a dedicated method to download the converted output. This allows users to programmatically retrieve processed diagrams in various formats, streamlining workflows that involve visual assets from the Cognite Data Fusion platform. The addition of a verification script also aids in immediate testing and understanding of the new feature. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a new download_converted_file method to the DiagramsAPI, enabling users to download converted diagram files. The changes are well-structured, including the core API implementation, unit tests, and a verification script. My review identifies a couple of opportunities to improve adherence to the repository's style guide by using more specific type hints, which will enhance type safety.
| """ | ||
| if (file_id is None) == (file_external_id is None): | ||
| raise ValueError("Exactly one of file_id or file_external_id must be provided") | ||
| params: dict[str, Any] = {"page": page} |
There was a problem hiding this comment.
The type hint for params can be more specific. According to the style guide (line 43), Any should be avoided when possible. The dictionary values are either integers (page, file_id) or a string (file_external_id), so dict[str, int | str] is a more precise type hint.
| params: dict[str, Any] = {"page": page} | |
| params: dict[str, int | str] = {"page": page} |
References
- The style guide requires using specific types instead of
Anywhenever possible. (link)
| client = CogniteClient() | ||
|
|
||
| mime_type = "image/png" if args.format == "png" else "image/svg+xml" | ||
| kwargs: dict = {"job_id": args.job_id, "page": args.page, "mime_type": mime_type} |
There was a problem hiding this comment.
The kwargs dictionary is untyped (dict is equivalent to dict[Any, Any]). The style guide emphasizes strong typing and using specific types (lines 5, 42, 43). The keys are strings and the values are a mix of integers and strings. Please provide a more specific type hint like dict[str, int | str].
| kwargs: dict = {"job_id": args.job_id, "page": args.page, "mime_type": mime_type} | |
| kwargs: dict[str, int | str] = {"job_id": args.job_id, "page": args.page, "mime_type": mime_type} |
References
- The style guide requires extensive use of type hints and avoiding
Anywhen possible. (link)
|
@xgkelly thanks for the PR! Please retarget it against the branch |
…oads
Made-with: Cursor
Description
Please describe the change you have made.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.