industrial-model 1.0.1__tar.gz → 1.1.1__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-1.0.1 → industrial_model-1.1.1}/PKG-INFO +2 -2
- {industrial_model-1.0.1 → industrial_model-1.1.1}/README.md +1 -1
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/__init__.py +13 -4
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/upsert_mapper.py +9 -3
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/utils.py +7 -1
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/engines/async_engine.py +5 -2
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/engines/engine.py +10 -4
- {industrial_model-1.0.1 → industrial_model-1.1.1}/pyproject.toml +1 -1
- {industrial_model-1.0.1 → industrial_model-1.1.1}/.gitignore +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/LICENSE +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/__init__.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/aggregation_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/models.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/optimizer.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/query_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/search_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/view_mapper.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/config.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/constants.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/engines/__init__.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/engines/_internal.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/models/__init__.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/models/base.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/models/entities.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/models/schemas.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/models/utils.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/py.typed +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/queries/__init__.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/queries/models.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/queries/params.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/queries/utils.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/statements/__init__.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/statements/expressions.py +0 -0
- {industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: industrial-model
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Industrial Model ORM
|
|
5
5
|
Project-URL: Homepage, https://github.com/lucasrosaalves/industrial-model
|
|
6
6
|
Project-URL: Source, https://github.com/lucasrosaalves/industrial-model
|
|
@@ -309,7 +309,7 @@ instances = engine.query_all_pages(
|
|
|
309
309
|
for instance in instances:
|
|
310
310
|
instance.aliases.append("new_alias")
|
|
311
311
|
|
|
312
|
-
engine.upsert(instances, replace=False)
|
|
312
|
+
engine.upsert(instances, replace=False, remove_unset=False)
|
|
313
313
|
```
|
|
314
314
|
|
|
315
315
|
---
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/__init__.py
RENAMED
|
@@ -124,20 +124,29 @@ class CogniteAdapter:
|
|
|
124
124
|
return data
|
|
125
125
|
|
|
126
126
|
def upsert(
|
|
127
|
-
self,
|
|
127
|
+
self,
|
|
128
|
+
entries: list[TWritableViewInstance],
|
|
129
|
+
replace: bool = False,
|
|
130
|
+
remove_unset: bool = False,
|
|
128
131
|
) -> None:
|
|
129
132
|
logger = logging.getLogger(__name__)
|
|
130
|
-
operation = self._upsert_mapper.map(entries)
|
|
133
|
+
operation = self._upsert_mapper.map(entries, remove_unset)
|
|
131
134
|
|
|
132
135
|
for node_chunk in operation.chunk_nodes():
|
|
133
|
-
logger.debug(
|
|
136
|
+
logger.debug(
|
|
137
|
+
f"Upserting {len(node_chunk)} nodes (replace={replace}, "
|
|
138
|
+
"remove_unset={remove_unset})"
|
|
139
|
+
)
|
|
134
140
|
self._cognite_client.data_modeling.instances.apply(
|
|
135
141
|
nodes=node_chunk,
|
|
136
142
|
replace=replace,
|
|
137
143
|
)
|
|
138
144
|
|
|
139
145
|
for edge_chunk in operation.chunk_edges():
|
|
140
|
-
logger.debug(
|
|
146
|
+
logger.debug(
|
|
147
|
+
f"Upserting {len(edge_chunk)} edges (replace={replace},"
|
|
148
|
+
"remove_unset={remove_unset})"
|
|
149
|
+
)
|
|
141
150
|
self._cognite_client.data_modeling.instances.apply(
|
|
142
151
|
edges=edge_chunk,
|
|
143
152
|
replace=replace,
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/upsert_mapper.py
RENAMED
|
@@ -25,14 +25,16 @@ class UpsertMapper:
|
|
|
25
25
|
def __init__(self, view_mapper: ViewMapper):
|
|
26
26
|
self._view_mapper = view_mapper
|
|
27
27
|
|
|
28
|
-
def map(
|
|
28
|
+
def map(
|
|
29
|
+
self, instances: list[TWritableViewInstance], remove_unset: bool
|
|
30
|
+
) -> UpsertOperation:
|
|
29
31
|
nodes: dict[tuple[str, str], NodeApply] = {}
|
|
30
32
|
edges: dict[tuple[str, str], EdgeApply] = {}
|
|
31
33
|
edges_to_delete: dict[tuple[str, str], EdgeContainer] = {}
|
|
32
34
|
|
|
33
35
|
for instance in instances:
|
|
34
36
|
entry_nodes, entry_edges, entry_edges_to_delete = self._map_instance(
|
|
35
|
-
instance
|
|
37
|
+
instance, remove_unset
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
nodes[instance.as_tuple()] = entry_nodes
|
|
@@ -48,7 +50,7 @@ class UpsertMapper:
|
|
|
48
50
|
)
|
|
49
51
|
|
|
50
52
|
def _map_instance(
|
|
51
|
-
self, instance: TWritableViewInstance
|
|
53
|
+
self, instance: TWritableViewInstance, remove_unset: bool
|
|
52
54
|
) -> tuple[NodeApply, list[EdgeApply], list[EdgeContainer]]:
|
|
53
55
|
view = self._view_mapper.get_view(instance.get_view_external_id())
|
|
54
56
|
|
|
@@ -59,6 +61,10 @@ class UpsertMapper:
|
|
|
59
61
|
property_key = instance.get_field_name(property_name)
|
|
60
62
|
if not property_key:
|
|
61
63
|
continue
|
|
64
|
+
|
|
65
|
+
if remove_unset and property_key not in instance.model_fields_set:
|
|
66
|
+
continue
|
|
67
|
+
|
|
62
68
|
entry = instance.__getattribute__(property_key)
|
|
63
69
|
|
|
64
70
|
if isinstance(property, MappedProperty):
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/utils.py
RENAMED
|
@@ -26,7 +26,13 @@ from industrial_model.models import (
|
|
|
26
26
|
get_parent_and_children_nodes,
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
NODE_PROPERTIES = {
|
|
29
|
+
NODE_PROPERTIES = {
|
|
30
|
+
"externalId",
|
|
31
|
+
"space",
|
|
32
|
+
"createdTime",
|
|
33
|
+
"deletedTime",
|
|
34
|
+
"lastUpdatedTime",
|
|
35
|
+
}
|
|
30
36
|
INTANCE_TYPE = Literal["node", "edge"]
|
|
31
37
|
|
|
32
38
|
|
|
@@ -55,9 +55,12 @@ class AsyncEngine:
|
|
|
55
55
|
return await self._engine.aggregate_async(statement)
|
|
56
56
|
|
|
57
57
|
async def upsert_async(
|
|
58
|
-
self,
|
|
58
|
+
self,
|
|
59
|
+
entries: list[TWritableViewInstance],
|
|
60
|
+
replace: bool = False,
|
|
61
|
+
remove_unset: bool = False,
|
|
59
62
|
) -> None:
|
|
60
|
-
return await self._engine.upsert_async(entries, replace)
|
|
63
|
+
return await self._engine.upsert_async(entries, replace, remove_unset)
|
|
61
64
|
|
|
62
65
|
async def delete_async(self, nodes: list[TViewInstance]) -> None:
|
|
63
66
|
return await self._engine.delete_async(nodes)
|
|
@@ -98,17 +98,23 @@ class Engine:
|
|
|
98
98
|
return await run_async(self.aggregate, statement)
|
|
99
99
|
|
|
100
100
|
def upsert(
|
|
101
|
-
self,
|
|
101
|
+
self,
|
|
102
|
+
entries: list[TWritableViewInstance],
|
|
103
|
+
replace: bool = False,
|
|
104
|
+
remove_unset: bool = False,
|
|
102
105
|
) -> None:
|
|
103
106
|
if not entries:
|
|
104
107
|
return
|
|
105
108
|
|
|
106
|
-
return self._cognite_adapter.upsert(entries, replace)
|
|
109
|
+
return self._cognite_adapter.upsert(entries, replace, remove_unset)
|
|
107
110
|
|
|
108
111
|
async def upsert_async(
|
|
109
|
-
self,
|
|
112
|
+
self,
|
|
113
|
+
entries: list[TWritableViewInstance],
|
|
114
|
+
replace: bool = False,
|
|
115
|
+
remove_unset: bool = False,
|
|
110
116
|
) -> None:
|
|
111
|
-
return await run_async(self.upsert, entries, replace)
|
|
117
|
+
return await run_async(self.upsert, entries, replace, remove_unset)
|
|
112
118
|
|
|
113
119
|
def delete(self, nodes: list[TViewInstance]) -> None:
|
|
114
120
|
self._cognite_adapter.delete(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/filter_mapper.py
RENAMED
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/models.py
RENAMED
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/optimizer.py
RENAMED
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/query_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/search_mapper.py
RENAMED
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/sort_mapper.py
RENAMED
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/cognite_adapters/view_mapper.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-1.0.1 → industrial_model-1.1.1}/industrial_model/statements/expressions.py
RENAMED
|
File without changes
|
|
File without changes
|