Skip to content

[CDF-24799] Pydantic validation for views #1672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Aashutosh-cognite
Copy link
Contributor

Description

This PR introduces pydantic validation model for View Resource class that matches the YAML file format that toolkit expects.

Changelog

  • Patch
  • Minor
  • Skip

Copy link

github-actions bot commented Jun 24, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19621 15356 78% 60% 🟢

New Files

File Coverage Status
cognite_toolkit/_cdf_tk/resource_classes/view_field_definitions.py 93% 🟢
cognite_toolkit/_cdf_tk/resource_classes/views.py 100% 🟢
TOTAL 97% 🟢

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/constants.py 100% 🟢
cognite_toolkit/_cdf_tk/resource_classes/container_field_definitions.py 93% 🟢
cognite_toolkit/_cdf_tk/resource_classes/containers.py 100% 🟢
TOTAL 98% 🟢

updated for commit: 7b699b5 by action🐍

Copy link
Collaborator

@doctrino doctrino left a comment

Choose a reason for hiding this comment

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

Good job a few adjustments.

)
filter: dict[str, Any] | None = Field(
default=None,
description="A filter Domain Specific Language (DSL) used to create advanced filter queries.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not correct, the filter for on a view is used to determine which instances are returned by the view.

description="Description of the content and suggested use for this property..",
max_length=1024,
)
source: ViewReference | None = Field(
Copy link
Collaborator

Choose a reason for hiding this comment

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

The description is incorrect. Suggest we only keep it on the derived classes. It is optional on the Container properties, while it is required for edges and reverse direct relations

return serialized_data


class CreateViewProperty(ViewProperty):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets call this ContainerViewProperty alternatively, MappedViewProperty

Copy link
Collaborator

@doctrino doctrino left a comment

Choose a reason for hiding this comment

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

Go go go!

@doctrino doctrino added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-risk-review Waiting for a member of the risk review team to take an action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants