cognite-toolkit 0.6.85__py3-none-any.whl → 0.6.86__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.
- cognite_toolkit/_cdf_tk/commands/_download.py +19 -17
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +21 -1
- cognite_toolkit/_cdf_tk/storageio/_base.py +16 -0
- cognite_toolkit/_cdf_tk/utils/producer_worker.py +3 -3
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
- cognite_toolkit/_resources/cdf.toml +1 -1
- cognite_toolkit/_version.py +1 -1
- {cognite_toolkit-0.6.85.dist-info → cognite_toolkit-0.6.86.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.6.85.dist-info → cognite_toolkit-0.6.86.dist-info}/RECORD +13 -13
- {cognite_toolkit-0.6.85.dist-info → cognite_toolkit-0.6.86.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.6.85.dist-info → cognite_toolkit-0.6.86.dist-info}/entry_points.txt +0 -0
- {cognite_toolkit-0.6.85.dist-info → cognite_toolkit-0.6.86.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from collections.abc import Iterable
|
|
1
|
+
from collections.abc import Callable, Iterable
|
|
2
2
|
from functools import partial
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
@@ -42,7 +42,7 @@ class DownloadCommand(ToolkitCommand):
|
|
|
42
42
|
|
|
43
43
|
console = io.client.console
|
|
44
44
|
for selector in selectors:
|
|
45
|
-
target_dir = output_dir / selector.group
|
|
45
|
+
target_dir = output_dir / sanitize_filename(selector.group)
|
|
46
46
|
if verbose:
|
|
47
47
|
console.print(f"Downloading {selector.display_name} '{selector!s}' to {target_dir.as_posix()!r}")
|
|
48
48
|
|
|
@@ -57,9 +57,10 @@ class DownloadCommand(ToolkitCommand):
|
|
|
57
57
|
|
|
58
58
|
selector.dump_to_file(target_dir)
|
|
59
59
|
columns: list[SchemaColumn] | None = None
|
|
60
|
-
|
|
60
|
+
is_table = file_format in TABLE_WRITE_CLS_BY_FORMAT
|
|
61
|
+
if is_table and isinstance(io, TableStorageIO):
|
|
61
62
|
columns = io.get_schema(selector)
|
|
62
|
-
elif
|
|
63
|
+
elif is_table:
|
|
63
64
|
raise ToolkitValueError(
|
|
64
65
|
f"Cannot download {selector.kind} in {file_format!r} format. The {selector.kind!r} storage type does not support table schemas."
|
|
65
66
|
)
|
|
@@ -69,7 +70,7 @@ class DownloadCommand(ToolkitCommand):
|
|
|
69
70
|
) as writer:
|
|
70
71
|
executor = ProducerWorkerExecutor[Page[T_CogniteResource], list[dict[str, JsonVal]]](
|
|
71
72
|
download_iterable=io.stream_data(selector, limit),
|
|
72
|
-
process=
|
|
73
|
+
process=self.create_data_process(io=io, selector=selector, is_table=is_table),
|
|
73
74
|
write=partial(writer.write_chunks, filestem=filestem),
|
|
74
75
|
iteration_count=iteration_count,
|
|
75
76
|
# Limit queue size to avoid filling up memory before the workers can write to disk.
|
|
@@ -124,19 +125,20 @@ class DownloadCommand(ToolkitCommand):
|
|
|
124
125
|
return False
|
|
125
126
|
|
|
126
127
|
@staticmethod
|
|
127
|
-
def
|
|
128
|
-
data_page: Page[T_CogniteResource],
|
|
128
|
+
def create_data_process(
|
|
129
129
|
io: StorageIO[T_Selector, T_CogniteResource],
|
|
130
130
|
selector: T_Selector,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
is_table: bool,
|
|
132
|
+
) -> Callable[[Page[T_CogniteResource]], list[dict[str, JsonVal]]]:
|
|
133
|
+
"""Creates a data processing function based on the IO type and whether the output is a table."""
|
|
134
|
+
if is_table and isinstance(io, TableStorageIO):
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
io: The StorageIO instance that defines how to process the data.
|
|
137
|
-
selector: The selection criteria used to identify the data.
|
|
136
|
+
def row_data_process(chunk: Page[T_CogniteResource]) -> list[dict[str, JsonVal]]:
|
|
137
|
+
return io.data_to_row(chunk.items, selector)
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
return row_data_process
|
|
140
|
+
|
|
141
|
+
def chunk_data_process(data_page: Page[T_CogniteResource]) -> list[dict[str, JsonVal]]:
|
|
142
|
+
return io.data_to_json_chunk(data_page.items, selector)
|
|
143
|
+
|
|
144
|
+
return chunk_data_process
|
|
@@ -67,7 +67,14 @@ from cognite_toolkit._cdf_tk.utils.useful_types import (
|
|
|
67
67
|
T_WritableCogniteResourceList,
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
-
from ._base import
|
|
70
|
+
from ._base import (
|
|
71
|
+
ConfigurableStorageIO,
|
|
72
|
+
Page,
|
|
73
|
+
StorageIOConfig,
|
|
74
|
+
TableStorageIO,
|
|
75
|
+
UploadableStorageIO,
|
|
76
|
+
UploadItem,
|
|
77
|
+
)
|
|
71
78
|
from .selectors import AssetCentricSelector, AssetSubtreeSelector, DataSetSelector
|
|
72
79
|
|
|
73
80
|
|
|
@@ -179,6 +186,19 @@ class BaseAssetCentricIO(
|
|
|
179
186
|
asset_ids.update(item.asset_ids or [])
|
|
180
187
|
self.client.lookup.assets.external_id(list(asset_ids))
|
|
181
188
|
|
|
189
|
+
def data_to_row(
|
|
190
|
+
self, data_chunk: Sequence[T_WritableCogniteResource], selector: AssetCentricSelector | None = None
|
|
191
|
+
) -> list[dict[str, JsonVal]]:
|
|
192
|
+
rows: list[dict[str, JsonVal]] = []
|
|
193
|
+
for chunk in self.data_to_json_chunk(data_chunk, selector):
|
|
194
|
+
if "metadata" in chunk and isinstance(chunk["metadata"], dict):
|
|
195
|
+
metadata = chunk.pop("metadata")
|
|
196
|
+
# MyPy does understand that metadata is a dict here due to the check above.
|
|
197
|
+
for key, value in metadata.items(): # type: ignore[union-attr]
|
|
198
|
+
chunk[f"metadata.{key}"] = value
|
|
199
|
+
rows.append(chunk)
|
|
200
|
+
return rows
|
|
201
|
+
|
|
182
202
|
|
|
183
203
|
class AssetIO(BaseAssetCentricIO[str, AssetWrite, Asset, AssetWriteList, AssetList]):
|
|
184
204
|
KIND = "Assets"
|
|
@@ -230,3 +230,19 @@ class TableStorageIO(StorageIO[T_Selector, T_CogniteResource], ABC):
|
|
|
230
230
|
|
|
231
231
|
"""
|
|
232
232
|
raise NotImplementedError()
|
|
233
|
+
|
|
234
|
+
@abstractmethod
|
|
235
|
+
def data_to_row(
|
|
236
|
+
self, data_chunk: Sequence[T_CogniteResource], selector: T_Selector | None = None
|
|
237
|
+
) -> list[dict[str, JsonVal]]:
|
|
238
|
+
"""Convert a chunk of data to a row-based JSON-compatible format.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
data_chunk: The chunk of data to convert, which should be a writable Cognite resource list.
|
|
242
|
+
selector: Optional selection criteria to identify the data. This is required for some storage types.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
A list of dictionaries representing the data in a JSON-compatible format.
|
|
246
|
+
|
|
247
|
+
"""
|
|
248
|
+
raise NotImplementedError()
|
|
@@ -235,7 +235,7 @@ class ProducerWorkerExecutor(Generic[T_Download, T_Processed]):
|
|
|
235
235
|
break
|
|
236
236
|
except Exception as e:
|
|
237
237
|
self._error_event.set()
|
|
238
|
-
self.error_message =
|
|
238
|
+
self.error_message = f"{type(e).__name__} {e!s}"
|
|
239
239
|
self.error_traceback = traceback.format_exc()
|
|
240
240
|
self.console.print(f"[red]Error[/red] occurred while {self.download_description}: {self.error_message}")
|
|
241
241
|
break
|
|
@@ -275,7 +275,7 @@ class ProducerWorkerExecutor(Generic[T_Download, T_Processed]):
|
|
|
275
275
|
continue
|
|
276
276
|
except Exception as e:
|
|
277
277
|
self._error_event.set()
|
|
278
|
-
self.error_message =
|
|
278
|
+
self.error_message = f"{type(e).__name__} {e!s}"
|
|
279
279
|
self.error_traceback = traceback.format_exc()
|
|
280
280
|
self.console.print(f"[red]Error[/red] occurred while {self.process_description}: {self.error_message}")
|
|
281
281
|
break
|
|
@@ -297,7 +297,7 @@ class ProducerWorkerExecutor(Generic[T_Download, T_Processed]):
|
|
|
297
297
|
continue
|
|
298
298
|
except Exception as e:
|
|
299
299
|
self._error_event.set()
|
|
300
|
-
self.error_message =
|
|
300
|
+
self.error_message = f"{type(e).__name__} {e!s}"
|
|
301
301
|
self.error_traceback = traceback.format_exc()
|
|
302
302
|
self.console.print(f"[red]Error[/red] occurred while {self.write_description}: {self.error_message}")
|
|
303
303
|
break
|
|
@@ -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.6.
|
|
7
|
+
version = "0.6.86"
|
|
8
8
|
|
|
9
9
|
[alpha_flags]
|
|
10
10
|
external-libraries = true
|
cognite_toolkit/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.6.
|
|
1
|
+
__version__ = "0.6.86"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite_toolkit
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.86
|
|
4
4
|
Summary: Official Cognite Data Fusion tool for project templates and configuration deployment
|
|
5
5
|
Project-URL: Homepage, https://docs.cognite.com/cdf/deploy/cdf_toolkit/
|
|
6
6
|
Project-URL: Changelog, https://github.com/cognitedata/toolkit/releases
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cognite_toolkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
cognite_toolkit/_cdf.py,sha256=1OSAvbOeuIrnsczEG2BtGqRP3L3sq0VMPthmugnqCUw,5821
|
|
3
|
-
cognite_toolkit/_version.py,sha256=
|
|
3
|
+
cognite_toolkit/_version.py,sha256=y8yiu6qqknI_Tf_P0-H0xuN1S1fZ-IRju7amwCqQF3E,23
|
|
4
4
|
cognite_toolkit/_cdf_tk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite_toolkit/_cdf_tk/cdf_toml.py,sha256=DAUmHf19ByVIGH4MDPdXKHZ0G97CxdD5J-EzHTq66C8,8025
|
|
6
6
|
cognite_toolkit/_cdf_tk/constants.py,sha256=e9XmGvQCqGq7zYQrNoopU5e2KnYZYBPyUC5raGShK7k,6364
|
|
@@ -95,7 +95,7 @@ cognite_toolkit/_cdf_tk/commands/__init__.py,sha256=OJYtHiERtUBXm3cjUTyPVaYIMVQp
|
|
|
95
95
|
cognite_toolkit/_cdf_tk/commands/_base.py,sha256=m2hnXo_AAHhsoSayHZO_zUa4xEt5w5oMB4WCHmJr-AY,2595
|
|
96
96
|
cognite_toolkit/_cdf_tk/commands/_changes.py,sha256=DIwuiRpDhWBDpsW3R3yqj0eWLAE3c_kPbmCaUkxjFuo,24852
|
|
97
97
|
cognite_toolkit/_cdf_tk/commands/_cli_commands.py,sha256=TK6U_rm6VZT_V941kTyHMoulWgJzbDC8YIIQDPJ5x3w,1011
|
|
98
|
-
cognite_toolkit/_cdf_tk/commands/_download.py,sha256=
|
|
98
|
+
cognite_toolkit/_cdf_tk/commands/_download.py,sha256=OBKPM_HGGA1i32th1SAgkQM_81CUFvm39kGqBuOeeTs,6816
|
|
99
99
|
cognite_toolkit/_cdf_tk/commands/_profile.py,sha256=_4iX3AHAI6eLmRVUlWXCSvVHx1BZW2yDr_i2i9ECg6U,43120
|
|
100
100
|
cognite_toolkit/_cdf_tk/commands/_purge.py,sha256=RadQHsmkPez3fZ5HCP9b82o2_fBx8P_-bTo7prkvWXU,32525
|
|
101
101
|
cognite_toolkit/_cdf_tk/commands/_upload.py,sha256=kXYmP1YMg-JvsuN1iYaMuZH1qZfapya2j-RABGhqGHo,11860
|
|
@@ -227,8 +227,8 @@ cognite_toolkit/_cdf_tk/resource_classes/robotics/location.py,sha256=dbc9HT-bc2Q
|
|
|
227
227
|
cognite_toolkit/_cdf_tk/resource_classes/robotics/map.py,sha256=j77z7CzCMiMj8r94BdUKCum9EuZRUjaSlUAy9K9DL_Q,942
|
|
228
228
|
cognite_toolkit/_cdf_tk/storageio/__init__.py,sha256=aM-skaPnKTH1B7HG0faeTUNf7u1b-sT8l7hh5JRZ1E8,2288
|
|
229
229
|
cognite_toolkit/_cdf_tk/storageio/_applications.py,sha256=bhyG1d2_9duPkX-otC2brVcpChvdXSPkYhBHS5T_72g,4343
|
|
230
|
-
cognite_toolkit/_cdf_tk/storageio/_asset_centric.py,sha256=
|
|
231
|
-
cognite_toolkit/_cdf_tk/storageio/_base.py,sha256=
|
|
230
|
+
cognite_toolkit/_cdf_tk/storageio/_asset_centric.py,sha256=d7WfCjuauIyUBfNJTgV5ZN-xSUmLGuuvLB0yPYnEg08,27734
|
|
231
|
+
cognite_toolkit/_cdf_tk/storageio/_base.py,sha256=BQPueVpmxIYtSZ53W4cwp7pFEzvvpBd7Bz_L7Anw8hc,9308
|
|
232
232
|
cognite_toolkit/_cdf_tk/storageio/_data_classes.py,sha256=s3TH04BJ1q7rXndRhEbVMEnoOXjxrGg4n-w9Z5uUL-o,3480
|
|
233
233
|
cognite_toolkit/_cdf_tk/storageio/_instances.py,sha256=_tKOdlo7tMJoh7y-47o7sySfDMRa-G-AFVprmzjn3EQ,9311
|
|
234
234
|
cognite_toolkit/_cdf_tk/storageio/_raw.py,sha256=5UkIk5MkyyCyGRYmyD6qTIsEDKbI2EulPesYbqM8qAA,3466
|
|
@@ -259,7 +259,7 @@ cognite_toolkit/_cdf_tk/utils/graphql_parser.py,sha256=2i2wDjg_Uw3hJ-pHtPK8hczIu
|
|
|
259
259
|
cognite_toolkit/_cdf_tk/utils/hashing.py,sha256=3NyNfljyYNTqAyAFBd6XlyWaj43jRzENxIuPdOY6nqo,2116
|
|
260
260
|
cognite_toolkit/_cdf_tk/utils/interactive_select.py,sha256=veV93_O-gATbQ1PfRbZq0VotTgaXA4JcU34j_nLKpSU,36155
|
|
261
261
|
cognite_toolkit/_cdf_tk/utils/modules.py,sha256=9RvOGUaGEi_-A7Qrq0E1tCx82QK8GbvEZXB7r1RnD_U,5974
|
|
262
|
-
cognite_toolkit/_cdf_tk/utils/producer_worker.py,sha256=
|
|
262
|
+
cognite_toolkit/_cdf_tk/utils/producer_worker.py,sha256=1l77HIehkq1ARCBH6SlZ_V-jd6QKijYKeWetcUmAXg0,14216
|
|
263
263
|
cognite_toolkit/_cdf_tk/utils/progress_tracker.py,sha256=LGpC22iSTTlo6FWi38kqBu_E4XouTvZU_N953WAzZWA,3865
|
|
264
264
|
cognite_toolkit/_cdf_tk/utils/repository.py,sha256=voQLZ6NiNvdAFxqeWHbvzDLsLHl6spjQBihiLyCsGW8,4104
|
|
265
265
|
cognite_toolkit/_cdf_tk/utils/sentry_utils.py,sha256=Q3ekrR0bWMtlPVQrfUSsETlkLIaDUZ2u-RdNFFr9-dg,564
|
|
@@ -284,13 +284,13 @@ cognite_toolkit/_repo_files/.gitignore,sha256=ip9kf9tcC5OguF4YF4JFEApnKYw0nG0vPi
|
|
|
284
284
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/README.md,sha256=OLA0D7yCX2tACpzvkA0IfkgQ4_swSd-OlJ1tYcTBpsA,240
|
|
285
285
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/deploy-pipeline.yml,sha256=brULcs8joAeBC_w_aoWjDDUHs3JheLMIR9ajPUK96nc,693
|
|
286
286
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/dry-run-pipeline.yml,sha256=OBFDhFWK1mlT4Dc6mDUE2Es834l8sAlYG50-5RxRtHk,723
|
|
287
|
-
cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=
|
|
288
|
-
cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=
|
|
289
|
-
cognite_toolkit/_resources/cdf.toml,sha256=
|
|
287
|
+
cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=SKpoFkXR8f0H7AhoDJHmdN-vNkVqmpXzzbhzzNSFGtc,667
|
|
288
|
+
cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=BiHNR_3PtLFgSH-Uz7KtKzDkywcsiA_oOjJ4M2it9lg,2430
|
|
289
|
+
cognite_toolkit/_resources/cdf.toml,sha256=vN6PvToANrJEjhUYpEzDdjUa1cSXa9NMgv1mp8iOb2I,487
|
|
290
290
|
cognite_toolkit/demo/__init__.py,sha256=-m1JoUiwRhNCL18eJ6t7fZOL7RPfowhCuqhYFtLgrss,72
|
|
291
291
|
cognite_toolkit/demo/_base.py,sha256=6xKBUQpXZXGQ3fJ5f7nj7oT0s2n7OTAGIa17ZlKHZ5U,8052
|
|
292
|
-
cognite_toolkit-0.6.
|
|
293
|
-
cognite_toolkit-0.6.
|
|
294
|
-
cognite_toolkit-0.6.
|
|
295
|
-
cognite_toolkit-0.6.
|
|
296
|
-
cognite_toolkit-0.6.
|
|
292
|
+
cognite_toolkit-0.6.86.dist-info/METADATA,sha256=gVYv6ykmqx89FtC_aWVCshPWVQ3B7LcpBUy1x8y17uQ,4501
|
|
293
|
+
cognite_toolkit-0.6.86.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
294
|
+
cognite_toolkit-0.6.86.dist-info/entry_points.txt,sha256=JlR7MH1_UMogC3QOyN4-1l36VbrCX9xUdQoHGkuJ6-4,83
|
|
295
|
+
cognite_toolkit-0.6.86.dist-info/licenses/LICENSE,sha256=CW0DRcx5tL-pCxLEN7ts2S9g2sLRAsWgHVEX4SN9_Mc,752
|
|
296
|
+
cognite_toolkit-0.6.86.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|