cognite-neat 0.100.0__py3-none-any.whl → 0.100.1__py3-none-any.whl

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.

Potentially problematic release.


This version of cognite-neat might be problematic. Click here for more details.

@@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
3
3
  from collections.abc import Callable, Collection, Iterable, Sequence
4
4
  from dataclasses import dataclass, field
5
5
  from graphlib import TopologicalSorter
6
- from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar, cast
6
+ from typing import TYPE_CHECKING, Any, ClassVar, Generic, Literal, TypeVar, cast
7
7
 
8
8
  from cognite.client.data_classes import filters
9
9
  from cognite.client.data_classes._base import (
@@ -363,9 +363,16 @@ class SpaceLoader(DataModelingLoader[str, SpaceApply, Space, SpaceApplyList, Spa
363
363
  return SpaceApplyList(schema.spaces.values())
364
364
 
365
365
  def has_data(self, item_id: str) -> bool:
366
- return bool(self._client.data_modeling.instances.list("node", limit=1, space=item_id)) or bool(
367
- self._client.data_modeling.instances.list("edge", limit=1, space=item_id)
368
- )
366
+ if self._client.data_modeling.instances.list("node", limit=1, space=item_id):
367
+ return True
368
+ if self._client.data_modeling.instances.list("edge", limit=1, space=item_id):
369
+ return True
370
+ # Need to check if there are any containers with data in the space. Typically,
371
+ # a schema space will not contain data, while it will have containers that have data in an instance space.
372
+ for container in self._client.data_modeling.containers(space=item_id, include_global=False):
373
+ if self._client.loaders.containers.has_data(container.as_id()):
374
+ return True
375
+ return False
369
376
 
370
377
 
371
378
  class ContainerLoader(DataModelingLoader[ContainerId, ContainerApply, Container, ContainerApplyList, ContainerList]):
@@ -490,10 +497,23 @@ class ContainerLoader(DataModelingLoader[ContainerId, ContainerApply, Container,
490
497
  return ContainerApplyList(schema.containers.values())
491
498
 
492
499
  def has_data(self, item_id: ContainerId) -> bool:
493
- has_data = filters.HasData(containers=[item_id])
494
- return bool(self._client.data_modeling.instances.list("node", limit=1, filter=has_data)) or bool(
495
- self._client.data_modeling.instances.list("edge", limit=1, filter=has_data)
496
- )
500
+ has_data_filter = filters.HasData(containers=[item_id])
501
+ has_data = False
502
+ instance_type: Literal["node", "edge"]
503
+ # Mypy does not understand that the instance type is Literal["node", "edge"]
504
+ for instance_type in ["node", "edge"]: # type: ignore[assignment]
505
+ try:
506
+ has_data = bool(
507
+ self._client.data_modeling.instances.list(instance_type, limit=1, filter=has_data_filter)
508
+ )
509
+ except CogniteAPIError as e:
510
+ if e.code != 400:
511
+ # If the container is used for nodes and we ask for edges, we get a 400 error. This
512
+ # means there is no edge data for this container.
513
+ raise
514
+ if has_data:
515
+ return True
516
+ return has_data
497
517
 
498
518
 
499
519
  class ViewLoader(DataModelingLoader[ViewId, ViewApply, View, ViewApplyList, ViewList]):
@@ -304,12 +304,12 @@ class DMSExporter(CDFExporter[DMSRules, DMSSchema]):
304
304
  and not loader.in_space(item, self.include_space)
305
305
  ):
306
306
  continue
307
-
308
- cdf_item = cdf_item_by_id.get(loader.get_id(item))
307
+ item_id = loader.get_id(item)
308
+ cdf_item = cdf_item_by_id.get(item_id)
309
309
  if cdf_item is None:
310
310
  categorized.to_create.append(item)
311
311
  elif is_redeploying or self.existing == "recreate":
312
- if loader.has_data(cdf_item) and not self.drop_data:
312
+ if not self.drop_data and loader.has_data(item_id):
313
313
  categorized.to_skip.append(cdf_item)
314
314
  else:
315
315
  categorized.to_delete.append(cdf_item.as_write())
@@ -132,7 +132,7 @@ class CDFToAPI:
132
132
  dry_run: bool = False,
133
133
  drop_data: bool = False,
134
134
  components: Component | Collection[Component] | None = None,
135
- ):
135
+ ) -> UploadResultList:
136
136
  """Export the verified DMS data model to CDF.
137
137
 
138
138
  Args:
@@ -164,5 +164,5 @@ class CDFToAPI:
164
164
  result = exporter.export_to_cdf(self._state.data_model.last_verified_dms_rules[1], self._client, dry_run)
165
165
  result.insert(0, UploadResultCore(name="schema", issues=conversion_issues))
166
166
  self._state.data_model.outcome.append(result)
167
- print("You can inspect the details with the .inspect.data_model.outcome(...) method.")
167
+ print("You can inspect the details with the .inspect.outcome.data_model(...) method.")
168
168
  return result
cognite/neat/_version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.100.0"
1
+ __version__ = "0.100.1"
2
2
  __engine__ = "^2.0.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.100.0
3
+ Version: 0.100.1
4
4
  Summary: Knowledge graph transformation
5
5
  Home-page: https://cognite-neat.readthedocs-hosted.com/
6
6
  License: Apache-2.0
@@ -73,7 +73,7 @@ cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx,sha256=dU6xZip3MVaVzKAF
73
73
  cognite/neat/_app/ui/neat-app/tsconfig.json,sha256=sw7AweQXRyJAIQ8Beft_380Q8zBr54pG1P_wutdPAIQ,664
74
74
  cognite/neat/_client/__init__.py,sha256=XpWT30mZdAJNHV84NJAWyAd2jZEGq9-IwvwK_wsOHdQ,177
75
75
  cognite/neat/_client/_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
- cognite/neat/_client/_api/data_modeling_loaders.py,sha256=1uxFZCVOSShWOy4wyMfCGVzOSJML_2GFrDn3Xqwz8ic,32943
76
+ cognite/neat/_client/_api/data_modeling_loaders.py,sha256=SBAz0MDJjw7FWjZOLpZZWJ741DdiEYI16iEJu_u5iuQ,33965
77
77
  cognite/neat/_client/_api/schema.py,sha256=ZxO9FkgFGF_sI6yVmrztWvb2zo7Exgxtq4-SX2dpISY,4830
78
78
  cognite/neat/_client/_api_client.py,sha256=6cNMizDuqMJZiOqiNRLX46BEtlCB-BpgGLyypksRVYU,616
79
79
  cognite/neat/_client/data_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -149,7 +149,7 @@ cognite/neat/_rules/catalog/__init__.py,sha256=dzx-DYYJDc861aFiOI5o1FsySD9F1agY8
149
149
  cognite/neat/_rules/catalog/info-rules-imf.xlsx,sha256=7odm5CoAU72-VTZk_z1u7GbycIb-X-8Yy3mtBGLjhE4,55511
150
150
  cognite/neat/_rules/exporters/__init__.py,sha256=jCwXAeyZJv7GNJ3hGG-80gb8LAidozsyFMzdNIsGt_Y,1204
151
151
  cognite/neat/_rules/exporters/_base.py,sha256=vadYWb5hVbjiPIhVIzlY6ARisoqhtJa6Ce0ysNHPXQc,1328
152
- cognite/neat/_rules/exporters/_rules2dms.py,sha256=13vr0RfZ1OdJKQh9Ye06HhY9MibyI6fIjAZNXOjPzM8,15784
152
+ cognite/neat/_rules/exporters/_rules2dms.py,sha256=csaFRdebr8WzqjUcUpjnKkTfbPctk_5D-w-G0p_WtsA,15812
153
153
  cognite/neat/_rules/exporters/_rules2excel.py,sha256=puFgIf_dolxv38Lkgzl9lDDREWDPdTApqgYCu9H-hf4,11689
154
154
  cognite/neat/_rules/exporters/_rules2instance_template.py,sha256=8HM1SkzcucaEYpQi96ncMnL8STArX9Oe09JBhJJAN4I,5810
155
155
  cognite/neat/_rules/exporters/_rules2ontology.py,sha256=ioMi1GUhnbvcfVOPb3Z0a24mIEe74AfxySETWMDS9Lc,21776
@@ -213,7 +213,7 @@ cognite/neat/_session/_read.py,sha256=4G34X_7hNs5V0gCLHPR1ktva6-fyGmwVc1Qu7T5yQd
213
213
  cognite/neat/_session/_set.py,sha256=NY0Vz8xD_a-UA8qWE1GFxHdmBl1BkT1KHQehQVKUorI,1914
214
214
  cognite/neat/_session/_show.py,sha256=_ev_Z41rkW4nlvhLf69PmttggKksnkCchOow7CmICyU,14124
215
215
  cognite/neat/_session/_state.py,sha256=rqKHkikagO1pf_fKpY-LZI1X5R_v6AyYpV72_3eSduM,5783
216
- cognite/neat/_session/_to.py,sha256=4BlDplDeWpKDtlU_gRsnWUtUU5O8udu60M99Clkj8uE,7345
216
+ cognite/neat/_session/_to.py,sha256=_NJn8tGTEcAoWpuCI6stquKNBuD8CqHqXLpSKkeT_1g,7365
217
217
  cognite/neat/_session/_wizard.py,sha256=O8d0FA87RIoiTOD2KLyTVsxwA2-ewAG2By4JfxXSL84,1474
218
218
  cognite/neat/_session/engine/__init__.py,sha256=aeI5pzljU5n1B-SVu3LwjYVsN1tSVhnJj-4ddflEo4U,120
219
219
  cognite/neat/_session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
@@ -236,7 +236,7 @@ cognite/neat/_utils/text.py,sha256=PvTEsEjaTu8SE8yYaKUrce4msboMj933dK7-0Eey_rE,3
236
236
  cognite/neat/_utils/time_.py,sha256=O30LUiDH9TdOYz8_a9pFqTtJdg8vEjC3qHCk8xZblG8,345
237
237
  cognite/neat/_utils/upload.py,sha256=iWKmsQgw4EHLv-11NjYu7zAj5LtqTAfNa87a1kWeuaU,5727
238
238
  cognite/neat/_utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP2DQ,1710
239
- cognite/neat/_version.py,sha256=eh_DxNC2vregq7YQ4Xva_dCIhx2cQZZzwj9dWC8c9Ro,46
239
+ cognite/neat/_version.py,sha256=nA_YK6_YjwJqujTlS_0t_IcLFjNgqEIsI8sSheyAdKI,46
240
240
  cognite/neat/_workflows/__init__.py,sha256=S0fZq7kvoqDKodHu1UIPsqcpdvXoefUWRPt1lqeQkQs,420
241
241
  cognite/neat/_workflows/base.py,sha256=O1pcmfbme2gIVF2eOGrKZSUDmhZc8L9rI8UfvLN2YAM,26839
242
242
  cognite/neat/_workflows/cdf_store.py,sha256=3pebnATPo6In4-1srpa3wzstynTOi3T6hwFX5uaie4c,18050
@@ -265,8 +265,8 @@ cognite/neat/_workflows/tasks.py,sha256=dr2xuIb8P5e5e9p_fjzRlvDbKsre2xGYrkc3wnRx
265
265
  cognite/neat/_workflows/triggers.py,sha256=u69xOsaTtM8_WD6ZeIIBB-XKwvlZmPHAsZQh_TnyHcM,7073
266
266
  cognite/neat/_workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
267
267
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
268
- cognite_neat-0.100.0.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
269
- cognite_neat-0.100.0.dist-info/METADATA,sha256=AjYvxb6mNdDWqksrQB8VxU32DVzWV-Hth9obwsZL6gU,9699
270
- cognite_neat-0.100.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
271
- cognite_neat-0.100.0.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
272
- cognite_neat-0.100.0.dist-info/RECORD,,
268
+ cognite_neat-0.100.1.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
269
+ cognite_neat-0.100.1.dist-info/METADATA,sha256=_uca35iR6CWYhSThIO4TX9xD6alAHLmNcjr9Jwda7UE,9699
270
+ cognite_neat-0.100.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
271
+ cognite_neat-0.100.1.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
272
+ cognite_neat-0.100.1.dist-info/RECORD,,