cognite-neat 0.120.0__py3-none-any.whl → 0.121.0__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.
- cognite/neat/_version.py +1 -1
- cognite/neat/core/_graph/extractors/_classic_cdf/_files.py +10 -3
- cognite/neat/session/_read.py +57 -0
- {cognite_neat-0.120.0.dist-info → cognite_neat-0.121.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.120.0.dist-info → cognite_neat-0.121.0.dist-info}/RECORD +7 -7
- {cognite_neat-0.120.0.dist-info → cognite_neat-0.121.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.120.0.dist-info → cognite_neat-0.121.0.dist-info}/licenses/LICENSE +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.121.0"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -20,7 +20,7 @@ class FilesExtractor(ClassicCDFBaseExtractor[FileMetadata]):
|
|
|
20
20
|
data_set_external_id: str,
|
|
21
21
|
) -> tuple[int | None, Iterable[FileMetadata]]:
|
|
22
22
|
items = client.files(data_set_external_ids=data_set_external_id)
|
|
23
|
-
return None, items
|
|
23
|
+
return None, cls._filter_out_instance_id(items)
|
|
24
24
|
|
|
25
25
|
@classmethod
|
|
26
26
|
def _from_hierarchy(
|
|
@@ -30,9 +30,16 @@ class FilesExtractor(ClassicCDFBaseExtractor[FileMetadata]):
|
|
|
30
30
|
filter=FileMetadataFilter(asset_subtree_ids=[{"externalId": root_asset_external_id}])
|
|
31
31
|
)[0].count
|
|
32
32
|
items = client.files(asset_subtree_external_ids=root_asset_external_id)
|
|
33
|
-
return total, items
|
|
33
|
+
return total, cls._filter_out_instance_id(items)
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
36
|
def _from_file(cls, file_path: str | Path) -> tuple[int | None, Iterable[FileMetadata]]:
|
|
37
37
|
file_metadata = FileMetadataList.load(Path(file_path).read_text())
|
|
38
|
-
return len(file_metadata), file_metadata
|
|
38
|
+
return len(file_metadata), cls._filter_out_instance_id(file_metadata)
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def _filter_out_instance_id(cls, items: Iterable[FileMetadata]) -> Iterable[FileMetadata]:
|
|
42
|
+
"""Filter out TimeSeries with InstanceId."""
|
|
43
|
+
# If the InstanceId is not None, it means that the TimeSeries is already connected to CogniteTimeSeries in DMS.
|
|
44
|
+
# We do not want to download it again.
|
|
45
|
+
return (item for item in items if item.instance_id is None)
|
cognite/neat/session/_read.py
CHANGED
|
@@ -468,6 +468,63 @@ class CDFClassicAPI(BaseReadAPI):
|
|
|
468
468
|
|
|
469
469
|
return extract_issues
|
|
470
470
|
|
|
471
|
+
def file_metadata(self, data_set_external_id: str, identifier: Literal["id", "externalId"] = "id") -> IssueList:
|
|
472
|
+
"""Read the file metadata from CDF into NEAT.
|
|
473
|
+
|
|
474
|
+
Note all files that have InstanceId set will be silently skipped. This method is for extracting
|
|
475
|
+
non-contextualized file medata only. If you want to include the potential connection from file metadata
|
|
476
|
+
to assets, use the `neat.read.cdf.graph()` method instead and select the asset hierarchy connected to this file.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
data_set_external_id: The external id of the data set
|
|
480
|
+
identifier: The identifier to use for the file metadata. Note selecting "id" can cause issues
|
|
481
|
+
if the external ID of the file metadata is missing. Default is "id".
|
|
482
|
+
|
|
483
|
+
Returns:
|
|
484
|
+
IssueList: A list of issues that occurred during the extraction.
|
|
485
|
+
|
|
486
|
+
Example:
|
|
487
|
+
```python
|
|
488
|
+
neat.read.cdf.time_series("data_set_external_id")
|
|
489
|
+
```
|
|
490
|
+
"""
|
|
491
|
+
namespace = CLASSIC_CDF_NAMESPACE
|
|
492
|
+
self._state._raise_exception_if_condition_not_met(
|
|
493
|
+
"Read time series",
|
|
494
|
+
empty_rules_store_required=True,
|
|
495
|
+
empty_instances_store_required=True,
|
|
496
|
+
client_required=True,
|
|
497
|
+
)
|
|
498
|
+
extractor = extractors.FilesExtractor.from_dataset(
|
|
499
|
+
cast(NeatClient, self._state.client),
|
|
500
|
+
data_set_external_id=data_set_external_id,
|
|
501
|
+
namespace=namespace,
|
|
502
|
+
identifier=identifier,
|
|
503
|
+
prefix="Classic",
|
|
504
|
+
skip_connections=True,
|
|
505
|
+
)
|
|
506
|
+
self._state.instances.neat_prefix_by_predicate_uri.update(
|
|
507
|
+
{
|
|
508
|
+
namespace["dataSetId"]: InstanceIdPrefix.data_set,
|
|
509
|
+
namespace["assetId"]: InstanceIdPrefix.asset,
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
self._state.instances.neat_prefix_by_type_uri.update(
|
|
513
|
+
{namespace[f"Classic{extractor._default_rdf_type}"]: InstanceIdPrefix.time_series}
|
|
514
|
+
)
|
|
515
|
+
extract_issues = self._state.instances.store.write(extractor)
|
|
516
|
+
|
|
517
|
+
if identifier == "externalId":
|
|
518
|
+
self._state.quoted_source_identifiers = True
|
|
519
|
+
|
|
520
|
+
self._state.instances.store.transform(
|
|
521
|
+
LiteralToEntity(None, namespace["source"], "ClassicSourceSystem", "name"),
|
|
522
|
+
)
|
|
523
|
+
# The above transformations creates a new type, so we need to update
|
|
524
|
+
self._state.instances.neat_prefix_by_type_uri.update({namespace["ClassicSourceSystem"]: "ClassicSourceSystem_"})
|
|
525
|
+
|
|
526
|
+
return extract_issues
|
|
527
|
+
|
|
471
528
|
|
|
472
529
|
@session_class_wrapper
|
|
473
530
|
class ExcelReadAPI(BaseReadAPI):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cognite/neat/__init__.py,sha256=12StS1dzH9_MElqxGvLWrNsxCJl9Hv8A2a9D0E5OD_U,193
|
|
2
|
-
cognite/neat/_version.py,sha256=
|
|
2
|
+
cognite/neat/_version.py,sha256=xJwEparSzjV7HbmKhGalETztG6Tt0qxJf_4jvRe15wA,46
|
|
3
3
|
cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
cognite/neat/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite/neat/core/_config.py,sha256=WT1BS8uADcFvGoUYOOfwFOVq_VBl472TisdoA3wLick,280
|
|
@@ -39,7 +39,7 @@ cognite/neat/core/_graph/extractors/_classic_cdf/_base.py,sha256=IJkdrKhUOfofPa1
|
|
|
39
39
|
cognite/neat/core/_graph/extractors/_classic_cdf/_classic.py,sha256=bYzTTcjDWgBc7frY-q9cy6Nz8hKSXIex-6nfEv_m_a8,24272
|
|
40
40
|
cognite/neat/core/_graph/extractors/_classic_cdf/_data_sets.py,sha256=xRFv9pVFgIMTZ45E8teMC0Ynku_CuZdcZkVCbhPuPBk,1294
|
|
41
41
|
cognite/neat/core/_graph/extractors/_classic_cdf/_events.py,sha256=B8hRoMAg8GQvApjxals5PfPyjmdPO93U3nj_G7g0kDQ,1394
|
|
42
|
-
cognite/neat/core/_graph/extractors/_classic_cdf/_files.py,sha256=
|
|
42
|
+
cognite/neat/core/_graph/extractors/_classic_cdf/_files.py,sha256=9lIleYyM3r0_CHteTEWboyknBeHYNtvgpNJuvS9UUU0,1894
|
|
43
43
|
cognite/neat/core/_graph/extractors/_classic_cdf/_labels.py,sha256=7guTZdGFT1r7ItE2VNgXwbBZ1y_005oB3fg1XbwT7WQ,2083
|
|
44
44
|
cognite/neat/core/_graph/extractors/_classic_cdf/_relationships.py,sha256=kNzrqHQuIZMBecZ8957Qs3-Pp2m2-k2CCfiUZlVwaD0,5395
|
|
45
45
|
cognite/neat/core/_graph/extractors/_classic_cdf/_sequences.py,sha256=zwHM52afnq-JHvLOTi4rH6DyfkTftxH6cmODwoZi8uw,11399
|
|
@@ -167,7 +167,7 @@ cognite/neat/session/_fix.py,sha256=OJ6xE6Icfdh9pO-ObnlGt-7nwbVVS_nC2fyFoHCDhjg,
|
|
|
167
167
|
cognite/neat/session/_inspect.py,sha256=Wual0vgetcIOje7IlTE0y-aM43Ydwf4WEr2LjbbBRZA,10116
|
|
168
168
|
cognite/neat/session/_mapping.py,sha256=sRSxrTq_ksUwt9NMgGDNXp5jd9U5ZXxYVZtpjrCBr1c,2670
|
|
169
169
|
cognite/neat/session/_prepare.py,sha256=s3sERSmdEHru80zO2W7CLrz7h9HuGVKubF7KNWK74qo,12742
|
|
170
|
-
cognite/neat/session/_read.py,sha256=
|
|
170
|
+
cognite/neat/session/_read.py,sha256=otmmTZFH_Cq5SI_ns3pXEJezzzRvwPRVyfjNSJjQkLE,34999
|
|
171
171
|
cognite/neat/session/_set.py,sha256=p6uo3LUUm5XpkotXTfeoVdlETfSVNGBauTKLqa4jW_M,4518
|
|
172
172
|
cognite/neat/session/_show.py,sha256=Psu94RoAaSZ6KyzXFKNHYeOhHjGwz8c3u314X75-oR0,10565
|
|
173
173
|
cognite/neat/session/_state.py,sha256=8yLenza6rcvk1q2hY5mI1-OXfjocoEOHLBRyz23-Lbw,6353
|
|
@@ -181,7 +181,7 @@ cognite/neat/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvc
|
|
|
181
181
|
cognite/neat/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
|
|
182
182
|
cognite/neat/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
|
|
183
183
|
cognite/neat/session/engine/_load.py,sha256=g52uYakQM03VqHt_RDHtpHso1-mFFifH5M4T2ScuH8A,5198
|
|
184
|
-
cognite_neat-0.
|
|
185
|
-
cognite_neat-0.
|
|
186
|
-
cognite_neat-0.
|
|
187
|
-
cognite_neat-0.
|
|
184
|
+
cognite_neat-0.121.0.dist-info/METADATA,sha256=kVGUUswt8v2KCpVbTcSLM3Dw1--dcl1vzHyMP3oNl2s,7608
|
|
185
|
+
cognite_neat-0.121.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
186
|
+
cognite_neat-0.121.0.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
187
|
+
cognite_neat-0.121.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|