industrial-model 0.1.35__tar.gz → 0.1.36__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.35 → industrial_model-0.1.36}/PKG-INFO +1 -1
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/engines/engine.py +2 -16
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/models/__init__.py +2 -0
- industrial_model-0.1.36/industrial_model/models/utils.py +58 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/pyproject.toml +1 -1
- {industrial_model-0.1.35 → industrial_model-0.1.36}/.gitignore +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/README.md +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/__init__.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/__init__.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/aggregation_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/models.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/optimizer.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/query_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/search_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/upsert_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/utils.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/view_mapper.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/config.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/constants.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/engines/__init__.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/engines/async_engine.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/models/base.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/models/entities.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/models/schemas.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/py.typed +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/queries/__init__.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/queries/models.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/queries/params.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/queries/utils.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/statements/__init__.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/statements/expressions.py +0 -0
- {industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/utils.py +0 -0
|
@@ -5,12 +5,12 @@ from cognite.client import CogniteClient
|
|
|
5
5
|
from industrial_model.cognite_adapters import CogniteAdapter
|
|
6
6
|
from industrial_model.config import DataModelId
|
|
7
7
|
from industrial_model.models import (
|
|
8
|
-
EdgeContainer,
|
|
9
8
|
PaginatedResult,
|
|
10
9
|
TAggregatedViewInstance,
|
|
11
10
|
TViewInstance,
|
|
12
11
|
TWritableViewInstance,
|
|
13
12
|
ValidationMode,
|
|
13
|
+
include_edges,
|
|
14
14
|
)
|
|
15
15
|
from industrial_model.statements import (
|
|
16
16
|
AggregationStatement,
|
|
@@ -96,24 +96,10 @@ class Engine:
|
|
|
96
96
|
for item in data:
|
|
97
97
|
try:
|
|
98
98
|
validated_item = entity.model_validate(item)
|
|
99
|
-
|
|
99
|
+
include_edges(item, validated_item)
|
|
100
100
|
result.append(validated_item)
|
|
101
101
|
except Exception:
|
|
102
102
|
if validation_mode == "ignoreOnError":
|
|
103
103
|
continue
|
|
104
104
|
raise
|
|
105
105
|
return result
|
|
106
|
-
|
|
107
|
-
def _include_edges(
|
|
108
|
-
self, item: dict[str, Any], validated_item: TViewInstance
|
|
109
|
-
) -> None:
|
|
110
|
-
if "_edges" not in item or not isinstance(item["_edges"], dict):
|
|
111
|
-
return
|
|
112
|
-
entries: dict[str, list[EdgeContainer]] = {}
|
|
113
|
-
for property_, edges in item["_edges"].items():
|
|
114
|
-
if not edges or not isinstance(edges, list):
|
|
115
|
-
continue
|
|
116
|
-
|
|
117
|
-
assert isinstance(edges[0], EdgeContainer)
|
|
118
|
-
entries[property_] = edges
|
|
119
|
-
validated_item._edges = entries
|
|
@@ -13,12 +13,14 @@ from .entities import (
|
|
|
13
13
|
WritableViewInstance,
|
|
14
14
|
)
|
|
15
15
|
from .schemas import get_parent_and_children_nodes, get_schema_properties
|
|
16
|
+
from .utils import include_edges
|
|
16
17
|
|
|
17
18
|
__all__ = [
|
|
18
19
|
"AggregatedViewInstance",
|
|
19
20
|
"RootModel",
|
|
20
21
|
"EdgeContainer",
|
|
21
22
|
"InstanceId",
|
|
23
|
+
"include_edges",
|
|
22
24
|
"TAggregatedViewInstance",
|
|
23
25
|
"TViewInstance",
|
|
24
26
|
"TWritableViewInstance",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .entities import EdgeContainer, TViewInstance, ViewInstance
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def include_edges(
|
|
7
|
+
root_item: dict[str, Any], validated_root_item: TViewInstance
|
|
8
|
+
) -> None:
|
|
9
|
+
if not isinstance(root_item, dict) or not isinstance(
|
|
10
|
+
validated_root_item, ViewInstance
|
|
11
|
+
):
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
for property_, value in root_item.items():
|
|
15
|
+
field_key = validated_root_item.get_field_name(property_)
|
|
16
|
+
if not field_key:
|
|
17
|
+
continue
|
|
18
|
+
_handle_edge_property(validated_root_item, value, field_key)
|
|
19
|
+
_include_edges(root_item, validated_root_item)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _handle_edge_property(
|
|
23
|
+
validated_root_item: TViewInstance, value: Any, field_key: str
|
|
24
|
+
) -> None:
|
|
25
|
+
attr_value = getattr(validated_root_item, field_key, None)
|
|
26
|
+
|
|
27
|
+
if isinstance(value, dict):
|
|
28
|
+
_handle_dict_property(value, attr_value)
|
|
29
|
+
return
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
not isinstance(value, list)
|
|
33
|
+
or not isinstance(attr_value, list)
|
|
34
|
+
or len(value) != len(attr_value)
|
|
35
|
+
):
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
for index, value_item in enumerate(value):
|
|
39
|
+
entry = attr_value[index]
|
|
40
|
+
_handle_dict_property(value_item, entry)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _handle_dict_property(value: Any, attr_value: Any) -> None:
|
|
44
|
+
if isinstance(value, dict) and isinstance(attr_value, ViewInstance):
|
|
45
|
+
include_edges(value, attr_value)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _include_edges(item: dict[str, Any], validated_item: TViewInstance) -> None:
|
|
49
|
+
if "_edges" not in item or not isinstance(item["_edges"], dict):
|
|
50
|
+
return
|
|
51
|
+
entries: dict[str, list[EdgeContainer]] = {}
|
|
52
|
+
for property_, edges in item["_edges"].items():
|
|
53
|
+
if not edges or not isinstance(edges, list):
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
assert isinstance(edges[0], EdgeContainer)
|
|
57
|
+
entries[property_] = edges
|
|
58
|
+
validated_item._edges = entries
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/models.py
RENAMED
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/optimizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/sort_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/utils.py
RENAMED
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/cognite_adapters/view_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/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
|
{industrial_model-0.1.35 → industrial_model-0.1.36}/industrial_model/statements/expressions.py
RENAMED
|
File without changes
|
|
File without changes
|