Skip to content

Commit

Permalink
Allowing multiple View properties to map to the same Container proper…
Browse files Browse the repository at this point in the history
…ty (#411)

[0.75.1] - 23-05-24
Fixed
Allowing that multiple View properties can map to the same Container property
  • Loading branch information
nikokaoja authored Apr 23, 2024
1 parent ff95651 commit 8172ce4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: run-explorer run-tests run-linters build-ui build-python build-docker run-docker compose-up

version="0.75.1"
version="0.75.2"
run-explorer:
@echo "Running explorer API server..."
# open "http://localhost:8000/static/index.html" || true
Expand Down
2 changes: 1 addition & 1 deletion cognite/neat/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.75.1"
__version__ = "0.75.2"
2 changes: 1 addition & 1 deletion cognite/neat/rules/issues/dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def dump(self) -> dict[str, Any]:

@dataclass(frozen=True)
class ContainerPropertyUsedMultipleTimesError(DMSSchemaError):
description = "The container property is used multiple times by the same view"
description = "The container property is used multiple times by the same view property"
fix = "Use unique container properties for when mapping to the same container"
error_name: ClassVar[str] = "ContainerPropertyUsedMultipleTimes"
container: dm.ContainerId
Expand Down
14 changes: 11 additions & 3 deletions cognite/neat/rules/models/rules/_dms_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,20 @@ def validate(self) -> list[DMSSchemaError]:
):
errors.add(MissingEdgeViewError(view=prop.edge_source, property=prop_name, referred_by=view_id))

# This allows for multiple view properties to be mapped to the same container property,
# as long as they have different external_id, otherwise this will lead to raising
# error ContainerPropertyUsedMultipleTimesError
property_count = Counter(
(prop.container, prop.container_property_identifier)
for prop in (view.properties or {}).values()
(prop.container, prop.container_property_identifier, view_property_identifier)
for view_property_identifier, prop in (view.properties or {}).items()
if isinstance(prop, dm.MappedPropertyApply)
)
for (container_id, container_property_identifier), count in property_count.items():

for (
container_id,
container_property_identifier,
_,
), count in property_count.items():
if count > 1:
view_properties = [
prop_name
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.75.2] - 23-05-24
### Fixed
- Allowing that multiple View properties can map to the same Container property

## [0.75.1] - 23-05-24
### Fixed
- No spaces in any of the subfolders of the `neat` package.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cognite-neat"
version = "0.75.1"
version = "0.75.2"
readme = "README.md"
description = "Knowledge graph transformation"
authors = [
Expand Down
11 changes: 0 additions & 11 deletions tests/tests_unit/rules/test_models/test_dms_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from cognite.client.data_classes import DatabaseWrite, DatabaseWriteList, TransformationWrite, TransformationWriteList

from cognite.neat.rules.issues.dms import (
ContainerPropertyUsedMultipleTimesError,
DirectRelationMissingSourceWarning,
DMSSchemaError,
DMSSchemaWarning,
Expand Down Expand Up @@ -113,16 +112,6 @@ def invalid_schema_test_cases() -> Iterable[ParameterSet]:
property="non_existing",
referred_by=dm.ViewId("my_space", "my_view1", "1"),
),
ContainerPropertyUsedMultipleTimesError(
referred_by=frozenset(
{
(dm.ViewId("my_space", "my_view2", "1"), "value"),
(dm.ViewId("my_space", "my_view2", "1"), "value2"),
}
),
container=dm.ContainerId("my_space", "my_container"),
property="value",
),
],
id="Missing container and properties. Container property used multiple times.",
)
Expand Down

0 comments on commit 8172ce4

Please sign in to comment.