cognite-toolkit 0.6.97__py3-none-any.whl → 0.7.30__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 +16 -17
- cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +13 -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 +692 -24
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +43 -101
- cognite_toolkit/_cdf_tk/apps/_landing_app.py +18 -4
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +249 -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/cdf_toml.py +20 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +23 -3
- cognite_toolkit/_cdf_tk/client/api/extended_functions.py +6 -9
- cognite_toolkit/_cdf_tk/client/api/infield.py +93 -1
- cognite_toolkit/_cdf_tk/client/api/migration.py +175 -1
- cognite_toolkit/_cdf_tk/client/api/streams.py +84 -0
- cognite_toolkit/_cdf_tk/client/api/three_d.py +50 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +25 -1
- cognite_toolkit/_cdf_tk/client/data_classes/canvas.py +46 -3
- cognite_toolkit/_cdf_tk/client/data_classes/charts.py +3 -3
- 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/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 +47 -0
- cognite_toolkit/_cdf_tk/client/testing.py +18 -2
- cognite_toolkit/_cdf_tk/commands/__init__.py +6 -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 +133 -91
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +73 -22
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +311 -43
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +5 -5
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +33 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +157 -8
- cognite_toolkit/_cdf_tk/commands/_migrate/selectors.py +9 -4
- cognite_toolkit/_cdf_tk/commands/_purge.py +27 -28
- 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 +15 -61
- 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 +6 -4
- 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/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 +8 -17
- 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 +4 -14
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +44 -43
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +4 -11
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +205 -66
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +5 -17
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +116 -27
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +6 -27
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +9 -28
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +3 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +3 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +4 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +4 -10
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +15 -44
- 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 +39 -31
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -40
- cognite_toolkit/_cdf_tk/cruds/_worker.py +24 -36
- 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/streams.py +29 -0
- 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 +338 -26
- 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 +436 -0
- cognite_toolkit/_cdf_tk/storageio/_instances.py +34 -2
- cognite_toolkit/_cdf_tk/storageio/_raw.py +26 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +62 -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/tk_warnings/other.py +4 -0
- cognite_toolkit/_cdf_tk/tracker.py +2 -2
- 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/_client.py +284 -18
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +50 -4
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +187 -0
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +9 -14
- 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 +79 -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.30.dist-info}/METADATA +24 -24
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.30.dist-info}/RECORD +153 -143
- cognite_toolkit-0.7.30.dist-info/WHEEL +4 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.30.dist-info}/entry_points.txt +1 -0
- 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/utils/table_writers.py +0 -434
- cognite_toolkit-0.6.97.dist-info/WHEEL +0 -4
- cognite_toolkit-0.6.97.dist-info/licenses/LICENSE +0 -18
|
@@ -12,13 +12,20 @@ from cognite_toolkit._cdf_tk.client.data_classes.apm_config_v1 import (
|
|
|
12
12
|
APMConfig,
|
|
13
13
|
APMConfigList,
|
|
14
14
|
APMConfigWrite,
|
|
15
|
-
APMConfigWriteList,
|
|
16
15
|
)
|
|
17
|
-
from cognite_toolkit._cdf_tk.client.data_classes.infield import
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.data_classes.infield import (
|
|
17
|
+
InFieldCDMLocationConfig,
|
|
18
|
+
InfieldLocationConfig,
|
|
19
|
+
InfieldLocationConfigList,
|
|
20
|
+
)
|
|
18
21
|
from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceResult, NodeIdentifier
|
|
19
22
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
20
23
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
21
|
-
from cognite_toolkit._cdf_tk.resource_classes import
|
|
24
|
+
from cognite_toolkit._cdf_tk.resource_classes import (
|
|
25
|
+
InFieldCDMLocationConfigYAML,
|
|
26
|
+
InfieldLocationConfigYAML,
|
|
27
|
+
InfieldV1YAML,
|
|
28
|
+
)
|
|
22
29
|
from cognite_toolkit._cdf_tk.utils import quote_int_value_by_key_in_yaml, safe_read
|
|
23
30
|
from cognite_toolkit._cdf_tk.utils.cdf import iterate_instances
|
|
24
31
|
from cognite_toolkit._cdf_tk.utils.diff_list import diff_list_hashable, diff_list_identifiable, hash_dict
|
|
@@ -31,14 +38,10 @@ from .group_scoped import GroupResourceScopedCRUD
|
|
|
31
38
|
|
|
32
39
|
|
|
33
40
|
@final
|
|
34
|
-
class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig
|
|
41
|
+
class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig]):
|
|
35
42
|
folder_name = "cdf_applications"
|
|
36
|
-
filename_pattern = r"^.*\.InfieldV1$" # Matches all yaml files whose stem ends with '.InfieldV1'.
|
|
37
|
-
filetypes = frozenset({"yaml", "yml"})
|
|
38
43
|
resource_cls = APMConfig
|
|
39
44
|
resource_write_cls = APMConfigWrite
|
|
40
|
-
list_cls = APMConfigList
|
|
41
|
-
list_write_cls = APMConfigWriteList
|
|
42
45
|
kind = "InfieldV1"
|
|
43
46
|
yaml_cls = InfieldV1YAML
|
|
44
47
|
dependencies = frozenset({DataSetsCRUD, AssetCRUD, SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
@@ -86,9 +89,9 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
86
89
|
f"Install the infield options with cdf modules init/add to deploy it."
|
|
87
90
|
)
|
|
88
91
|
|
|
89
|
-
def create(self, items:
|
|
92
|
+
def create(self, items: Sequence[APMConfigWrite]) -> NodeApplyResultList:
|
|
90
93
|
result = self.client.data_modeling.instances.apply(
|
|
91
|
-
nodes=
|
|
94
|
+
nodes=[item.as_node() for item in items], auto_create_direct_relations=True, replace=False
|
|
92
95
|
)
|
|
93
96
|
return result.nodes
|
|
94
97
|
|
|
@@ -98,9 +101,9 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
98
101
|
).nodes
|
|
99
102
|
return APMConfigList.from_nodes(result)
|
|
100
103
|
|
|
101
|
-
def update(self, items:
|
|
104
|
+
def update(self, items: Sequence[APMConfigWrite]) -> NodeApplyResultList:
|
|
102
105
|
result = self.client.data_modeling.instances.apply(
|
|
103
|
-
nodes=
|
|
106
|
+
nodes=[item.as_node() for item in items], auto_create_direct_relations=True, replace=True
|
|
104
107
|
)
|
|
105
108
|
return result.nodes
|
|
106
109
|
|
|
@@ -243,27 +246,19 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
243
246
|
|
|
244
247
|
|
|
245
248
|
@final
|
|
246
|
-
class InFieldLocationConfigCRUD(
|
|
247
|
-
ResourceCRUD[
|
|
248
|
-
NodeIdentifier,
|
|
249
|
-
InfieldLocationConfig,
|
|
250
|
-
InfieldLocationConfig,
|
|
251
|
-
InfieldLocationConfigList,
|
|
252
|
-
InfieldLocationConfigList,
|
|
253
|
-
]
|
|
254
|
-
):
|
|
249
|
+
class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConfig, InfieldLocationConfig]):
|
|
255
250
|
folder_name = "cdf_applications"
|
|
256
|
-
filename_pattern = r"^.*\.InFieldLocationConfig$"
|
|
257
|
-
filetypes = frozenset({"yaml", "yml"})
|
|
258
251
|
resource_cls = InfieldLocationConfig
|
|
259
252
|
resource_write_cls = InfieldLocationConfig
|
|
260
|
-
list_cls = InfieldLocationConfigList
|
|
261
|
-
list_write_cls = InfieldLocationConfigList
|
|
262
253
|
kind = "InFieldLocationConfig"
|
|
263
254
|
yaml_cls = InfieldLocationConfigYAML
|
|
264
255
|
dependencies = frozenset({SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
265
256
|
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
266
257
|
|
|
258
|
+
@property
|
|
259
|
+
def display_name(self) -> str:
|
|
260
|
+
return "infield location configs"
|
|
261
|
+
|
|
267
262
|
@classmethod
|
|
268
263
|
def get_id(cls, item: InfieldLocationConfig | dict) -> NodeIdentifier:
|
|
269
264
|
if isinstance(item, dict):
|
|
@@ -306,7 +301,7 @@ class InFieldLocationConfigCRUD(
|
|
|
306
301
|
|
|
307
302
|
return dumped
|
|
308
303
|
|
|
309
|
-
def create(self, items:
|
|
304
|
+
def create(self, items: Sequence[InfieldLocationConfig]) -> list[InstanceResult]:
|
|
310
305
|
created = self.client.infield.config.apply(items)
|
|
311
306
|
config_ids = {config.as_id() for config in items}
|
|
312
307
|
# We filter out all the data exploration configs that were created along with the infield location configs
|
|
@@ -316,7 +311,7 @@ class InFieldLocationConfigCRUD(
|
|
|
316
311
|
def retrieve(self, ids: SequenceNotStr[NodeIdentifier]) -> InfieldLocationConfigList:
|
|
317
312
|
return InfieldLocationConfigList(self.client.infield.config.retrieve(list(ids)))
|
|
318
313
|
|
|
319
|
-
def update(self, items:
|
|
314
|
+
def update(self, items: Sequence[InfieldLocationConfig]) -> Sized:
|
|
320
315
|
return self.create(items)
|
|
321
316
|
|
|
322
317
|
def delete(self, ids: SequenceNotStr[NodeIdentifier]) -> int:
|
|
@@ -347,3 +342,97 @@ class InFieldLocationConfigCRUD(
|
|
|
347
342
|
elif json_path == ("dataExplorationConfig", "documents", "supportedFormats"):
|
|
348
343
|
return diff_list_hashable(local, cdf)
|
|
349
344
|
return super().diff_list(local, cdf, json_path)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@final
|
|
348
|
+
class InFieldCDMLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InFieldCDMLocationConfig, InFieldCDMLocationConfig]):
|
|
349
|
+
folder_name = "cdf_applications"
|
|
350
|
+
resource_cls = InFieldCDMLocationConfig
|
|
351
|
+
resource_write_cls = InFieldCDMLocationConfig
|
|
352
|
+
kind = "InFieldCDMLocationConfig"
|
|
353
|
+
yaml_cls = InFieldCDMLocationConfigYAML
|
|
354
|
+
dependencies = frozenset({SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
355
|
+
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
356
|
+
|
|
357
|
+
@property
|
|
358
|
+
def display_name(self) -> str:
|
|
359
|
+
return "infield CDM location configs"
|
|
360
|
+
|
|
361
|
+
@classmethod
|
|
362
|
+
def get_id(cls, item: InFieldCDMLocationConfig | dict) -> NodeIdentifier:
|
|
363
|
+
if isinstance(item, dict):
|
|
364
|
+
return NodeIdentifier(space=item["space"], external_id=item["externalId"])
|
|
365
|
+
return NodeIdentifier(space=item.space, external_id=item.external_id)
|
|
366
|
+
|
|
367
|
+
@classmethod
|
|
368
|
+
def dump_id(cls, id: NodeIdentifier) -> dict[str, Any]:
|
|
369
|
+
return id.dump(include_type=False)
|
|
370
|
+
|
|
371
|
+
@classmethod
|
|
372
|
+
def get_required_capability(
|
|
373
|
+
cls, items: Sequence[InFieldCDMLocationConfig] | None, read_only: bool
|
|
374
|
+
) -> Capability | list[Capability]:
|
|
375
|
+
if not items or items is None:
|
|
376
|
+
return []
|
|
377
|
+
|
|
378
|
+
actions = (
|
|
379
|
+
[DataModelInstancesAcl.Action.Read]
|
|
380
|
+
if read_only
|
|
381
|
+
else [DataModelInstancesAcl.Action.Read, DataModelInstancesAcl.Action.Write]
|
|
382
|
+
)
|
|
383
|
+
instance_spaces = sorted({item.space for item in items})
|
|
384
|
+
|
|
385
|
+
return DataModelInstancesAcl(actions, DataModelInstancesAcl.Scope.SpaceID(instance_spaces))
|
|
386
|
+
|
|
387
|
+
def dump_resource(self, resource: InFieldCDMLocationConfig, local: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
388
|
+
dumped = resource.as_write().dump()
|
|
389
|
+
local = local or {}
|
|
390
|
+
if "existingVersion" not in local:
|
|
391
|
+
# Existing version is typically not set when creating nodes, but we get it back
|
|
392
|
+
# when we retrieve the node from the server.
|
|
393
|
+
dumped.pop("existingVersion", None)
|
|
394
|
+
dumped.pop("instanceType", None)
|
|
395
|
+
return dumped
|
|
396
|
+
|
|
397
|
+
def create(self, items: Sequence[InFieldCDMLocationConfig]) -> list[InstanceResult]:
|
|
398
|
+
return self.client.infield.cdm_config.apply(items)
|
|
399
|
+
|
|
400
|
+
def retrieve(self, ids: SequenceNotStr[NodeIdentifier]) -> list[InFieldCDMLocationConfig]:
|
|
401
|
+
return self.client.infield.cdm_config.retrieve(list(ids))
|
|
402
|
+
|
|
403
|
+
def update(self, items: Sequence[InFieldCDMLocationConfig]) -> Sized:
|
|
404
|
+
return self.create(items)
|
|
405
|
+
|
|
406
|
+
def delete(self, ids: SequenceNotStr[NodeIdentifier]) -> int:
|
|
407
|
+
# We must retrieve the full resource to delete it.
|
|
408
|
+
retrieved = self.retrieve(list(ids))
|
|
409
|
+
_ = self.client.infield.cdm_config.delete(retrieved)
|
|
410
|
+
return len(retrieved)
|
|
411
|
+
|
|
412
|
+
def _iterate(
|
|
413
|
+
self,
|
|
414
|
+
data_set_external_id: str | None = None,
|
|
415
|
+
space: str | None = None,
|
|
416
|
+
parent_ids: list[Hashable] | None = None,
|
|
417
|
+
) -> Iterable[InFieldCDMLocationConfig]:
|
|
418
|
+
raise NotImplementedError(f"Iteration over {self.display_name} is not supported.")
|
|
419
|
+
|
|
420
|
+
def diff_list(
|
|
421
|
+
self, local: list[Any], cdf: list[Any], json_path: tuple[str | int, ...]
|
|
422
|
+
) -> tuple[dict[int, int], list[int]]:
|
|
423
|
+
if json_path == ("accessManagement", "templateAdmins"):
|
|
424
|
+
return diff_list_hashable(local, cdf)
|
|
425
|
+
elif json_path == ("accessManagement", "checklistAdmins"):
|
|
426
|
+
return diff_list_hashable(local, cdf)
|
|
427
|
+
elif json_path == ("disciplines",):
|
|
428
|
+
return diff_list_identifiable(local, cdf, get_identifier=hash_dict)
|
|
429
|
+
elif len(json_path) == 3 and json_path[0] == "dataFilters" and json_path[2] == "instanceSpaces":
|
|
430
|
+
# Handles dataFilters.<entity>.instanceSpaces (e.g., files, assets, operations, timeSeries, etc.)
|
|
431
|
+
return diff_list_hashable(local, cdf)
|
|
432
|
+
elif json_path == ("dataExplorationConfig", "filters"):
|
|
433
|
+
return diff_list_identifiable(local, cdf, get_identifier=hash_dict)
|
|
434
|
+
elif len(json_path) == 4 and json_path[:2] == ("dataExplorationConfig", "filters") and json_path[3] == "values":
|
|
435
|
+
# Handles dataExplorationConfig.filters[i].values
|
|
436
|
+
return diff_list_hashable(local, cdf)
|
|
437
|
+
|
|
438
|
+
return super().diff_list(local, cdf, json_path)
|
|
@@ -21,7 +21,6 @@ from cognite.client.data_classes import (
|
|
|
21
21
|
FileMetadata,
|
|
22
22
|
FileMetadataList,
|
|
23
23
|
FileMetadataWrite,
|
|
24
|
-
FileMetadataWriteList,
|
|
25
24
|
)
|
|
26
25
|
from cognite.client.data_classes.capabilities import (
|
|
27
26
|
Capability,
|
|
@@ -37,7 +36,6 @@ from rich import print
|
|
|
37
36
|
from cognite_toolkit._cdf_tk.client.data_classes.extendable_cognite_file import (
|
|
38
37
|
ExtendableCogniteFile,
|
|
39
38
|
ExtendableCogniteFileApply,
|
|
40
|
-
ExtendableCogniteFileApplyList,
|
|
41
39
|
ExtendableCogniteFileList,
|
|
42
40
|
)
|
|
43
41
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceContainerCRUD, ResourceCRUD
|
|
@@ -57,19 +55,11 @@ from .datamodel import SpaceCRUD, ViewCRUD
|
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
@final
|
|
60
|
-
class FileMetadataCRUD(
|
|
61
|
-
ResourceContainerCRUD[str, FileMetadataWrite, FileMetadata, FileMetadataWriteList, FileMetadataList]
|
|
62
|
-
):
|
|
58
|
+
class FileMetadataCRUD(ResourceContainerCRUD[str, FileMetadataWrite, FileMetadata]):
|
|
63
59
|
item_name = "file contents"
|
|
64
60
|
folder_name = "files"
|
|
65
|
-
filename_pattern = (
|
|
66
|
-
# Matches all yaml files except file names whose stem ends with `.CogniteFile` or `File`.
|
|
67
|
-
r"(?i)^(?!.*(?:File|CogniteFile)$).*$"
|
|
68
|
-
)
|
|
69
61
|
resource_cls = FileMetadata
|
|
70
62
|
resource_write_cls = FileMetadataWrite
|
|
71
|
-
list_cls = FileMetadataList
|
|
72
|
-
list_write_cls = FileMetadataWriteList
|
|
73
63
|
yaml_cls = FileMetadataYAML
|
|
74
64
|
kind = "FileMetadata"
|
|
75
65
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD, LabelCRUD, AssetCRUD})
|
|
@@ -151,7 +141,7 @@ class FileMetadataCRUD(
|
|
|
151
141
|
dumped["assetExternalIds"] = self.client.lookup.assets.external_id(asset_ids)
|
|
152
142
|
return dumped
|
|
153
143
|
|
|
154
|
-
def create(self, items:
|
|
144
|
+
def create(self, items: Sequence[FileMetadataWrite]) -> FileMetadataList:
|
|
155
145
|
created = FileMetadataList([])
|
|
156
146
|
for meta in items:
|
|
157
147
|
try:
|
|
@@ -164,7 +154,7 @@ class FileMetadataCRUD(
|
|
|
164
154
|
def retrieve(self, ids: SequenceNotStr[str]) -> FileMetadataList:
|
|
165
155
|
return self.client.files.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
166
156
|
|
|
167
|
-
def update(self, items:
|
|
157
|
+
def update(self, items: Sequence[FileMetadataWrite]) -> FileMetadataList:
|
|
168
158
|
return self.client.files.update(items, mode="replace")
|
|
169
159
|
|
|
170
160
|
def delete(self, ids: str | int | SequenceNotStr[str | int] | None) -> int:
|
|
@@ -197,24 +187,13 @@ class FileMetadataCRUD(
|
|
|
197
187
|
|
|
198
188
|
|
|
199
189
|
@final
|
|
200
|
-
class CogniteFileCRUD(
|
|
201
|
-
ResourceContainerCRUD[
|
|
202
|
-
NodeId,
|
|
203
|
-
ExtendableCogniteFileApply,
|
|
204
|
-
ExtendableCogniteFile,
|
|
205
|
-
ExtendableCogniteFileApplyList,
|
|
206
|
-
ExtendableCogniteFileList,
|
|
207
|
-
]
|
|
208
|
-
):
|
|
190
|
+
class CogniteFileCRUD(ResourceContainerCRUD[NodeId, ExtendableCogniteFileApply, ExtendableCogniteFile]):
|
|
209
191
|
template_pattern = "$FILENAME"
|
|
210
192
|
item_name = "file contents"
|
|
211
193
|
folder_name = "files"
|
|
212
|
-
filename_pattern = r"^.*CogniteFile" # Matches all yaml files whose stem ends with 'CogniteFile'.
|
|
213
194
|
kind = "CogniteFile"
|
|
214
195
|
resource_cls = ExtendableCogniteFile
|
|
215
196
|
resource_write_cls = ExtendableCogniteFileApply
|
|
216
|
-
list_cls = ExtendableCogniteFileList
|
|
217
|
-
list_write_cls = ExtendableCogniteFileApplyList
|
|
218
197
|
yaml_cls = CogniteFileYAML
|
|
219
198
|
dependencies = frozenset({GroupAllScopedCRUD, SpaceCRUD, ViewCRUD})
|
|
220
199
|
|
|
@@ -294,7 +273,7 @@ class CogniteFileCRUD(
|
|
|
294
273
|
return diff_list_identifiable(local, cdf, get_identifier=dm_identifier)
|
|
295
274
|
return super().diff_list(local, cdf, json_path)
|
|
296
275
|
|
|
297
|
-
def create(self, items:
|
|
276
|
+
def create(self, items: Sequence[ExtendableCogniteFileApply]) -> NodeApplyResultList:
|
|
298
277
|
created = self.client.data_modeling.instances.apply(
|
|
299
278
|
nodes=items, replace=False, skip_on_version_conflict=True, auto_create_direct_relations=True
|
|
300
279
|
)
|
|
@@ -310,7 +289,7 @@ class CogniteFileCRUD(
|
|
|
310
289
|
)
|
|
311
290
|
return ExtendableCogniteFileList(items)
|
|
312
291
|
|
|
313
|
-
def update(self, items:
|
|
292
|
+
def update(self, items: Sequence[ExtendableCogniteFileApply]) -> NodeApplyResultList:
|
|
314
293
|
updated = self.client.data_modeling.instances.apply(nodes=items, replace=True)
|
|
315
294
|
return updated.nodes
|
|
316
295
|
|
|
@@ -12,9 +12,7 @@ from cognite.client.data_classes import (
|
|
|
12
12
|
FunctionSchedule,
|
|
13
13
|
FunctionSchedulesList,
|
|
14
14
|
FunctionScheduleWrite,
|
|
15
|
-
FunctionScheduleWriteList,
|
|
16
15
|
FunctionWrite,
|
|
17
|
-
FunctionWriteList,
|
|
18
16
|
)
|
|
19
17
|
from cognite.client.data_classes.capabilities import (
|
|
20
18
|
AllScope,
|
|
@@ -38,7 +36,6 @@ from cognite_toolkit._cdf_tk.exceptions import (
|
|
|
38
36
|
ResourceCreationError,
|
|
39
37
|
ToolkitRequiredValueError,
|
|
40
38
|
)
|
|
41
|
-
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
42
39
|
from cognite_toolkit._cdf_tk.resource_classes import FunctionScheduleYAML, FunctionsYAML
|
|
43
40
|
from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning, LowSeverityWarning
|
|
44
41
|
from cognite_toolkit._cdf_tk.utils import (
|
|
@@ -57,16 +54,11 @@ from .group_scoped import GroupResourceScopedCRUD
|
|
|
57
54
|
|
|
58
55
|
|
|
59
56
|
@final
|
|
60
|
-
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function
|
|
57
|
+
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function]):
|
|
61
58
|
support_drop = True
|
|
62
59
|
folder_name = "functions"
|
|
63
|
-
filename_pattern = (
|
|
64
|
-
r"^(?:(?!schedule).)*$" # Matches all yaml files except file names who's stem contain *.schedule.
|
|
65
|
-
)
|
|
66
60
|
resource_cls = Function
|
|
67
61
|
resource_write_cls = FunctionWrite
|
|
68
|
-
list_cls = FunctionList
|
|
69
|
-
list_write_cls = FunctionWriteList
|
|
70
62
|
kind = "Function"
|
|
71
63
|
yaml_cls = FunctionsYAML
|
|
72
64
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
@@ -302,7 +294,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
302
294
|
self.client.functions.activate()
|
|
303
295
|
return False
|
|
304
296
|
|
|
305
|
-
def create(self, items:
|
|
297
|
+
def create(self, items: Sequence[FunctionWrite]) -> FunctionList:
|
|
306
298
|
created = FunctionList([], cognite_client=self.client)
|
|
307
299
|
if not self._is_activated("create"):
|
|
308
300
|
return created
|
|
@@ -328,7 +320,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
328
320
|
" problem persists, please contact Cognite support."
|
|
329
321
|
)
|
|
330
322
|
item.file_id = file_id
|
|
331
|
-
created_item = self.client.functions.create_with_429_retry(item
|
|
323
|
+
created_item = self.client.functions.create_with_429_retry(item)
|
|
332
324
|
self._warn_if_cpu_or_memory_changed(created_item, item)
|
|
333
325
|
created.append(created_item)
|
|
334
326
|
return created
|
|
@@ -349,18 +341,14 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
349
341
|
function_rootdir = self.function_dir_by_external_id[external_id]
|
|
350
342
|
data_set_id = self.data_set_id_by_external_id.get(external_id)
|
|
351
343
|
space = self.space_by_external_id.get(external_id)
|
|
352
|
-
if (
|
|
353
|
-
Flags.FUNCTION_COGNITE_FILE.is_enabled()
|
|
354
|
-
and space is None
|
|
355
|
-
and self.project_data_modeling_status.casefold() == "data_modeling_only"
|
|
356
|
-
):
|
|
344
|
+
if space is None and self.project_data_modeling_status.casefold() == "data_modeling_only":
|
|
357
345
|
raise ResourceCreationError(
|
|
358
346
|
f"Function {external_id!r} must have a space set when the project is in DATA_MODELING_ONLY mode. "
|
|
359
347
|
"This is used to set the NodeId of the CogniteFile created for the function code."
|
|
360
348
|
)
|
|
361
349
|
|
|
362
350
|
with create_temporary_zip(function_rootdir, "function.zip") as zip_path:
|
|
363
|
-
if
|
|
351
|
+
if space:
|
|
364
352
|
cognite_file = CogniteFileApply(
|
|
365
353
|
space=space,
|
|
366
354
|
external_id=external_id,
|
|
@@ -416,7 +404,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
416
404
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
417
405
|
functions = self.retrieve(ids)
|
|
418
406
|
|
|
419
|
-
self.client.functions.delete_with_429_retry(external_id=ids, ignore_unknown_ids=True
|
|
407
|
+
self.client.functions.delete_with_429_retry(external_id=ids, ignore_unknown_ids=True)
|
|
420
408
|
file_ids = {func.file_id for func in functions if func.file_id}
|
|
421
409
|
self.client.files.delete(id=list(file_ids), ignore_unknown_ids=True)
|
|
422
410
|
return len(ids)
|
|
@@ -431,17 +419,10 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
431
419
|
|
|
432
420
|
|
|
433
421
|
@final
|
|
434
|
-
class FunctionScheduleCRUD(
|
|
435
|
-
ResourceCRUD[
|
|
436
|
-
FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule, FunctionScheduleWriteList, FunctionSchedulesList
|
|
437
|
-
]
|
|
438
|
-
):
|
|
422
|
+
class FunctionScheduleCRUD(ResourceCRUD[FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule]):
|
|
439
423
|
folder_name = "functions"
|
|
440
|
-
filename_pattern = r"^.*schedule.*$" # Matches all yaml files who's stem contain *.schedule
|
|
441
424
|
resource_cls = FunctionSchedule
|
|
442
425
|
resource_write_cls = FunctionScheduleWrite
|
|
443
|
-
list_cls = FunctionSchedulesList
|
|
444
|
-
list_write_cls = FunctionScheduleWriteList
|
|
445
426
|
kind = "Schedule"
|
|
446
427
|
yaml_cls = FunctionScheduleYAML
|
|
447
428
|
dependencies = frozenset({FunctionCRUD, GroupResourceScopedCRUD, GroupAllScopedCRUD})
|
|
@@ -562,7 +543,7 @@ class FunctionScheduleCRUD(
|
|
|
562
543
|
)
|
|
563
544
|
return schedules
|
|
564
545
|
|
|
565
|
-
def create(self, items:
|
|
546
|
+
def create(self, items: Sequence[FunctionScheduleWrite]) -> FunctionSchedulesList:
|
|
566
547
|
created_list = FunctionSchedulesList([], cognite_client=self.client)
|
|
567
548
|
function_id_by_external_id = self._get_function_ids_by_external_id(items)
|
|
568
549
|
|
|
@@ -591,7 +572,7 @@ class FunctionScheduleCRUD(
|
|
|
591
572
|
created_list.append(created)
|
|
592
573
|
return created_list
|
|
593
574
|
|
|
594
|
-
def _get_function_ids_by_external_id(self, items:
|
|
575
|
+
def _get_function_ids_by_external_id(self, items: Sequence[FunctionScheduleWrite]) -> dict[str, int]:
|
|
595
576
|
functions_to_lookup = list({item.function_external_id for item in items if item.function_external_id})
|
|
596
577
|
if not functions_to_lookup:
|
|
597
578
|
return {}
|
|
@@ -8,21 +8,17 @@ from cognite.client.data_classes.hosted_extractors import (
|
|
|
8
8
|
Destination,
|
|
9
9
|
DestinationList,
|
|
10
10
|
DestinationWrite,
|
|
11
|
-
DestinationWriteList,
|
|
12
11
|
EventHubSourceWrite,
|
|
13
12
|
Job,
|
|
14
13
|
JobList,
|
|
15
14
|
JobWrite,
|
|
16
|
-
JobWriteList,
|
|
17
15
|
KafkaSourceWrite,
|
|
18
16
|
Mapping,
|
|
19
17
|
MappingList,
|
|
20
18
|
MappingWrite,
|
|
21
|
-
MappingWriteList,
|
|
22
19
|
Source,
|
|
23
20
|
SourceList,
|
|
24
21
|
SourceWrite,
|
|
25
|
-
SourceWriteList,
|
|
26
22
|
)
|
|
27
23
|
from cognite.client.data_classes.hosted_extractors.sources import (
|
|
28
24
|
AuthenticationWrite,
|
|
@@ -48,13 +44,10 @@ from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning
|
|
|
48
44
|
from .data_organization import DataSetsCRUD
|
|
49
45
|
|
|
50
46
|
|
|
51
|
-
class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source
|
|
47
|
+
class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source]):
|
|
52
48
|
folder_name = "hosted_extractors"
|
|
53
|
-
filename_pattern = r".*\.Source$" # Matches all yaml files whose stem ends with '.Source'.
|
|
54
49
|
resource_cls = Source
|
|
55
50
|
resource_write_cls = SourceWrite
|
|
56
|
-
list_cls = SourceList
|
|
57
|
-
list_write_cls = SourceWriteList
|
|
58
51
|
kind = "Source"
|
|
59
52
|
yaml_cls = HostedExtractorSourceYAML
|
|
60
53
|
_doc_base_url = "https://api-docs.cognite.com/20230101-alpha/tag/"
|
|
@@ -93,13 +86,13 @@ class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source, SourceWri
|
|
|
93
86
|
HostedExtractorsAcl.Scope.All(),
|
|
94
87
|
)
|
|
95
88
|
|
|
96
|
-
def create(self, items:
|
|
89
|
+
def create(self, items: Sequence[SourceWrite]) -> SourceList:
|
|
97
90
|
return self.client.hosted_extractors.sources.create(items)
|
|
98
91
|
|
|
99
92
|
def retrieve(self, ids: SequenceNotStr[str]) -> SourceList:
|
|
100
93
|
return self.client.hosted_extractors.sources.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
101
94
|
|
|
102
|
-
def update(self, items:
|
|
95
|
+
def update(self, items: Sequence[SourceWrite]) -> SourceList:
|
|
103
96
|
return self.client.hosted_extractors.sources.update(items, mode="replace")
|
|
104
97
|
|
|
105
98
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -151,15 +144,10 @@ class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source, SourceWri
|
|
|
151
144
|
yield auth.client_secret
|
|
152
145
|
|
|
153
146
|
|
|
154
|
-
class HostedExtractorDestinationCRUD(
|
|
155
|
-
ResourceCRUD[str, DestinationWrite, Destination, DestinationWriteList, DestinationList]
|
|
156
|
-
):
|
|
147
|
+
class HostedExtractorDestinationCRUD(ResourceCRUD[str, DestinationWrite, Destination]):
|
|
157
148
|
folder_name = "hosted_extractors"
|
|
158
|
-
filename_pattern = r".*\.Destination$" # Matches all yaml files whose stem ends with '.Destination'.
|
|
159
149
|
resource_cls = Destination
|
|
160
150
|
resource_write_cls = DestinationWrite
|
|
161
|
-
list_cls = DestinationList
|
|
162
|
-
list_write_cls = DestinationWriteList
|
|
163
151
|
dependencies = frozenset({DataSetsCRUD})
|
|
164
152
|
kind = "Destination"
|
|
165
153
|
_doc_base_url = "https://api-docs.cognite.com/20230101-alpha/tag/"
|
|
@@ -202,13 +190,13 @@ class HostedExtractorDestinationCRUD(
|
|
|
202
190
|
HostedExtractorsAcl.Scope.All(),
|
|
203
191
|
)
|
|
204
192
|
|
|
205
|
-
def create(self, items:
|
|
193
|
+
def create(self, items: Sequence[DestinationWrite]) -> DestinationList:
|
|
206
194
|
return self.client.hosted_extractors.destinations.create(items)
|
|
207
195
|
|
|
208
196
|
def retrieve(self, ids: SequenceNotStr[str]) -> DestinationList:
|
|
209
197
|
return self.client.hosted_extractors.destinations.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
210
198
|
|
|
211
|
-
def update(self, items:
|
|
199
|
+
def update(self, items: Sequence[DestinationWrite]) -> DestinationList:
|
|
212
200
|
return self.client.hosted_extractors.destinations.update(items, mode="replace")
|
|
213
201
|
|
|
214
202
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -254,13 +242,10 @@ class HostedExtractorDestinationCRUD(
|
|
|
254
242
|
yield self._authentication_by_id[id_].client_secret
|
|
255
243
|
|
|
256
244
|
|
|
257
|
-
class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job
|
|
245
|
+
class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job]):
|
|
258
246
|
folder_name = "hosted_extractors"
|
|
259
|
-
filename_pattern = r".*\.Job$" # Matches all yaml files whose stem ends with '.Job'.
|
|
260
247
|
resource_cls = Job
|
|
261
248
|
resource_write_cls = JobWrite
|
|
262
|
-
list_cls = JobList
|
|
263
|
-
list_write_cls = JobWriteList
|
|
264
249
|
dependencies = frozenset({HostedExtractorSourceCRUD, HostedExtractorDestinationCRUD})
|
|
265
250
|
kind = "Job"
|
|
266
251
|
yaml_cls = HostedExtractorJobYAML
|
|
@@ -306,13 +291,13 @@ class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job, JobWriteList, JobL
|
|
|
306
291
|
dumped.pop("config", None)
|
|
307
292
|
return dumped
|
|
308
293
|
|
|
309
|
-
def create(self, items:
|
|
294
|
+
def create(self, items: Sequence[JobWrite]) -> JobList:
|
|
310
295
|
return self.client.hosted_extractors.jobs.create(items)
|
|
311
296
|
|
|
312
297
|
def retrieve(self, ids: SequenceNotStr[str]) -> JobList:
|
|
313
298
|
return self.client.hosted_extractors.jobs.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
314
299
|
|
|
315
|
-
def update(self, items:
|
|
300
|
+
def update(self, items: Sequence[JobWrite]) -> JobList:
|
|
316
301
|
return self.client.hosted_extractors.jobs.update(items, mode="replace")
|
|
317
302
|
|
|
318
303
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -335,13 +320,10 @@ class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job, JobWriteList, JobL
|
|
|
335
320
|
yield HostedExtractorDestinationCRUD, item["destinationId"]
|
|
336
321
|
|
|
337
322
|
|
|
338
|
-
class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping
|
|
323
|
+
class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping]):
|
|
339
324
|
folder_name = "hosted_extractors"
|
|
340
|
-
filename_pattern = r".*\.Mapping$" # Matches all yaml files whose stem ends with '.Mapping'.
|
|
341
325
|
resource_cls = Mapping
|
|
342
326
|
resource_write_cls = MappingWrite
|
|
343
|
-
list_cls = MappingList
|
|
344
|
-
list_write_cls = MappingWriteList
|
|
345
327
|
# This is not an explicit dependency, however, adding it here as mapping will should be deployed after source.
|
|
346
328
|
dependencies = frozenset({HostedExtractorSourceCRUD})
|
|
347
329
|
kind = "Mapping"
|
|
@@ -381,13 +363,13 @@ class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping, Mappin
|
|
|
381
363
|
HostedExtractorsAcl.Scope.All(),
|
|
382
364
|
)
|
|
383
365
|
|
|
384
|
-
def create(self, items:
|
|
366
|
+
def create(self, items: Sequence[MappingWrite]) -> MappingList:
|
|
385
367
|
return self.client.hosted_extractors.mappings.create(items)
|
|
386
368
|
|
|
387
369
|
def retrieve(self, ids: SequenceNotStr[str]) -> MappingList:
|
|
388
370
|
return self.client.hosted_extractors.mappings.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
389
371
|
|
|
390
|
-
def update(self, items:
|
|
372
|
+
def update(self, items: Sequence[MappingWrite]) -> MappingList:
|
|
391
373
|
return self.client.hosted_extractors.mappings.update(items)
|
|
392
374
|
|
|
393
375
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -18,7 +18,6 @@ from cognite_toolkit._cdf_tk.client.data_classes.streamlit_ import (
|
|
|
18
18
|
Streamlit,
|
|
19
19
|
StreamlitList,
|
|
20
20
|
StreamlitWrite,
|
|
21
|
-
StreamlitWriteList,
|
|
22
21
|
)
|
|
23
22
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
24
23
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitNotADirectoryError, ToolkitRequiredValueError
|
|
@@ -34,13 +33,10 @@ from .data_organization import DataSetsCRUD
|
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
@final
|
|
37
|
-
class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit
|
|
36
|
+
class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit]):
|
|
38
37
|
folder_name = "streamlit"
|
|
39
|
-
filename_pattern = r".*streamlit$"
|
|
40
38
|
resource_cls = Streamlit
|
|
41
39
|
resource_write_cls = StreamlitWrite
|
|
42
|
-
list_cls = StreamlitList
|
|
43
|
-
list_write_cls = StreamlitWriteList
|
|
44
40
|
kind = "Streamlit"
|
|
45
41
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
46
42
|
_doc_url = "Files/operation/initFileUpload"
|
|
@@ -157,7 +153,7 @@ class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit, StreamlitWriteL
|
|
|
157
153
|
missing.append(recommended.name)
|
|
158
154
|
return missing
|
|
159
155
|
|
|
160
|
-
def create(self, items:
|
|
156
|
+
def create(self, items: Sequence[StreamlitWrite]) -> StreamlitList:
|
|
161
157
|
created = StreamlitList([])
|
|
162
158
|
for item in items:
|
|
163
159
|
content = self._as_json_string(item.external_id, item.entrypoint)
|
|
@@ -172,7 +168,7 @@ class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit, StreamlitWriteL
|
|
|
172
168
|
files = self.client.files.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
173
169
|
return StreamlitList([Streamlit.from_file(file) for file in files])
|
|
174
170
|
|
|
175
|
-
def update(self, items:
|
|
171
|
+
def update(self, items: Sequence[StreamlitWrite]) -> StreamlitList:
|
|
176
172
|
files = []
|
|
177
173
|
for item in items:
|
|
178
174
|
content = self._as_json_string(item.external_id, item.entrypoint)
|
|
@@ -11,7 +11,6 @@ from cognite_toolkit._cdf_tk.client.data_classes.location_filters import (
|
|
|
11
11
|
LocationFilter,
|
|
12
12
|
LocationFilterList,
|
|
13
13
|
LocationFilterWrite,
|
|
14
|
-
LocationFilterWriteList,
|
|
15
14
|
)
|
|
16
15
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
17
16
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
@@ -28,15 +27,10 @@ from .timeseries import TimeSeriesCRUD
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
@final
|
|
31
|
-
class LocationFilterCRUD(
|
|
32
|
-
ResourceCRUD[str, LocationFilterWrite, LocationFilter, LocationFilterWriteList, LocationFilterList]
|
|
33
|
-
):
|
|
30
|
+
class LocationFilterCRUD(ResourceCRUD[str, LocationFilterWrite, LocationFilter]):
|
|
34
31
|
folder_name = "locations"
|
|
35
|
-
filename_pattern = r"^.*LocationFilter$"
|
|
36
32
|
resource_cls = LocationFilter
|
|
37
33
|
resource_write_cls = LocationFilterWrite
|
|
38
|
-
list_cls = LocationFilterList
|
|
39
|
-
list_write_cls = LocationFilterWriteList
|
|
40
34
|
yaml_cls = LocationYAML
|
|
41
35
|
dependencies = frozenset(
|
|
42
36
|
{
|
|
@@ -182,10 +176,7 @@ class LocationFilterCRUD(
|
|
|
182
176
|
*e.args[1:],
|
|
183
177
|
) from None
|
|
184
178
|
|
|
185
|
-
def create(self, items: LocationFilterWrite
|
|
186
|
-
if isinstance(items, LocationFilterWrite):
|
|
187
|
-
items = LocationFilterWriteList([items])
|
|
188
|
-
|
|
179
|
+
def create(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
189
180
|
created: list[LocationFilter] = []
|
|
190
181
|
# Note: the Location API does not support batch creation, so we need to do this one by one.
|
|
191
182
|
# Furthermore, we could not do the parentExternalId->parentId lookup before the parent was created,
|
|
@@ -213,10 +204,7 @@ class LocationFilterCRUD(
|
|
|
213
204
|
_recursive_find(all_locations)
|
|
214
205
|
return LocationFilterList(found_locations)
|
|
215
206
|
|
|
216
|
-
def update(self, items: LocationFilterWrite
|
|
217
|
-
if isinstance(items, LocationFilterWrite):
|
|
218
|
-
items = LocationFilterWriteList([items])
|
|
219
|
-
|
|
207
|
+
def update(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
220
208
|
updated = []
|
|
221
209
|
ids = {item.external_id: item.id for item in self.retrieve([item.external_id for item in items])}
|
|
222
210
|
for update in items:
|