Skip to content

feat(infield): add validation for new DataExplorationConfig properties#3009

Merged
serhiikindrat-cdf merged 28 commits into
mainfrom
FO-3617-add-toolkit-validations-for-activities-and-notifications-configurations
May 22, 2026
Merged

feat(infield): add validation for new DataExplorationConfig properties#3009
serhiikindrat-cdf merged 28 commits into
mainfrom
FO-3617-add-toolkit-validations-for-activities-and-notifications-configurations

Conversation

@serhiikindrat-cdf
Copy link
Copy Markdown
Contributor

@serhiikindrat-cdf serhiikindrat-cdf commented May 18, 2026

Description

Add build-time validation for InField CDM location configs that reference activities and notifications card views in dataExplorationConfig.

  • Register assetActivitiesCard / assetNotificationsCard as explicit view dependencies on build (get_dependencies / get_dependent_items), so DependencyRuleSet can flag missing views.
  • Add InFieldCDMViewPropertiesRuleSet to verify required view property names in CDF when a client is available.

Test check for the view existance:
image
Test check for the required properties existance:
image

Tasks:

Bump

  • Patch
  • Skip

Changelog

Improved

  • [alpha] When running cdf build with InFieldCDMLocationConfig resources, Toolkit now more strictly validates assetActivitiesCard and assetNotificationsCard view references and their required properties.

@gemini-code-assist
Copy link
Copy Markdown
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 counterproductive. 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
43147 37078 86% 80% 🟢

New Files

File Coverage Status
cognite_toolkit/_cdf_tk/rules/_infield.py 97% 🟢
TOTAL 97% 🟢

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py 87% 🟢
cognite_toolkit/_cdf_tk/rules/init.py 100% 🟢
cognite_toolkit/_cdf_tk/yaml_classes/infield_cdm_location_config.py 100% 🟢
TOTAL 96% 🟢

updated for commit: 226bf4a by action🐍

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 94.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.93%. Comparing base (37f0f48) to head (226bf4a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kit/_cdf_tk/resource_ios/_resource_ios/fieldops.py 87.50% 3 Missing ⚠️
cognite_toolkit/_cdf_tk/rules/_infield.py 96.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3009      +/-   ##
==========================================
+ Coverage   85.91%   85.93%   +0.01%     
==========================================
  Files         469      470       +1     
  Lines       43059    43147      +88     
==========================================
+ Hits        36994    37078      +84     
- Misses       6065     6069       +4     
Files with missing lines Coverage Δ
cognite_toolkit/_cdf_tk/rules/__init__.py 100.00% <100.00%> (ø)
...cdf_tk/yaml_classes/infield_cdm_location_config.py 100.00% <100.00%> (ø)
cognite_toolkit/_cdf_tk/rules/_infield.py 96.77% <96.77%> (ø)
...kit/_cdf_tk/resource_ios/_resource_ios/fieldops.py 86.96% <87.50%> (-0.05%) ⬇️

... and 1 file with indirect coverage changes

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

@serhiikindrat-cdf serhiikindrat-cdf marked this pull request as ready for review May 19, 2026 13:33
@serhiikindrat-cdf serhiikindrat-cdf requested review from a team as code owners May 19, 2026 13:33
Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/yaml_classes/infield_cdm_location_config.py
@gulkaktus
Copy link
Copy Markdown
Contributor

/gemini review

Copy link
Copy Markdown
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 introduces the InFieldCDMViewPropertiesRuleSet to validate that InField CDM card views exist in CDF and contain all required properties. It also updates dependency tracking in InFieldCDMLocationConfigIO and adds the necessary fields to the YAML configuration models. Feedback includes expanding dependency tracking to include asset_properties_card, avoiding broad exception handling in the validation logic, and batching API calls to prevent performance issues during view retrieval.

Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/resource_ios/_resource_ios/fieldops.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Copy link
Copy Markdown
Contributor

@gulkaktus gulkaktus left a comment

Choose a reason for hiding this comment

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

Left a few comments, looks good mostly!

gulkaktus
gulkaktus previously approved these changes May 22, 2026
Copy link
Copy Markdown
Contributor

@gulkaktus gulkaktus left a comment

Choose a reason for hiding this comment

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

Lgtm!

Comment on lines +398 to +409
def get_dependencies(cls, resource: InFieldCDMLocationConfigYAML) -> Iterable[tuple[type[ResourceIO], Identifier]]:
if data_exploration_config := resource.data_exploration_config:
for card_attr in INFIELD_CDM_CARD_VIEW_ATTR_TO_JSON_KEY:
if card_mapping := getattr(data_exploration_config, card_attr, None):
yield (
ViewIO,
ViewId(
space=card_mapping.space,
external_id=card_mapping.external_id,
version=card_mapping.version,
),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
def get_dependencies(cls, resource: InFieldCDMLocationConfigYAML) -> Iterable[tuple[type[ResourceIO], Identifier]]:
if data_exploration_config := resource.data_exploration_config:
for card_attr in INFIELD_CDM_CARD_VIEW_ATTR_TO_JSON_KEY:
if card_mapping := getattr(data_exploration_config, card_attr, None):
yield (
ViewIO,
ViewId(
space=card_mapping.space,
external_id=card_mapping.external_id,
version=card_mapping.version,
),
)
def get_dependencies(cls, resource: InFieldCDMLocationConfigYAML) -> Iterable[tuple[type[ResourceIO], Identifier]]:
if resource.data_exploration_config is None:
return
for card_attr in INFIELD_CDM_CARD_VIEW_ATTR_TO_JSON_KEY:
card_mapping = getattr(resource.data_exploration_config, card_attr, None)
if card_mapping is None:
continue
yield (
ViewIO,
ViewId(
space=card_mapping.space,
external_id=card_mapping.external_id,
version=card_mapping.version,
),
)

Nitpick, but it would be nice to reduce the indent here if we can, for example something like this



class InFieldCDMViewPropertiesRuleSet(ToolkitGlobalRuleSet):
CODE: ClassVar[str] = "INFIELD-CDM-VIEW-PROPERTIES"
Copy link
Copy Markdown
Contributor

@Magssch Magssch May 22, 2026

Choose a reason for hiding this comment

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

Suggested change
CODE: ClassVar[str] = "INFIELD-CDM-VIEW-PROPERTIES"
CODE_PREFIX: ClassVar[str] = "INFIELD-CDM"

This should be a prefix to align with the parent class ToolkitGlobalRuleSet

view = views_by_id.get(view_id)
if view is None:
yield ConsistencyError(
code=self.CODE,
Copy link
Copy Markdown
Contributor

@Magssch Magssch May 22, 2026

Choose a reason for hiding this comment

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

Continuing from the comment above, this should be structured like CODE_PREFIX + "-Something"

You can find an example in cognite_toolkit/_cdf_tk/rules/_dependencies.py or cognite_toolkit/_cdf_tk/rules/_functions.py.

For example this one could be something like f"{CODE_PREFIX}-VIEW-NOT-FOUND"

missing = required - set(view.properties.keys())
if missing:
yield ConsistencyError(
code=self.CODE,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For example this one could be something like f"{CODE_PREFIX}-VIEW-MISSING_PROPERTIES"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed: aef3f3b
image

Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py Outdated
@serhiikindrat-cdf serhiikindrat-cdf requested a review from Magssch May 22, 2026 13:01
Comment thread tests/test_unit/test_cdf_tk/test_rules/test_infield.py Outdated
Comment thread cognite_toolkit/_cdf_tk/rules/_infield.py
Copy link
Copy Markdown
Contributor

@Magssch Magssch left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for the contribution @serhiikindrat-cdf ! :)

@serhiikindrat-cdf serhiikindrat-cdf merged commit bb0e0e8 into main May 22, 2026
14 checks passed
@serhiikindrat-cdf serhiikindrat-cdf deleted the FO-3617-add-toolkit-validations-for-activities-and-notifications-configurations branch May 22, 2026 13:57
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.

3 participants