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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import collections.abc
|
|
2
2
|
import io
|
|
3
|
-
from collections.abc import Hashable, Iterable
|
|
3
|
+
from collections.abc import Hashable, Iterable, Sequence
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Any, final
|
|
6
6
|
|
|
@@ -10,53 +10,69 @@ from cognite.client.data_classes import (
|
|
|
10
10
|
Asset,
|
|
11
11
|
AssetList,
|
|
12
12
|
AssetWrite,
|
|
13
|
-
AssetWriteList,
|
|
14
13
|
Event,
|
|
15
14
|
EventList,
|
|
16
15
|
EventWrite,
|
|
17
|
-
EventWriteList,
|
|
18
|
-
Sequence,
|
|
19
16
|
SequenceList,
|
|
20
17
|
SequenceWrite,
|
|
21
|
-
SequenceWriteList,
|
|
22
18
|
capabilities,
|
|
23
19
|
)
|
|
20
|
+
from cognite.client.data_classes import Sequence as CDFSequence
|
|
24
21
|
from cognite.client.data_classes.capabilities import Capability
|
|
25
22
|
from cognite.client.exceptions import CogniteAPIError, CogniteNotFoundError
|
|
26
23
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
27
24
|
from rich.console import Console
|
|
28
25
|
|
|
29
26
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
30
|
-
from cognite_toolkit._cdf_tk.client.data_classes.sequences import (
|
|
27
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.sequences import (
|
|
31
28
|
ToolkitSequenceRows,
|
|
32
29
|
ToolkitSequenceRowsList,
|
|
33
30
|
ToolkitSequenceRowsWrite,
|
|
34
|
-
ToolkitSequenceRowsWriteList,
|
|
35
31
|
)
|
|
32
|
+
from cognite_toolkit._cdf_tk.constants import TABLE_FORMATS, YAML_SUFFIX
|
|
36
33
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
34
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
37
35
|
from cognite_toolkit._cdf_tk.resource_classes import AssetYAML, EventYAML, SequenceRowYAML, SequenceYAML
|
|
38
|
-
from cognite_toolkit._cdf_tk.tk_warnings import LowSeverityWarning
|
|
36
|
+
from cognite_toolkit._cdf_tk.tk_warnings import LowSeverityWarning, ToolkitDeprecationWarning
|
|
39
37
|
from cognite_toolkit._cdf_tk.utils import load_yaml_inject_variables
|
|
40
38
|
from cognite_toolkit._cdf_tk.utils.diff_list import diff_list_hashable, diff_list_identifiable
|
|
41
39
|
from cognite_toolkit._cdf_tk.utils.file import read_csv
|
|
42
40
|
|
|
43
41
|
from .data_organization import DataSetsCRUD, LabelCRUD
|
|
44
42
|
|
|
43
|
+
_DEPRECATION_WARNING_ISSUED = False
|
|
44
|
+
|
|
45
45
|
|
|
46
46
|
@final
|
|
47
|
-
class AssetCRUD(ResourceCRUD[str, AssetWrite, Asset
|
|
47
|
+
class AssetCRUD(ResourceCRUD[str, AssetWrite, Asset]):
|
|
48
48
|
folder_name = "classic"
|
|
49
|
-
filename_pattern = r"^.*\.Asset$" # Matches all yaml files whose stem ends with '.Asset'.
|
|
50
|
-
filetypes = frozenset({"yaml", "yml", "csv", "parquet"})
|
|
51
49
|
resource_cls = Asset
|
|
52
50
|
resource_write_cls = AssetWrite
|
|
53
|
-
list_cls = AssetList
|
|
54
|
-
list_write_cls = AssetWriteList
|
|
55
51
|
yaml_cls = AssetYAML
|
|
56
52
|
kind = "Asset"
|
|
57
53
|
dependencies = frozenset({DataSetsCRUD, LabelCRUD})
|
|
58
54
|
_doc_url = "Assets/operation/createAssets"
|
|
59
55
|
|
|
56
|
+
@classmethod
|
|
57
|
+
def is_supported_file(cls, file: Path) -> bool:
|
|
58
|
+
if Flags.v08.is_enabled():
|
|
59
|
+
return super().is_supported_file(file)
|
|
60
|
+
global _DEPRECATION_WARNING_ISSUED
|
|
61
|
+
if not file.stem.casefold().endswith(cls.kind.casefold()):
|
|
62
|
+
return False
|
|
63
|
+
if file.suffix in YAML_SUFFIX:
|
|
64
|
+
return True
|
|
65
|
+
if file.suffix in TABLE_FORMATS:
|
|
66
|
+
if not _DEPRECATION_WARNING_ISSUED:
|
|
67
|
+
ToolkitDeprecationWarning(
|
|
68
|
+
feature="deployment of asset from CSV or Parquet files",
|
|
69
|
+
alternative="data plugin and cdf data upload commands",
|
|
70
|
+
removal_version="0.8",
|
|
71
|
+
).print_warning()
|
|
72
|
+
_DEPRECATION_WARNING_ISSUED = True
|
|
73
|
+
return True
|
|
74
|
+
return False
|
|
75
|
+
|
|
60
76
|
@property
|
|
61
77
|
def display_name(self) -> str:
|
|
62
78
|
return "assets"
|
|
@@ -103,13 +119,13 @@ class AssetCRUD(ResourceCRUD[str, AssetWrite, Asset, AssetWriteList, AssetList])
|
|
|
103
119
|
|
|
104
120
|
return capabilities.AssetsAcl(actions, scope)
|
|
105
121
|
|
|
106
|
-
def create(self, items:
|
|
122
|
+
def create(self, items: Sequence[AssetWrite]) -> AssetList:
|
|
107
123
|
return self.client.assets.create(items)
|
|
108
124
|
|
|
109
125
|
def retrieve(self, ids: SequenceNotStr[str]) -> AssetList:
|
|
110
126
|
return self.client.assets.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
111
127
|
|
|
112
|
-
def update(self, items:
|
|
128
|
+
def update(self, items: Sequence[AssetWrite]) -> AssetList:
|
|
113
129
|
return self.client.assets.update(items, mode="replace")
|
|
114
130
|
|
|
115
131
|
def delete(self, ids: SequenceNotStr[str | int]) -> int:
|
|
@@ -232,13 +248,10 @@ class AssetCRUD(ResourceCRUD[str, AssetWrite, Asset, AssetWriteList, AssetList])
|
|
|
232
248
|
|
|
233
249
|
|
|
234
250
|
@final
|
|
235
|
-
class SequenceCRUD(ResourceCRUD[str, SequenceWrite,
|
|
251
|
+
class SequenceCRUD(ResourceCRUD[str, SequenceWrite, CDFSequence]):
|
|
236
252
|
folder_name = "classic"
|
|
237
|
-
|
|
238
|
-
resource_cls = Sequence
|
|
253
|
+
resource_cls = CDFSequence
|
|
239
254
|
resource_write_cls = SequenceWrite
|
|
240
|
-
list_cls = SequenceList
|
|
241
|
-
list_write_cls = SequenceWriteList
|
|
242
255
|
kind = "Sequence"
|
|
243
256
|
dependencies = frozenset({DataSetsCRUD, AssetCRUD})
|
|
244
257
|
yaml_cls = SequenceYAML
|
|
@@ -249,7 +262,7 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
249
262
|
return "sequences"
|
|
250
263
|
|
|
251
264
|
@classmethod
|
|
252
|
-
def get_id(cls, item:
|
|
265
|
+
def get_id(cls, item: CDFSequence | SequenceWrite | dict) -> str:
|
|
253
266
|
if isinstance(item, dict):
|
|
254
267
|
return item["externalId"]
|
|
255
268
|
if not item.external_id:
|
|
@@ -257,7 +270,7 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
257
270
|
return item.external_id
|
|
258
271
|
|
|
259
272
|
@classmethod
|
|
260
|
-
def get_internal_id(cls, item:
|
|
273
|
+
def get_internal_id(cls, item: CDFSequence | dict) -> int:
|
|
261
274
|
if isinstance(item, dict):
|
|
262
275
|
return item["id"]
|
|
263
276
|
if not item.id:
|
|
@@ -270,7 +283,7 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
270
283
|
|
|
271
284
|
@classmethod
|
|
272
285
|
def get_required_capability(
|
|
273
|
-
cls, items:
|
|
286
|
+
cls, items: Sequence[SequenceWrite] | None, read_only: bool
|
|
274
287
|
) -> Capability | list[Capability]:
|
|
275
288
|
if not items and items is not None:
|
|
276
289
|
return []
|
|
@@ -294,7 +307,7 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
294
307
|
resource["assetId"] = self.client.lookup.assets.id(asset_external_id, is_dry_run)
|
|
295
308
|
return SequenceWrite._load(resource)
|
|
296
309
|
|
|
297
|
-
def dump_resource(self, resource:
|
|
310
|
+
def dump_resource(self, resource: CDFSequence, local: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
298
311
|
dumped = resource.as_write().dump()
|
|
299
312
|
local = local or {}
|
|
300
313
|
if data_set_id := dumped.pop("dataSetId", None):
|
|
@@ -322,13 +335,13 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
322
335
|
return super().diff_list(local, cdf, json_path)
|
|
323
336
|
return diff_list_identifiable(local, cdf, get_identifier=lambda col: col["externalId"])
|
|
324
337
|
|
|
325
|
-
def create(self, items:
|
|
338
|
+
def create(self, items: Sequence[SequenceWrite]) -> SequenceList:
|
|
326
339
|
return self.client.sequences.create(items)
|
|
327
340
|
|
|
328
341
|
def retrieve(self, ids: SequenceNotStr[str]) -> SequenceList:
|
|
329
342
|
return self.client.sequences.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
330
343
|
|
|
331
|
-
def update(self, items:
|
|
344
|
+
def update(self, items: Sequence[SequenceWrite]) -> SequenceList:
|
|
332
345
|
return self.client.sequences.upsert(items, mode="replace")
|
|
333
346
|
|
|
334
347
|
def delete(self, ids: SequenceNotStr[str | int]) -> int:
|
|
@@ -349,7 +362,7 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
349
362
|
data_set_external_id: str | None = None,
|
|
350
363
|
space: str | None = None,
|
|
351
364
|
parent_ids: list[Hashable] | None = None,
|
|
352
|
-
) -> Iterable[
|
|
365
|
+
) -> Iterable[CDFSequence]:
|
|
353
366
|
return iter(
|
|
354
367
|
self.client.sequences(data_set_external_ids=[data_set_external_id] if data_set_external_id else None)
|
|
355
368
|
)
|
|
@@ -363,17 +376,10 @@ class SequenceCRUD(ResourceCRUD[str, SequenceWrite, Sequence, SequenceWriteList,
|
|
|
363
376
|
|
|
364
377
|
|
|
365
378
|
@final
|
|
366
|
-
class SequenceRowCRUD(
|
|
367
|
-
ResourceCRUD[
|
|
368
|
-
str, ToolkitSequenceRowsWrite, ToolkitSequenceRows, ToolkitSequenceRowsWriteList, ToolkitSequenceRowsList
|
|
369
|
-
]
|
|
370
|
-
):
|
|
379
|
+
class SequenceRowCRUD(ResourceCRUD[str, ToolkitSequenceRowsWrite, ToolkitSequenceRows]):
|
|
371
380
|
folder_name = "classic"
|
|
372
|
-
filename_pattern = r"^.*\.SequenceRow$"
|
|
373
381
|
resource_cls = ToolkitSequenceRows
|
|
374
382
|
resource_write_cls = ToolkitSequenceRowsWrite
|
|
375
|
-
list_cls = ToolkitSequenceRowsList
|
|
376
|
-
list_write_cls = ToolkitSequenceRowsWriteList
|
|
377
383
|
kind = "SequenceRow"
|
|
378
384
|
dependencies = frozenset({SequenceCRUD})
|
|
379
385
|
parent_resource = frozenset({SequenceCRUD})
|
|
@@ -418,8 +424,7 @@ class SequenceRowCRUD(
|
|
|
418
424
|
# We don't have any capabilities for SequenceRows, that is already handled by the Sequence
|
|
419
425
|
return []
|
|
420
426
|
|
|
421
|
-
def create(self, items:
|
|
422
|
-
item: ToolkitSequenceRowsWrite
|
|
427
|
+
def create(self, items: Sequence[ToolkitSequenceRowsWrite]) -> Sequence[ToolkitSequenceRowsWrite]:
|
|
423
428
|
for item in items:
|
|
424
429
|
self.client.sequences.rows.insert(item.as_sequence_rows(), external_id=item.external_id)
|
|
425
430
|
return items
|
|
@@ -495,14 +500,10 @@ class SequenceRowCRUD(
|
|
|
495
500
|
|
|
496
501
|
|
|
497
502
|
@final
|
|
498
|
-
class EventCRUD(ResourceCRUD[str, EventWrite, Event
|
|
503
|
+
class EventCRUD(ResourceCRUD[str, EventWrite, Event]):
|
|
499
504
|
folder_name = "classic"
|
|
500
|
-
filename_pattern = r"^.*\.Event$" # Matches all yaml files whose stem ends with '.Event'.
|
|
501
|
-
filetypes = frozenset({"yaml", "yml"})
|
|
502
505
|
resource_cls = Event
|
|
503
506
|
resource_write_cls = EventWrite
|
|
504
|
-
list_cls = EventList
|
|
505
|
-
list_write_cls = EventWriteList
|
|
506
507
|
yaml_cls = EventYAML
|
|
507
508
|
kind = "Event"
|
|
508
509
|
dependencies = frozenset({DataSetsCRUD, AssetCRUD})
|
|
@@ -554,13 +555,13 @@ class EventCRUD(ResourceCRUD[str, EventWrite, Event, EventWriteList, EventList])
|
|
|
554
555
|
|
|
555
556
|
return capabilities.EventsAcl(actions, scope)
|
|
556
557
|
|
|
557
|
-
def create(self, items:
|
|
558
|
+
def create(self, items: Sequence[EventWrite]) -> EventList:
|
|
558
559
|
return self.client.events.create(items)
|
|
559
560
|
|
|
560
561
|
def retrieve(self, ids: SequenceNotStr[str]) -> EventList:
|
|
561
562
|
return self.client.events.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
562
563
|
|
|
563
|
-
def update(self, items:
|
|
564
|
+
def update(self, items: Sequence[EventWrite]) -> EventList:
|
|
564
565
|
return self.client.events.update(items, mode="replace")
|
|
565
566
|
|
|
566
567
|
def delete(self, ids: SequenceNotStr[str | int]) -> int:
|
|
@@ -7,11 +7,10 @@ from cognite.client.utils.useful_types import SequenceNotStr
|
|
|
7
7
|
from rich.console import Console
|
|
8
8
|
|
|
9
9
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
10
|
-
from cognite_toolkit._cdf_tk.client.data_classes.search_config import (
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import (
|
|
11
11
|
SearchConfig,
|
|
12
12
|
SearchConfigList,
|
|
13
13
|
SearchConfigWrite,
|
|
14
|
-
SearchConfigWriteList,
|
|
15
14
|
ViewId,
|
|
16
15
|
)
|
|
17
16
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
@@ -23,14 +22,11 @@ from .datamodel import ViewCRUD
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
@final
|
|
26
|
-
class SearchConfigCRUD(ResourceCRUD[ViewId, SearchConfigWrite, SearchConfig
|
|
25
|
+
class SearchConfigCRUD(ResourceCRUD[ViewId, SearchConfigWrite, SearchConfig]):
|
|
27
26
|
support_drop = False
|
|
28
27
|
folder_name = "cdf_applications"
|
|
29
|
-
filename_pattern = r"^.*SearchConfig$"
|
|
30
28
|
resource_cls = SearchConfig
|
|
31
29
|
resource_write_cls = SearchConfigWrite
|
|
32
|
-
list_cls = SearchConfigList
|
|
33
|
-
list_write_cls = SearchConfigWriteList
|
|
34
30
|
yaml_cls = SearchConfigYAML
|
|
35
31
|
dependencies = frozenset({ViewCRUD})
|
|
36
32
|
kind = "SearchConfig"
|
|
@@ -104,20 +100,17 @@ class SearchConfigCRUD(ResourceCRUD[ViewId, SearchConfigWrite, SearchConfig, Sea
|
|
|
104
100
|
return diff_list_identifiable(local, cdf, get_identifier=dm_identifier)
|
|
105
101
|
return super().diff_list(local, cdf, json_path)
|
|
106
102
|
|
|
107
|
-
def _upsert(self, items: SearchConfigWrite
|
|
103
|
+
def _upsert(self, items: Sequence[SearchConfigWrite]) -> SearchConfigList:
|
|
108
104
|
"""
|
|
109
105
|
Upsert search configurations using the upsert method
|
|
110
106
|
"""
|
|
111
|
-
if isinstance(items, SearchConfigWrite):
|
|
112
|
-
items = SearchConfigWriteList([items])
|
|
113
|
-
|
|
114
107
|
result = SearchConfigList([])
|
|
115
108
|
for item in items:
|
|
116
109
|
created = self.client.search.configurations.upsert(item)
|
|
117
110
|
result.append(created)
|
|
118
111
|
return result
|
|
119
112
|
|
|
120
|
-
def create(self, items:
|
|
113
|
+
def create(self, items: Sequence[SearchConfigWrite]) -> SearchConfigList:
|
|
121
114
|
"""
|
|
122
115
|
Create new search configurations using the upsert method
|
|
123
116
|
"""
|
|
@@ -129,7 +122,7 @@ class SearchConfigCRUD(ResourceCRUD[ViewId, SearchConfigWrite, SearchConfig, Sea
|
|
|
129
122
|
# The API does not support server-side filtering, so we filter in memory.
|
|
130
123
|
return SearchConfigList([config for config in all_configs if config.view in ids])
|
|
131
124
|
|
|
132
|
-
def update(self, items:
|
|
125
|
+
def update(self, items: Sequence[SearchConfigWrite]) -> SearchConfigList:
|
|
133
126
|
"""
|
|
134
127
|
Update search configurations using the upsert method
|
|
135
128
|
"""
|
|
@@ -21,7 +21,6 @@ from cognite.client.data_classes import (
|
|
|
21
21
|
DataSet,
|
|
22
22
|
DataSetList,
|
|
23
23
|
DataSetWrite,
|
|
24
|
-
DataSetWriteList,
|
|
25
24
|
LabelDefinition,
|
|
26
25
|
LabelDefinitionList,
|
|
27
26
|
LabelDefinitionWrite,
|
|
@@ -31,7 +30,6 @@ from cognite.client.data_classes.capabilities import (
|
|
|
31
30
|
Capability,
|
|
32
31
|
DataSetsAcl,
|
|
33
32
|
)
|
|
34
|
-
from cognite.client.data_classes.labels import LabelDefinitionWriteList
|
|
35
33
|
from cognite.client.exceptions import CogniteAPIError, CogniteDuplicatedError, CogniteNotFoundError
|
|
36
34
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
37
35
|
|
|
@@ -45,13 +43,11 @@ from .auth import GroupAllScopedCRUD
|
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
@final
|
|
48
|
-
class DataSetsCRUD(ResourceCRUD[str, DataSetWrite, DataSet
|
|
46
|
+
class DataSetsCRUD(ResourceCRUD[str, DataSetWrite, DataSet]):
|
|
49
47
|
support_drop = False
|
|
50
48
|
folder_name = "data_sets"
|
|
51
49
|
resource_cls = DataSet
|
|
52
50
|
resource_write_cls = DataSetWrite
|
|
53
|
-
list_cls = DataSetList
|
|
54
|
-
list_write_cls = DataSetWriteList
|
|
55
51
|
yaml_cls = DataSetYAML
|
|
56
52
|
kind = "DataSet"
|
|
57
53
|
dependencies = frozenset({GroupAllScopedCRUD})
|
|
@@ -142,7 +138,7 @@ class DataSetsCRUD(ResourceCRUD[str, DataSetWrite, DataSet, DataSetWriteList, Da
|
|
|
142
138
|
def retrieve(self, ids: SequenceNotStr[str]) -> DataSetList:
|
|
143
139
|
return self.client.data_sets.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
144
140
|
|
|
145
|
-
def update(self, items:
|
|
141
|
+
def update(self, items: Sequence[DataSetWrite]) -> DataSetList:
|
|
146
142
|
return self.client.data_sets.update(items, mode="replace")
|
|
147
143
|
|
|
148
144
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -158,15 +154,10 @@ class DataSetsCRUD(ResourceCRUD[str, DataSetWrite, DataSet, DataSetWriteList, Da
|
|
|
158
154
|
|
|
159
155
|
|
|
160
156
|
@final
|
|
161
|
-
class LabelCRUD(
|
|
162
|
-
ResourceCRUD[str, LabelDefinitionWrite, LabelDefinition, LabelDefinitionWriteList, LabelDefinitionList]
|
|
163
|
-
):
|
|
157
|
+
class LabelCRUD(ResourceCRUD[str, LabelDefinitionWrite, LabelDefinition]):
|
|
164
158
|
folder_name = "classic"
|
|
165
|
-
filename_pattern = r"^.*Label$" # Matches all yaml files whose stem ends with *Label.
|
|
166
159
|
resource_cls = LabelDefinition
|
|
167
160
|
resource_write_cls = LabelDefinitionWrite
|
|
168
|
-
list_cls = LabelDefinitionList
|
|
169
|
-
list_write_cls = LabelDefinitionWriteList
|
|
170
161
|
yaml_cls = LabelsYAML
|
|
171
162
|
kind = "Label"
|
|
172
163
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
@@ -210,7 +201,7 @@ class LabelCRUD(
|
|
|
210
201
|
|
|
211
202
|
return capabilities.LabelsAcl(actions, scope)
|
|
212
203
|
|
|
213
|
-
def create(self, items:
|
|
204
|
+
def create(self, items: Sequence[LabelDefinitionWrite]) -> LabelDefinitionList:
|
|
214
205
|
return self.client.labels.create(items)
|
|
215
206
|
|
|
216
207
|
def retrieve(self, ids: SequenceNotStr[str]) -> LabelDefinitionList:
|