cognite-toolkit 0.7.30__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.
Files changed (121) hide show
  1. cognite_toolkit/_cdf.py +5 -6
  2. cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
  3. cognite_toolkit/_cdf_tk/apps/_core_app.py +7 -1
  4. cognite_toolkit/_cdf_tk/apps/_download_app.py +2 -2
  5. cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
  6. cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
  7. cognite_toolkit/_cdf_tk/apps/_migrate_app.py +177 -2
  8. cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
  9. cognite_toolkit/_cdf_tk/client/_toolkit_client.py +9 -9
  10. cognite_toolkit/_cdf_tk/client/api/infield.py +38 -33
  11. cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +15 -7
  12. cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
  13. cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
  14. cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
  15. cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +9 -9
  16. cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
  17. cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
  18. cognite_toolkit/_cdf_tk/client/api/{location_filters.py → legacy/location_filters.py} +1 -1
  19. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
  20. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
  21. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
  22. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
  23. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
  24. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
  25. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
  26. cognite_toolkit/_cdf_tk/client/api/{search_config.py → legacy/search_config.py} +5 -1
  27. cognite_toolkit/_cdf_tk/client/api/migration.py +2 -3
  28. cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
  29. cognite_toolkit/_cdf_tk/client/api/search.py +2 -2
  30. cognite_toolkit/_cdf_tk/client/api/streams.py +21 -17
  31. cognite_toolkit/_cdf_tk/client/api/three_d.py +343 -9
  32. cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
  33. cognite_toolkit/_cdf_tk/client/data_classes/base.py +12 -32
  34. cognite_toolkit/_cdf_tk/client/data_classes/instance_api.py +18 -13
  35. cognite_toolkit/_cdf_tk/client/data_classes/legacy/__init__.py +0 -0
  36. cognite_toolkit/_cdf_tk/client/data_classes/{canvas.py → legacy/canvas.py} +1 -1
  37. cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +65 -0
  38. cognite_toolkit/_cdf_tk/client/testing.py +24 -16
  39. cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
  40. cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +8 -2
  41. cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
  42. cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +35 -4
  43. cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +149 -14
  44. cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
  45. cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
  46. cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +19 -1
  47. cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +220 -3
  48. cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
  49. cognite_toolkit/_cdf_tk/commands/_purge.py +9 -11
  50. cognite_toolkit/_cdf_tk/commands/build_cmd.py +1 -1
  51. cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
  52. cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +241 -0
  53. cognite_toolkit/_cdf_tk/commands/build_v2/build_input.py +85 -0
  54. cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +27 -0
  55. cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
  56. cognite_toolkit/_cdf_tk/commands/run.py +1 -1
  57. cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +2 -2
  58. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +1 -1
  59. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +1 -1
  60. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
  61. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
  62. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
  63. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +22 -20
  64. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +1 -1
  65. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +14 -2
  66. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
  67. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +1 -1
  68. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
  69. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +1 -1
  70. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
  71. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +49 -14
  72. cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
  73. cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
  74. cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
  75. cognite_toolkit/_cdf_tk/storageio/_applications.py +2 -2
  76. cognite_toolkit/_cdf_tk/storageio/_file_content.py +1 -2
  77. cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
  78. cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +10 -1
  79. cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
  80. cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
  81. cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
  82. cognite_toolkit/_cdf_tk/utils/http_client/_client.py +3 -2
  83. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +6 -0
  84. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +67 -7
  85. cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
  86. cognite_toolkit/_cdf_tk/utils/interactive_select.py +51 -4
  87. cognite_toolkit/_cdf_tk/validation.py +4 -0
  88. cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
  89. cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
  90. cognite_toolkit/_resources/cdf.toml +1 -1
  91. cognite_toolkit/_version.py +1 -1
  92. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/METADATA +1 -1
  93. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/RECORD +119 -113
  94. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/WHEEL +1 -1
  95. cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
  96. cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
  97. /cognite_toolkit/_cdf_tk/{prototypes/commands → client/api/legacy}/__init__.py +0 -0
  98. /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
  99. /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
  100. /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
  101. /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
  102. /cognite_toolkit/_cdf_tk/client/data_classes/{apm_config_v1.py → legacy/apm_config_v1.py} +0 -0
  103. /cognite_toolkit/_cdf_tk/client/data_classes/{charts.py → legacy/charts.py} +0 -0
  104. /cognite_toolkit/_cdf_tk/client/data_classes/{extendable_cognite_file.py → legacy/extendable_cognite_file.py} +0 -0
  105. /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetadata.py → legacy/extended_filemetadata.py} +0 -0
  106. /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetdata.py → legacy/extended_filemetdata.py} +0 -0
  107. /cognite_toolkit/_cdf_tk/client/data_classes/{extended_timeseries.py → legacy/extended_timeseries.py} +0 -0
  108. /cognite_toolkit/_cdf_tk/client/data_classes/{functions.py → legacy/functions.py} +0 -0
  109. /cognite_toolkit/_cdf_tk/client/data_classes/{graphql_data_models.py → legacy/graphql_data_models.py} +0 -0
  110. /cognite_toolkit/_cdf_tk/client/data_classes/{instances.py → legacy/instances.py} +0 -0
  111. /cognite_toolkit/_cdf_tk/client/data_classes/{location_filters.py → legacy/location_filters.py} +0 -0
  112. /cognite_toolkit/_cdf_tk/client/data_classes/{migration.py → legacy/migration.py} +0 -0
  113. /cognite_toolkit/_cdf_tk/client/data_classes/{pending_instances_ids.py → legacy/pending_instances_ids.py} +0 -0
  114. /cognite_toolkit/_cdf_tk/client/data_classes/{project.py → legacy/project.py} +0 -0
  115. /cognite_toolkit/_cdf_tk/client/data_classes/{raw.py → legacy/raw.py} +0 -0
  116. /cognite_toolkit/_cdf_tk/client/data_classes/{robotics.py → legacy/robotics.py} +0 -0
  117. /cognite_toolkit/_cdf_tk/client/data_classes/{search_config.py → legacy/search_config.py} +0 -0
  118. /cognite_toolkit/_cdf_tk/client/data_classes/{sequences.py → legacy/sequences.py} +0 -0
  119. /cognite_toolkit/_cdf_tk/client/data_classes/{streamlit_.py → legacy/streamlit_.py} +0 -0
  120. /cognite_toolkit/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
  121. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/entry_points.txt +0 -0
@@ -52,10 +52,10 @@ from rich.console import Console
52
52
  from rich.panel import Panel
53
53
 
54
54
  from cognite_toolkit._cdf_tk.client import ToolkitClient
55
- from cognite_toolkit._cdf_tk.client.data_classes.location_filters import LocationFilterList
56
- from cognite_toolkit._cdf_tk.client.data_classes.search_config import SearchConfigList
57
- from cognite_toolkit._cdf_tk.client.data_classes.search_config import ViewId as SearchConfigViewId
58
- from cognite_toolkit._cdf_tk.client.data_classes.streamlit_ import Streamlit, StreamlitList
55
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.location_filters import LocationFilterList
56
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import SearchConfigList
57
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import ViewId as SearchConfigViewId
58
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.streamlit_ import Streamlit, StreamlitList
59
59
  from cognite_toolkit._cdf_tk.cruds import (
60
60
  AgentCRUD,
61
61
  ContainerCRUD,
@@ -30,7 +30,7 @@ from rich.progress import Progress
30
30
  from rich.table import Table
31
31
 
32
32
  from cognite_toolkit._cdf_tk.client import ToolkitClient, ToolkitClientConfig
33
- from cognite_toolkit._cdf_tk.client.data_classes.functions import FunctionScheduleID
33
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.functions import FunctionScheduleID
34
34
  from cognite_toolkit._cdf_tk.constants import _RUNNING_IN_BROWSER
35
35
  from cognite_toolkit._cdf_tk.cruds import FunctionCRUD, FunctionScheduleCRUD, WorkflowVersionCRUD
36
36
  from cognite_toolkit._cdf_tk.cruds._resource_cruds.workflow import WorkflowTriggerCRUD
@@ -6,8 +6,8 @@ from typing import TYPE_CHECKING, cast, final
6
6
  import pandas as pd
7
7
  from cognite.client.data_classes import FileMetadataWrite
8
8
 
9
- from cognite_toolkit._cdf_tk.client.data_classes.extendable_cognite_file import ExtendableCogniteFileApply
10
- from cognite_toolkit._cdf_tk.client.data_classes.raw import RawTable
9
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.extendable_cognite_file import ExtendableCogniteFileApply
10
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawTable
11
11
  from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
12
12
  from cognite_toolkit._cdf_tk.protocols import (
13
13
  T_ResourceRequest,
@@ -41,7 +41,7 @@ from rich.console import Console
41
41
  from rich.markup import escape
42
42
 
43
43
  from cognite_toolkit._cdf_tk.client import ToolkitClient
44
- from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawTable
44
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawTable
45
45
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
46
46
  from cognite_toolkit._cdf_tk.exceptions import ToolkitWrongResourceError
47
47
  from cognite_toolkit._cdf_tk.resource_classes import GroupYAML, SecurityCategoriesYAML
@@ -24,7 +24,7 @@ from cognite.client.utils.useful_types import SequenceNotStr
24
24
  from rich.console import Console
25
25
 
26
26
  from cognite_toolkit._cdf_tk.client import ToolkitClient
27
- from cognite_toolkit._cdf_tk.client.data_classes.sequences import (
27
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.sequences import (
28
28
  ToolkitSequenceRows,
29
29
  ToolkitSequenceRowsList,
30
30
  ToolkitSequenceRowsWrite,
@@ -7,7 +7,7 @@ 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,
@@ -73,7 +73,7 @@ from rich.panel import Panel
73
73
 
74
74
  from cognite_toolkit._cdf_tk import constants
75
75
  from cognite_toolkit._cdf_tk.client import ToolkitClient
76
- from cognite_toolkit._cdf_tk.client.data_classes.graphql_data_models import (
76
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.graphql_data_models import (
77
77
  GraphQLDataModel,
78
78
  GraphQLDataModelList,
79
79
  GraphQLDataModelWrite,
@@ -35,7 +35,7 @@ from cognite.client.data_classes.extractionpipelines import (
35
35
  from cognite.client.exceptions import CogniteAPIError, CogniteDuplicatedError, CogniteNotFoundError
36
36
  from cognite.client.utils.useful_types import SequenceNotStr
37
37
 
38
- from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawTable
38
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawTable
39
39
  from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
40
40
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
41
41
  from cognite_toolkit._cdf_tk.exceptions import (
@@ -8,17 +8,17 @@ 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.apm_config_v1 import (
12
- APMConfig,
13
- APMConfigList,
14
- APMConfigWrite,
15
- )
16
11
  from cognite_toolkit._cdf_tk.client.data_classes.infield import (
17
12
  InFieldCDMLocationConfig,
18
13
  InfieldLocationConfig,
19
14
  InfieldLocationConfigList,
20
15
  )
21
- from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceResult, NodeIdentifier
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 (
18
+ APMConfig,
19
+ APMConfigList,
20
+ APMConfigWrite,
21
+ )
22
22
  from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
23
23
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
24
24
  from cognite_toolkit._cdf_tk.resource_classes import (
@@ -246,7 +246,7 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig]):
246
246
 
247
247
 
248
248
  @final
249
- class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConfig, InfieldLocationConfig]):
249
+ class InFieldLocationConfigCRUD(ResourceCRUD[TypedNodeIdentifier, InfieldLocationConfig, InfieldLocationConfig]):
250
250
  folder_name = "cdf_applications"
251
251
  resource_cls = InfieldLocationConfig
252
252
  resource_write_cls = InfieldLocationConfig
@@ -260,13 +260,13 @@ class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConf
260
260
  return "infield location configs"
261
261
 
262
262
  @classmethod
263
- def get_id(cls, item: InfieldLocationConfig | dict) -> NodeIdentifier:
263
+ def get_id(cls, item: InfieldLocationConfig | dict) -> TypedNodeIdentifier:
264
264
  if isinstance(item, dict):
265
- return NodeIdentifier(space=item["space"], external_id=item["externalId"])
266
- return NodeIdentifier(space=item.space, external_id=item.external_id)
265
+ return TypedNodeIdentifier(space=item["space"], external_id=item["externalId"])
266
+ return TypedNodeIdentifier(space=item.space, external_id=item.external_id)
267
267
 
268
268
  @classmethod
269
- def dump_id(cls, id: NodeIdentifier) -> dict[str, Any]:
269
+ def dump_id(cls, id: TypedNodeIdentifier) -> dict[str, Any]:
270
270
  return id.dump(include_type=False)
271
271
 
272
272
  @classmethod
@@ -308,13 +308,13 @@ class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConf
308
308
  # as we only want to count the infield location configs here.
309
309
  return [res for res in created if res.as_id() in config_ids]
310
310
 
311
- def retrieve(self, ids: SequenceNotStr[NodeIdentifier]) -> InfieldLocationConfigList:
311
+ def retrieve(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> InfieldLocationConfigList:
312
312
  return InfieldLocationConfigList(self.client.infield.config.retrieve(list(ids)))
313
313
 
314
314
  def update(self, items: Sequence[InfieldLocationConfig]) -> Sized:
315
315
  return self.create(items)
316
316
 
317
- def delete(self, ids: SequenceNotStr[NodeIdentifier]) -> int:
317
+ def delete(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> int:
318
318
  # We must retrieve the full resource to get hte DataExplorationConfig linked resource deleted as well.
319
319
  retrieved = self.retrieve(list(ids))
320
320
  # Then, we pass the entire resource to the delete method, which will delete both the InfieldLocationConfig
@@ -345,7 +345,9 @@ class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConf
345
345
 
346
346
 
347
347
  @final
348
- class InFieldCDMLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InFieldCDMLocationConfig, InFieldCDMLocationConfig]):
348
+ class InFieldCDMLocationConfigCRUD(
349
+ ResourceCRUD[TypedNodeIdentifier, InFieldCDMLocationConfig, InFieldCDMLocationConfig]
350
+ ):
349
351
  folder_name = "cdf_applications"
350
352
  resource_cls = InFieldCDMLocationConfig
351
353
  resource_write_cls = InFieldCDMLocationConfig
@@ -359,13 +361,13 @@ class InFieldCDMLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InFieldCDMLocati
359
361
  return "infield CDM location configs"
360
362
 
361
363
  @classmethod
362
- def get_id(cls, item: InFieldCDMLocationConfig | dict) -> NodeIdentifier:
364
+ def get_id(cls, item: InFieldCDMLocationConfig | dict) -> TypedNodeIdentifier:
363
365
  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
+ return TypedNodeIdentifier(space=item["space"], external_id=item["externalId"])
367
+ return TypedNodeIdentifier(space=item.space, external_id=item.external_id)
366
368
 
367
369
  @classmethod
368
- def dump_id(cls, id: NodeIdentifier) -> dict[str, Any]:
370
+ def dump_id(cls, id: TypedNodeIdentifier) -> dict[str, Any]:
369
371
  return id.dump(include_type=False)
370
372
 
371
373
  @classmethod
@@ -397,13 +399,13 @@ class InFieldCDMLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InFieldCDMLocati
397
399
  def create(self, items: Sequence[InFieldCDMLocationConfig]) -> list[InstanceResult]:
398
400
  return self.client.infield.cdm_config.apply(items)
399
401
 
400
- def retrieve(self, ids: SequenceNotStr[NodeIdentifier]) -> list[InFieldCDMLocationConfig]:
402
+ def retrieve(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> list[InFieldCDMLocationConfig]:
401
403
  return self.client.infield.cdm_config.retrieve(list(ids))
402
404
 
403
405
  def update(self, items: Sequence[InFieldCDMLocationConfig]) -> Sized:
404
406
  return self.create(items)
405
407
 
406
- def delete(self, ids: SequenceNotStr[NodeIdentifier]) -> int:
408
+ def delete(self, ids: SequenceNotStr[TypedNodeIdentifier]) -> int:
407
409
  # We must retrieve the full resource to delete it.
408
410
  retrieved = self.retrieve(list(ids))
409
411
  _ = self.client.infield.cdm_config.delete(retrieved)
@@ -33,7 +33,7 @@ from cognite.client.utils._time import convert_data_modelling_timestamp
33
33
  from cognite.client.utils.useful_types import SequenceNotStr
34
34
  from rich import print
35
35
 
36
- 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 (
37
37
  ExtendableCogniteFile,
38
38
  ExtendableCogniteFileApply,
39
39
  ExtendableCogniteFileList,
@@ -22,6 +22,7 @@ from cognite.client.data_classes.capabilities import (
22
22
  FunctionsAcl,
23
23
  SessionsAcl,
24
24
  )
25
+ from cognite.client.data_classes.data_modeling import NodeId
25
26
  from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteFileApply
26
27
  from cognite.client.data_classes.functions import HANDLER_FILE_NAME
27
28
  from cognite.client.exceptions import CogniteAPIError
@@ -30,7 +31,7 @@ from rich import print
30
31
  from rich.console import Console
31
32
 
32
33
  from cognite_toolkit._cdf_tk.client import ToolkitClient
33
- from cognite_toolkit._cdf_tk.client.data_classes.functions import FunctionScheduleID
34
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.functions import FunctionScheduleID
34
35
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
35
36
  from cognite_toolkit._cdf_tk.exceptions import (
36
37
  ResourceCreationError,
@@ -406,7 +407,18 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function]):
406
407
 
407
408
  self.client.functions.delete_with_429_retry(external_id=ids, ignore_unknown_ids=True)
408
409
  file_ids = {func.file_id for func in functions if func.file_id}
409
- self.client.files.delete(id=list(file_ids), ignore_unknown_ids=True)
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))
410
422
  return len(ids)
411
423
 
412
424
  def _iterate(
@@ -14,7 +14,7 @@ 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,
@@ -7,7 +7,7 @@ from cognite.client.data_classes.capabilities import Capability, LocationFilters
7
7
  from cognite.client.data_classes.data_modeling import DataModelId, ViewId
8
8
  from cognite.client.utils.useful_types import SequenceNotStr
9
9
 
10
- from cognite_toolkit._cdf_tk.client.data_classes.location_filters import (
10
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.location_filters import (
11
11
  LocationFilter,
12
12
  LocationFilterList,
13
13
  LocationFilterWrite,
@@ -6,7 +6,7 @@ from cognite.client.data_classes.capabilities import Capability
6
6
  from cognite.client.data_classes.data_modeling import NodeList, ViewId
7
7
  from cognite.client.utils.useful_types import SequenceNotStr
8
8
 
9
- from cognite_toolkit._cdf_tk.client.data_classes.migration import (
9
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import (
10
10
  ResourceViewMapping,
11
11
  ResourceViewMappingApply,
12
12
  )
@@ -29,7 +29,7 @@ from rich import print
29
29
  from rich.console import Console
30
30
 
31
31
  from cognite_toolkit._cdf_tk.client import ToolkitClient
32
- from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawDatabaseList, RawTable, RawTableList
32
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawDatabaseList, RawTable, RawTableList
33
33
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceContainerCRUD, ResourceCRUD
34
34
  from cognite_toolkit._cdf_tk.resource_classes import DatabaseYAML, TableYAML
35
35
 
@@ -9,7 +9,7 @@ from cognite.client.data_classes.capabilities import Capability
9
9
  from cognite.client.exceptions import CogniteAPIError
10
10
  from cognite.client.utils.useful_types import SequenceNotStr
11
11
 
12
- from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
12
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
13
13
  DataPostProcessing,
14
14
  DataPostProcessingList,
15
15
  DataPostProcessingWrite,
@@ -26,6 +26,8 @@
26
26
  # limitations under the License.
27
27
 
28
28
 
29
+ import random
30
+ import time
29
31
  import warnings
30
32
  from collections import defaultdict
31
33
  from collections.abc import Callable, Hashable, Iterable, Sequence
@@ -63,7 +65,7 @@ from rich import print
63
65
  from rich.console import Console
64
66
 
65
67
  from cognite_toolkit._cdf_tk.client import ToolkitClient
66
- from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawTable
68
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawTable
67
69
  from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
68
70
  from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
69
71
  from cognite_toolkit._cdf_tk.exceptions import (
@@ -427,25 +429,58 @@ class TransformationCRUD(ResourceCRUD[str, TransformationWrite, Transformation])
427
429
  raise error from e
428
430
  raise e
429
431
  except CogniteAPIError as e:
430
- if "Failed to bind session using nonce for" in e.message and len(chunk) > 1:
431
- MediumSeverityWarning(
432
- f"Failed to create {len(chunk)} transformations in a batch due to nonce binding error. "
433
- "Trying to recover by creating them one by one."
434
- ).print_warning(console=self.console)
435
- # Retry one by one
436
- for item in chunk:
437
- recovered = self._execute_in_batches(items=[item], api_call=api_call)
438
- results.extend(recovered)
439
- if self.console:
440
- self.console.print(
441
- f" [bold green]RECOVERED:[/] Successfully created {len(chunk)} transformations one by one."
442
- )
432
+ if "Failed to bind session using nonce" in e.message and len(chunk) > 1:
433
+ results.extend(self._execute_one_by_one(chunk, api_call))
443
434
  else:
444
435
  raise
445
436
  else:
446
437
  results.extend(chunk_results)
447
438
  return results
448
439
 
440
+ def _execute_one_by_one(
441
+ self,
442
+ chunk: Sequence[TransformationWrite],
443
+ api_call: Callable[[Sequence[TransformationWrite]], TransformationList],
444
+ ) -> TransformationList:
445
+ MediumSeverityWarning(
446
+ f"Failed to create {len(chunk)} transformations in a batch due to nonce binding error. "
447
+ "Trying to recover by creating them one by one."
448
+ ).print_warning(console=self.client.console)
449
+ # Retry one by one
450
+ failed_ids: list[str] = []
451
+ success_count = 0
452
+ delay = 0.3
453
+ self._sleep_with_jitter(delay, delay + 0.3)
454
+ results = TransformationList([])
455
+ for item in chunk:
456
+ try:
457
+ recovered = api_call([item])
458
+ except CogniteAPIError as e:
459
+ if "Failed to bind session using nonce" in e.message:
460
+ failed_ids.append(item.external_id or "<missing>")
461
+ self._sleep_with_jitter(delay, delay + 0.3)
462
+ else:
463
+ raise
464
+ else:
465
+ results.extend(recovered)
466
+ success_count += 1
467
+ message = f" [bold]RECOVERY COMPLETE:[/] Successfully created {success_count:,} transformations"
468
+ if failed_ids:
469
+ message += f", failed to create {len(failed_ids):,} transformations: {humanize_collection(failed_ids)}"
470
+ else:
471
+ message += "."
472
+ if failed_ids:
473
+ HighSeverityWarning(message).print_warning(include_timestamp=True, console=self.client.console)
474
+ else:
475
+ self.client.console.print(message)
476
+ return results
477
+
478
+ @staticmethod
479
+ def _sleep_with_jitter(base_delay: float, max_delay: float) -> None:
480
+ """Sleeps for a random duration between base_delay and max_delay (inclusive)."""
481
+ sleep_time = random.uniform(base_delay, max_delay)
482
+ time.sleep(sleep_time)
483
+
449
484
  def _update_nonce(self, items: Sequence[TransformationWrite]) -> None:
450
485
  for item in items:
451
486
  if not item.external_id:
@@ -68,6 +68,7 @@ class ModuleToml:
68
68
  title: str | None = None
69
69
  id: str | None = None
70
70
  is_selected_by_default: bool = False
71
+ package_id: str | None = None
71
72
  if "module" in data:
72
73
  title = data["module"].get("title")
73
74
  id = data["module"].get("id")
@@ -2,7 +2,7 @@ from typing import ClassVar
2
2
 
3
3
  from pydantic import Field
4
4
 
5
- from cognite_toolkit._cdf_tk.client.data_classes.search_config import SearchConfigWrite
5
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import SearchConfigWrite
6
6
 
7
7
  from .base import BaseModelResource, ToolkitResource
8
8
 
@@ -1,4 +1,5 @@
1
- from typing import Literal
1
+ from abc import ABC
2
+ from typing import Annotated, Literal
2
3
 
3
4
  from cognite.client.data_classes import WorkflowVersionUpsert
4
5
  from pydantic import Field, JsonValue
@@ -6,18 +7,141 @@ from pydantic import Field, JsonValue
6
7
  from .base import BaseModelResource, ToolkitResource
7
8
 
8
9
 
10
+ class WorkflowVersionId(BaseModelResource):
11
+ workflow_external_id: str = Field(
12
+ max_length=255,
13
+ description="Identifier for a workflow. Must be unique for the project. No trailing or leading whitespace and no null characters allowed.",
14
+ )
15
+ version: str = Field(
16
+ max_length=255,
17
+ description="Identifier for a version. Must be unique for the workflow. No trailing or leading whitespace and no null characters allowed.",
18
+ )
19
+
20
+
21
+ class CogniteFunctionRef(BaseModelResource):
22
+ external_id: str = Field(
23
+ description="The external id of the Cognite Function in the project. This can be either a function external ID or a reference like ${myTaskExternalId.output.someKey}"
24
+ )
25
+ data: str | JsonValue | None = Field(
26
+ None, description="Input data that will be passed to the Cognite Function. Limited to 100KB in size."
27
+ )
28
+
29
+
30
+ class FunctionTaskParameters(BaseModelResource):
31
+ function: CogniteFunctionRef
32
+ is_async_complete: bool = Field(
33
+ False, description="Defines if the execution of the task should be completed asynchronously."
34
+ )
35
+
36
+
37
+ class TransformationRef(BaseModelResource):
38
+ external_id: str = Field(
39
+ description="The external id of the Transformation in the project. This can be either a transformation external ID or a reference like ${myTaskExternalId.output.someKey}"
40
+ )
41
+ concurrency_policy: Literal["fail", "waitForCurrent", "restartAfterCurrent"] = Field(
42
+ "fail",
43
+ description="""Determines the behavior of the task if the Transformation is already running.
44
+
45
+ fail: The task fails if another instance of the Transformation is currently running.
46
+ waitForCurrent: The task will pause and wait for the already running Transformation to complete. Once completed, the task is completed. This mode is useful for preventing redundant Transformation runs.
47
+ restartAfterCurrent: The task waits for the ongoing Transformation to finish. After completion, the task restarts the Transformation. This mode ensures that the most recent data can be used by following tasks.""",
48
+ )
49
+ use_transformation_credentials: bool = Field(
50
+ False,
51
+ description="If set to true, the transformation will run using the client credentials configured on the transformation. If set to false, the transformation will run using the client credentials used to trigger the workflow.",
52
+ )
53
+
54
+
55
+ class TransformationTaskParameters(BaseModelResource):
56
+ transformation: TransformationRef
57
+
58
+
59
+ class CDFRequest(BaseModelResource):
60
+ resource_path: str = Field(
61
+ description="The path of the request. The path should be prefixed by {cluster}.cognitedata.com/api/v1/project/{project} based on the relevant cluster and project. It can also contain references like ${myTaskExternalId.output.someKey}"
62
+ )
63
+ method: Literal["POST", "GET", "PUT"] | str = Field(
64
+ description="The HTTP method of the request. It can also be a reference like ${myTaskExternalId.output.someKey}"
65
+ )
66
+ query_parameters: dict[str, JsonValue] | str | None = Field(
67
+ None,
68
+ description="The query parameters of the request. It can also be a reference like ${myTaskExternalId.output.someKey}",
69
+ )
70
+ body: JsonValue | str | None = Field(
71
+ None, description="The body of the request. It can also be a reference like ${myTaskExternalId.output.someKey}"
72
+ )
73
+ request_timeout_in_millis: float | str | None = Field(
74
+ None,
75
+ description="The timeout for the request in milliseconds. It can also be a reference like ${myTaskExternalId.output.someKey}",
76
+ )
77
+ cdf_version_header: Literal["alpha", "beta"] | str | None = Field(
78
+ None, description="The Cognite Data Fusion version header to use for the request."
79
+ )
80
+
81
+
82
+ class CDFTaskParameters(BaseModelResource):
83
+ cdf_request: CDFRequest
84
+
85
+
86
+ class DynamicRef(BaseModelResource):
87
+ tasks: str = Field(
88
+ description="A Reference is an expression that allows dynamically injecting input to a task during execution. References can be used to reference the input of the Workflow, the output of a previous task in the Workflow, or the input of a previous task in the Workflow. Note that the injected value must be valid in the context of the property it is injected into. Example Task reference: ${myTaskExternalId.output.someKey} Example Workflow input reference: ${workflow.input.myKey}"
89
+ )
90
+
91
+
92
+ class DynamicTaskParameters(BaseModelResource):
93
+ dynamic: DynamicRef = Field(description="Reference to another task to use as the definition for this task.")
94
+
95
+
96
+ class SubworkflowRef(BaseModelResource):
97
+ tasks: "WorkflowVersionId | list[Task]" = Field(
98
+ description="Reference to the subworkflow to execute. This can be either a reference to an existing workflow version or an inline definition of tasks."
99
+ )
100
+
101
+
102
+ class SubworkflowTaskParameters(BaseModelResource):
103
+ subworkflow: SubworkflowRef = Field(description="Reference to the subworkflow to execute.")
104
+
105
+
106
+ class SimulatorInputUnit(BaseModelResource):
107
+ name: str = Field(description="Name of the unit.")
108
+
109
+
110
+ class SimulatorInput(BaseModelResource):
111
+ reference_id: str = Field(description="Reference id of the value to override.")
112
+ value: str | int | float | list[str] | list[int] | list[float] = Field(
113
+ description="Override the value used for a simulation run."
114
+ )
115
+ unit: SimulatorInputUnit | None = Field(None, description="Override the unit of the value")
116
+
117
+
118
+ class SimulationRef(BaseModelResource):
119
+ routine_external_id: str = Field(description="The external id of the routine to be executed.")
120
+ run_time: int | None = Field(
121
+ None,
122
+ description="Run time in milliseconds. Reference timestamp used for data pre-processing and data sampling.",
123
+ )
124
+ inputs: list[SimulatorInput] | None = Field(
125
+ None, description="List of inputs to be provided to the simulation.", max_length=200
126
+ )
127
+
128
+
129
+ class SimulationTaskParameters(BaseModelResource):
130
+ simulation: SimulationRef = Field(description="Reference to the simulation to execute.")
131
+
132
+
9
133
  class TaskId(BaseModelResource):
10
134
  external_id: str = Field(
11
135
  max_length=255, description="The external ID provided by the client. Must be unique for the resource type."
12
136
  )
13
137
 
14
138
 
15
- class TaskDefinition(BaseModelResource):
139
+ class TaskDefinition(BaseModelResource, ABC):
16
140
  external_id: str = Field(
17
141
  max_length=255,
18
142
  description="Identifier for the task. Must be unique within the version. No trailing or leading whitespace and no null characters allowed.",
19
143
  )
20
- type: Literal["function", "transformation", "cdf", "dynamic", "subworkflow", "simulation"]
144
+ type: str
21
145
  name: str | None = Field(
22
146
  default=None,
23
147
  max_length=255,
@@ -28,7 +152,6 @@ class TaskDefinition(BaseModelResource):
28
152
  max_length=500,
29
153
  description="Description of the intention of the task",
30
154
  )
31
- parameters: JsonValue = Field()
32
155
  retries: int = Field(
33
156
  3,
34
157
  ge=0,
@@ -52,13 +175,49 @@ class TaskDefinition(BaseModelResource):
52
175
  )
53
176
 
54
177
 
178
+ class FunctionTask(TaskDefinition):
179
+ type: Literal["function"] = "function"
180
+ parameters: FunctionTaskParameters
181
+
182
+
183
+ class TransformationTask(TaskDefinition):
184
+ type: Literal["transformation"] = "transformation"
185
+ parameters: TransformationTaskParameters
186
+
187
+
188
+ class CDFTask(TaskDefinition):
189
+ type: Literal["cdfRequest"] = "cdfRequest"
190
+ parameters: CDFTaskParameters
191
+
192
+
193
+ class DynamicTask(TaskDefinition):
194
+ type: Literal["dynamic"] = "dynamic"
195
+ parameters: DynamicTaskParameters
196
+
197
+
198
+ class SubworkflowTask(TaskDefinition):
199
+ type: Literal["subworkflow"] = "subworkflow"
200
+ parameters: SubworkflowTaskParameters
201
+
202
+
203
+ class SimulationTask(TaskDefinition):
204
+ type: Literal["simulation"] = "simulation"
205
+ parameters: SimulationTaskParameters
206
+
207
+
208
+ Task = Annotated[
209
+ FunctionTask | TransformationTask | CDFTask | DynamicTask | SubworkflowTask | SimulationTask,
210
+ Field(discriminator="type"),
211
+ ]
212
+
213
+
55
214
  class WorkflowDefinition(BaseModelResource):
56
215
  description: str | None = Field(
57
216
  default=None,
58
217
  max_length=500,
59
218
  description="The description of the workflow version.",
60
219
  )
61
- tasks: list[TaskDefinition]
220
+ tasks: list[Task]
62
221
 
63
222
 
64
223
  class WorkflowVersionYAML(ToolkitResource):
@@ -2,11 +2,11 @@ from collections.abc import Iterable, Sequence
2
2
  from typing import Any
3
3
 
4
4
  from cognite_toolkit._cdf_tk.client import ToolkitClient
5
- from cognite_toolkit._cdf_tk.client.data_classes.canvas import (
5
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.canvas import (
6
6
  IndustrialCanvas,
7
7
  IndustrialCanvasApply,
8
8
  )
9
- from cognite_toolkit._cdf_tk.client.data_classes.charts import Chart, ChartList, ChartWrite
9
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.charts import Chart, ChartList, ChartWrite
10
10
  from cognite_toolkit._cdf_tk.exceptions import ToolkitNotImplementedError
11
11
  from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning, MediumSeverityWarning
12
12
  from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
@@ -145,8 +145,7 @@ class FileContentIO(UploadableStorageIO[FileContentSelector, MetadataWithFilePat
145
145
  identifiers_map: dict[FileIdentifier, FileMetadata] = {}
146
146
  for item in metadata:
147
147
  if item.id is not None:
148
- # MyPy does cooperate well with Pydantic.
149
- identifiers_map[FileInternalID(internal_id=item.id)] = item # type: ignore[call-arg]
148
+ identifiers_map[FileInternalID(internal_id=item.id)] = item
150
149
  if item.external_id is not None:
151
150
  identifiers_map[FileExternalID(external_id=item.external_id)] = item
152
151
  if item.instance_id is not None:
@@ -17,7 +17,7 @@ from cognite.client.utils._identifier import InstanceId
17
17
 
18
18
  from cognite_toolkit._cdf_tk import constants
19
19
  from cognite_toolkit._cdf_tk.client import ToolkitClient
20
- from cognite_toolkit._cdf_tk.client.data_classes.instances import InstanceList
20
+ from cognite_toolkit._cdf_tk.client.data_classes.legacy.instances import InstanceList
21
21
  from cognite_toolkit._cdf_tk.cruds import ContainerCRUD, SpaceCRUD, ViewCRUD
22
22
  from cognite_toolkit._cdf_tk.utils import sanitize_filename
23
23
  from cognite_toolkit._cdf_tk.utils.cdf import iterate_instances