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
|
@@ -8,17 +8,24 @@ from cognite.client.data_classes.data_modeling import NodeApplyResultList, NodeI
|
|
|
8
8
|
from cognite.client.exceptions import CogniteAPIError
|
|
9
9
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
10
10
|
|
|
11
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.data_classes.infield import (
|
|
12
|
+
InFieldCDMLocationConfig,
|
|
13
|
+
InfieldLocationConfig,
|
|
14
|
+
InfieldLocationConfigList,
|
|
15
|
+
)
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceResult, TypedNodeIdentifier
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.apm_config_v1 import (
|
|
12
18
|
APMConfig,
|
|
13
19
|
APMConfigList,
|
|
14
20
|
APMConfigWrite,
|
|
15
|
-
APMConfigWriteList,
|
|
16
21
|
)
|
|
17
|
-
from cognite_toolkit._cdf_tk.client.data_classes.infield import InfieldLocationConfig, InfieldLocationConfigList
|
|
18
|
-
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,35 +246,27 @@ 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[TypedNodeIdentifier, 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
|
-
def get_id(cls, item: InfieldLocationConfig | dict) ->
|
|
263
|
+
def get_id(cls, item: InfieldLocationConfig | dict) -> TypedNodeIdentifier:
|
|
269
264
|
if isinstance(item, dict):
|
|
270
|
-
return
|
|
271
|
-
return
|
|
265
|
+
return TypedNodeIdentifier(space=item["space"], external_id=item["externalId"])
|
|
266
|
+
return TypedNodeIdentifier(space=item.space, external_id=item.external_id)
|
|
272
267
|
|
|
273
268
|
@classmethod
|
|
274
|
-
def dump_id(cls, id:
|
|
269
|
+
def dump_id(cls, id: TypedNodeIdentifier) -> dict[str, Any]:
|
|
275
270
|
return id.dump(include_type=False)
|
|
276
271
|
|
|
277
272
|
@classmethod
|
|
@@ -306,20 +301,20 @@ 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
|
|
313
308
|
# as we only want to count the infield location configs here.
|
|
314
309
|
return [res for res in created if res.as_id() in config_ids]
|
|
315
310
|
|
|
316
|
-
def retrieve(self, ids: SequenceNotStr[
|
|
311
|
+
def retrieve(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> 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
|
-
def delete(self, ids: SequenceNotStr[
|
|
317
|
+
def delete(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> int:
|
|
323
318
|
# We must retrieve the full resource to get hte DataExplorationConfig linked resource deleted as well.
|
|
324
319
|
retrieved = self.retrieve(list(ids))
|
|
325
320
|
# Then, we pass the entire resource to the delete method, which will delete both the InfieldLocationConfig
|
|
@@ -347,3 +342,99 @@ 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(
|
|
349
|
+
ResourceCRUD[TypedNodeIdentifier, InFieldCDMLocationConfig, InFieldCDMLocationConfig]
|
|
350
|
+
):
|
|
351
|
+
folder_name = "cdf_applications"
|
|
352
|
+
resource_cls = InFieldCDMLocationConfig
|
|
353
|
+
resource_write_cls = InFieldCDMLocationConfig
|
|
354
|
+
kind = "InFieldCDMLocationConfig"
|
|
355
|
+
yaml_cls = InFieldCDMLocationConfigYAML
|
|
356
|
+
dependencies = frozenset({SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
357
|
+
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
358
|
+
|
|
359
|
+
@property
|
|
360
|
+
def display_name(self) -> str:
|
|
361
|
+
return "infield CDM location configs"
|
|
362
|
+
|
|
363
|
+
@classmethod
|
|
364
|
+
def get_id(cls, item: InFieldCDMLocationConfig | dict) -> TypedNodeIdentifier:
|
|
365
|
+
if isinstance(item, dict):
|
|
366
|
+
return TypedNodeIdentifier(space=item["space"], external_id=item["externalId"])
|
|
367
|
+
return TypedNodeIdentifier(space=item.space, external_id=item.external_id)
|
|
368
|
+
|
|
369
|
+
@classmethod
|
|
370
|
+
def dump_id(cls, id: TypedNodeIdentifier) -> dict[str, Any]:
|
|
371
|
+
return id.dump(include_type=False)
|
|
372
|
+
|
|
373
|
+
@classmethod
|
|
374
|
+
def get_required_capability(
|
|
375
|
+
cls, items: Sequence[InFieldCDMLocationConfig] | None, read_only: bool
|
|
376
|
+
) -> Capability | list[Capability]:
|
|
377
|
+
if not items or items is None:
|
|
378
|
+
return []
|
|
379
|
+
|
|
380
|
+
actions = (
|
|
381
|
+
[DataModelInstancesAcl.Action.Read]
|
|
382
|
+
if read_only
|
|
383
|
+
else [DataModelInstancesAcl.Action.Read, DataModelInstancesAcl.Action.Write]
|
|
384
|
+
)
|
|
385
|
+
instance_spaces = sorted({item.space for item in items})
|
|
386
|
+
|
|
387
|
+
return DataModelInstancesAcl(actions, DataModelInstancesAcl.Scope.SpaceID(instance_spaces))
|
|
388
|
+
|
|
389
|
+
def dump_resource(self, resource: InFieldCDMLocationConfig, local: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
390
|
+
dumped = resource.as_write().dump()
|
|
391
|
+
local = local or {}
|
|
392
|
+
if "existingVersion" not in local:
|
|
393
|
+
# Existing version is typically not set when creating nodes, but we get it back
|
|
394
|
+
# when we retrieve the node from the server.
|
|
395
|
+
dumped.pop("existingVersion", None)
|
|
396
|
+
dumped.pop("instanceType", None)
|
|
397
|
+
return dumped
|
|
398
|
+
|
|
399
|
+
def create(self, items: Sequence[InFieldCDMLocationConfig]) -> list[InstanceResult]:
|
|
400
|
+
return self.client.infield.cdm_config.apply(items)
|
|
401
|
+
|
|
402
|
+
def retrieve(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> list[InFieldCDMLocationConfig]:
|
|
403
|
+
return self.client.infield.cdm_config.retrieve(list(ids))
|
|
404
|
+
|
|
405
|
+
def update(self, items: Sequence[InFieldCDMLocationConfig]) -> Sized:
|
|
406
|
+
return self.create(items)
|
|
407
|
+
|
|
408
|
+
def delete(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> int:
|
|
409
|
+
# We must retrieve the full resource to delete it.
|
|
410
|
+
retrieved = self.retrieve(list(ids))
|
|
411
|
+
_ = self.client.infield.cdm_config.delete(retrieved)
|
|
412
|
+
return len(retrieved)
|
|
413
|
+
|
|
414
|
+
def _iterate(
|
|
415
|
+
self,
|
|
416
|
+
data_set_external_id: str | None = None,
|
|
417
|
+
space: str | None = None,
|
|
418
|
+
parent_ids: list[Hashable] | None = None,
|
|
419
|
+
) -> Iterable[InFieldCDMLocationConfig]:
|
|
420
|
+
raise NotImplementedError(f"Iteration over {self.display_name} is not supported.")
|
|
421
|
+
|
|
422
|
+
def diff_list(
|
|
423
|
+
self, local: list[Any], cdf: list[Any], json_path: tuple[str | int, ...]
|
|
424
|
+
) -> tuple[dict[int, int], list[int]]:
|
|
425
|
+
if json_path == ("accessManagement", "templateAdmins"):
|
|
426
|
+
return diff_list_hashable(local, cdf)
|
|
427
|
+
elif json_path == ("accessManagement", "checklistAdmins"):
|
|
428
|
+
return diff_list_hashable(local, cdf)
|
|
429
|
+
elif json_path == ("disciplines",):
|
|
430
|
+
return diff_list_identifiable(local, cdf, get_identifier=hash_dict)
|
|
431
|
+
elif len(json_path) == 3 and json_path[0] == "dataFilters" and json_path[2] == "instanceSpaces":
|
|
432
|
+
# Handles dataFilters.<entity>.instanceSpaces (e.g., files, assets, operations, timeSeries, etc.)
|
|
433
|
+
return diff_list_hashable(local, cdf)
|
|
434
|
+
elif json_path == ("dataExplorationConfig", "filters"):
|
|
435
|
+
return diff_list_identifiable(local, cdf, get_identifier=hash_dict)
|
|
436
|
+
elif len(json_path) == 4 and json_path[:2] == ("dataExplorationConfig", "filters") and json_path[3] == "values":
|
|
437
|
+
# Handles dataExplorationConfig.filters[i].values
|
|
438
|
+
return diff_list_hashable(local, cdf)
|
|
439
|
+
|
|
440
|
+
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,
|
|
@@ -34,10 +33,9 @@ from cognite.client.utils._time import convert_data_modelling_timestamp
|
|
|
34
33
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
35
34
|
from rich import print
|
|
36
35
|
|
|
37
|
-
from cognite_toolkit._cdf_tk.client.data_classes.extendable_cognite_file import (
|
|
36
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.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,
|
|
@@ -24,6 +22,7 @@ from cognite.client.data_classes.capabilities import (
|
|
|
24
22
|
FunctionsAcl,
|
|
25
23
|
SessionsAcl,
|
|
26
24
|
)
|
|
25
|
+
from cognite.client.data_classes.data_modeling import NodeId
|
|
27
26
|
from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteFileApply
|
|
28
27
|
from cognite.client.data_classes.functions import HANDLER_FILE_NAME
|
|
29
28
|
from cognite.client.exceptions import CogniteAPIError
|
|
@@ -32,13 +31,12 @@ from rich import print
|
|
|
32
31
|
from rich.console import Console
|
|
33
32
|
|
|
34
33
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
35
|
-
from cognite_toolkit._cdf_tk.client.data_classes.functions import FunctionScheduleID
|
|
34
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.functions import FunctionScheduleID
|
|
36
35
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
37
36
|
from cognite_toolkit._cdf_tk.exceptions import (
|
|
38
37
|
ResourceCreationError,
|
|
39
38
|
ToolkitRequiredValueError,
|
|
40
39
|
)
|
|
41
|
-
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
42
40
|
from cognite_toolkit._cdf_tk.resource_classes import FunctionScheduleYAML, FunctionsYAML
|
|
43
41
|
from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning, LowSeverityWarning
|
|
44
42
|
from cognite_toolkit._cdf_tk.utils import (
|
|
@@ -57,16 +55,11 @@ from .group_scoped import GroupResourceScopedCRUD
|
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
@final
|
|
60
|
-
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function
|
|
58
|
+
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function]):
|
|
61
59
|
support_drop = True
|
|
62
60
|
folder_name = "functions"
|
|
63
|
-
filename_pattern = (
|
|
64
|
-
r"^(?:(?!schedule).)*$" # Matches all yaml files except file names who's stem contain *.schedule.
|
|
65
|
-
)
|
|
66
61
|
resource_cls = Function
|
|
67
62
|
resource_write_cls = FunctionWrite
|
|
68
|
-
list_cls = FunctionList
|
|
69
|
-
list_write_cls = FunctionWriteList
|
|
70
63
|
kind = "Function"
|
|
71
64
|
yaml_cls = FunctionsYAML
|
|
72
65
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
@@ -302,7 +295,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
302
295
|
self.client.functions.activate()
|
|
303
296
|
return False
|
|
304
297
|
|
|
305
|
-
def create(self, items:
|
|
298
|
+
def create(self, items: Sequence[FunctionWrite]) -> FunctionList:
|
|
306
299
|
created = FunctionList([], cognite_client=self.client)
|
|
307
300
|
if not self._is_activated("create"):
|
|
308
301
|
return created
|
|
@@ -328,7 +321,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
328
321
|
" problem persists, please contact Cognite support."
|
|
329
322
|
)
|
|
330
323
|
item.file_id = file_id
|
|
331
|
-
created_item = self.client.functions.create_with_429_retry(item
|
|
324
|
+
created_item = self.client.functions.create_with_429_retry(item)
|
|
332
325
|
self._warn_if_cpu_or_memory_changed(created_item, item)
|
|
333
326
|
created.append(created_item)
|
|
334
327
|
return created
|
|
@@ -349,18 +342,14 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
349
342
|
function_rootdir = self.function_dir_by_external_id[external_id]
|
|
350
343
|
data_set_id = self.data_set_id_by_external_id.get(external_id)
|
|
351
344
|
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
|
-
):
|
|
345
|
+
if space is None and self.project_data_modeling_status.casefold() == "data_modeling_only":
|
|
357
346
|
raise ResourceCreationError(
|
|
358
347
|
f"Function {external_id!r} must have a space set when the project is in DATA_MODELING_ONLY mode. "
|
|
359
348
|
"This is used to set the NodeId of the CogniteFile created for the function code."
|
|
360
349
|
)
|
|
361
350
|
|
|
362
351
|
with create_temporary_zip(function_rootdir, "function.zip") as zip_path:
|
|
363
|
-
if
|
|
352
|
+
if space:
|
|
364
353
|
cognite_file = CogniteFileApply(
|
|
365
354
|
space=space,
|
|
366
355
|
external_id=external_id,
|
|
@@ -416,9 +405,20 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
416
405
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
417
406
|
functions = self.retrieve(ids)
|
|
418
407
|
|
|
419
|
-
self.client.functions.delete_with_429_retry(external_id=ids, ignore_unknown_ids=True
|
|
408
|
+
self.client.functions.delete_with_429_retry(external_id=ids, ignore_unknown_ids=True)
|
|
420
409
|
file_ids = {func.file_id for func in functions if func.file_id}
|
|
421
|
-
self.client.files.
|
|
410
|
+
files = self.client.files.retrieve_multiple(list(file_ids), ignore_unknown_ids=True)
|
|
411
|
+
dm_file_nodes: set[NodeId] = set()
|
|
412
|
+
classic_file_ids: set[int] = set()
|
|
413
|
+
for file in files:
|
|
414
|
+
if file.instance_id is not None:
|
|
415
|
+
dm_file_nodes.add(file.instance_id)
|
|
416
|
+
else:
|
|
417
|
+
classic_file_ids.add(file.id)
|
|
418
|
+
if classic_file_ids:
|
|
419
|
+
self.client.files.delete(id=list(classic_file_ids), ignore_unknown_ids=True)
|
|
420
|
+
if dm_file_nodes:
|
|
421
|
+
self.client.data_modeling.instances.delete(list(dm_file_nodes))
|
|
422
422
|
return len(ids)
|
|
423
423
|
|
|
424
424
|
def _iterate(
|
|
@@ -431,17 +431,10 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
431
431
|
|
|
432
432
|
|
|
433
433
|
@final
|
|
434
|
-
class FunctionScheduleCRUD(
|
|
435
|
-
ResourceCRUD[
|
|
436
|
-
FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule, FunctionScheduleWriteList, FunctionSchedulesList
|
|
437
|
-
]
|
|
438
|
-
):
|
|
434
|
+
class FunctionScheduleCRUD(ResourceCRUD[FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule]):
|
|
439
435
|
folder_name = "functions"
|
|
440
|
-
filename_pattern = r"^.*schedule.*$" # Matches all yaml files who's stem contain *.schedule
|
|
441
436
|
resource_cls = FunctionSchedule
|
|
442
437
|
resource_write_cls = FunctionScheduleWrite
|
|
443
|
-
list_cls = FunctionSchedulesList
|
|
444
|
-
list_write_cls = FunctionScheduleWriteList
|
|
445
438
|
kind = "Schedule"
|
|
446
439
|
yaml_cls = FunctionScheduleYAML
|
|
447
440
|
dependencies = frozenset({FunctionCRUD, GroupResourceScopedCRUD, GroupAllScopedCRUD})
|
|
@@ -562,7 +555,7 @@ class FunctionScheduleCRUD(
|
|
|
562
555
|
)
|
|
563
556
|
return schedules
|
|
564
557
|
|
|
565
|
-
def create(self, items:
|
|
558
|
+
def create(self, items: Sequence[FunctionScheduleWrite]) -> FunctionSchedulesList:
|
|
566
559
|
created_list = FunctionSchedulesList([], cognite_client=self.client)
|
|
567
560
|
function_id_by_external_id = self._get_function_ids_by_external_id(items)
|
|
568
561
|
|
|
@@ -591,7 +584,7 @@ class FunctionScheduleCRUD(
|
|
|
591
584
|
created_list.append(created)
|
|
592
585
|
return created_list
|
|
593
586
|
|
|
594
|
-
def _get_function_ids_by_external_id(self, items:
|
|
587
|
+
def _get_function_ids_by_external_id(self, items: Sequence[FunctionScheduleWrite]) -> dict[str, int]:
|
|
595
588
|
functions_to_lookup = list({item.function_external_id for item in items if item.function_external_id})
|
|
596
589
|
if not functions_to_lookup:
|
|
597
590
|
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:
|
|
@@ -14,11 +14,10 @@ from packaging.requirements import Requirement
|
|
|
14
14
|
from rich.console import Console
|
|
15
15
|
|
|
16
16
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
17
|
-
from cognite_toolkit._cdf_tk.client.data_classes.streamlit_ import (
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.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)
|