cognite-toolkit 0.6.97__py3-none-any.whl → 0.7.39__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.
- cognite_toolkit/_cdf.py +21 -23
- cognite_toolkit/_cdf_tk/apps/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +19 -5
- cognite_toolkit/_cdf_tk/apps/_data_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dev_app.py +86 -0
- cognite_toolkit/_cdf_tk/apps/_download_app.py +693 -25
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +44 -102
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_landing_app.py +18 -4
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +424 -9
- cognite_toolkit/_cdf_tk/apps/_modules_app.py +0 -3
- cognite_toolkit/_cdf_tk/apps/_purge.py +15 -43
- cognite_toolkit/_cdf_tk/apps/_run.py +11 -0
- cognite_toolkit/_cdf_tk/apps/_upload_app.py +45 -6
- cognite_toolkit/_cdf_tk/builders/__init__.py +2 -2
- cognite_toolkit/_cdf_tk/builders/_base.py +28 -42
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/cdf_toml.py +20 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +32 -12
- cognite_toolkit/_cdf_tk/client/api/infield.py +114 -17
- cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +15 -7
- cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
- cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +15 -18
- cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
- cognite_toolkit/_cdf_tk/client/api/{location_filters.py → legacy/location_filters.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/{search_config.py → legacy/search_config.py} +5 -1
- cognite_toolkit/_cdf_tk/client/api/migration.py +177 -4
- cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
- cognite_toolkit/_cdf_tk/client/api/search.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/streams.py +88 -0
- cognite_toolkit/_cdf_tk/client/api/three_d.py +384 -0
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +37 -33
- cognite_toolkit/_cdf_tk/client/data_classes/charts_data.py +95 -213
- cognite_toolkit/_cdf_tk/client/data_classes/infield.py +32 -18
- cognite_toolkit/_cdf_tk/client/data_classes/instance_api.py +18 -13
- cognite_toolkit/_cdf_tk/client/data_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/data_classes/{canvas.py → legacy/canvas.py} +47 -4
- cognite_toolkit/_cdf_tk/client/data_classes/{charts.py → legacy/charts.py} +3 -3
- cognite_toolkit/_cdf_tk/client/data_classes/{migration.py → legacy/migration.py} +10 -2
- cognite_toolkit/_cdf_tk/client/data_classes/streams.py +90 -0
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +112 -0
- cognite_toolkit/_cdf_tk/client/testing.py +42 -18
- cognite_toolkit/_cdf_tk/commands/__init__.py +7 -6
- cognite_toolkit/_cdf_tk/commands/_changes.py +3 -42
- cognite_toolkit/_cdf_tk/commands/_download.py +21 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py +0 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +22 -20
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +140 -92
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +108 -26
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +448 -45
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +6 -6
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +52 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +377 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/selectors.py +9 -4
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +36 -39
- cognite_toolkit/_cdf_tk/commands/_questionary_style.py +16 -0
- cognite_toolkit/_cdf_tk/commands/_upload.py +109 -86
- cognite_toolkit/_cdf_tk/commands/about.py +221 -0
- cognite_toolkit/_cdf_tk/commands/auth.py +19 -12
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +16 -62
- cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +241 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_input.py +85 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +27 -0
- cognite_toolkit/_cdf_tk/commands/clean.py +63 -16
- cognite_toolkit/_cdf_tk/commands/deploy.py +20 -17
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +10 -8
- cognite_toolkit/_cdf_tk/commands/init.py +225 -3
- cognite_toolkit/_cdf_tk/commands/modules.py +20 -44
- cognite_toolkit/_cdf_tk/commands/pull.py +6 -19
- cognite_toolkit/_cdf_tk/commands/resources.py +179 -0
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/constants.py +20 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +19 -5
- cognite_toolkit/_cdf_tk/cruds/_base_cruds.py +14 -70
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +10 -19
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +4 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/agent.py +11 -9
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +45 -44
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +5 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +206 -67
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +6 -18
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +126 -35
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +7 -28
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +23 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +4 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -16
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +5 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +5 -11
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +16 -45
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +94 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/three_d_model.py +3 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +75 -32
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -40
- cognite_toolkit/_cdf_tk/cruds/_worker.py +24 -36
- cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +16 -36
- cognite_toolkit/_cdf_tk/plugins.py +2 -1
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +12 -0
- cognite_toolkit/_cdf_tk/resource_classes/functions.py +3 -1
- cognite_toolkit/_cdf_tk/resource_classes/infield_cdm_location_config.py +109 -0
- cognite_toolkit/_cdf_tk/resource_classes/migration.py +8 -17
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/streams.py +29 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
- cognite_toolkit/_cdf_tk/storageio/__init__.py +9 -21
- cognite_toolkit/_cdf_tk/storageio/_annotations.py +19 -16
- cognite_toolkit/_cdf_tk/storageio/_applications.py +340 -28
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +67 -104
- cognite_toolkit/_cdf_tk/storageio/_base.py +61 -29
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +276 -20
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +435 -0
- cognite_toolkit/_cdf_tk/storageio/_instances.py +35 -3
- cognite_toolkit/_cdf_tk/storageio/_raw.py +26 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +71 -4
- cognite_toolkit/_cdf_tk/storageio/selectors/_base.py +14 -2
- cognite_toolkit/_cdf_tk/storageio/selectors/_canvas.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_charts.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_datapoints.py +23 -3
- cognite_toolkit/_cdf_tk/storageio/selectors/_file_content.py +164 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
- cognite_toolkit/_cdf_tk/tk_warnings/other.py +4 -0
- cognite_toolkit/_cdf_tk/tracker.py +2 -2
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/dtype_conversion.py +9 -3
- cognite_toolkit/_cdf_tk/utils/fileio/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/utils/fileio/_base.py +5 -1
- cognite_toolkit/_cdf_tk/utils/fileio/_readers.py +112 -20
- cognite_toolkit/_cdf_tk/utils/fileio/_writers.py +15 -15
- cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_client.py +285 -18
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +56 -4
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +247 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +60 -18
- cognite_toolkit/_cdf_tk/utils/sql_parser.py +2 -3
- cognite_toolkit/_cdf_tk/utils/useful_types.py +6 -2
- cognite_toolkit/_cdf_tk/validation.py +83 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
- cognite_toolkit/_resources/cdf.toml +5 -4
- cognite_toolkit/_version.py +1 -1
- cognite_toolkit/config.dev.yaml +13 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/METADATA +24 -24
- cognite_toolkit-0.7.39.dist-info/RECORD +322 -0
- cognite_toolkit-0.7.39.dist-info/WHEEL +4 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/entry_points.txt +1 -0
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/commands/_migrate/canvas.py +0 -201
- cognite_toolkit/_cdf_tk/commands/dump_data.py +0 -489
- cognite_toolkit/_cdf_tk/commands/featureflag.py +0 -27
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- cognite_toolkit/_cdf_tk/utils/table_writers.py +0 -434
- cognite_toolkit-0.6.97.dist-info/RECORD +0 -306
- cognite_toolkit-0.6.97.dist-info/WHEEL +0 -4
- cognite_toolkit-0.6.97.dist-info/licenses/LICENSE +0 -18
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/api/legacy}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{apm_config_v1.py → legacy/apm_config_v1.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extendable_cognite_file.py → legacy/extendable_cognite_file.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetadata.py → legacy/extended_filemetadata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetdata.py → legacy/extended_filemetdata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_timeseries.py → legacy/extended_timeseries.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{functions.py → legacy/functions.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{graphql_data_models.py → legacy/graphql_data_models.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{instances.py → legacy/instances.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{location_filters.py → legacy/location_filters.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{pending_instances_ids.py → legacy/pending_instances_ids.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{project.py → legacy/project.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{raw.py → legacy/raw.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{robotics.py → legacy/robotics.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{search_config.py → legacy/search_config.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{sequences.py → legacy/sequences.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{streamlit_.py → legacy/streamlit_.py} +0 -0
- /cognite_toolkit/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
|
@@ -34,29 +34,26 @@ from cognite.client.data_classes.capabilities import (
|
|
|
34
34
|
from cognite.client.data_classes.data_modeling import (
|
|
35
35
|
Container,
|
|
36
36
|
ContainerApply,
|
|
37
|
-
ContainerApplyList,
|
|
38
37
|
ContainerList,
|
|
39
38
|
DataModel,
|
|
40
39
|
DataModelApply,
|
|
41
|
-
DataModelApplyList,
|
|
42
40
|
DataModelList,
|
|
41
|
+
DirectRelation,
|
|
43
42
|
Edge,
|
|
44
43
|
EdgeApply,
|
|
45
|
-
EdgeApplyList,
|
|
46
44
|
EdgeApplyResultList,
|
|
47
45
|
EdgeList,
|
|
46
|
+
MappedProperty,
|
|
48
47
|
Node,
|
|
49
48
|
NodeApply,
|
|
50
|
-
NodeApplyList,
|
|
51
49
|
NodeApplyResultList,
|
|
52
50
|
NodeList,
|
|
51
|
+
RequiresConstraint,
|
|
53
52
|
Space,
|
|
54
53
|
SpaceApply,
|
|
55
|
-
SpaceApplyList,
|
|
56
54
|
SpaceList,
|
|
57
55
|
View,
|
|
58
56
|
ViewApply,
|
|
59
|
-
ViewApplyList,
|
|
60
57
|
ViewList,
|
|
61
58
|
)
|
|
62
59
|
from cognite.client.data_classes.data_modeling.graphql import DMLApplyResult
|
|
@@ -74,12 +71,12 @@ from rich.console import Console
|
|
|
74
71
|
from rich.markup import escape
|
|
75
72
|
from rich.panel import Panel
|
|
76
73
|
|
|
74
|
+
from cognite_toolkit._cdf_tk import constants
|
|
77
75
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
78
|
-
from cognite_toolkit._cdf_tk.client.data_classes.graphql_data_models import (
|
|
76
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.graphql_data_models import (
|
|
79
77
|
GraphQLDataModel,
|
|
80
78
|
GraphQLDataModelList,
|
|
81
79
|
GraphQLDataModelWrite,
|
|
82
|
-
GraphQLDataModelWriteList,
|
|
83
80
|
)
|
|
84
81
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING, HAS_DATA_FILTER_LIMIT
|
|
85
82
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import (
|
|
@@ -114,14 +111,11 @@ from .auth import GroupAllScopedCRUD
|
|
|
114
111
|
|
|
115
112
|
|
|
116
113
|
@final
|
|
117
|
-
class SpaceCRUD(ResourceContainerCRUD[str, SpaceApply, Space
|
|
114
|
+
class SpaceCRUD(ResourceContainerCRUD[str, SpaceApply, Space]):
|
|
118
115
|
item_name = "nodes and edges"
|
|
119
|
-
folder_name = "
|
|
120
|
-
filename_pattern = r"^.*space$"
|
|
116
|
+
folder_name = "data_modeling"
|
|
121
117
|
resource_cls = Space
|
|
122
118
|
resource_write_cls = SpaceApply
|
|
123
|
-
list_write_cls = SpaceApplyList
|
|
124
|
-
list_cls = SpaceList
|
|
125
119
|
kind = "Space"
|
|
126
120
|
yaml_cls = SpaceYAML
|
|
127
121
|
dependencies = frozenset({GroupAllScopedCRUD})
|
|
@@ -246,18 +240,26 @@ class SpaceCRUD(ResourceContainerCRUD[str, SpaceApply, Space, SpaceApplyList, Sp
|
|
|
246
240
|
yield instances.as_ids()
|
|
247
241
|
|
|
248
242
|
|
|
249
|
-
class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container
|
|
243
|
+
class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container]):
|
|
250
244
|
item_name = "nodes and edges"
|
|
251
|
-
folder_name = "
|
|
252
|
-
filename_pattern = r"^.*container$"
|
|
245
|
+
folder_name = "data_modeling"
|
|
253
246
|
resource_cls = Container
|
|
254
247
|
resource_write_cls = ContainerApply
|
|
255
|
-
list_cls = ContainerList
|
|
256
|
-
list_write_cls = ContainerApplyList
|
|
257
248
|
kind = "Container"
|
|
258
249
|
dependencies = frozenset({SpaceCRUD})
|
|
259
250
|
yaml_cls = ContainerYAML
|
|
260
251
|
_doc_url = "Containers/operation/ApplyContainers"
|
|
252
|
+
sub_folder_name = "containers"
|
|
253
|
+
|
|
254
|
+
def __init__(
|
|
255
|
+
self,
|
|
256
|
+
client: ToolkitClient,
|
|
257
|
+
build_dir: Path | None,
|
|
258
|
+
console: Console | None = None,
|
|
259
|
+
topological_sort_implements: bool = False,
|
|
260
|
+
) -> None:
|
|
261
|
+
super().__init__(client, build_dir, console)
|
|
262
|
+
self._container_by_id: dict[ContainerId, Container] = {}
|
|
261
263
|
|
|
262
264
|
@property
|
|
263
265
|
def display_name(self) -> str:
|
|
@@ -314,6 +316,7 @@ class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container
|
|
|
314
316
|
|
|
315
317
|
def dump_resource(self, resource: Container, local: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
316
318
|
dumped = resource.as_write().dump()
|
|
319
|
+
has_local = local is not None
|
|
317
320
|
local = local or {}
|
|
318
321
|
for key in ["constraints", "indexes"]:
|
|
319
322
|
if not dumped.get(key) and key not in local:
|
|
@@ -325,15 +328,16 @@ class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container
|
|
|
325
328
|
continue
|
|
326
329
|
local_prop = local_prop_by_id[prop_id]
|
|
327
330
|
for key, default in [("immutable", False), ("autoIncrement", False), ("nullable", True)]:
|
|
328
|
-
if cdf_prop.get(key) is default and key not in local_prop:
|
|
331
|
+
if has_local and cdf_prop.get(key) is default and key not in local_prop:
|
|
329
332
|
cdf_prop.pop(key, None)
|
|
330
333
|
cdf_type = cdf_prop.get("type", {})
|
|
331
334
|
local_type = local_prop.get("type", {})
|
|
332
335
|
for key, type_default in [("list", False), ("collation", "ucs_basic")]:
|
|
333
|
-
if cdf_type.get(key) == type_default and key not in local_type:
|
|
336
|
+
if has_local and cdf_type.get(key) == type_default and key not in local_type:
|
|
334
337
|
cdf_type.pop(key, None)
|
|
335
|
-
|
|
336
|
-
|
|
338
|
+
if has_local and "usedFor" not in local and dumped.get("usedFor") == "node":
|
|
339
|
+
# Only drop if set to default by server.
|
|
340
|
+
dumped.pop("usedFor", None)
|
|
337
341
|
return dumped
|
|
338
342
|
|
|
339
343
|
def create(self, items: Sequence[ContainerApply]) -> ContainerList:
|
|
@@ -425,6 +429,71 @@ class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container
|
|
|
425
429
|
):
|
|
426
430
|
yield instances.as_ids()
|
|
427
431
|
|
|
432
|
+
def _lookup_containers(self, container_ids: Sequence[ContainerId]) -> dict[ContainerId, Container]:
|
|
433
|
+
ids_to_lookup = [container_id for container_id in container_ids if container_id not in self._container_by_id]
|
|
434
|
+
if ids_to_lookup:
|
|
435
|
+
retrieved_containers = self.client.data_modeling.containers.retrieve(ids_to_lookup)
|
|
436
|
+
for container in retrieved_containers:
|
|
437
|
+
self._container_by_id[container.as_id()] = container
|
|
438
|
+
if missing_container_ids := set(container_ids) - set(self._container_by_id.keys()):
|
|
439
|
+
MediumSeverityWarning(
|
|
440
|
+
f"Containers {missing_container_ids} not found or you don't have permission to access them."
|
|
441
|
+
).print_warning(console=self.console)
|
|
442
|
+
return {
|
|
443
|
+
container_id: self._container_by_id[container_id]
|
|
444
|
+
for container_id in container_ids
|
|
445
|
+
if container_id in self._container_by_id
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
def _find_direct_container_dependencies(
|
|
449
|
+
self, container_ids: Sequence[ContainerId]
|
|
450
|
+
) -> dict[ContainerId, set[ContainerId]]:
|
|
451
|
+
containers_by_id = self._lookup_containers(container_ids)
|
|
452
|
+
container_dependencies: dict[ContainerId, set[ContainerId]] = defaultdict(set)
|
|
453
|
+
for container_id, container in containers_by_id.items():
|
|
454
|
+
for constraint in container.constraints.values():
|
|
455
|
+
if not isinstance(constraint, RequiresConstraint):
|
|
456
|
+
continue
|
|
457
|
+
container_dependencies[container_id].add(constraint.require)
|
|
458
|
+
for property in container.properties.values():
|
|
459
|
+
if not isinstance(property.type, DirectRelation) or property.type.container is None:
|
|
460
|
+
continue
|
|
461
|
+
container_dependencies[container_id].add(property.type.container)
|
|
462
|
+
return container_dependencies
|
|
463
|
+
|
|
464
|
+
def _propagate_indirect_container_dependencies(
|
|
465
|
+
self, container_dependencies_by_id: dict[ContainerId, set[ContainerId]], dependants: Sequence[ContainerId]
|
|
466
|
+
) -> dict[ContainerId, set[ContainerId]]:
|
|
467
|
+
"""Propagate indirect container dependencies using a recursive approach.
|
|
468
|
+
|
|
469
|
+
Args:
|
|
470
|
+
container_dependencies_by_id: Mapping of container IDs to their direct dependencies
|
|
471
|
+
dependants: Chain of dependant containers to propagate dependencies to
|
|
472
|
+
|
|
473
|
+
Returns:
|
|
474
|
+
Updated dictionary mapping each container ID to all its direct and indirect dependencies
|
|
475
|
+
"""
|
|
476
|
+
current_container_id = dependants[0]
|
|
477
|
+
dependencies_to_propagate: set[ContainerId] = set()
|
|
478
|
+
for container_dependency in container_dependencies_by_id[current_container_id]:
|
|
479
|
+
if container_dependency in container_dependencies_by_id:
|
|
480
|
+
# If already processed, propagate its dependencies to current container instead of revisiting it
|
|
481
|
+
dependencies_to_propagate.update(container_dependencies_by_id[container_dependency])
|
|
482
|
+
continue
|
|
483
|
+
self._propagate_indirect_container_dependencies(
|
|
484
|
+
container_dependencies_by_id, [container_dependency, *dependants]
|
|
485
|
+
)
|
|
486
|
+
container_dependencies_by_id[current_container_id].update(dependencies_to_propagate)
|
|
487
|
+
return container_dependencies_by_id
|
|
488
|
+
|
|
489
|
+
def _find_direct_and_indirect_container_dependencies(
|
|
490
|
+
self, container_ids: Sequence[ContainerId]
|
|
491
|
+
) -> dict[ContainerId, set[ContainerId]]:
|
|
492
|
+
container_dependencies_by_id = self._find_direct_container_dependencies(container_ids)
|
|
493
|
+
for container_id in list(container_dependencies_by_id.keys()):
|
|
494
|
+
self._propagate_indirect_container_dependencies(container_dependencies_by_id, [container_id])
|
|
495
|
+
return container_dependencies_by_id
|
|
496
|
+
|
|
428
497
|
@staticmethod
|
|
429
498
|
def _chunker(seq: Sequence, size: int) -> Iterable[Sequence]:
|
|
430
499
|
return (seq[pos : pos + size] for pos in range(0, len(seq), size))
|
|
@@ -434,17 +503,15 @@ class ContainerCRUD(ResourceContainerCRUD[ContainerId, ContainerApply, Container
|
|
|
434
503
|
return sanitize_filename(f"{id.space}_{id.external_id}")
|
|
435
504
|
|
|
436
505
|
|
|
437
|
-
class ViewCRUD(ResourceCRUD[ViewId, ViewApply, View
|
|
438
|
-
folder_name = "
|
|
439
|
-
filename_pattern = r"^.*view$"
|
|
506
|
+
class ViewCRUD(ResourceCRUD[ViewId, ViewApply, View]):
|
|
507
|
+
folder_name = "data_modeling"
|
|
440
508
|
resource_cls = View
|
|
441
509
|
resource_write_cls = ViewApply
|
|
442
|
-
list_cls = ViewList
|
|
443
|
-
list_write_cls = ViewApplyList
|
|
444
510
|
kind = "View"
|
|
445
511
|
dependencies = frozenset({SpaceCRUD, ContainerCRUD})
|
|
446
512
|
yaml_cls = ViewYAML
|
|
447
513
|
_doc_url = "Views/operation/ApplyViews"
|
|
514
|
+
sub_folder_name = "views"
|
|
448
515
|
|
|
449
516
|
def __init__(
|
|
450
517
|
self,
|
|
@@ -556,7 +623,9 @@ class ViewCRUD(ResourceCRUD[ViewId, ViewApply, View, ViewApplyList, ViewList]):
|
|
|
556
623
|
# We sort the implements in topological order to ensure that the child view get the order grandparent,
|
|
557
624
|
# parent, such that the parent's source is used.
|
|
558
625
|
try:
|
|
559
|
-
dumped["implements"] = [
|
|
626
|
+
dumped["implements"] = [
|
|
627
|
+
view_id.dump() for view_id in self.topological_sort_implements(resource.implements)
|
|
628
|
+
]
|
|
560
629
|
except ToolkitCycleError as e:
|
|
561
630
|
warning = MediumSeverityWarning(f"Failed to sort implements for view {resource.as_id()}: {e}")
|
|
562
631
|
warning.print_warning(console=self.console)
|
|
@@ -669,14 +738,51 @@ class ViewCRUD(ResourceCRUD[ViewId, ViewApply, View, ViewApplyList, ViewList]):
|
|
|
669
738
|
self._view_by_id[view.as_id()] = view
|
|
670
739
|
return {view_id: self._view_by_id[view_id] for view_id in view_ids if view_id in self._view_by_id}
|
|
671
740
|
|
|
672
|
-
def
|
|
741
|
+
def get_readonly_properties(self, view_id: ViewId) -> set[str]:
|
|
742
|
+
"""Retrieve the set of read-only properties for a given view."""
|
|
743
|
+
|
|
744
|
+
readonly_properties: set[str] = set()
|
|
745
|
+
|
|
746
|
+
# Retrieve the view to check its properties
|
|
747
|
+
view = self._lookup_views([view_id]).get(view_id)
|
|
748
|
+
if view is None:
|
|
749
|
+
return readonly_properties
|
|
750
|
+
|
|
751
|
+
# Check each property in the view
|
|
752
|
+
for property_identifier, property in view.properties.items():
|
|
753
|
+
if isinstance(
|
|
754
|
+
property, MappedProperty
|
|
755
|
+
) and property.container_property_identifier in constants.READONLY_CONTAINER_PROPERTIES.get(
|
|
756
|
+
property.container, set()
|
|
757
|
+
):
|
|
758
|
+
readonly_properties.add(property_identifier)
|
|
759
|
+
return readonly_properties
|
|
760
|
+
|
|
761
|
+
def _build_view_implements_dependencies(
|
|
762
|
+
self, view_by_ids: dict[ViewId, View], include: set[ViewId] | None = None
|
|
763
|
+
) -> dict[ViewId, set[ViewId]]:
|
|
764
|
+
"""Build a dependency graph based on view implements relationships.
|
|
765
|
+
|
|
766
|
+
Args:
|
|
767
|
+
view_by_ids: Mapping of view IDs to View objects
|
|
768
|
+
include: Optional set of view IDs to include in the dependencies, if None, all views are included.
|
|
769
|
+
|
|
770
|
+
Returns:
|
|
771
|
+
Dictionary mapping each view ID to the set of view IDs it depends on (implements)
|
|
772
|
+
"""
|
|
773
|
+
dependencies: dict[ViewId, set[ViewId]] = {}
|
|
774
|
+
for view_id, view in view_by_ids.items():
|
|
775
|
+
dependencies[view_id] = set()
|
|
776
|
+
for implemented_view_id in view.implements or []:
|
|
777
|
+
if include is None or implemented_view_id in include:
|
|
778
|
+
dependencies[view_id].add(implemented_view_id)
|
|
779
|
+
return dependencies
|
|
780
|
+
|
|
781
|
+
def topological_sort_implements(self, view_ids: list[ViewId]) -> list[ViewId]:
|
|
673
782
|
"""Sorts the views in topological order based on their implements and through properties."""
|
|
674
783
|
view_by_ids = self._lookup_views(view_ids)
|
|
675
|
-
parents_by_child
|
|
676
|
-
|
|
677
|
-
parents_by_child[child] = set()
|
|
678
|
-
for parent in view.implements or []:
|
|
679
|
-
parents_by_child[child].add(parent)
|
|
784
|
+
parents_by_child = self._build_view_implements_dependencies(view_by_ids)
|
|
785
|
+
|
|
680
786
|
try:
|
|
681
787
|
sorted_views = list(TopologicalSorter(parents_by_child).static_order())
|
|
682
788
|
except CycleError as e:
|
|
@@ -686,15 +792,60 @@ class ViewCRUD(ResourceCRUD[ViewId, ViewApply, View, ViewApplyList, ViewList]):
|
|
|
686
792
|
|
|
687
793
|
return sorted_views
|
|
688
794
|
|
|
795
|
+
def topological_sort_container_constraints(self, view_ids: list[ViewId]) -> list[ViewId]:
|
|
796
|
+
"""Sorts the views in topological order based on their container constraints."""
|
|
797
|
+
|
|
798
|
+
view_by_ids = self._lookup_views(view_ids)
|
|
799
|
+
if missing_view_ids := set(view_ids) - set(view_by_ids.keys()):
|
|
800
|
+
MediumSeverityWarning(
|
|
801
|
+
f"Views {missing_view_ids} not found or you don't have permission to access them, skipping dependency check."
|
|
802
|
+
).print_warning(console=self.console)
|
|
803
|
+
return view_ids
|
|
804
|
+
|
|
805
|
+
view_to_containers: dict[ViewId, set[ContainerId]] = {}
|
|
806
|
+
container_to_views: defaultdict[ContainerId, set[ViewId]] = defaultdict(set)
|
|
807
|
+
for view_id, view in view_by_ids.items():
|
|
808
|
+
view_to_containers[view_id] = view.referenced_containers()
|
|
809
|
+
for container_id in view_to_containers[view_id]:
|
|
810
|
+
container_to_views[container_id].add(view_id)
|
|
811
|
+
|
|
812
|
+
container_crud = ContainerCRUD.create_loader(self.client)
|
|
813
|
+
container_dependencies_by_id = container_crud._find_direct_and_indirect_container_dependencies(
|
|
814
|
+
list(container_to_views.keys())
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
# First, add view dependencies based on implements relationships
|
|
818
|
+
view_dependencies = self._build_view_implements_dependencies(view_by_ids, set(view_to_containers.keys()))
|
|
819
|
+
|
|
820
|
+
# Then, add view dependencies based on mapped container constraints
|
|
821
|
+
for view_id, mapped_containers in view_to_containers.items():
|
|
822
|
+
for container_id in mapped_containers:
|
|
823
|
+
# Get all containers this container depends on
|
|
824
|
+
if container_id not in container_dependencies_by_id:
|
|
825
|
+
continue
|
|
826
|
+
for required_container in container_dependencies_by_id[container_id]:
|
|
827
|
+
if required_container not in container_to_views:
|
|
828
|
+
continue
|
|
829
|
+
# If this view already implements the required container, the requirement is self-satisfied
|
|
830
|
+
# and we don't need to depend on other views that also implement it (they are peers).
|
|
831
|
+
if required_container in mapped_containers:
|
|
832
|
+
continue
|
|
833
|
+
# This view doesn't implement the required container, so depend on all views that do
|
|
834
|
+
view_dependencies[view_id].update(container_to_views[required_container])
|
|
835
|
+
try:
|
|
836
|
+
sorted_views = list(TopologicalSorter(view_dependencies).static_order())
|
|
837
|
+
except CycleError as e:
|
|
838
|
+
raise ToolkitCycleError(
|
|
839
|
+
f"Failed to sort views topologically. This likely due to a cycle in implements. {e.args[1]}"
|
|
840
|
+
)
|
|
841
|
+
return sorted_views
|
|
842
|
+
|
|
689
843
|
|
|
690
844
|
@final
|
|
691
|
-
class DataModelCRUD(ResourceCRUD[DataModelId, DataModelApply, DataModel
|
|
692
|
-
folder_name = "
|
|
693
|
-
filename_pattern = r"^.*datamodel$"
|
|
845
|
+
class DataModelCRUD(ResourceCRUD[DataModelId, DataModelApply, DataModel]):
|
|
846
|
+
folder_name = "data_modeling"
|
|
694
847
|
resource_cls = DataModel
|
|
695
848
|
resource_write_cls = DataModelApply
|
|
696
|
-
list_cls = DataModelList
|
|
697
|
-
list_write_cls = DataModelApplyList
|
|
698
849
|
kind = "DataModel"
|
|
699
850
|
dependencies = frozenset({SpaceCRUD, ViewCRUD})
|
|
700
851
|
yaml_cls = DataModelYAML
|
|
@@ -771,13 +922,13 @@ class DataModelCRUD(ResourceCRUD[DataModelId, DataModelApply, DataModel, DataMod
|
|
|
771
922
|
return diff_list_identifiable(local, cdf, get_identifier=dm_identifier)
|
|
772
923
|
return super().diff_list(local, cdf, json_path)
|
|
773
924
|
|
|
774
|
-
def create(self, items:
|
|
925
|
+
def create(self, items: Sequence[DataModelApply]) -> DataModelList:
|
|
775
926
|
return self.client.data_modeling.data_models.apply(items)
|
|
776
927
|
|
|
777
928
|
def retrieve(self, ids: SequenceNotStr[DataModelId]) -> DataModelList:
|
|
778
929
|
return self.client.data_modeling.data_models.retrieve(cast(Sequence, ids))
|
|
779
930
|
|
|
780
|
-
def update(self, items:
|
|
931
|
+
def update(self, items: Sequence[DataModelApply]) -> DataModelList:
|
|
781
932
|
updated = self.create(items)
|
|
782
933
|
# There is a bug in the API not raising an exception if view is removed from a data model.
|
|
783
934
|
# So we check here that the update was fixed.
|
|
@@ -821,18 +972,16 @@ class DataModelCRUD(ResourceCRUD[DataModelId, DataModelApply, DataModel, DataMod
|
|
|
821
972
|
|
|
822
973
|
|
|
823
974
|
@final
|
|
824
|
-
class NodeCRUD(ResourceContainerCRUD[NodeId, NodeApply, Node
|
|
975
|
+
class NodeCRUD(ResourceContainerCRUD[NodeId, NodeApply, Node]):
|
|
825
976
|
item_name = "nodes"
|
|
826
|
-
folder_name = "
|
|
827
|
-
filename_pattern = r"^.*node$"
|
|
977
|
+
folder_name = "data_modeling"
|
|
828
978
|
resource_cls = Node
|
|
829
979
|
resource_write_cls = NodeApply
|
|
830
|
-
list_cls = NodeList
|
|
831
|
-
list_write_cls = NodeApplyList
|
|
832
980
|
kind = "Node"
|
|
833
981
|
yaml_cls = NodeYAML
|
|
834
982
|
dependencies = frozenset({SpaceCRUD, ViewCRUD, ContainerCRUD})
|
|
835
983
|
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
984
|
+
sub_folder_name = "nodes"
|
|
836
985
|
|
|
837
986
|
def __init__(
|
|
838
987
|
self,
|
|
@@ -928,7 +1077,7 @@ class NodeCRUD(ResourceContainerCRUD[NodeId, NodeApply, Node, NodeApplyList, Nod
|
|
|
928
1077
|
|
|
929
1078
|
return dumped
|
|
930
1079
|
|
|
931
|
-
def create(self, items:
|
|
1080
|
+
def create(self, items: Sequence[NodeApply]) -> NodeApplyResultList:
|
|
932
1081
|
result = self.client.data_modeling.instances.apply(
|
|
933
1082
|
# Note replace should never be relevant as Toolkit always checks whether the node exists before applying.
|
|
934
1083
|
nodes=items,
|
|
@@ -940,7 +1089,7 @@ class NodeCRUD(ResourceContainerCRUD[NodeId, NodeApply, Node, NodeApplyList, Nod
|
|
|
940
1089
|
def retrieve(self, ids: SequenceNotStr[NodeId]) -> NodeList:
|
|
941
1090
|
return self.client.data_modeling.instances.retrieve(nodes=cast(Sequence, ids), sources=self.view_id).nodes
|
|
942
1091
|
|
|
943
|
-
def update(self, items:
|
|
1092
|
+
def update(self, items: Sequence[NodeApply]) -> NodeApplyResultList:
|
|
944
1093
|
result = self.client.data_modeling.instances.apply(
|
|
945
1094
|
nodes=items, auto_create_direct_relations=True, replace=False
|
|
946
1095
|
)
|
|
@@ -977,17 +1126,10 @@ class NodeCRUD(ResourceContainerCRUD[NodeId, NodeApply, Node, NodeApplyList, Nod
|
|
|
977
1126
|
return sanitize_filename(f"{id.space}_{id.external_id}")
|
|
978
1127
|
|
|
979
1128
|
|
|
980
|
-
class GraphQLCRUD(
|
|
981
|
-
|
|
982
|
-
DataModelId, GraphQLDataModelWrite, GraphQLDataModel, GraphQLDataModelWriteList, GraphQLDataModelList
|
|
983
|
-
]
|
|
984
|
-
):
|
|
985
|
-
folder_name = "data_models"
|
|
986
|
-
filename_pattern = r"^.*GraphQLSchema"
|
|
1129
|
+
class GraphQLCRUD(ResourceContainerCRUD[DataModelId, GraphQLDataModelWrite, GraphQLDataModel]):
|
|
1130
|
+
folder_name = "data_modeling"
|
|
987
1131
|
resource_cls = GraphQLDataModel
|
|
988
1132
|
resource_write_cls = GraphQLDataModelWrite
|
|
989
|
-
list_cls = GraphQLDataModelList
|
|
990
|
-
list_write_cls = GraphQLDataModelWriteList
|
|
991
1133
|
kind = "GraphQLSchema"
|
|
992
1134
|
dependencies = frozenset({SpaceCRUD, ContainerCRUD})
|
|
993
1135
|
item_name = "views"
|
|
@@ -1101,7 +1243,7 @@ class GraphQLCRUD(
|
|
|
1101
1243
|
dumped["graphqlFile"] = match.group(3)
|
|
1102
1244
|
return dumped
|
|
1103
1245
|
|
|
1104
|
-
def create(self, items:
|
|
1246
|
+
def create(self, items: Sequence[GraphQLDataModelWrite]) -> list[DMLApplyResult]:
|
|
1105
1247
|
creation_order = self._topological_sort(items)
|
|
1106
1248
|
|
|
1107
1249
|
created_list: list[DMLApplyResult] = []
|
|
@@ -1132,7 +1274,7 @@ class GraphQLCRUD(
|
|
|
1132
1274
|
result = self.client.data_modeling.data_models.retrieve(list(ids), inline_views=False)
|
|
1133
1275
|
return GraphQLDataModelList([GraphQLDataModel._load(d.dump()) for d in result])
|
|
1134
1276
|
|
|
1135
|
-
def update(self, items:
|
|
1277
|
+
def update(self, items: Sequence[GraphQLDataModelWrite]) -> list[DMLApplyResult]:
|
|
1136
1278
|
return self.create(items)
|
|
1137
1279
|
|
|
1138
1280
|
def delete(self, ids: SequenceNotStr[DataModelId]) -> int:
|
|
@@ -1157,7 +1299,7 @@ class GraphQLCRUD(
|
|
|
1157
1299
|
def drop_data(self, ids: SequenceNotStr[DataModelId]) -> int:
|
|
1158
1300
|
return self.delete(ids)
|
|
1159
1301
|
|
|
1160
|
-
def _topological_sort(self, items:
|
|
1302
|
+
def _topological_sort(self, items: Sequence[GraphQLDataModelWrite]) -> list[GraphQLDataModelWrite]:
|
|
1161
1303
|
to_sort = {item.as_id(): item for item in items}
|
|
1162
1304
|
dependencies: dict[DataModelId, set[DataModelId]] = {}
|
|
1163
1305
|
for item in items:
|
|
@@ -1180,14 +1322,11 @@ class GraphQLCRUD(
|
|
|
1180
1322
|
|
|
1181
1323
|
|
|
1182
1324
|
@final
|
|
1183
|
-
class EdgeCRUD(ResourceContainerCRUD[EdgeId, EdgeApply, Edge
|
|
1325
|
+
class EdgeCRUD(ResourceContainerCRUD[EdgeId, EdgeApply, Edge]):
|
|
1184
1326
|
item_name = "edges"
|
|
1185
|
-
folder_name = "
|
|
1186
|
-
filename_pattern = r"^.*edge"
|
|
1327
|
+
folder_name = "data_modeling"
|
|
1187
1328
|
resource_cls = Edge
|
|
1188
1329
|
resource_write_cls = EdgeApply
|
|
1189
|
-
list_cls = EdgeList
|
|
1190
|
-
list_write_cls = EdgeApplyList
|
|
1191
1330
|
kind = "Edge"
|
|
1192
1331
|
yaml_cls = EdgeYAML
|
|
1193
1332
|
dependencies = frozenset({SpaceCRUD, ViewCRUD, ContainerCRUD, NodeCRUD})
|
|
@@ -1278,7 +1417,7 @@ class EdgeCRUD(ResourceContainerCRUD[EdgeId, EdgeApply, Edge, EdgeApplyList, Edg
|
|
|
1278
1417
|
|
|
1279
1418
|
return dumped
|
|
1280
1419
|
|
|
1281
|
-
def create(self, items:
|
|
1420
|
+
def create(self, items: Sequence[EdgeApply]) -> EdgeApplyResultList:
|
|
1282
1421
|
result = self.client.data_modeling.instances.apply(
|
|
1283
1422
|
edges=items, auto_create_direct_relations=True, replace=False
|
|
1284
1423
|
)
|
|
@@ -1287,7 +1426,7 @@ class EdgeCRUD(ResourceContainerCRUD[EdgeId, EdgeApply, Edge, EdgeApplyList, Edg
|
|
|
1287
1426
|
def retrieve(self, ids: SequenceNotStr[EdgeId]) -> EdgeList:
|
|
1288
1427
|
return self.client.data_modeling.instances.retrieve(nodes=cast(Sequence, ids)).edges
|
|
1289
1428
|
|
|
1290
|
-
def update(self, items:
|
|
1429
|
+
def update(self, items: Sequence[EdgeApply]) -> EdgeApplyResultList:
|
|
1291
1430
|
result = self.client.data_modeling.instances.apply(
|
|
1292
1431
|
edges=items, auto_create_direct_relations=False, replace=True
|
|
1293
1432
|
)
|
|
@@ -30,14 +30,12 @@ from cognite.client.data_classes.capabilities import (
|
|
|
30
30
|
from cognite.client.data_classes.extractionpipelines import (
|
|
31
31
|
ExtractionPipelineConfigList,
|
|
32
32
|
ExtractionPipelineConfigWrite,
|
|
33
|
-
ExtractionPipelineConfigWriteList,
|
|
34
33
|
ExtractionPipelineWrite,
|
|
35
|
-
ExtractionPipelineWriteList,
|
|
36
34
|
)
|
|
37
35
|
from cognite.client.exceptions import CogniteAPIError, CogniteDuplicatedError, CogniteNotFoundError
|
|
38
36
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
39
37
|
|
|
40
|
-
from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawTable
|
|
38
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawTable
|
|
41
39
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
42
40
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
43
41
|
from cognite_toolkit._cdf_tk.exceptions import (
|
|
@@ -61,15 +59,10 @@ from .raw import RawDatabaseCRUD, RawTableCRUD
|
|
|
61
59
|
|
|
62
60
|
|
|
63
61
|
@final
|
|
64
|
-
class ExtractionPipelineCRUD(
|
|
65
|
-
ResourceCRUD[str, ExtractionPipelineWrite, ExtractionPipeline, ExtractionPipelineWriteList, ExtractionPipelineList]
|
|
66
|
-
):
|
|
62
|
+
class ExtractionPipelineCRUD(ResourceCRUD[str, ExtractionPipelineWrite, ExtractionPipeline]):
|
|
67
63
|
folder_name = "extraction_pipelines"
|
|
68
|
-
filename_pattern = r"^(?:(?!\.config).)*$" # Matches all yaml files except file names who's stem contain *.config.
|
|
69
64
|
resource_cls = ExtractionPipeline
|
|
70
65
|
resource_write_cls = ExtractionPipelineWrite
|
|
71
|
-
list_cls = ExtractionPipelineList
|
|
72
|
-
list_write_cls = ExtractionPipelineWriteList
|
|
73
66
|
kind = "ExtractionPipeline"
|
|
74
67
|
dependencies = frozenset({DataSetsCRUD, RawDatabaseCRUD, RawTableCRUD, GroupAllScopedCRUD})
|
|
75
68
|
yaml_cls = ExtractionPipelineYAML
|
|
@@ -177,7 +170,7 @@ class ExtractionPipelineCRUD(
|
|
|
177
170
|
def retrieve(self, ids: SequenceNotStr[str]) -> ExtractionPipelineList:
|
|
178
171
|
return self.client.extraction_pipelines.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
179
172
|
|
|
180
|
-
def update(self, items:
|
|
173
|
+
def update(self, items: Sequence[ExtractionPipelineWrite]) -> ExtractionPipelineList:
|
|
181
174
|
# Bug in SDK overload so need the ignore.
|
|
182
175
|
return self.client.extraction_pipelines.update(items, mode="replace") # type: ignore[call-overload]
|
|
183
176
|
|
|
@@ -218,16 +211,11 @@ class ExtractionPipelineConfigCRUD(
|
|
|
218
211
|
str,
|
|
219
212
|
ExtractionPipelineConfigWrite,
|
|
220
213
|
ExtractionPipelineConfig,
|
|
221
|
-
ExtractionPipelineConfigWriteList,
|
|
222
|
-
ExtractionPipelineConfigList,
|
|
223
214
|
]
|
|
224
215
|
):
|
|
225
216
|
folder_name = "extraction_pipelines"
|
|
226
|
-
filename_pattern = r"^.*config$"
|
|
227
217
|
resource_cls = ExtractionPipelineConfig
|
|
228
218
|
resource_write_cls = ExtractionPipelineConfigWrite
|
|
229
|
-
list_cls = ExtractionPipelineConfigList
|
|
230
|
-
list_write_cls = ExtractionPipelineConfigWriteList
|
|
231
219
|
kind = "Config"
|
|
232
220
|
dependencies = frozenset({ExtractionPipelineCRUD})
|
|
233
221
|
_doc_url = "Extraction-Pipelines-Config/operation/createExtPipeConfig"
|
|
@@ -347,18 +335,18 @@ class ExtractionPipelineConfigCRUD(
|
|
|
347
335
|
return diff_list_force_hashable(local, cdf)
|
|
348
336
|
return super().diff_list(local, cdf, json_path)
|
|
349
337
|
|
|
350
|
-
def _upsert(self, items:
|
|
338
|
+
def _upsert(self, items: Sequence[ExtractionPipelineConfigWrite]) -> ExtractionPipelineConfigList:
|
|
351
339
|
upserted = ExtractionPipelineConfigList([])
|
|
352
340
|
for item in items:
|
|
353
341
|
created = self.client.extraction_pipelines.config.create(item)
|
|
354
342
|
upserted.append(created)
|
|
355
343
|
return upserted
|
|
356
344
|
|
|
357
|
-
def create(self, items:
|
|
345
|
+
def create(self, items: Sequence[ExtractionPipelineConfigWrite]) -> ExtractionPipelineConfigList:
|
|
358
346
|
return self._upsert(items)
|
|
359
347
|
|
|
360
348
|
# configs cannot be updated, instead new revision is created
|
|
361
|
-
def update(self, items:
|
|
349
|
+
def update(self, items: Sequence[ExtractionPipelineConfigWrite]) -> ExtractionPipelineConfigList:
|
|
362
350
|
return self._upsert(items)
|
|
363
351
|
|
|
364
352
|
def retrieve(self, ids: SequenceNotStr[str]) -> ExtractionPipelineConfigList:
|