cognite-neat 0.75.8__py3-none-any.whl → 0.76.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/app/api/configuration.py +4 -9
- cognite/neat/app/api/routers/configuration.py +2 -1
- cognite/neat/app/api/routers/crud.py +5 -5
- cognite/neat/app/api/routers/data_exploration.py +3 -1
- cognite/neat/app/api/routers/rules.py +3 -3
- cognite/neat/app/api/routers/workflows.py +3 -3
- cognite/neat/app/ui/neat-app/build/asset-manifest.json +3 -3
- cognite/neat/app/ui/neat-app/build/index.html +1 -1
- cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js → main.ec7f72e2.js} +3 -3
- cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js.map → main.ec7f72e2.js.map} +1 -1
- cognite/neat/config.py +147 -12
- cognite/neat/constants.py +1 -0
- cognite/neat/graph/exceptions.py +1 -2
- cognite/neat/legacy/graph/exceptions.py +1 -2
- cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +1 -2
- cognite/neat/legacy/graph/loaders/_asset_loader.py +8 -13
- cognite/neat/legacy/graph/loaders/_base.py +2 -4
- cognite/neat/legacy/graph/loaders/_exceptions.py +1 -3
- cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +4 -8
- cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +2 -4
- cognite/neat/legacy/graph/loaders/rdf_to_dms.py +2 -4
- cognite/neat/legacy/graph/loaders/validator.py +1 -1
- cognite/neat/legacy/graph/transformations/transformer.py +1 -2
- cognite/neat/legacy/rules/exporters/_rules2dms.py +1 -2
- cognite/neat/legacy/rules/exporters/_validation.py +4 -8
- cognite/neat/legacy/rules/importers/_base.py +0 -4
- cognite/neat/legacy/rules/importers/_dms2rules.py +0 -2
- cognite/neat/legacy/rules/models/rdfpath.py +1 -2
- cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +89 -0
- cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +152 -0
- cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +139 -0
- cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +270 -0
- cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +65 -0
- cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +116 -0
- cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +67 -0
- cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +64 -0
- cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +95 -0
- cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +111 -0
- cognite/neat/rules/exporters/_models.py +3 -0
- cognite/neat/rules/exporters/_rules2dms.py +46 -4
- cognite/neat/rules/exporters/_rules2excel.py +2 -11
- cognite/neat/rules/exporters/_validation.py +6 -8
- cognite/neat/rules/importers/_base.py +8 -4
- cognite/neat/rules/importers/_dms2rules.py +321 -129
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +2 -4
- cognite/neat/rules/importers/_dtdl2rules/spec.py +2 -4
- cognite/neat/rules/importers/_owl2rules/_owl2rules.py +2 -4
- cognite/neat/rules/importers/_spreadsheet2rules.py +18 -16
- cognite/neat/rules/importers/_yaml2rules.py +2 -4
- cognite/neat/rules/issues/base.py +3 -0
- cognite/neat/rules/issues/dms.py +144 -58
- cognite/neat/rules/issues/fileread.py +41 -0
- cognite/neat/rules/issues/formatters.py +3 -1
- cognite/neat/rules/issues/importing.py +155 -0
- cognite/neat/rules/issues/spreadsheet.py +12 -9
- cognite/neat/rules/models/entities.py +30 -8
- cognite/neat/rules/models/rdfpath.py +1 -2
- cognite/neat/rules/models/rules/_base.py +5 -6
- cognite/neat/rules/models/rules/_dms_architect_rules.py +494 -333
- cognite/neat/rules/models/rules/_dms_rules_write.py +43 -52
- cognite/neat/rules/models/rules/_dms_schema.py +112 -22
- cognite/neat/rules/models/rules/_domain_rules.py +5 -0
- cognite/neat/rules/models/rules/_information_rules.py +13 -6
- cognite/neat/rules/models/wrapped_entities.py +166 -0
- cognite/neat/utils/cdf_loaders/_data_modeling.py +3 -1
- cognite/neat/utils/cdf_loaders/_ingestion.py +2 -4
- cognite/neat/utils/spreadsheet.py +2 -4
- cognite/neat/utils/utils.py +2 -4
- cognite/neat/workflows/base.py +5 -5
- cognite/neat/workflows/manager.py +32 -22
- cognite/neat/workflows/model.py +3 -3
- cognite/neat/workflows/steps/lib/__init__.py +0 -7
- cognite/neat/workflows/steps/lib/current/__init__.py +6 -0
- cognite/neat/workflows/steps/lib/{rules_exporter.py → current/rules_exporter.py} +8 -8
- cognite/neat/workflows/steps/lib/{rules_importer.py → current/rules_importer.py} +4 -4
- cognite/neat/workflows/steps/lib/io/__init__.py +1 -0
- cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_contextualization.py +2 -2
- cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_extractor.py +9 -9
- cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_loader.py +9 -9
- cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_store.py +4 -4
- cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_transformer.py +2 -2
- cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_exporter.py +15 -17
- cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_importer.py +7 -7
- cognite/neat/workflows/steps/step_model.py +5 -9
- cognite/neat/workflows/steps_registry.py +20 -11
- {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/RECORD +98 -86
- cognite/neat/app/api/data_classes/configuration.py +0 -121
- /cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js.LICENSE.txt → main.ec7f72e2.js.LICENSE.txt} +0 -0
- /cognite/neat/workflows/steps/lib/{graph_extractor.py → current/graph_extractor.py} +0 -0
- /cognite/neat/workflows/steps/lib/{graph_loader.py → current/graph_loader.py} +0 -0
- /cognite/neat/workflows/steps/lib/{graph_store.py → current/graph_store.py} +0 -0
- /cognite/neat/workflows/steps/lib/{rules_validator.py → current/rules_validator.py} +0 -0
- /cognite/neat/workflows/steps/lib/{io_steps.py → io/io_steps.py} +0 -0
- /cognite/neat/workflows/steps/lib/{v1 → legacy}/__init__.py +0 -0
- {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/entry_points.txt +0 -0
cognite/neat/config.py
CHANGED
|
@@ -1,39 +1,169 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
1
4
|
import shutil
|
|
5
|
+
import sys
|
|
2
6
|
from pathlib import Path
|
|
7
|
+
from typing import Literal, cast
|
|
8
|
+
|
|
9
|
+
import yaml
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
11
|
+
from yaml import safe_load
|
|
3
12
|
|
|
4
13
|
from cognite.neat.constants import EXAMPLE_GRAPHS, EXAMPLE_RULES, EXAMPLE_WORKFLOWS
|
|
14
|
+
from cognite.neat.utils.cdf import InteractiveCogniteClient, ServiceCogniteClient
|
|
15
|
+
|
|
16
|
+
if sys.version_info >= (3, 11):
|
|
17
|
+
from enum import StrEnum
|
|
18
|
+
from typing import Self
|
|
19
|
+
else:
|
|
20
|
+
from backports.strenum import StrEnum
|
|
21
|
+
from typing_extensions import Self
|
|
22
|
+
|
|
23
|
+
LOG_FORMAT = "%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s"
|
|
24
|
+
LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RulesStoreType(StrEnum):
|
|
28
|
+
"""Rules Store type"""
|
|
29
|
+
|
|
30
|
+
CDF = "cdf"
|
|
31
|
+
FILE = "file"
|
|
32
|
+
URL = "url"
|
|
33
|
+
GOOGLE_SHEET = "google_sheet"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class WorkflowsStoreType(StrEnum):
|
|
37
|
+
"""Workflows Store type"""
|
|
38
|
+
|
|
39
|
+
CDF = "cdf"
|
|
40
|
+
FILE = "file"
|
|
41
|
+
URL = "url"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Config(BaseModel):
|
|
45
|
+
workflows_store_type: WorkflowsStoreType = WorkflowsStoreType.FILE
|
|
46
|
+
data_store_path: Path = Field(default_factory=lambda: Path.cwd() / "data")
|
|
47
|
+
|
|
48
|
+
workflow_downloader_filter: list[str] | None = Field(
|
|
49
|
+
description="List of workflow names+tags to filter on when downloading workflows from CDF. "
|
|
50
|
+
"Example name:workflow_name=version,tag:tag_name",
|
|
51
|
+
default=None,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
cdf_client: InteractiveCogniteClient | ServiceCogniteClient = ServiceCogniteClient()
|
|
55
|
+
cdf_default_dataset_id: int = 0
|
|
56
|
+
load_examples: bool = True
|
|
57
|
+
|
|
58
|
+
log_level: Literal["ERROR", "WARNING", "INFO", "DEBUG"] = "INFO"
|
|
59
|
+
log_format: str = LOG_FORMAT
|
|
60
|
+
download_workflows_from_cdf: bool = Field(
|
|
61
|
+
default=False, description="Downloads all workflows from CDF automatically and stores them locally"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
stop_on_error: bool = False
|
|
5
65
|
|
|
66
|
+
@property
|
|
67
|
+
def _dir_suffix(self) -> str:
|
|
68
|
+
is_test_running = "pytest" in sys.modules
|
|
69
|
+
if is_test_running:
|
|
70
|
+
# Todo change the below to f"-{os.getpid()}" when all tests supports parallel execution.
|
|
71
|
+
return ""
|
|
72
|
+
return ""
|
|
6
73
|
|
|
7
|
-
|
|
74
|
+
@property
|
|
75
|
+
def rules_store_path(self) -> Path:
|
|
76
|
+
return self.data_store_path / f"rules{self._dir_suffix}"
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def workflows_store_path(self) -> Path:
|
|
80
|
+
return self.data_store_path / f"workflows{self._dir_suffix}"
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def source_graph_path(self) -> Path:
|
|
84
|
+
return self.data_store_path / f"source-graphs{self._dir_suffix}"
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def staging_path(self) -> Path:
|
|
88
|
+
return self.data_store_path / f"staging{self._dir_suffix}"
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_yaml(cls, filepath: Path) -> Self:
|
|
92
|
+
return cls(**safe_load(filepath.read_text()))
|
|
93
|
+
|
|
94
|
+
def to_yaml(self, filepath: Path):
|
|
95
|
+
# Parse as json to avoid Path and Enum objects
|
|
96
|
+
dump = json.loads(self.json())
|
|
97
|
+
|
|
98
|
+
with filepath.open("w") as f:
|
|
99
|
+
yaml.safe_dump(dump, f)
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_env(cls) -> Self:
|
|
103
|
+
missing = "Missing"
|
|
104
|
+
cdf_config = ServiceCogniteClient(
|
|
105
|
+
project=os.environ.get("NEAT_CDF_PROJECT", missing),
|
|
106
|
+
client_id=os.environ.get("NEAT_CDF_CLIENT_ID", missing),
|
|
107
|
+
client_secret=os.environ.get("NEAT_CDF_CLIENT_SECRET", missing),
|
|
108
|
+
base_url=os.environ.get("NEAT_CDF_BASE_URL", missing),
|
|
109
|
+
token_url=os.environ.get("NEAT_CDF_TOKEN_URL", missing),
|
|
110
|
+
scopes=[os.environ.get("NEAT_CDF_SCOPES", missing)],
|
|
111
|
+
timeout=int(os.environ.get("NEAT_CDF_CLIENT_TIMEOUT", "60")),
|
|
112
|
+
max_workers=int(os.environ.get("NEAT_CDF_CLIENT_MAX_WORKERS", "3")),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if workflow_downloader_filter_value := os.environ.get("NEAT_WORKFLOW_DOWNLOADER_FILTER", None):
|
|
116
|
+
workflow_downloader_filter = workflow_downloader_filter_value.split(",")
|
|
117
|
+
else:
|
|
118
|
+
workflow_downloader_filter = None
|
|
119
|
+
|
|
120
|
+
return cls(
|
|
121
|
+
cdf_client=cdf_config,
|
|
122
|
+
workflows_store_type=os.environ.get( # type: ignore[arg-type]
|
|
123
|
+
"NEAT_WORKFLOWS_STORE_TYPE", WorkflowsStoreType.FILE
|
|
124
|
+
),
|
|
125
|
+
data_store_path=Path(os.environ.get("NEAT_DATA_PATH", "/app/data")),
|
|
126
|
+
cdf_default_dataset_id=int(os.environ.get("NEAT_CDF_DEFAULT_DATASET_ID", 6476640149881990)),
|
|
127
|
+
log_level=cast(Literal["ERROR", "WARNING", "INFO", "DEBUG"], os.environ.get("NEAT_LOG_LEVEL", "INFO")),
|
|
128
|
+
workflow_downloader_filter=workflow_downloader_filter,
|
|
129
|
+
load_examples=bool(os.environ.get("NEAT_LOAD_EXAMPLES", True) in ["True", "true", "1"]),
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def copy_examples_to_directory(config: Config):
|
|
8
134
|
"""
|
|
9
135
|
Copier over all the examples to the target_data_directory,
|
|
10
136
|
without overwriting
|
|
11
137
|
|
|
12
138
|
Args:
|
|
13
139
|
target_data_dir : The target directory
|
|
140
|
+
suffix : The suffix to add to the directory names
|
|
14
141
|
|
|
15
142
|
"""
|
|
16
143
|
|
|
17
|
-
print(f"Copying examples into {
|
|
18
|
-
_copy_examples(EXAMPLE_RULES,
|
|
19
|
-
_copy_examples(EXAMPLE_GRAPHS,
|
|
20
|
-
_copy_examples(EXAMPLE_WORKFLOWS,
|
|
21
|
-
|
|
144
|
+
print(f"Copying examples into {config.data_store_path}")
|
|
145
|
+
_copy_examples(EXAMPLE_RULES, config.rules_store_path)
|
|
146
|
+
_copy_examples(EXAMPLE_GRAPHS, config.source_graph_path)
|
|
147
|
+
_copy_examples(EXAMPLE_WORKFLOWS, config.workflows_store_path)
|
|
148
|
+
config.staging_path.mkdir(exist_ok=True, parents=True)
|
|
22
149
|
|
|
23
150
|
|
|
24
|
-
def create_data_dir_structure(
|
|
151
|
+
def create_data_dir_structure(config: Config) -> None:
|
|
25
152
|
"""
|
|
26
153
|
Create the data directory structure in empty directory
|
|
27
154
|
|
|
28
155
|
Args:
|
|
29
156
|
target_data_dir : The target directory
|
|
157
|
+
suffix : The suffix to add to the directory names
|
|
30
158
|
|
|
31
159
|
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
160
|
+
for path in (
|
|
161
|
+
config.rules_store_path,
|
|
162
|
+
config.source_graph_path,
|
|
163
|
+
config.staging_path,
|
|
164
|
+
config.workflows_store_path,
|
|
165
|
+
):
|
|
166
|
+
path.mkdir(exist_ok=True, parents=True)
|
|
37
167
|
|
|
38
168
|
|
|
39
169
|
def _copy_examples(source_dir: Path, target_dir: Path):
|
|
@@ -44,3 +174,8 @@ def _copy_examples(source_dir: Path, target_dir: Path):
|
|
|
44
174
|
if not (target := target_dir / relative).exists():
|
|
45
175
|
target.parent.mkdir(exist_ok=True, parents=True)
|
|
46
176
|
shutil.copy2(current, target)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def configure_logging(level: str = "DEBUG", log_format: str = LOG_FORMAT):
|
|
180
|
+
"""Configure logging based on config."""
|
|
181
|
+
logging.basicConfig(format=log_format, level=logging.getLevelName(level), datefmt=LOG_DATE_FORMAT)
|
cognite/neat/constants.py
CHANGED
|
@@ -9,6 +9,7 @@ PACKAGE_DIRECTORY = Path(neat.__file__).parent
|
|
|
9
9
|
|
|
10
10
|
EXAMPLE_RULES = PACKAGE_DIRECTORY / "legacy" / "rules" / "examples"
|
|
11
11
|
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "legacy" / "graph" / "examples"
|
|
12
|
+
_OLD_WORKFLOWS = PACKAGE_DIRECTORY / "legacy" / "workflows" / "examples"
|
|
12
13
|
EXAMPLE_WORKFLOWS = PACKAGE_DIRECTORY / "workflows" / "examples"
|
|
13
14
|
|
|
14
15
|
DEFAULT_NAMESPACE = Namespace("http://purl.org/cognite/neat#")
|
cognite/neat/graph/exceptions.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""This module contains the definition of validation errors and warnings raised during graph methods
|
|
2
|
-
"""
|
|
1
|
+
"""This module contains the definition of validation errors and warnings raised during graph methods"""
|
|
3
2
|
|
|
4
3
|
from cognite.neat.constants import DEFAULT_DOCS_URL
|
|
5
4
|
from cognite.neat.exceptions import NeatException
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""This module contains the definition of validation errors and warnings raised during graph methods
|
|
2
|
-
"""
|
|
1
|
+
"""This module contains the definition of validation errors and warnings raised during graph methods"""
|
|
3
2
|
|
|
4
3
|
from cognite.neat.constants import DEFAULT_DOCS_URL
|
|
5
4
|
from cognite.neat.exceptions import NeatException
|
|
@@ -119,12 +119,10 @@ class AssetLoader(CogniteLoader[AssetResource]):
|
|
|
119
119
|
self._loaded_labels: set[str] = set()
|
|
120
120
|
|
|
121
121
|
@overload
|
|
122
|
-
def load(self, stop_on_exception: Literal[True]) -> Iterable[AssetResource]:
|
|
123
|
-
...
|
|
122
|
+
def load(self, stop_on_exception: Literal[True]) -> Iterable[AssetResource]: ...
|
|
124
123
|
|
|
125
124
|
@overload
|
|
126
|
-
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[AssetResource | ErrorDetails]:
|
|
127
|
-
...
|
|
125
|
+
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[AssetResource | ErrorDetails]: ...
|
|
128
126
|
|
|
129
127
|
def load(self, stop_on_exception: bool = False) -> Iterable[AssetResource | ErrorDetails]:
|
|
130
128
|
if self.rules.metadata.namespace is None:
|
|
@@ -259,12 +257,10 @@ class AssetLoader(CogniteLoader[AssetResource]):
|
|
|
259
257
|
)
|
|
260
258
|
|
|
261
259
|
@overload
|
|
262
|
-
def load_assets(self, stop_on_exception: Literal[True]) -> Iterable[AssetWrite]:
|
|
263
|
-
...
|
|
260
|
+
def load_assets(self, stop_on_exception: Literal[True]) -> Iterable[AssetWrite]: ...
|
|
264
261
|
|
|
265
262
|
@overload
|
|
266
|
-
def load_assets(self, stop_on_exception: Literal[False] = False) -> Iterable[AssetWrite | ErrorDetails]:
|
|
267
|
-
...
|
|
263
|
+
def load_assets(self, stop_on_exception: Literal[False] = False) -> Iterable[AssetWrite | ErrorDetails]: ...
|
|
268
264
|
|
|
269
265
|
def load_assets(self, stop_on_exception: Literal[True, False] = False) -> Iterable[AssetWrite | ErrorDetails]:
|
|
270
266
|
for asset_resource in self.load(stop_on_exception):
|
|
@@ -272,14 +268,12 @@ class AssetLoader(CogniteLoader[AssetResource]):
|
|
|
272
268
|
yield asset_resource
|
|
273
269
|
|
|
274
270
|
@overload
|
|
275
|
-
def load_relationships(self, stop_on_exception: Literal[True]) -> Iterable[RelationshipWrite]:
|
|
276
|
-
...
|
|
271
|
+
def load_relationships(self, stop_on_exception: Literal[True]) -> Iterable[RelationshipWrite]: ...
|
|
277
272
|
|
|
278
273
|
@overload
|
|
279
274
|
def load_relationships(
|
|
280
275
|
self, stop_on_exception: Literal[False] = False
|
|
281
|
-
) -> Iterable[RelationshipWrite | ErrorDetails]:
|
|
282
|
-
...
|
|
276
|
+
) -> Iterable[RelationshipWrite | ErrorDetails]: ...
|
|
283
277
|
|
|
284
278
|
def load_relationships(
|
|
285
279
|
self, stop_on_exception: Literal[True, False] = False
|
|
@@ -348,7 +342,8 @@ class AssetLoader(CogniteLoader[AssetResource]):
|
|
|
348
342
|
A dictionary with property type as key and a list of values as value.
|
|
349
343
|
"""
|
|
350
344
|
properties_value_tuples: list[tuple[str, str]] = [
|
|
351
|
-
remove_namespace(prop, value)
|
|
345
|
+
remove_namespace(prop, value) # type: ignore[misc]
|
|
346
|
+
for _, prop, value in properties_values
|
|
352
347
|
]
|
|
353
348
|
# We add an identifier which will be used as fallback for external_id
|
|
354
349
|
properties_value_tuples.append((self._identifier, remove_namespace(instance_id)))
|
|
@@ -26,12 +26,10 @@ class BaseLoader(ABC, Generic[T_Output]):
|
|
|
26
26
|
self.graph_store = graph_store
|
|
27
27
|
|
|
28
28
|
@overload
|
|
29
|
-
def load(self, stop_on_exception: Literal[True]) -> Iterable[T_Output]:
|
|
30
|
-
...
|
|
29
|
+
def load(self, stop_on_exception: Literal[True]) -> Iterable[T_Output]: ...
|
|
31
30
|
|
|
32
31
|
@overload
|
|
33
|
-
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[T_Output | ErrorDetails]:
|
|
34
|
-
...
|
|
32
|
+
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[T_Output | ErrorDetails]: ...
|
|
35
33
|
|
|
36
34
|
@abstractmethod
|
|
37
35
|
def load(self, stop_on_exception: bool = False) -> Iterable[T_Output | ErrorDetails]:
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"""This module contains the definition of validation errors and warnings raised by various extractors
|
|
2
|
-
"""
|
|
3
|
-
|
|
1
|
+
"""This module contains the definition of validation errors and warnings raised by various extractors"""
|
|
4
2
|
|
|
5
3
|
from pydantic_core import ErrorDetails, PydanticCustomError
|
|
6
4
|
|
|
@@ -772,8 +772,7 @@ def categorize_assets(
|
|
|
772
772
|
partitions: int = 2,
|
|
773
773
|
stop_on_exception: bool = False,
|
|
774
774
|
meta_keys: NeatMetadataKeys | None = None,
|
|
775
|
-
) -> dict:
|
|
776
|
-
...
|
|
775
|
+
) -> dict: ...
|
|
777
776
|
|
|
778
777
|
|
|
779
778
|
@overload
|
|
@@ -785,8 +784,7 @@ def categorize_assets(
|
|
|
785
784
|
partitions: int = 2,
|
|
786
785
|
stop_on_exception: bool = False,
|
|
787
786
|
meta_keys: NeatMetadataKeys | None = None,
|
|
788
|
-
) -> tuple[dict, dict]:
|
|
789
|
-
...
|
|
787
|
+
) -> tuple[dict, dict]: ...
|
|
790
788
|
|
|
791
789
|
|
|
792
790
|
def categorize_assets(
|
|
@@ -1000,13 +998,11 @@ AssetLike: TypeAlias = Asset | dict[str, Any]
|
|
|
1000
998
|
|
|
1001
999
|
|
|
1002
1000
|
@overload
|
|
1003
|
-
def remove_non_existing_labels(client: CogniteClient, assets: Sequence[AssetLike]) -> Sequence[AssetLike]:
|
|
1004
|
-
...
|
|
1001
|
+
def remove_non_existing_labels(client: CogniteClient, assets: Sequence[AssetLike]) -> Sequence[AssetLike]: ...
|
|
1005
1002
|
|
|
1006
1003
|
|
|
1007
1004
|
@overload
|
|
1008
|
-
def remove_non_existing_labels(client: CogniteClient, assets: Mapping[str, AssetLike]) -> Mapping[str, AssetLike]:
|
|
1009
|
-
...
|
|
1005
|
+
def remove_non_existing_labels(client: CogniteClient, assets: Mapping[str, AssetLike]) -> Mapping[str, AssetLike]: ...
|
|
1010
1006
|
|
|
1011
1007
|
|
|
1012
1008
|
def remove_non_existing_labels(
|
|
@@ -343,8 +343,7 @@ def categorize_relationships(
|
|
|
343
343
|
data_set_id: int,
|
|
344
344
|
return_report: Literal[False] = False,
|
|
345
345
|
partitions: int = 40,
|
|
346
|
-
) -> dict[str, list[Relationship] | list[RelationshipUpdate]]:
|
|
347
|
-
...
|
|
346
|
+
) -> dict[str, list[Relationship] | list[RelationshipUpdate]]: ...
|
|
348
347
|
|
|
349
348
|
|
|
350
349
|
@overload
|
|
@@ -354,8 +353,7 @@ def categorize_relationships(
|
|
|
354
353
|
data_set_id: int,
|
|
355
354
|
return_report: Literal[True],
|
|
356
355
|
partitions: int = 40,
|
|
357
|
-
) -> tuple[dict[str, list[Relationship] | list[RelationshipUpdate]], dict[str, set]]:
|
|
358
|
-
...
|
|
356
|
+
) -> tuple[dict[str, list[Relationship] | list[RelationshipUpdate]], dict[str, set]]: ...
|
|
359
357
|
|
|
360
358
|
|
|
361
359
|
def categorize_relationships(
|
|
@@ -33,12 +33,10 @@ class DMSLoader(CogniteLoader[InstanceApply]):
|
|
|
33
33
|
self.add_class_prefix = add_class_prefix
|
|
34
34
|
|
|
35
35
|
@overload
|
|
36
|
-
def load(self, stop_on_exception: Literal[True]) -> Iterable[InstanceApply]:
|
|
37
|
-
...
|
|
36
|
+
def load(self, stop_on_exception: Literal[True]) -> Iterable[InstanceApply]: ...
|
|
38
37
|
|
|
39
38
|
@overload
|
|
40
|
-
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[InstanceApply | ErrorDetails]:
|
|
41
|
-
...
|
|
39
|
+
def load(self, stop_on_exception: Literal[False] = False) -> Iterable[InstanceApply | ErrorDetails]: ...
|
|
42
40
|
|
|
43
41
|
def load(self, stop_on_exception: bool = False) -> Iterable[InstanceApply | ErrorDetails]:
|
|
44
42
|
"""Load the graph with data."""
|
|
@@ -46,7 +46,7 @@ def _find_circular_reference_path(
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def validate_asset_hierarchy(
|
|
49
|
-
assets: dict[str, dict[str, Any]]
|
|
49
|
+
assets: dict[str, dict[str, Any]],
|
|
50
50
|
) -> tuple[list[str], list[list[str]], dict[str, list[str]]]:
|
|
51
51
|
"""Validates asset hierarchy and reports on orphan assets and circular dependency
|
|
52
52
|
|
|
@@ -15,13 +15,11 @@ from cognite.neat.legacy.rules.models.rules import (
|
|
|
15
15
|
@overload
|
|
16
16
|
def are_entity_names_dms_compliant(
|
|
17
17
|
transformation_rules: Rules, return_report: Literal[True]
|
|
18
|
-
) -> tuple[bool, list[dict]]:
|
|
19
|
-
...
|
|
18
|
+
) -> tuple[bool, list[dict]]: ...
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
@overload
|
|
23
|
-
def are_entity_names_dms_compliant(transformation_rules: Rules, return_report: Literal[False] = False) -> bool:
|
|
24
|
-
...
|
|
22
|
+
def are_entity_names_dms_compliant(transformation_rules: Rules, return_report: Literal[False] = False) -> bool: ...
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
def are_entity_names_dms_compliant(
|
|
@@ -107,13 +105,11 @@ def are_entity_names_dms_compliant(
|
|
|
107
105
|
|
|
108
106
|
|
|
109
107
|
@overload
|
|
110
|
-
def are_properties_redefined(transformation_rules: Rules, return_report: Literal[True]) -> tuple[bool, list[dict]]:
|
|
111
|
-
...
|
|
108
|
+
def are_properties_redefined(transformation_rules: Rules, return_report: Literal[True]) -> tuple[bool, list[dict]]: ...
|
|
112
109
|
|
|
113
110
|
|
|
114
111
|
@overload
|
|
115
|
-
def are_properties_redefined(transformation_rules: Rules, return_report: Literal[False] = False) -> bool:
|
|
116
|
-
...
|
|
112
|
+
def are_properties_redefined(transformation_rules: Rules, return_report: Literal[False] = False) -> bool: ...
|
|
117
113
|
|
|
118
114
|
|
|
119
115
|
def are_properties_redefined(
|
|
@@ -14,10 +14,6 @@ class BaseImporter(ABC):
|
|
|
14
14
|
BaseImporter class which all importers inherit from.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
-
@abstractmethod
|
|
18
|
-
def __init__(self):
|
|
19
|
-
...
|
|
20
|
-
|
|
21
17
|
@abstractmethod
|
|
22
18
|
def to_tables(self) -> dict[str, pd.DataFrame]:
|
|
23
19
|
"""Creates raw tables from the data."""
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
configs: []
|
|
2
|
+
description: null
|
|
3
|
+
implementation_module: null
|
|
4
|
+
name: Export DMS
|
|
5
|
+
steps:
|
|
6
|
+
- complex_configs: {}
|
|
7
|
+
configs: {}
|
|
8
|
+
description: null
|
|
9
|
+
enabled: true
|
|
10
|
+
id: step_861205
|
|
11
|
+
label: Upload Rules Spreadsheet
|
|
12
|
+
max_retries: 0
|
|
13
|
+
method: null
|
|
14
|
+
params:
|
|
15
|
+
file_type: rules
|
|
16
|
+
retry_delay: 3
|
|
17
|
+
stype: file_uploader
|
|
18
|
+
system_component_id: null
|
|
19
|
+
transition_to:
|
|
20
|
+
- step_295479
|
|
21
|
+
trigger: true
|
|
22
|
+
ui_config:
|
|
23
|
+
pos_x: 629
|
|
24
|
+
pos_y: 57
|
|
25
|
+
- complex_configs: {}
|
|
26
|
+
configs:
|
|
27
|
+
File name: ''
|
|
28
|
+
Report formatter: BasicHTML
|
|
29
|
+
Role: infer
|
|
30
|
+
description: null
|
|
31
|
+
enabled: true
|
|
32
|
+
id: step_295479
|
|
33
|
+
label: Validate
|
|
34
|
+
max_retries: 0
|
|
35
|
+
method: ExcelToRules
|
|
36
|
+
params: {}
|
|
37
|
+
retry_delay: 3
|
|
38
|
+
stype: stdstep
|
|
39
|
+
system_component_id: null
|
|
40
|
+
transition_to:
|
|
41
|
+
- step_50885
|
|
42
|
+
trigger: false
|
|
43
|
+
ui_config:
|
|
44
|
+
pos_x: 629
|
|
45
|
+
pos_y: 161
|
|
46
|
+
- complex_configs:
|
|
47
|
+
Components:
|
|
48
|
+
containers: true
|
|
49
|
+
data_models: true
|
|
50
|
+
spaces: true
|
|
51
|
+
views: true
|
|
52
|
+
configs:
|
|
53
|
+
Dry run: 'False'
|
|
54
|
+
Existing component handling: update
|
|
55
|
+
Multi-space components create: 'True'
|
|
56
|
+
description: null
|
|
57
|
+
enabled: true
|
|
58
|
+
id: step_50885
|
|
59
|
+
label: Export Data Model to CDF
|
|
60
|
+
max_retries: 0
|
|
61
|
+
method: RulesToDMS
|
|
62
|
+
params: {}
|
|
63
|
+
retry_delay: 3
|
|
64
|
+
stype: stdstep
|
|
65
|
+
system_component_id: null
|
|
66
|
+
transition_to:
|
|
67
|
+
- step_171560
|
|
68
|
+
trigger: false
|
|
69
|
+
ui_config:
|
|
70
|
+
pos_x: 629
|
|
71
|
+
pos_y: 243
|
|
72
|
+
- complex_configs: {}
|
|
73
|
+
configs: {}
|
|
74
|
+
description: null
|
|
75
|
+
enabled: true
|
|
76
|
+
id: step_171560
|
|
77
|
+
label: Export Transformations
|
|
78
|
+
max_retries: 0
|
|
79
|
+
method: RulesToCDFTransformations
|
|
80
|
+
params: {}
|
|
81
|
+
retry_delay: 3
|
|
82
|
+
stype: stdstep
|
|
83
|
+
system_component_id: null
|
|
84
|
+
transition_to: []
|
|
85
|
+
trigger: false
|
|
86
|
+
ui_config:
|
|
87
|
+
pos_x: 629
|
|
88
|
+
pos_y: 342
|
|
89
|
+
system_components: []
|