Skip to content

[CDF-26630]👷 Group pydantic classes.#2525

Open
doctrino wants to merge 16 commits intomainfrom
groups-crud
Open

[CDF-26630]👷 Group pydantic classes.#2525
doctrino wants to merge 16 commits intomainfrom
groups-crud

Conversation

@doctrino
Copy link
Collaborator

Description

Replace the PySDK with pydantic classes for Gropus.

Bump

  • Patch
  • Skip

Changelog

Improved

  • Serialization of groups

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@doctrino
Copy link
Collaborator Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant refactoring that replaces the legacy SDK classes for Groups with new Pydantic-based models. This is a great improvement for type safety and consistency with the newer parts of the toolkit. The changes are extensive, touching the API client, CRUD logic, command-line tools, and tests.

I've found two critical issues related to the new GroupsAPI.list implementation that break pagination, which will affect any operation that needs to list all groups. Please see my detailed comments.

Other than these critical issues, the refactoring looks solid and well-executed. The use of Pydantic models and validators to handle API inconsistencies is a good practice.

@doctrino doctrino marked this pull request as ready for review February 17, 2026 13:14
@doctrino doctrino requested review from a team as code owners February 17, 2026 13:14
Comment on lines +198 to +199
# The dataproduct API is not yet supported in CDF.
DataProductsAPI,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronpal Note that I forgot to comment on this in your PR, but without it the smoke tests will fail tomorrow morning

@doctrino doctrino enabled auto-merge (squash) February 17, 2026 13:15
Comment on lines 571 to 575
def convert_scope_format(cls, value: Any) -> Any:
"""Preserve original scope for unknown ACLs."""
if not isinstance(value, dict):
return value
return value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, both that and the above. It slipped passed me in my review of the agent.

List of GroupResponse objects.
Args:
all_groups: Whether to return all groups (requires admin permissions).
.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.

Comment on lines +110 to +113
try:
listed = api.list(limit=10)
except TypeError:
listed = api.list() # Some APIs do not support limit parameter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too broad? Can it mask other errors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since we do the exact same call without the limit parameter right after. If there is another exception, it will raised then.

I can do something like

            try:
                listed = api.list(limit=10)
            except TypeError as e:
                if "unexpected keyword argument 'limit'" in str(e):
                    listed = api.list()  # Some APIs do not support limit parameter
                else:
                    raise e

but I think it is a bit messy.

Alternative is to write a custom test for GroupsAPI.

What do you think?

Copy link
Collaborator

@ronpal ronpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments

@doctrino doctrino requested a review from ronpal February 17, 2026 20:28
@github-actions
Copy link

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
34397 29526 86% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/client/_toolkit_client.py 100% 🟢
cognite_toolkit/_cdf_tk/client/api/groups.py 100% 🟢
cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py 99% 🟢
cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py 96% 🟢
cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py 88% 🟢
cognite_toolkit/_cdf_tk/client/testing.py 100% 🟢
cognite_toolkit/_cdf_tk/commands/dump_resource.py 76% 🟢
cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py 80% 🟢
cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py 90% 🟢
TOTAL 92% 🟢

updated for commit: 9a42169 by action🐍

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 72.63158% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.83%. Comparing base (a3740c9) to head (9a42169).

Files with missing lines Patch % Lines
...nite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py 57.69% 22 Missing ⚠️
...it/_cdf_tk/client/resource_classes/group/scopes.py 81.25% 3 Missing ⚠️
cognite_toolkit/_cdf_tk/commands/dump_resource.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2525      +/-   ##
==========================================
- Coverage   85.84%   85.83%   -0.01%     
==========================================
  Files         414      414              
  Lines       34386    34397      +11     
==========================================
+ Hits        29518    29526       +8     
- Misses       4868     4871       +3     
Files with missing lines Coverage Δ
cognite_toolkit/_cdf_tk/client/_toolkit_client.py 100.00% <100.00%> (ø)
cognite_toolkit/_cdf_tk/client/api/groups.py 100.00% <100.00%> (ø)
...lkit/_cdf_tk/client/resource_classes/group/acls.py 99.32% <100.00%> (+0.34%) ⬆️
...kit/_cdf_tk/client/resource_classes/group/group.py 96.42% <100.00%> (ø)
cognite_toolkit/_cdf_tk/client/testing.py 100.00% <100.00%> (ø)
..._toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py 89.92% <100.00%> (ø)
cognite_toolkit/_cdf_tk/commands/dump_resource.py 76.38% <85.71%> (+0.04%) ⬆️
...it/_cdf_tk/client/resource_classes/group/scopes.py 88.31% <81.25%> (-2.02%) ⬇️
...nite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py 80.00% <57.69%> (-0.60%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants