Skip to content

Commit

Permalink
Take CDM and TypedInstances to GA (#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
erlendvollset authored Sep 12, 2024
1 parent 26dc07b commit 8d32e03
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 517 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.60.0] - 2024-09-12
### Changed
- Some changes to the typed instances functionality in the data modeling client
- The `TypedNode`, `TypedEdge`, etc. classes are moved from `data_classes.data_modeling.typed_instances` to `data_classes.data_modeling.instances`
- The `properties` attribute on `TypedNode`/`TypedEdge` now return data
- The `sources` attribute on `TypedNodeApply`/`TypedEdgeApply` now returns data


## [7.59.3] - 2024-09-12
### Fixed
- JSONDecodeError can no longer be raised in environments where simplejson is used instead of built-in json.
Expand Down
11 changes: 4 additions & 7 deletions cognite/client/_api/data_modeling/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@
T_Edge,
T_Node,
TargetUnit,
TypedEdge,
TypedNode,
TypeInformation,
)
from cognite.client.data_classes.data_modeling.query import (
Query,
QueryResult,
SourceSelector,
)
from cognite.client.data_classes.data_modeling.typed_instances import (
TypedEdge,
TypedNode,
)
from cognite.client.data_classes.data_modeling.views import View
from cognite.client.data_classes.filters import _BASIC_FILTERS, Filter, _validate_filter
from cognite.client.utils._auxiliary import load_yaml_or_json
Expand Down Expand Up @@ -372,7 +370,7 @@ def retrieve_edges(
... deleted_time: Union[int, None] = None,
... ) -> None:
... super().__init__(
... space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time, None
... space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
... )
... self.flow_rate = flow_rate
...
Expand Down Expand Up @@ -475,8 +473,7 @@ def retrieve_nodes(
... last_updated_time=last_updated_time,
... created_time=created_time,
... type=type,
... deleted_time=deleted_time,
... properties=None,
... deleted_time=deleted_time
... )
... self.name = name
... self.birth_year = birth_year
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.59.3"
__version__ = "7.60.0"
__api_subversion__ = "20230101"
6 changes: 1 addition & 5 deletions cognite/client/data_classes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,8 @@ def to_pandas(
pandas.DataFrame: The dataframe.
"""
pd = local_import("pandas")
from cognite.client.data_classes.data_modeling.typed_instances import _TypedInstance

if isinstance(self, _TypedInstance): # TODO: This is hacky, but it works for now
dumped = self.dump(camel_case=camel_case, use_attribute_name=not camel_case) # type: ignore [call-arg]
else:
dumped = self.dump(camel_case=camel_case)
dumped = self.dump(camel_case=camel_case)

for element in ignore or []:
dumped.pop(element, None)
Expand Down
4 changes: 1 addition & 3 deletions cognite/client/data_classes/data_modeling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@
NodeList,
NodeListWithCursor,
NodeOrEdgeData,
)
from cognite.client.data_classes.data_modeling.spaces import Space, SpaceApply, SpaceApplyList, SpaceList
from cognite.client.data_classes.data_modeling.typed_instances import (
PropertyOptions,
TypedEdge,
TypedEdgeApply,
TypedNode,
TypedNodeApply,
)
from cognite.client.data_classes.data_modeling.spaces import Space, SpaceApply, SpaceApplyList, SpaceList
from cognite.client.data_classes.data_modeling.views import (
ConnectionDefinition,
EdgeConnection,
Expand Down
66 changes: 18 additions & 48 deletions cognite/client/data_classes/data_modeling/cdm/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from cognite.client.data_classes.data_modeling import DirectRelationReference
from cognite.client.data_classes.data_modeling.ids import ViewId
from cognite.client.data_classes.data_modeling.typed_instances import (
from cognite.client.data_classes.data_modeling.instances import (
PropertyOptions,
TypedEdge,
TypedEdgeApply,
Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.translation_x = translation_x
self.translation_y = translation_y
self.translation_z = translation_z
Expand Down Expand Up @@ -128,7 +128,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.translation_x = translation_x
self.translation_y = translation_y
self.translation_z = translation_z
Expand Down Expand Up @@ -197,7 +197,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.front = DirectRelationReference.load(front) if front else None
self.back = DirectRelationReference.load(back) if back else None
self.left = DirectRelationReference.load(left) if left else None
Expand Down Expand Up @@ -246,7 +246,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.front = DirectRelationReference.load(front) if front else None
self.back = DirectRelationReference.load(back) if back else None
self.left = DirectRelationReference.load(left) if left else None
Expand Down Expand Up @@ -308,7 +308,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.status = status
self.published = published
self.revision_type = revision_type
Expand Down Expand Up @@ -351,7 +351,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.status = status
self.published = published
self.revision_type = revision_type
Expand Down Expand Up @@ -406,7 +406,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.name = name
self.description = description
self.tags = tags
Expand Down Expand Up @@ -449,7 +449,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.name = name
self.description = description
self.tags = tags
Expand Down Expand Up @@ -508,7 +508,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.start_time = start_time
self.end_time = end_time
self.scheduled_start_time = scheduled_start_time
Expand Down Expand Up @@ -550,7 +550,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.start_time = start_time
self.end_time = end_time
self.scheduled_start_time = scheduled_start_time
Expand Down Expand Up @@ -616,7 +616,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.source_id = source_id
self.source_context = source_context
self.source = DirectRelationReference.load(source) if source else None
Expand Down Expand Up @@ -666,7 +666,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.source_id = source_id
self.source_context = source_context
self.source = DirectRelationReference.load(source) if source else None
Expand Down Expand Up @@ -722,7 +722,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.object_3d = DirectRelationReference.load(object_3d) if object_3d else None


Expand Down Expand Up @@ -755,7 +755,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.object_3d = DirectRelationReference.load(object_3d) if object_3d else None

def as_write(self) -> CogniteVisualizableApply:
Expand Down Expand Up @@ -4519,17 +4519,7 @@ def __init__(
deleted_time: int | None = None,
) -> None:
TypedEdge.__init__(
self,
space,
external_id,
version,
type,
last_updated_time,
created_time,
start_node,
end_node,
deleted_time,
None,
self, space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
)
self.translation_x = translation_x
self.translation_y = translation_y
Expand Down Expand Up @@ -4643,17 +4633,7 @@ def __init__(
deleted_time: int | None = None,
) -> None:
TypedEdge.__init__(
self,
space,
external_id,
version,
type,
last_updated_time,
created_time,
start_node,
end_node,
deleted_time,
None,
self, space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
)
self.name = name
self.description = description
Expand Down Expand Up @@ -4768,17 +4748,7 @@ def __init__(
deleted_time: int | None = None,
) -> None:
TypedEdge.__init__(
self,
space,
external_id,
version,
type,
last_updated_time,
created_time,
start_node,
end_node,
deleted_time,
None,
self, space, external_id, version, type, last_updated_time, created_time, start_node, end_node, deleted_time
)
self.source_id = source_id
self.source_context = source_context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
CogniteTimeSeriesApply,
)
from cognite.client.data_classes.data_modeling.ids import ViewId
from cognite.client.data_classes.data_modeling.typed_instances import (
from cognite.client.data_classes.data_modeling.instances import (
PropertyOptions,
TypedNode,
TypedNodeApply,
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
) -> None:
TypedNodeApply.__init__(self, space, external_id, existing_version, None, type)
TypedNodeApply.__init__(self, space, external_id, existing_version, type)
self.extracted_data = extracted_data


Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(
type: DirectRelationReference | None = None,
deleted_time: int | None = None,
) -> None:
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, None, type)
TypedNode.__init__(self, space, external_id, version, last_updated_time, created_time, deleted_time, type)
self.extracted_data = extracted_data

def as_write(self) -> CogniteExtractorDataApply:
Expand Down
Loading

0 comments on commit 8d32e03

Please sign in to comment.