cognite-toolkit 0.7.36__py3-none-any.whl → 0.7.38__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.
@@ -133,6 +133,9 @@ class IndustrialCanvasAPI:
133
133
 
134
134
  @classmethod
135
135
  def _retrieve_query(cls, external_id: str) -> query.Query:
136
+ # The limit for canvas components must be high enough to cover all annotations/references in a canvas.
137
+ # Using 1000 as a safe upper bound (same as _APPLY_LIMIT).
138
+ query_limit = 1000
136
139
  return query.Query(
137
140
  with_={
138
141
  "canvas": query.NodeResultSetExpression(
@@ -142,18 +145,21 @@ class IndustrialCanvasAPI:
142
145
  "solutionTags": query.NodeResultSetExpression(
143
146
  from_="canvas",
144
147
  through=Canvas.get_source().as_property_ref("solutionTags"),
148
+ limit=query_limit,
145
149
  ),
146
150
  "annotationEdges": query.EdgeResultSetExpression(
147
151
  from_="canvas",
148
152
  filter=filters.Equals(["edge", "type"], ANNOTATION_EDGE_TYPE.dump()),
149
153
  node_filter=filters.HasData(views=[CanvasAnnotation.get_source()]),
150
154
  direction="outwards",
155
+ limit=query_limit,
151
156
  ),
152
157
  "containerReferenceEdges": query.EdgeResultSetExpression(
153
158
  from_="canvas",
154
159
  filter=filters.Equals(["edge", "type"], CONTAINER_REFERENCE_EDGE_TYPE.dump()),
155
160
  node_filter=filters.HasData(views=[ContainerReference.get_source()]),
156
161
  direction="outwards",
162
+ limit=query_limit,
157
163
  ),
158
164
  "fdmInstanceContainerReferenceEdges": query.EdgeResultSetExpression(
159
165
  from_="canvas",
@@ -163,11 +169,14 @@ class IndustrialCanvasAPI:
163
169
  ),
164
170
  node_filter=filters.HasData(views=[FdmInstanceContainerReference.get_source()]),
165
171
  direction="outwards",
172
+ limit=query_limit,
173
+ ),
174
+ "annotations": query.NodeResultSetExpression(from_="annotationEdges", limit=query_limit),
175
+ "containerReferences": query.NodeResultSetExpression(
176
+ from_="containerReferenceEdges", limit=query_limit
166
177
  ),
167
- "annotations": query.NodeResultSetExpression(from_="annotationEdges"),
168
- "containerReferences": query.NodeResultSetExpression(from_="containerReferenceEdges"),
169
178
  "fdmInstanceContainerReferences": query.NodeResultSetExpression(
170
- from_="fdmInstanceContainerReferenceEdges"
179
+ from_="fdmInstanceContainerReferenceEdges", limit=query_limit
171
180
  ),
172
181
  },
173
182
  select={
@@ -9,6 +9,7 @@ from cognite.client.data_classes.data_modeling import (
9
9
  MappedProperty,
10
10
  NodeApply,
11
11
  NodeId,
12
+ ViewId,
12
13
  )
13
14
  from cognite.client.data_classes.data_modeling.instances import EdgeApply, NodeOrEdgeData, PropertyValueWrite
14
15
  from cognite.client.data_classes.data_modeling.views import ViewProperty
@@ -29,7 +30,7 @@ from cognite_toolkit._cdf_tk.utils.useful_types import (
29
30
  AssetCentricTypeExtended,
30
31
  )
31
32
 
32
- from .data_model import INSTANCE_SOURCE_VIEW_ID
33
+ from .data_model import COGNITE_MIGRATION_SPACE_ID, INSTANCE_SOURCE_VIEW_ID
33
34
  from .issues import ConversionIssue, FailedConversion, InvalidPropertyDataType
34
35
 
35
36
 
@@ -169,6 +170,7 @@ def asset_centric_to_dm(
169
170
  view_source: ResourceViewMappingApply,
170
171
  view_properties: dict[str, ViewProperty],
171
172
  direct_relation_cache: DirectRelationCache,
173
+ preferred_consumer_view: ViewId | None = None,
172
174
  ) -> tuple[NodeApply | EdgeApply | None, ConversionIssue]:
173
175
  """Convert an asset-centric resource to a data model instance.
174
176
 
@@ -178,6 +180,7 @@ def asset_centric_to_dm(
178
180
  view_source (ResourceViewMappingApply): The view source defining how to map the resource to the data model.
179
181
  view_properties (dict[str, ViewProperty]): The defined properties referenced in the view source mapping.
180
182
  direct_relation_cache (DirectRelationCache): Cache for direct relation references.
183
+ preferred_consumer_view (ViewId | None): The preferred consumer view for the instance.
181
184
 
182
185
  Returns:
183
186
  tuple[NodeApply | EdgeApply, ConversionIssue]: A tuple containing the converted NodeApply and any ConversionIssue encountered.
@@ -213,7 +216,10 @@ def asset_centric_to_dm(
213
216
  "id": id_,
214
217
  "dataSetId": data_set_id,
215
218
  "classicExternalId": external_id,
219
+ "resourceViewMapping": {"space": COGNITE_MIGRATION_SPACE_ID, "externalId": view_source.external_id},
216
220
  }
221
+ if preferred_consumer_view:
222
+ instance_source_properties["preferredConsumerViewId"] = preferred_consumer_view.dump()
217
223
  sources.append(NodeOrEdgeData(source=INSTANCE_SOURCE_VIEW_ID, properties=instance_source_properties))
218
224
 
219
225
  instance: NodeApply | EdgeApply
@@ -147,6 +147,7 @@ class AssetCentricMapper(
147
147
  view_source=view_source,
148
148
  view_properties=view_properties,
149
149
  direct_relation_cache=self._direct_relation_cache,
150
+ preferred_consumer_view=mapping.preferred_consumer_view,
150
151
  )
151
152
  if mapping.instance_id.space == MISSING_INSTANCE_SPACE:
152
153
  conversion_issue.missing_instance_space = f"Missing instance space for dataset ID {mapping.data_set_id!r}"
@@ -4,6 +4,7 @@ from cognite.client.data_classes.data_modeling.containers import BTreeIndex
4
4
  SPACE = dm.SpaceApply(
5
5
  "cognite_migration", description="Space for the asset-centric to data modeling migration", name="cdf_migration"
6
6
  )
7
+ COGNITE_MIGRATION_SPACE_ID = SPACE.space
7
8
 
8
9
  RESOURCE_VIEW_MAPPING = dm.ContainerApply(
9
10
  space=SPACE.space,
@@ -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
@@ -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(
@@ -12,7 +12,7 @@ jobs:
12
12
  environment: dev
13
13
  name: Deploy
14
14
  container:
15
- image: cognite/toolkit:0.7.36
15
+ image: cognite/toolkit:0.7.38
16
16
  env:
17
17
  CDF_CLUSTER: ${{ vars.CDF_CLUSTER }}
18
18
  CDF_PROJECT: ${{ vars.CDF_PROJECT }}
@@ -10,7 +10,7 @@ jobs:
10
10
  environment: dev
11
11
  name: Deploy Dry Run
12
12
  container:
13
- image: cognite/toolkit:0.7.36
13
+ image: cognite/toolkit:0.7.38
14
14
  env:
15
15
  CDF_CLUSTER: ${{ vars.CDF_CLUSTER }}
16
16
  CDF_PROJECT: ${{ vars.CDF_PROJECT }}
@@ -4,7 +4,7 @@ default_env = "<DEFAULT_ENV_PLACEHOLDER>"
4
4
  [modules]
5
5
  # This is the version of the modules. It should not be changed manually.
6
6
  # It will be updated by the 'cdf modules upgrade' command.
7
- version = "0.7.36"
7
+ version = "0.7.38"
8
8
 
9
9
 
10
10
  [plugins]
@@ -1 +1 @@
1
- __version__ = "0.7.36"
1
+ __version__ = "0.7.38"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite_toolkit
3
- Version: 0.7.36
3
+ Version: 0.7.38
4
4
  Summary: Official Cognite Data Fusion tool for project templates and configuration deployment
5
5
  Author: Cognite AS
6
6
  Author-email: Cognite AS <support@cognite.com>
@@ -33,7 +33,7 @@ cognite_toolkit/_cdf_tk/client/_toolkit_client.py,sha256=S2D0N3Cea39Bhl2NIu8jbQy
33
33
  cognite_toolkit/_cdf_tk/client/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  cognite_toolkit/_cdf_tk/client/api/infield.py,sha256=B7sydnhE1cKhp9OJxkjmTAfRREWZTaD8EuSvscZoE8w,11039
35
35
  cognite_toolkit/_cdf_tk/client/api/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py,sha256=2TVKPlgtXviPxW9tOX_tv7I06K-SnYovg5c9sxBE3f4,8843
36
+ cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py,sha256=t5TNNtoCyOHwQbbYetT27Xh5eSwNIZVnBBCIh7y8KC4,9299
37
37
  cognite_toolkit/_cdf_tk/client/api/legacy/charts.py,sha256=YZ2jjHoKinRiqOBzosq6abvzStA4B6VezI1wSy3_U2k,4960
38
38
  cognite_toolkit/_cdf_tk/client/api/legacy/dml.py,sha256=8b1lo86JdvfEsz9mP2rx0Mp9fyWsU6mbXHqLBtvSidU,3546
39
39
  cognite_toolkit/_cdf_tk/client/api/legacy/extended_data_modeling.py,sha256=yrMDViyvEboVrUr6lm0EHm_9mVBxVCLGBLMLY0-QBGw,12974
@@ -104,11 +104,11 @@ cognite_toolkit/_cdf_tk/commands/_download.py,sha256=dVddH9t7oGx1kdQ3CCYYQb96Uxx
104
104
  cognite_toolkit/_cdf_tk/commands/_import_cmd.py,sha256=RkJ7RZI6zxe0_1xrPB-iJhCVchurmIAChilx0_XMR6k,11141
105
105
  cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py,sha256=8ki04tJGH1dHdF2NtVF4HyhaC0XDDS7onrH_nvd9KtE,153
106
106
  cognite_toolkit/_cdf_tk/commands/_migrate/command.py,sha256=l2P0Em05aEJvNZH4WkEIm-QfO3TAjG1rc_YxELuQIQM,14214
107
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py,sha256=VxoFLS0Xi9uviICShxHHXbUU_wliqNZL3PxD0qveOSU,16810
107
+ cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py,sha256=NTDt2bNL30r-iWtDmO95rxSkMeylcRveNh0kueKc1y8,17244
108
108
  cognite_toolkit/_cdf_tk/commands/_migrate/creators.py,sha256=hQ9o_N2aY9nqHOKlwP7tI7mAYLCPkPLSJGe_QTwglWc,9612
109
109
  cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py,sha256=__o2JZ3GkD0uqtjjpumHJF8KLdqCFrbMZOoEQHAeOLo,11488
110
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py,sha256=282o0zDiY5_zqMNTQApn5uaM73vgo_FuNnQo3sicq9Y,24366
111
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py,sha256=i1eUsNX6Dueol9STIEwyksBnBsWUk13O8qHIjW964pM,7860
110
+ cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py,sha256=dQdRx7qN_-hi2ALIZUw1hTdYpPtoe8H9_VLWlioIFUQ,24435
111
+ cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py,sha256=0lRyDRJ8zo00OngwWagQgHQIaemK4eufW9kbWwZ9Yo0,7901
112
112
  cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py,sha256=HRh-VlVWbOLjQfP968lReYtZFptjUEa4JbbZxiw5Qy8,5551
113
113
  cognite_toolkit/_cdf_tk/commands/_migrate/issues.py,sha256=uEMI5azCpHWAvEauRY9ZvsvNO0_aaUpdNP7_nM7oBC4,7547
114
114
  cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py,sha256=7gD7uKOy8kPa9u9rvRcOnZsuLGTD0WhU8szKGQ3GDoM,26782
@@ -151,7 +151,7 @@ cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py,sha256=4uTr3Mx89yaPsr
151
151
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py,sha256=nvMIDeAksJ_0iWvorK8k1BemSrTAUhll_JgCMNiUjZ4,17708
152
152
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py,sha256=4DL6koP_wwBqfgRveSAYbTVkcTJfjvrj0s2JXJ_p8yQ,20750
153
153
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py,sha256=YGsrp0_yLcpyUvVc_-EW7Rb6LTl_cKtWNmuJDbxbqhs,14862
154
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py,sha256=QHihJsyCc9EJImPQSIZDQsxDewCglBc6iSHXjLeutMs,28402
154
+ cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py,sha256=nSIZKLAC19PVh-Lf0BehfEO1d6kRZFCzEj72cA5Ksj0,28973
155
155
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/group_scoped.py,sha256=WEg8-CxMP64WfE_XXIlH114zM51K0uLaYa4atd992zI,1690
156
156
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py,sha256=P0hlXK0_FmO86U-gDHMHz8N0vpDtPoKupiQfhNP5KLE,14619
157
157
  cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py,sha256=5KMKhUCdtiOJpqSjC5YRkZ_ssodvPrzUoIi-pSIYri8,7863
@@ -309,14 +309,14 @@ cognite_toolkit/_repo_files/.gitignore,sha256=ip9kf9tcC5OguF4YF4JFEApnKYw0nG0vPi
309
309
  cognite_toolkit/_repo_files/AzureDevOps/.devops/README.md,sha256=OLA0D7yCX2tACpzvkA0IfkgQ4_swSd-OlJ1tYcTBpsA,240
310
310
  cognite_toolkit/_repo_files/AzureDevOps/.devops/deploy-pipeline.yml,sha256=brULcs8joAeBC_w_aoWjDDUHs3JheLMIR9ajPUK96nc,693
311
311
  cognite_toolkit/_repo_files/AzureDevOps/.devops/dry-run-pipeline.yml,sha256=OBFDhFWK1mlT4Dc6mDUE2Es834l8sAlYG50-5RxRtHk,723
312
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=ofqsT_RZbUsrih1RE9qrzOOQK72T9aM4HwIu5OOdM20,667
313
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=Lul-1240VOiishKOBBWDJua7KIEuJziNJXcpgz8mRgE,2430
314
- cognite_toolkit/_resources/cdf.toml,sha256=DIpC1r6ql-BAasLk7nvhpPLpQeykwAU-XYG57VF8-iQ,475
315
- cognite_toolkit/_version.py,sha256=s_fO2Pb37oajrH9N1MYPwjM5YVV5bZvqGHD_GGAAiec,23
312
+ cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=slEyMNTmrTPtEgXE0doIjIaQ9gbSN_YwMLWCRaEpbvc,667
313
+ cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=TA55MiwpfFuQE5SM1O2niT-SZBq2nE1mGgio4uVo2U4,2430
314
+ cognite_toolkit/_resources/cdf.toml,sha256=Tm7hhHJxd3bWEJmFz6O_v7Pq18mpOetVExdrUUnaufY,475
315
+ cognite_toolkit/_version.py,sha256=bmWrV8MUOLbHKnFCEpSH0OI-m3Rwe5OkY4oMckUViBE,23
316
316
  cognite_toolkit/config.dev.yaml,sha256=M33FiIKdS3XKif-9vXniQ444GTZ-bLXV8aFH86u9iUQ,332
317
317
  cognite_toolkit/demo/__init__.py,sha256=-m1JoUiwRhNCL18eJ6t7fZOL7RPfowhCuqhYFtLgrss,72
318
318
  cognite_toolkit/demo/_base.py,sha256=6xKBUQpXZXGQ3fJ5f7nj7oT0s2n7OTAGIa17ZlKHZ5U,8052
319
- cognite_toolkit-0.7.36.dist-info/WHEEL,sha256=xDCZ-UyfvkGuEHPeI7BcJzYKIZzdqN8A8o1M5Om8IyA,79
320
- cognite_toolkit-0.7.36.dist-info/entry_points.txt,sha256=EtZ17K2mUjh-AY0QNU1CPIB_aDSSOdmtNI_4Fj967mA,84
321
- cognite_toolkit-0.7.36.dist-info/METADATA,sha256=IVa9xEH1DSyQh4n7Ipr0HyVjKHPLoZUAgI0hole3qjo,4507
322
- cognite_toolkit-0.7.36.dist-info/RECORD,,
319
+ cognite_toolkit-0.7.38.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
320
+ cognite_toolkit-0.7.38.dist-info/entry_points.txt,sha256=EtZ17K2mUjh-AY0QNU1CPIB_aDSSOdmtNI_4Fj967mA,84
321
+ cognite_toolkit-0.7.38.dist-info/METADATA,sha256=obcR-ekvY-B8F-lQNmx78NLJfTsrRtPZnYGWjidg56A,4507
322
+ cognite_toolkit-0.7.38.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.9.17
2
+ Generator: uv 0.9.18
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any