cognite-toolkit 0.6.97__py3-none-any.whl → 0.7.30__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 (136) hide show
  1. cognite_toolkit/_cdf.py +16 -17
  2. cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
  3. cognite_toolkit/_cdf_tk/apps/_core_app.py +13 -5
  4. cognite_toolkit/_cdf_tk/apps/_data_app.py +1 -1
  5. cognite_toolkit/_cdf_tk/apps/_dev_app.py +86 -0
  6. cognite_toolkit/_cdf_tk/apps/_download_app.py +692 -24
  7. cognite_toolkit/_cdf_tk/apps/_dump_app.py +43 -101
  8. cognite_toolkit/_cdf_tk/apps/_landing_app.py +18 -4
  9. cognite_toolkit/_cdf_tk/apps/_migrate_app.py +249 -9
  10. cognite_toolkit/_cdf_tk/apps/_modules_app.py +0 -3
  11. cognite_toolkit/_cdf_tk/apps/_purge.py +15 -43
  12. cognite_toolkit/_cdf_tk/apps/_run.py +11 -0
  13. cognite_toolkit/_cdf_tk/apps/_upload_app.py +45 -6
  14. cognite_toolkit/_cdf_tk/builders/__init__.py +2 -2
  15. cognite_toolkit/_cdf_tk/builders/_base.py +28 -42
  16. cognite_toolkit/_cdf_tk/cdf_toml.py +20 -1
  17. cognite_toolkit/_cdf_tk/client/_toolkit_client.py +23 -3
  18. cognite_toolkit/_cdf_tk/client/api/extended_functions.py +6 -9
  19. cognite_toolkit/_cdf_tk/client/api/infield.py +93 -1
  20. cognite_toolkit/_cdf_tk/client/api/migration.py +175 -1
  21. cognite_toolkit/_cdf_tk/client/api/streams.py +84 -0
  22. cognite_toolkit/_cdf_tk/client/api/three_d.py +50 -0
  23. cognite_toolkit/_cdf_tk/client/data_classes/base.py +25 -1
  24. cognite_toolkit/_cdf_tk/client/data_classes/canvas.py +46 -3
  25. cognite_toolkit/_cdf_tk/client/data_classes/charts.py +3 -3
  26. cognite_toolkit/_cdf_tk/client/data_classes/charts_data.py +95 -213
  27. cognite_toolkit/_cdf_tk/client/data_classes/infield.py +32 -18
  28. cognite_toolkit/_cdf_tk/client/data_classes/migration.py +10 -2
  29. cognite_toolkit/_cdf_tk/client/data_classes/streams.py +90 -0
  30. cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +47 -0
  31. cognite_toolkit/_cdf_tk/client/testing.py +18 -2
  32. cognite_toolkit/_cdf_tk/commands/__init__.py +6 -6
  33. cognite_toolkit/_cdf_tk/commands/_changes.py +3 -42
  34. cognite_toolkit/_cdf_tk/commands/_download.py +21 -11
  35. cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py +0 -2
  36. cognite_toolkit/_cdf_tk/commands/_migrate/command.py +22 -20
  37. cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +133 -91
  38. cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +73 -22
  39. cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +311 -43
  40. cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +5 -5
  41. cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +33 -0
  42. cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +157 -8
  43. cognite_toolkit/_cdf_tk/commands/_migrate/selectors.py +9 -4
  44. cognite_toolkit/_cdf_tk/commands/_purge.py +27 -28
  45. cognite_toolkit/_cdf_tk/commands/_questionary_style.py +16 -0
  46. cognite_toolkit/_cdf_tk/commands/_upload.py +109 -86
  47. cognite_toolkit/_cdf_tk/commands/about.py +221 -0
  48. cognite_toolkit/_cdf_tk/commands/auth.py +19 -12
  49. cognite_toolkit/_cdf_tk/commands/build_cmd.py +15 -61
  50. cognite_toolkit/_cdf_tk/commands/clean.py +63 -16
  51. cognite_toolkit/_cdf_tk/commands/deploy.py +20 -17
  52. cognite_toolkit/_cdf_tk/commands/dump_resource.py +6 -4
  53. cognite_toolkit/_cdf_tk/commands/init.py +225 -3
  54. cognite_toolkit/_cdf_tk/commands/modules.py +20 -44
  55. cognite_toolkit/_cdf_tk/commands/pull.py +6 -19
  56. cognite_toolkit/_cdf_tk/commands/resources.py +179 -0
  57. cognite_toolkit/_cdf_tk/constants.py +20 -1
  58. cognite_toolkit/_cdf_tk/cruds/__init__.py +19 -5
  59. cognite_toolkit/_cdf_tk/cruds/_base_cruds.py +14 -70
  60. cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +8 -17
  61. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +4 -1
  62. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/agent.py +11 -9
  63. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +4 -14
  64. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +44 -43
  65. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +4 -11
  66. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -13
  67. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +205 -66
  68. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +5 -17
  69. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +116 -27
  70. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +6 -27
  71. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +9 -28
  72. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -30
  73. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +3 -7
  74. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +3 -15
  75. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +4 -12
  76. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +4 -10
  77. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -8
  78. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +15 -44
  79. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +94 -0
  80. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/three_d_model.py +3 -7
  81. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +5 -15
  82. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +39 -31
  83. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -40
  84. cognite_toolkit/_cdf_tk/cruds/_worker.py +24 -36
  85. cognite_toolkit/_cdf_tk/feature_flags.py +16 -36
  86. cognite_toolkit/_cdf_tk/plugins.py +2 -1
  87. cognite_toolkit/_cdf_tk/resource_classes/__init__.py +4 -0
  88. cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +12 -0
  89. cognite_toolkit/_cdf_tk/resource_classes/functions.py +3 -1
  90. cognite_toolkit/_cdf_tk/resource_classes/infield_cdm_location_config.py +109 -0
  91. cognite_toolkit/_cdf_tk/resource_classes/migration.py +8 -17
  92. cognite_toolkit/_cdf_tk/resource_classes/streams.py +29 -0
  93. cognite_toolkit/_cdf_tk/storageio/__init__.py +9 -21
  94. cognite_toolkit/_cdf_tk/storageio/_annotations.py +19 -16
  95. cognite_toolkit/_cdf_tk/storageio/_applications.py +338 -26
  96. cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +67 -104
  97. cognite_toolkit/_cdf_tk/storageio/_base.py +61 -29
  98. cognite_toolkit/_cdf_tk/storageio/_datapoints.py +276 -20
  99. cognite_toolkit/_cdf_tk/storageio/_file_content.py +436 -0
  100. cognite_toolkit/_cdf_tk/storageio/_instances.py +34 -2
  101. cognite_toolkit/_cdf_tk/storageio/_raw.py +26 -0
  102. cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +62 -4
  103. cognite_toolkit/_cdf_tk/storageio/selectors/_base.py +14 -2
  104. cognite_toolkit/_cdf_tk/storageio/selectors/_canvas.py +14 -0
  105. cognite_toolkit/_cdf_tk/storageio/selectors/_charts.py +14 -0
  106. cognite_toolkit/_cdf_tk/storageio/selectors/_datapoints.py +23 -3
  107. cognite_toolkit/_cdf_tk/storageio/selectors/_file_content.py +164 -0
  108. cognite_toolkit/_cdf_tk/tk_warnings/other.py +4 -0
  109. cognite_toolkit/_cdf_tk/tracker.py +2 -2
  110. cognite_toolkit/_cdf_tk/utils/dtype_conversion.py +9 -3
  111. cognite_toolkit/_cdf_tk/utils/fileio/__init__.py +2 -0
  112. cognite_toolkit/_cdf_tk/utils/fileio/_base.py +5 -1
  113. cognite_toolkit/_cdf_tk/utils/fileio/_readers.py +112 -20
  114. cognite_toolkit/_cdf_tk/utils/fileio/_writers.py +15 -15
  115. cognite_toolkit/_cdf_tk/utils/http_client/_client.py +284 -18
  116. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +50 -4
  117. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +187 -0
  118. cognite_toolkit/_cdf_tk/utils/interactive_select.py +9 -14
  119. cognite_toolkit/_cdf_tk/utils/sql_parser.py +2 -3
  120. cognite_toolkit/_cdf_tk/utils/useful_types.py +6 -2
  121. cognite_toolkit/_cdf_tk/validation.py +79 -1
  122. cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
  123. cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
  124. cognite_toolkit/_resources/cdf.toml +5 -4
  125. cognite_toolkit/_version.py +1 -1
  126. cognite_toolkit/config.dev.yaml +13 -0
  127. {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.30.dist-info}/METADATA +24 -24
  128. {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.30.dist-info}/RECORD +153 -143
  129. cognite_toolkit-0.7.30.dist-info/WHEEL +4 -0
  130. {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.30.dist-info}/entry_points.txt +1 -0
  131. cognite_toolkit/_cdf_tk/commands/_migrate/canvas.py +0 -201
  132. cognite_toolkit/_cdf_tk/commands/dump_data.py +0 -489
  133. cognite_toolkit/_cdf_tk/commands/featureflag.py +0 -27
  134. cognite_toolkit/_cdf_tk/utils/table_writers.py +0 -434
  135. cognite_toolkit-0.6.97.dist-info/WHEEL +0 -4
  136. cognite_toolkit-0.6.97.dist-info/licenses/LICENSE +0 -18
cognite_toolkit/_cdf.py CHANGED
@@ -25,18 +25,18 @@ from cognite_toolkit._cdf_tk.apps import (
25
25
  AuthApp,
26
26
  CoreApp,
27
27
  DataApp,
28
+ DevApp,
28
29
  DumpApp,
29
30
  LandingApp,
30
31
  MigrateApp,
31
32
  ModulesApp,
32
33
  ProfileApp,
33
- PurgeApp,
34
34
  RepoApp,
35
35
  RunApp,
36
36
  )
37
37
  from cognite_toolkit._cdf_tk.cdf_toml import CDFToml
38
38
  from cognite_toolkit._cdf_tk.commands import (
39
- CollectCommand,
39
+ AboutCommand,
40
40
  )
41
41
  from cognite_toolkit._cdf_tk.constants import HINT_LEAD_TEXT, URL, USE_SENTRY
42
42
  from cognite_toolkit._cdf_tk.exceptions import (
@@ -89,15 +89,18 @@ user_app = typer.Typer(**default_typer_kws, hidden=True) # type: ignore [arg-ty
89
89
  landing_app = LandingApp(**default_typer_kws)
90
90
 
91
91
  _app.add_typer(AuthApp(**default_typer_kws), name="auth")
92
+ _app.add_typer(RepoApp(**default_typer_kws), name="repo")
93
+
94
+
92
95
  if Plugins.run.value.is_enabled():
93
96
  _app.add_typer(RunApp(**default_typer_kws), name="run")
94
- _app.add_typer(RepoApp(**default_typer_kws), name="repo")
95
97
 
96
98
  if Plugins.dump.value.is_enabled():
97
99
  _app.add_typer(DumpApp(**default_typer_kws), name="dump")
98
100
 
99
- if Plugins.purge.value.is_enabled() and not Flags.v07.is_enabled():
100
- _app.add_typer(PurgeApp(**default_typer_kws), name="purge")
101
+
102
+ if Plugins.dev.value.is_enabled():
103
+ _app.add_typer(DevApp(**default_typer_kws), name="dev")
101
104
 
102
105
  if Flags.PROFILE.is_enabled():
103
106
  _app.add_typer(ProfileApp(**default_typer_kws), name="profile")
@@ -105,13 +108,20 @@ if Flags.PROFILE.is_enabled():
105
108
  if Flags.MIGRATE.is_enabled():
106
109
  _app.add_typer(MigrateApp(**default_typer_kws), name="migrate")
107
110
 
108
- if Flags.v07.is_enabled():
111
+ if Plugins.data.value.is_enabled():
109
112
  _app.add_typer(DataApp(**default_typer_kws), name="data")
110
113
 
111
114
  _app.add_typer(ModulesApp(**default_typer_kws), name="modules")
112
115
  _app.command("init")(landing_app.main_init)
113
116
 
114
117
 
118
+ @_app.command("about")
119
+ def about() -> None:
120
+ """Display information about the Toolkit installation and configuration."""
121
+ cmd = AboutCommand()
122
+ cmd.run(lambda: cmd.execute(Path.cwd()))
123
+
124
+
115
125
  def app() -> NoReturn:
116
126
  # --- Main entry point ---
117
127
  # Users run 'app()' directly, but that doesn't allow us to control excepton handling:
@@ -144,17 +154,6 @@ def app() -> NoReturn:
144
154
  raise SystemExit(0)
145
155
 
146
156
 
147
- @_app.command("collect", hidden=True)
148
- def collect(
149
- action: str = typer.Argument(
150
- help="Whether to explicitly opt-in or opt-out of usage data collection. [opt-in, opt-out]"
151
- ),
152
- ) -> None:
153
- """Collect usage information for the toolkit."""
154
- cmd = CollectCommand()
155
- cmd.run(lambda: cmd.execute(action)) # type: ignore [arg-type]
156
-
157
-
158
157
  @user_app.callback(invoke_without_command=True)
159
158
  def user_main(ctx: typer.Context) -> None:
160
159
  """Commands to give information about the toolkit."""
@@ -1,6 +1,7 @@
1
1
  from ._auth_app import AuthApp
2
2
  from ._core_app import CoreApp
3
3
  from ._data_app import DataApp
4
+ from ._dev_app import DevApp
4
5
  from ._download_app import DownloadApp
5
6
  from ._dump_app import DumpApp
6
7
  from ._landing_app import LandingApp
@@ -16,6 +17,7 @@ __all__ = [
16
17
  "AuthApp",
17
18
  "CoreApp",
18
19
  "DataApp",
20
+ "DevApp",
19
21
  "DownloadApp",
20
22
  "DumpApp",
21
23
  "LandingApp",
@@ -15,7 +15,6 @@ from cognite_toolkit._cdf_tk.client import ToolkitClient
15
15
  from cognite_toolkit._cdf_tk.commands import BuildCommand, CleanCommand, DeployCommand
16
16
  from cognite_toolkit._cdf_tk.commands.clean import AVAILABLE_DATA_TYPES
17
17
  from cognite_toolkit._cdf_tk.exceptions import ToolkitFileNotFoundError
18
- from cognite_toolkit._cdf_tk.feature_flags import Flags
19
18
  from cognite_toolkit._cdf_tk.utils import get_cicd_environment
20
19
  from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
21
20
  from cognite_toolkit._version import __version__ as current_version
@@ -193,7 +192,6 @@ class CoreApp(typer.Typer):
193
192
  "--exit-non-zero-on-warning",
194
193
  "-w",
195
194
  help="Exit with non-zero code on warning.",
196
- hidden=not Flags.EXIT_ON_WARNING.is_enabled(),
197
195
  ),
198
196
  ] = False,
199
197
  ) -> None:
@@ -206,7 +204,7 @@ class CoreApp(typer.Typer):
206
204
  client = EnvironmentVariables.create_from_environment().get_client()
207
205
 
208
206
  print_warning = True
209
- if Flags.EXIT_ON_WARNING.is_enabled() and exit_on_warning:
207
+ if exit_on_warning:
210
208
  print_warning = False
211
209
 
212
210
  cmd = BuildCommand(print_warning=print_warning)
@@ -223,7 +221,7 @@ class CoreApp(typer.Typer):
223
221
  )
224
222
  )
225
223
 
226
- if Flags.EXIT_ON_WARNING.is_enabled() and exit_on_warning and cmd.warning_list:
224
+ if exit_on_warning and cmd.warning_list:
227
225
  print("\n[bold red]Warnings raised during the build process:[/]\n")
228
226
 
229
227
  for warning in cmd.warning_list:
@@ -345,7 +343,15 @@ class CoreApp(typer.Typer):
345
343
  list[str] | None,
346
344
  typer.Option(
347
345
  "--include",
348
- help=f"Specify which resource types to deploy, supported types: {AVAILABLE_DATA_TYPES}",
346
+ help=f"Specify which resource types to clean, supported types: {AVAILABLE_DATA_TYPES}",
347
+ ),
348
+ ] = None,
349
+ module: Annotated[
350
+ str | None,
351
+ typer.Option(
352
+ "--module",
353
+ "-m",
354
+ help="Specify name or path of the module to clean",
349
355
  ),
350
356
  ] = None,
351
357
  verbose: Annotated[
@@ -368,6 +374,8 @@ class CoreApp(typer.Typer):
368
374
  build_env_name,
369
375
  dry_run,
370
376
  include,
377
+ module,
371
378
  verbose,
379
+ all_modules=False,
372
380
  )
373
381
  )
@@ -18,7 +18,7 @@ class DataApp(typer.Typer):
18
18
 
19
19
  @staticmethod
20
20
  def main(ctx: typer.Context) -> None:
21
- """Commands to work with data download/upload/purge."""
21
+ """Plugin to work with data in CDF"""
22
22
  if ctx.invoked_subcommand is None:
23
23
  print("Use [bold yellow]cdf data --help[/] for more information.")
24
24
  return None
@@ -0,0 +1,86 @@
1
+ from pathlib import Path
2
+ from typing import Annotated, Any
3
+
4
+ import typer
5
+ from rich import print
6
+
7
+ from cognite_toolkit._cdf_tk.cdf_toml import CDFToml
8
+ from cognite_toolkit._cdf_tk.commands import ResourcesCommand
9
+ from cognite_toolkit._cdf_tk.feature_flags import FeatureFlag, Flags
10
+
11
+ from ._run import RunApp
12
+
13
+ CDF_TOML = CDFToml.load(Path.cwd())
14
+
15
+
16
+ class DevApp(typer.Typer):
17
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
18
+ super().__init__(*args, **kwargs)
19
+ self.callback(invoke_without_command=True)(self.main)
20
+ self.add_typer(RunApp(*args, **kwargs), name="run")
21
+ if FeatureFlag.is_enabled(Flags.CREATE):
22
+ self.command("create")(self.create)
23
+
24
+ @staticmethod
25
+ def main(ctx: typer.Context) -> None:
26
+ """Commands to work with development."""
27
+ if ctx.invoked_subcommand is None:
28
+ print("Use [bold yellow]cdf dev --help[/] for more information.")
29
+ return None
30
+
31
+ def create(
32
+ self,
33
+ kind: Annotated[
34
+ list[str] | None,
35
+ typer.Argument(
36
+ help="The kind of resource to create. eg. container, space, view, datamodel, etc.",
37
+ callback=lambda ctx, param, value: [
38
+ s.strip() for item in value or [] for s in item.split(",") if s.strip()
39
+ ],
40
+ ),
41
+ ] = None,
42
+ module: Annotated[
43
+ str | None,
44
+ typer.Option(
45
+ "--module",
46
+ "-m",
47
+ help="Name of an existing module or a new module to create the resource in.",
48
+ ),
49
+ ] = None,
50
+ prefix: Annotated[
51
+ str | None,
52
+ typer.Option(
53
+ "--prefix",
54
+ "-p",
55
+ help="The prefix of the resource file to create without suffixes and extensions. "
56
+ "eg. --prefix=my_space. If not provided, a default prefix like 'my_<kind>' will be used.",
57
+ ),
58
+ ] = None,
59
+ verbose: Annotated[
60
+ bool,
61
+ typer.Option(
62
+ "--verbose",
63
+ "-v",
64
+ help="Turn on to get more verbose output when running the command",
65
+ ),
66
+ ] = False,
67
+ organization_dir: Annotated[
68
+ Path,
69
+ typer.Option(
70
+ "--organization-dir",
71
+ "-o",
72
+ help="Path to the organization directory",
73
+ ),
74
+ ] = CDF_TOML.cdf.default_organization_dir,
75
+ ) -> None:
76
+ """create resource YAMLs."""
77
+ cmd = ResourcesCommand()
78
+ cmd.run(
79
+ lambda: cmd.create(
80
+ organization_dir=organization_dir,
81
+ module_name=module,
82
+ kind=kind,
83
+ prefix=prefix,
84
+ verbose=verbose,
85
+ )
86
+ )