cognite-toolkit 0.7.62__py3-none-any.whl → 0.7.64__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.
@@ -20,6 +20,7 @@ from cognite.client.data_classes.documents import SourceFileProperty
20
20
  from cognite.client.data_classes.events import EventProperty
21
21
 
22
22
  from cognite_toolkit._cdf_tk.client import ToolkitClient
23
+ from cognite_toolkit._cdf_tk.client.resource_classes.data_modeling import NodeReference
23
24
  from cognite_toolkit._cdf_tk.client.resource_classes.legacy.apm_config_v1 import APMConfig, APMConfigList
24
25
  from cognite_toolkit._cdf_tk.cruds import NodeCRUD, ResourceCRUD, SpaceCRUD
25
26
  from cognite_toolkit._cdf_tk.exceptions import ToolkitMissingResourceError, ToolkitRequiredValueError
@@ -146,6 +147,7 @@ class SourceSystemCreator(MigrationCreator[NodeApplyList]):
146
147
  self.hierarchy = hierarchy
147
148
 
148
149
  def create_resources(self) -> NodeApplyList:
150
+ existing_resources = self._get_existing_source_systems()
149
151
  seen: set[str] = set()
150
152
  nodes = NodeApplyList([])
151
153
  for source in self._lookup_sources():
@@ -153,6 +155,9 @@ class SourceSystemCreator(MigrationCreator[NodeApplyList]):
153
155
  if not isinstance(source_str, str) or source_str in seen:
154
156
  continue
155
157
  seen.add(source_str)
158
+ if existing_id := existing_resources.get(source_str):
159
+ self.client.console.print(f"Skipping {source_str} as it already exists in {existing_id!r}.")
160
+ continue
156
161
  nodes.append(
157
162
  NodeApply(
158
163
  space=self._instance_space,
@@ -165,6 +170,10 @@ class SourceSystemCreator(MigrationCreator[NodeApplyList]):
165
170
  )
166
171
  return nodes
167
172
 
173
+ def _get_existing_source_systems(self) -> dict[str, NodeReference]:
174
+ all_existing = self.client.migration.created_source_system.list(limit=-1)
175
+ return {node.source: NodeReference(space=node.space, external_id=node.external_id) for node in all_existing}
176
+
168
177
  def resource_configs(self, resources: NodeApplyList) -> list[ResourceConfig]:
169
178
  output: list[ResourceConfig] = []
170
179
  for node in resources:
@@ -21,6 +21,7 @@ from collections import defaultdict
21
21
  from dataclasses import dataclass
22
22
  from pathlib import Path
23
23
  from time import sleep
24
+ from typing import Literal
24
25
 
25
26
  import questionary
26
27
  from cognite.client.data_classes.capabilities import (
@@ -160,7 +161,10 @@ class AuthCommand(ToolkitCommand):
160
161
  if not user_groups:
161
162
  raise AuthorizationError("The current user is not member of any groups in the CDF project.")
162
163
 
163
- loader_capabilities, loaders_by_capability_tuple = self._get_capabilities_by_loader(client)
164
+ data_modeling_status = client.project.status().this_project.data_modeling_status
165
+ loader_capabilities, loaders_by_capability_tuple = self._get_capabilities_by_loader(
166
+ client, data_modeling_status
167
+ )
164
168
  toolkit_group = self._create_toolkit_group(loader_capabilities, demo_principal)
165
169
 
166
170
  if not is_demo:
@@ -200,7 +204,7 @@ class AuthCommand(ToolkitCommand):
200
204
  and questionary.confirm("Do you want to update the group with the missing capabilities?").unsafe_ask()
201
205
  ) or is_demo:
202
206
  has_added_capabilities = self._update_missing_capabilities(
203
- client, cdf_toolkit_group, missing_capabilities, dry_run
207
+ client, cdf_toolkit_group, missing_capabilities, dry_run, data_modeling_status
204
208
  )
205
209
  elif is_toolkit_group_existing: # and not is_user_in_toolkit_group
206
210
  self.warn(MediumSeverityWarning(f"The current client is not member of the {toolkit_group.name!r} group."))
@@ -215,7 +219,9 @@ class AuthCommand(ToolkitCommand):
215
219
  and missing_capabilities
216
220
  and questionary.confirm("Do you want to update the group with the missing capabilities?").unsafe_ask()
217
221
  ):
218
- self._update_missing_capabilities(client, cdf_toolkit_group, missing_capabilities, dry_run)
222
+ self._update_missing_capabilities(
223
+ client, cdf_toolkit_group, missing_capabilities, dry_run, data_modeling_status
224
+ )
219
225
  elif is_demo:
220
226
  # We create the group for the demo user
221
227
  cdf_toolkit_group = self._create_toolkit_group_in_cdf(client, toolkit_group)
@@ -360,6 +366,7 @@ class AuthCommand(ToolkitCommand):
360
366
  existing_group: Group,
361
367
  missing_capabilities: list[Capability],
362
368
  dry_run: bool,
369
+ data_modeling_status: Literal["HYBRID", "DATA_MODELING_ONLY"],
363
370
  ) -> bool:
364
371
  """Updates the missing capabilities. This assumes interactive mode."""
365
372
  updated_toolkit_group = GroupWrite.load(existing_group.dump())
@@ -368,6 +375,24 @@ class AuthCommand(ToolkitCommand):
368
375
  else:
369
376
  updated_toolkit_group.capabilities.extend(missing_capabilities)
370
377
 
378
+ if data_modeling_status == "DATA_MODELING_ONLY":
379
+ # Remove any AssetsAcl and RelationshipsAcl capabilities as these
380
+ # are not allowed in DATA_MODELING_ONLY projects.
381
+ filtered_capabilities: list[Capability] = []
382
+ removed: list[str] = []
383
+ for cap in updated_toolkit_group.capabilities:
384
+ if isinstance(cap, AssetsAcl | RelationshipsAcl):
385
+ removed.append(str(cap))
386
+ else:
387
+ filtered_capabilities.append(cap)
388
+ if removed:
389
+ self.console(
390
+ f"Removing {humanize_collection(removed)} as the project is in DATA_MODELING_ONLY mode."
391
+ f"These capabilities are not allowed in DATA_MODELING_ONLY projects.",
392
+ prefix=" [bold yellow]INFO[/] - ",
393
+ )
394
+ updated_toolkit_group.capabilities = filtered_capabilities
395
+
371
396
  with warnings.catch_warnings():
372
397
  # If the user has unknown capabilities, we don't want the user to see the warning:
373
398
  # "UserWarning: Unknown capability '<unknown warning>' will be ignored in comparison"
@@ -424,11 +449,10 @@ class AuthCommand(ToolkitCommand):
424
449
 
425
450
  @staticmethod
426
451
  def _get_capabilities_by_loader(
427
- client: ToolkitClient,
452
+ client: ToolkitClient, data_modeling_status: Literal["HYBRID", "DATA_MODELING_ONLY"]
428
453
  ) -> tuple[list[Capability], dict[tuple, list[str]]]:
429
454
  loaders_by_capability_tuple: dict[tuple, list[str]] = defaultdict(list)
430
455
  capability_by_id: dict[frozenset[tuple], Capability] = {}
431
- project_type = client.project.status().this_project.data_modeling_status
432
456
  for crud_cls in cruds.RESOURCE_CRUD_LIST:
433
457
  crud = crud_cls.create_loader(client)
434
458
  if crud.prerequisite_warning() is not None:
@@ -451,7 +475,7 @@ class AuthCommand(ToolkitCommand):
451
475
  capability = crud_cls.get_required_capability(None, read_only=False)
452
476
  capabilities = capability if isinstance(capability, list) else [capability]
453
477
  for cap in capabilities:
454
- if project_type == "DATA_MODELING_ONLY" and isinstance(cap, AssetsAcl | RelationshipsAcl):
478
+ if data_modeling_status == "DATA_MODELING_ONLY" and isinstance(cap, AssetsAcl | RelationshipsAcl):
455
479
  continue
456
480
  id_ = frozenset(cap.as_tuples())
457
481
  if id_ not in capability_by_id:
@@ -12,7 +12,7 @@ jobs:
12
12
  environment: dev
13
13
  name: Deploy
14
14
  container:
15
- image: cognite/toolkit:0.7.62
15
+ image: cognite/toolkit:0.7.64
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.62
13
+ image: cognite/toolkit:0.7.64
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.62"
7
+ version = "0.7.64"
8
8
 
9
9
 
10
10
  [plugins]
@@ -1 +1 @@
1
- __version__ = "0.7.62"
1
+ __version__ = "0.7.64"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite_toolkit
3
- Version: 0.7.62
3
+ Version: 0.7.64
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>
@@ -225,7 +225,7 @@ cognite_toolkit/_cdf_tk/commands/_import_cmd.py,sha256=_qUF8xdJFoXDbtDYGCVC6kz9k
225
225
  cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py,sha256=8ki04tJGH1dHdF2NtVF4HyhaC0XDDS7onrH_nvd9KtE,153
226
226
  cognite_toolkit/_cdf_tk/commands/_migrate/command.py,sha256=meyp2cFcq5Wtq4FvELSqdwHRA45o9FMWFL_5AnXALvc,13587
227
227
  cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py,sha256=-LTIQUalqlRZxK0rfKWqljHLVh8VIH7yq_P-timfQDw,18318
228
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py,sha256=Gp3CKruTxeSDS3HiWiLsQ4mN2SZ4BQB5xQ50o68GTs8,9616
228
+ cognite_toolkit/_cdf_tk/commands/_migrate/creators.py,sha256=-1dIhKKSbyfH9Wcc1BVP_WTOMhW4CvRFQ5gBBGquXIE,10241
229
229
  cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py,sha256=_b2hXpTUI2_t-WKHzYXw1iSGb3w4pcIb53CTi9rbJ7k,13667
230
230
  cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py,sha256=qHYeFCBBGPejbgC_g_uHNM8fJLBkxWBBNKLFILkPaTI,28097
231
231
  cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py,sha256=0lRyDRJ8zo00OngwWagQgHQIaemK4eufW9kbWwZ9Yo0,7901
@@ -241,7 +241,7 @@ cognite_toolkit/_cdf_tk/commands/_upload.py,sha256=h4Ct02_7zyGr_SfQ2hOQAkDEcbjak
241
241
  cognite_toolkit/_cdf_tk/commands/_utils.py,sha256=UxMJW5QYKts4om5n6x2Tq2ihvfO9gWjhQKeqZNFTlKg,402
242
242
  cognite_toolkit/_cdf_tk/commands/_virtual_env.py,sha256=GFAid4hplixmj9_HkcXqU5yCLj-fTXm4cloGD6U2swY,2180
243
243
  cognite_toolkit/_cdf_tk/commands/about.py,sha256=pEXNdCeJYONOalH8x-7QRsKLgj-9gdIqN16pPxA3bhg,9395
244
- cognite_toolkit/_cdf_tk/commands/auth.py,sha256=dDw6zi7vQKHKD6soumvngTg16H2FKvg7G79PQMrnrrU,32542
244
+ cognite_toolkit/_cdf_tk/commands/auth.py,sha256=l_WW_tDgkpN_e0Aoc_3EYql_omYZTg5PBtMFCSbJ_b8,33780
245
245
  cognite_toolkit/_cdf_tk/commands/build_cmd.py,sha256=e9BwCdfc_QyEJLC5jxmmD_Tbvy7oL-fC6HBoaMyQbjU,29145
246
246
  cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
247
247
  cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py,sha256=B_Ddt8oB3tWto0Ocja9kvWaoIZyt8Oa-ukuoptQBYww,5916
@@ -432,13 +432,13 @@ cognite_toolkit/_repo_files/.gitignore,sha256=ip9kf9tcC5OguF4YF4JFEApnKYw0nG0vPi
432
432
  cognite_toolkit/_repo_files/AzureDevOps/.devops/README.md,sha256=OLA0D7yCX2tACpzvkA0IfkgQ4_swSd-OlJ1tYcTBpsA,240
433
433
  cognite_toolkit/_repo_files/AzureDevOps/.devops/deploy-pipeline.yml,sha256=brULcs8joAeBC_w_aoWjDDUHs3JheLMIR9ajPUK96nc,693
434
434
  cognite_toolkit/_repo_files/AzureDevOps/.devops/dry-run-pipeline.yml,sha256=OBFDhFWK1mlT4Dc6mDUE2Es834l8sAlYG50-5RxRtHk,723
435
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=jJYHZX7YNodw2J3zPCKpUt7zOcRq4Z9DDWSUFu2mpMc,667
436
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=a2RU5KGKbZS_SSvkInZtkbswTrWMQkqSr42Wlhx4Di0,2430
437
- cognite_toolkit/_resources/cdf.toml,sha256=r-m4fwgvn8-Q6ZHEEr7NWW9HOhavJZUCNxlS7_HcTjA,475
438
- cognite_toolkit/_version.py,sha256=-lU0l5-pIa7inPRB-7jzbkH90Ef12r9upMApt29G7Nk,23
435
+ cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=7FN5fi7yF2adj-ke8bq9ctcgQzGtCyOaIuKkoK3qYTs,667
436
+ cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=fvN1_GVygzZ1hiDlE6riH89hGodmICuVtsGQNBXR10I,2430
437
+ cognite_toolkit/_resources/cdf.toml,sha256=Wx_KlVj5a5EoQXUMrQEy7jYT8hlejSLRi52EtHQKHrk,475
438
+ cognite_toolkit/_version.py,sha256=YcVDXDbCWggmIHUePf77MZIOJHqpdf1nK5FnmEuIUrY,23
439
439
  cognite_toolkit/demo/__init__.py,sha256=-m1JoUiwRhNCL18eJ6t7fZOL7RPfowhCuqhYFtLgrss,72
440
440
  cognite_toolkit/demo/_base.py,sha256=6xKBUQpXZXGQ3fJ5f7nj7oT0s2n7OTAGIa17ZlKHZ5U,8052
441
- cognite_toolkit-0.7.62.dist-info/WHEEL,sha256=e_m4S054HL0hyR3CpOk-b7Q7fDX6BuFkgL5OjAExXas,80
442
- cognite_toolkit-0.7.62.dist-info/entry_points.txt,sha256=EtZ17K2mUjh-AY0QNU1CPIB_aDSSOdmtNI_4Fj967mA,84
443
- cognite_toolkit-0.7.62.dist-info/METADATA,sha256=WAFBnCs67Rq4CJev_KTtMluhrABDvTE_5yrnOVbuJKg,5026
444
- cognite_toolkit-0.7.62.dist-info/RECORD,,
441
+ cognite_toolkit-0.7.64.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
442
+ cognite_toolkit-0.7.64.dist-info/entry_points.txt,sha256=EtZ17K2mUjh-AY0QNU1CPIB_aDSSOdmtNI_4Fj967mA,84
443
+ cognite_toolkit-0.7.64.dist-info/METADATA,sha256=MJAqtZLpAeeqDqCyUiJIvxCJJmlcE51qJjNmN-YsaYw,5026
444
+ cognite_toolkit-0.7.64.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.9.27
2
+ Generator: uv 0.9.28
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any