[CDF-27148] 🚄Use pydantic classes in InstanceIO#2528
Conversation
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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors InstanceIO to use new Pydantic classes, which is a great improvement for type safety and code clarity, aligning well with the repository's style guide. The changes are well-implemented across the board, including updates to selectors, commands, and tests. I have one suggestion regarding a naming convention for a constant to ensure full adherence to the style guide.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
4898446 to
3156551
Compare
| chunk = InstanceList([]) | ||
| instance_filter = self._build_instance_filter(selector) | ||
| total = 0 | ||
| for instance in iterate_instances(client=self.client, **selector.as_filter_args()): |
There was a problem hiding this comment.
Just a note that as_filter_args seems to be unused as of this change
| def items(self) -> InstanceIdCSVList: | ||
| return InstanceIdCSVList.read_csv_file(self.datafile) | ||
|
|
||
| @lru_cache(maxsize=1) |
There was a problem hiding this comment.
I think this one should probably be @cached_property since it takes no arguments (and seems like that is usually recommended instead of lru_cache when used with self)
|
|
||
| def download_ids(self, selector: InstanceSelector, limit: int | None = None) -> Iterable[list[InstanceId]]: | ||
| def download_ids(self, selector: InstanceSelector, limit: int | None = None) -> Iterable[Sequence[InstanceId]]: | ||
| # Switch to use pydantic classes once purge has been updated. |
There was a problem hiding this comment.
Should this comment have a TODO: prefix?
| chunk = InstanceList([]) | ||
| instance_filter = self._build_instance_filter(selector) | ||
| total = 0 | ||
| for instance in iterate_instances(client=self.client, **selector.as_filter_args()): |
There was a problem hiding this comment.
Same goes for iterate_instances
| def as_id(self) -> ViewId: | ||
| return ViewId(space=self.space, external_id=self.external_id, version=self.version) | ||
| def as_id(self) -> ViewReference: | ||
| return ViewReference(space=self.space, external_id=self.external_id, version=self.version or "latest") |
There was a problem hiding this comment.
Since self.version can be None it seems like we should account for creating a ViewReferenceNoVersion here conditionally (?), I don't think we handle"latest" as a default version string anywhere?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2528 +/- ##
==========================================
- Coverage 85.83% 85.83% -0.01%
==========================================
Files 414 414
Lines 34409 34386 -23
==========================================
- Hits 29536 29515 -21
+ Misses 4873 4871 -2
🚀 New features to boost your workflow:
|
Description
Use the new pydantic classes in the InstanceIO
Bump
Changelog
Improved