diff --git a/Makefile b/Makefile index 6bc4d7619..ce1d4f9e9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: run-explorer run-tests run-linters build-ui build-python build-docker run-docker compose-up -version="0.77.1" +version="0.77.2" run-explorer: @echo "Running explorer API server..." # open "http://localhost:8000/static/index.html" || true diff --git a/cognite/neat/_version.py b/cognite/neat/_version.py index e7697f644..1c94e6b61 100644 --- a/cognite/neat/_version.py +++ b/cognite/neat/_version.py @@ -1 +1 @@ -__version__ = "0.77.1" +__version__ = "0.77.2" diff --git a/cognite/neat/rules/issues/dms.py b/cognite/neat/rules/issues/dms.py index 1761f8d71..673e9ea79 100644 --- a/cognite/neat/rules/issues/dms.py +++ b/cognite/neat/rules/issues/dms.py @@ -507,6 +507,26 @@ def dump(self) -> dict[str, Any]: return output +@dataclass(frozen=True) +class RawFilterAppliedToViewWarning(DMSSchemaWarning): + description = "Raw filter is applied to a view, which is against the neat data modeling lifecycle." + fix = "Do not use raw filter, instead use HasData filter or nodeType filter or change the data model design." + error_name: ClassVar[str] = "RawFilterAppliedToView" + view_id: dm.ViewId + + def message(self) -> str: + return ( + f"RawFilter applied to the view {self.view_id}." + " The usage of RawFilter is against the neat team recommendations and the neat data modeling lifecycle." + " When opting for raw filter, the user is responsible for any errors that arise in neat." + ) + + def dump(self) -> dict[str, Any]: + output = super().dump() + output["view_id"] = self.view_id.dump() + return output + + @dataclass(frozen=True) class NodeTypeFilterOnParentViewWarning(DMSSchemaWarning): description = ( diff --git a/cognite/neat/rules/models/dms/_rules_input.py b/cognite/neat/rules/models/dms/_rules_input.py index 4175c4203..25761be7e 100644 --- a/cognite/neat/rules/models/dms/_rules_input.py +++ b/cognite/neat/rules/models/dms/_rules_input.py @@ -237,7 +237,7 @@ class DMSViewInput: description: str | None = None implements: str | None = None reference: str | None = None - filter_: Literal["hasData", "nodeType"] | None = None + filter_: Literal["hasData", "nodeType", "rawFilter"] | None = None in_model: bool = True @classmethod diff --git a/cognite/neat/rules/models/dms/_validation.py b/cognite/neat/rules/models/dms/_validation.py index 4f9e15df6..f3da8ec60 100644 --- a/cognite/neat/rules/models/dms/_validation.py +++ b/cognite/neat/rules/models/dms/_validation.py @@ -8,6 +8,7 @@ from cognite.neat.rules.models._base import ExtensionCategory, SchemaCompleteness from cognite.neat.rules.models.data_types import DataType from cognite.neat.rules.models.entities import ContainerEntity +from cognite.neat.rules.models.wrapped_entities import RawFilter from ._rules import DMSProperty, DMSRules @@ -25,6 +26,7 @@ def __init__(self, rules: DMSRules): self.issue_list = IssueList() def validate(self) -> IssueList: + self._validate_best_practices() self._consistent_container_properties() self._referenced_views_and_containers_are_existing() self._validate_extension() @@ -241,6 +243,15 @@ def _validate_performance(self) -> None: ) ) + def _validate_best_practices(self) -> None: + for view in self.views: + if view.filter_ and isinstance(view.filter_, RawFilter): + self.issue_list.append( + issues.dms.RawFilterAppliedToViewWarning( + view_id=view.view.as_id(), + ) + ) + @staticmethod def _changed_attributes_and_properties( new_dumped: dict[str, Any], existing_dumped: dict[str, Any] diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d6dd9ede9..477735a7b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,9 +15,14 @@ Changes are grouped as follows: - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [0.77.2] - 14-05-24 +### Added +- Missing warning when `RawFilter` is used to warn users that the usage of this filter is not recommended. + + ## [0.77.1] - 14-05-24 ### Added -- Support for `RawFilters` allow arbitrary filters to be applied to the data model. +- Support for `RawFilter` allow arbitrary filters to be applied to the data model. ## [0.77.0] - 13-05-24 diff --git a/pyproject.toml b/pyproject.toml index f617077b4..d96ac7200 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cognite-neat" -version = "0.77.1" +version = "0.77.2" readme = "README.md" description = "Knowledge graph transformation" authors = [