industrial-model 0.1.30__tar.gz → 0.1.31__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {industrial_model-0.1.30 → industrial_model-0.1.31}/PKG-INFO +1 -1
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/query_result_mapper.py +34 -8
- {industrial_model-0.1.30 → industrial_model-0.1.31}/pyproject.toml +1 -1
- {industrial_model-0.1.30 → industrial_model-0.1.31}/.gitignore +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/README.md +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/aggregation_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/models.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/optimizer.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/query_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/search_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/upsert_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/utils.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/view_mapper.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/config.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/constants.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/engines/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/engines/async_engine.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/engines/engine.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/models/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/models/base.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/models/entities.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/models/schemas.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/py.typed +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/queries/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/queries/models.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/queries/params.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/queries/utils.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/statements/__init__.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/statements/expressions.py +0 -0
- {industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/utils.py +0 -0
|
@@ -10,6 +10,10 @@ from cognite.client.data_classes.data_modeling import (
|
|
|
10
10
|
NodeList,
|
|
11
11
|
View,
|
|
12
12
|
)
|
|
13
|
+
from cognite.client.data_classes.data_modeling.data_types import (
|
|
14
|
+
ListablePropertyType,
|
|
15
|
+
)
|
|
16
|
+
from cognite.client.data_classes.data_modeling.instances import PropertyValue
|
|
13
17
|
from cognite.client.data_classes.data_modeling.views import (
|
|
14
18
|
MultiReverseDirectRelation,
|
|
15
19
|
SingleReverseDirectRelation,
|
|
@@ -112,13 +116,13 @@ class QueryResultMapper:
|
|
|
112
116
|
):
|
|
113
117
|
continue
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
(element.get("space", ""), element.get("externalId", ""))
|
|
117
|
-
if isinstance(element, dict)
|
|
118
|
-
else (node.space, node.external_id)
|
|
119
|
-
)
|
|
119
|
+
element_keys = self._get_element_keys(node, element)
|
|
120
120
|
|
|
121
|
-
node_entries =
|
|
121
|
+
node_entries = [
|
|
122
|
+
item
|
|
123
|
+
for element_key in element_keys
|
|
124
|
+
for item in mapping_nodes.get(element_key, [])
|
|
125
|
+
]
|
|
122
126
|
if not node_entries:
|
|
123
127
|
if mapping_key in properties:
|
|
124
128
|
properties.pop(mapping_key)
|
|
@@ -126,7 +130,11 @@ class QueryResultMapper:
|
|
|
126
130
|
|
|
127
131
|
entry_data = self.nodes_to_dict(node_entries)
|
|
128
132
|
properties[mapping_key] = entry_data if is_list else entry_data[0]
|
|
129
|
-
edge_entries =
|
|
133
|
+
edge_entries = [
|
|
134
|
+
item
|
|
135
|
+
for element_key in element_keys
|
|
136
|
+
for item in mapping_edges.get(element_key, [])
|
|
137
|
+
]
|
|
130
138
|
if edge_entries:
|
|
131
139
|
edges_mapping[mapping_key] = self._edges_to_model(edge_entries)
|
|
132
140
|
properties["_edges"] = edges_mapping
|
|
@@ -137,6 +145,21 @@ class QueryResultMapper:
|
|
|
137
145
|
|
|
138
146
|
return dict(result)
|
|
139
147
|
|
|
148
|
+
def _get_element_keys(
|
|
149
|
+
self, node: Node, element: PropertyValue | None
|
|
150
|
+
) -> list[tuple[str, str]]:
|
|
151
|
+
if isinstance(element, dict):
|
|
152
|
+
return [(element.get("space", ""), element.get("externalId", ""))]
|
|
153
|
+
|
|
154
|
+
if isinstance(element, list):
|
|
155
|
+
return [
|
|
156
|
+
(item.get("space", ""), item.get("externalId", ""))
|
|
157
|
+
for item in element
|
|
158
|
+
if isinstance(item, dict)
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
return [(node.space, node.external_id)]
|
|
162
|
+
|
|
140
163
|
def _get_property_mappings(
|
|
141
164
|
self,
|
|
142
165
|
key: str,
|
|
@@ -159,7 +182,10 @@ class QueryResultMapper:
|
|
|
159
182
|
self._view_mapper.get_view(property.source.external_id),
|
|
160
183
|
query_result,
|
|
161
184
|
)
|
|
162
|
-
is_list =
|
|
185
|
+
is_list = (
|
|
186
|
+
isinstance(property.type, ListablePropertyType)
|
|
187
|
+
and property.type.is_list
|
|
188
|
+
)
|
|
163
189
|
connection_type = ConnectionTypeEnum.DIRECT_RELATION
|
|
164
190
|
elif isinstance(property, SingleReverseDirectRelation) and property.source:
|
|
165
191
|
nodes = self._map_node_property(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/models.py
RENAMED
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/optimizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/sort_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/utils.py
RENAMED
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/cognite_adapters/view_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/engines/async_engine.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.30 → industrial_model-0.1.31}/industrial_model/statements/expressions.py
RENAMED
|
File without changes
|
|
File without changes
|