Skip to content

[CDF-27563] 😁 Standardize validation#2792

Open
doctrino wants to merge 37 commits intomainfrom
standardizing-validation
Open

[CDF-27563] 😁 Standardize validation#2792
doctrino wants to merge 37 commits intomainfrom
standardizing-validation

Conversation

@doctrino
Copy link
Copy Markdown
Contributor

@doctrino doctrino commented Mar 26, 2026

Description

Reorganization of the validation to match the data structures we now use.

In progress

image

Completed

image

Bump

  • Patch
  • Skip

@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

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.

cdf_project = config.environment.project
validation_type = config.environment.validation_type

# Todo optimize by only searching for yaml files in the selected modules paths if selection is provided.
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.

We do not want to do this. Instead, we should find all yaml files so we can give proper error output. It is a trade-off between performance and useability, and then we should side with useability.

...


class ConsistencyWarning(Insight):
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.

Not used.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
39525 33439 85% 80% 🟢

New Files

File Coverage Status
cognite_toolkit/_cdf_tk/rules/_auth.py 100% 🟢
cognite_toolkit/_cdf_tk/rules/_dependencies.py 88% 🟢
cognite_toolkit/_cdf_tk/rules/_neat.py 84% 🟢
TOTAL 90% 🟢

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/client/api/views.py 94% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/build_v2.py 76% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/init.py 100% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_build.py 96% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_insights.py 85% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_lineage.py 71% 🟢
cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_module.py 95% 🟢
cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py 88% 🟢
cognite_toolkit/_cdf_tk/rules/init.py 100% 🟢
cognite_toolkit/_cdf_tk/rules/_base.py 97% 🟢
cognite_toolkit/_cdf_tk/rules/_orchestrator.py 91% 🟢
TOTAL 90% 🟢

updated for commit: fcc11d6 by action🐍

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 84.11215% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.60%. Comparing base (5b3dcd7) to head (fcc11d6).

Files with missing lines Patch % Lines
...nite_toolkit/_cdf_tk/commands/build_v2/build_v2.py 67.77% 29 Missing ⚠️
cognite_toolkit/_cdf_tk/rules/_neat.py 83.58% 11 Missing ⚠️
cognite_toolkit/_cdf_tk/rules/_dependencies.py 87.50% 5 Missing ⚠️
cognite_toolkit/_cdf_tk/client/api/views.py 83.33% 2 Missing ⚠️
cognite_toolkit/_cdf_tk/rules/_orchestrator.py 93.33% 2 Missing ⚠️
...t/_cdf_tk/commands/build_v2/data_classes/_build.py 95.23% 1 Missing ⚠️
cognite_toolkit/_cdf_tk/rules/_base.py 96.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2792      +/-   ##
==========================================
- Coverage   84.66%   84.60%   -0.07%     
==========================================
  Files         447      447              
  Lines       39428    39525      +97     
==========================================
+ Hits        33383    33439      +56     
- Misses       6045     6086      +41     
Files with missing lines Coverage Δ
..._cdf_tk/commands/build_v2/data_classes/__init__.py 100.00% <100.00%> (ø)
...cdf_tk/commands/build_v2/data_classes/_insights.py 84.90% <100.00%> (ø)
..._cdf_tk/commands/build_v2/data_classes/_lineage.py 71.09% <ø> (+1.56%) ⬆️
.../_cdf_tk/commands/build_v2/data_classes/_module.py 95.03% <100.00%> (+0.07%) ⬆️
...toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py 88.18% <100.00%> (ø)
cognite_toolkit/_cdf_tk/rules/__init__.py 100.00% <100.00%> (ø)
cognite_toolkit/_cdf_tk/rules/_auth.py 100.00% <100.00%> (ø)
...t/_cdf_tk/commands/build_v2/data_classes/_build.py 96.05% <95.23%> (+3.64%) ⬆️
cognite_toolkit/_cdf_tk/rules/_base.py 96.87% <96.77%> (-3.13%) ⬇️
cognite_toolkit/_cdf_tk/client/api/views.py 94.44% <83.33%> (-5.56%) ⬇️
... and 4 more

... 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.

Comment on lines -83 to -86
def resource_by_type_by_kind(self) -> dict[ResourceType, list[Path]]:
"""Organizes built files by their resource type and kind."""
resource_by_type: dict[ResourceType, list[Path]] = defaultdict(list)
for resource in self.resources:
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.

I avoid having logic on the DTO objects that are not used or only used in one location.

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.

Moved to the NeatRule

Comment on lines -90 to +93
dependency_insights = self._dependency_validation(built_modules, client)

global_insights = self._global_validation(built_modules, client)
plan = self._create_validation_plan(built_modules, client)
if parameters.verbose:
self._display_validation_plan(plan)
validation_results = self._run_validation(plan, console)
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.

This is the main change, instead of having one function for each validation (dependency, neat (only called in global validation). Standardize them into a ToolkitGlobalRulSet. Then, use the create plan, display, and run validation.

BASE_CODE = "AUTH"


class CheckDataSetMissing(ToolkitLocalRule):
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.

Moved from the specialist rule only applied to Workflow. This applies to all resources that have a data set.

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.

No need to keep this :)

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.

Combining the previous neat plugin with the logic to execute it that was in the build v2 function.

@doctrino
Copy link
Copy Markdown
Contributor Author

/gemini review

@doctrino doctrino marked this pull request as ready for review March 27, 2026 06:44
@doctrino doctrino requested review from a team as code owners March 27, 2026 06:44
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 refactors the validation logic in the build process by introducing a new validation plan system and replacing the previous RulesOrchestrator with LocalRulesOrchestrator and NeatRules. It also updates data classes to support these changes, including the addition of ValidationResult and FailedValidation models. A critical bug was identified in the validation loop where the status check incorrectly compared a RuleSetStatus object to a string instead of checking its code attribute.

Base automatically changed from module-validation to main March 27, 2026 10:49
@doctrino doctrino enabled auto-merge (squash) March 27, 2026 11:00

results: list[ViewResponse] = []
# The API does not support mixing ViewId and ViewNoVersionId in the same request.
if view_ids:
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.

This is an random issue I found

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.

1 participant