cognite-toolkit 0.6.84__py3-none-any.whl → 0.6.85__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.

Potentially problematic release.


This version of cognite-toolkit might be problematic. Click here for more details.

@@ -17,7 +17,7 @@ from cognite_toolkit._cdf_tk.storageio.selectors import (
17
17
  )
18
18
  from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
19
19
  from cognite_toolkit._cdf_tk.utils.cli_args import parse_view_str
20
- from cognite_toolkit._cdf_tk.utils.interactive_select import DataModelingSelect
20
+ from cognite_toolkit._cdf_tk.utils.interactive_select import AssetInteractiveSelect, DataModelingSelect
21
21
 
22
22
 
23
23
  class InstanceTypeEnum(str, Enum):
@@ -39,8 +39,8 @@ class PurgeApp(typer.Typer):
39
39
  if ctx.invoked_subcommand is None:
40
40
  print("Use [bold yellow]cdf purge --help[/] for more information.")
41
41
 
42
+ @staticmethod
42
43
  def purge_dataset(
43
- self,
44
44
  ctx: typer.Context,
45
45
  external_id: Annotated[
46
46
  str | None,
@@ -53,7 +53,46 @@ class PurgeApp(typer.Typer):
53
53
  typer.Option(
54
54
  "--include-dataset",
55
55
  "-i",
56
- help="Include dataset in the purge. This will also archive the dataset.",
56
+ help="Whether to archive the dataset itself after purging its contents.",
57
+ hidden=Flags.v07.is_enabled(),
58
+ ),
59
+ ] = False,
60
+ archive_dataset: Annotated[
61
+ bool,
62
+ typer.Option(
63
+ "--archive-dataset",
64
+ help="Whether to archive the dataset itself after purging its contents.",
65
+ hidden=not Flags.v07.is_enabled(),
66
+ ),
67
+ ] = False,
68
+ skip_data: Annotated[
69
+ bool,
70
+ typer.Option(
71
+ "--skip-data",
72
+ "-s",
73
+ help="Skip deleting the data in the dataset, only delete configurations. The resources that are "
74
+ "considered data are: time series, event, files, assets, sequences, relationships, "
75
+ "labels, and 3D Models",
76
+ hidden=not Flags.v07.is_enabled(),
77
+ ),
78
+ ] = False,
79
+ include_configurations: Annotated[
80
+ bool,
81
+ typer.Option(
82
+ "--include-configurations",
83
+ "-c",
84
+ help="Include configurations, workflows, extraction pipelines and transformations in the purge.",
85
+ hidden=not Flags.v07.is_enabled(),
86
+ ),
87
+ ] = False,
88
+ asset_recursive: Annotated[
89
+ bool,
90
+ typer.Option(
91
+ "--asset-recursive",
92
+ "-a",
93
+ help="When deleting assets, delete all child assets recursively. CAVEAT: This can lead to assets"
94
+ " not in the selected dataset being deleted if they are children of assets in the dataset.",
95
+ hidden=not Flags.v07.is_enabled(),
57
96
  ),
58
97
  ] = False,
59
98
  dry_run: Annotated[
@@ -84,11 +123,52 @@ class PurgeApp(typer.Typer):
84
123
  """This command will delete the contents of the specified dataset"""
85
124
  cmd = PurgeCommand()
86
125
  client = EnvironmentVariables.create_from_environment().get_client()
126
+
127
+ if external_id is None:
128
+ # Is Interactive
129
+ interactive = AssetInteractiveSelect(client, operation="purge")
130
+ external_id = interactive.select_data_set(allow_empty=False)
131
+ if Flags.v07.is_enabled():
132
+ skip_data = not questionary.confirm(
133
+ "Delete data in the dataset (time series, events, files, assets, sequences, relationships, labels, 3D models)?",
134
+ default=True,
135
+ ).ask()
136
+ include_configurations = questionary.confirm(
137
+ "Delete configurations (workflows, extraction pipelines and transformations) in the dataset?",
138
+ default=False,
139
+ ).ask()
140
+ asset_recursive = questionary.confirm(
141
+ "When deleting assets, delete all child assets recursively? (WARNING: This can lead "
142
+ "to assets not in the selected dataset being deleted if they are children of assets in the dataset.)",
143
+ default=False,
144
+ ).ask()
145
+ archive_dataset = questionary.confirm("Archive the dataset itself after purging?", default=False).ask()
146
+ dry_run = questionary.confirm("Dry run?", default=True).ask()
147
+ verbose = questionary.confirm("Verbose?", default=True).ask()
148
+
149
+ user_options = [archive_dataset, dry_run, verbose]
150
+ if Flags.v07.is_enabled():
151
+ user_options.extend([skip_data, include_configurations, asset_recursive])
152
+
153
+ if any(selected is None for selected in user_options):
154
+ raise typer.Abort("Aborted by user.")
155
+
156
+ else:
157
+ archive_dataset = archive_dataset if Flags.v07.is_enabled() else include_dataset
158
+
159
+ if not Flags.v07.is_enabled():
160
+ skip_data = False
161
+ include_configurations = True
162
+ asset_recursive = False
163
+
87
164
  cmd.run(
88
165
  lambda: cmd.dataset(
89
166
  client,
90
167
  external_id,
91
- include_dataset,
168
+ archive_dataset,
169
+ not skip_data,
170
+ include_configurations,
171
+ asset_recursive,
92
172
  dry_run,
93
173
  auto_yes,
94
174
  verbose,