cognite-toolkit 0.6.97__py3-none-any.whl → 0.7.39__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.
- cognite_toolkit/_cdf.py +21 -23
- cognite_toolkit/_cdf_tk/apps/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +19 -5
- cognite_toolkit/_cdf_tk/apps/_data_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dev_app.py +86 -0
- cognite_toolkit/_cdf_tk/apps/_download_app.py +693 -25
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +44 -102
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_landing_app.py +18 -4
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +424 -9
- cognite_toolkit/_cdf_tk/apps/_modules_app.py +0 -3
- cognite_toolkit/_cdf_tk/apps/_purge.py +15 -43
- cognite_toolkit/_cdf_tk/apps/_run.py +11 -0
- cognite_toolkit/_cdf_tk/apps/_upload_app.py +45 -6
- cognite_toolkit/_cdf_tk/builders/__init__.py +2 -2
- cognite_toolkit/_cdf_tk/builders/_base.py +28 -42
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/cdf_toml.py +20 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +32 -12
- cognite_toolkit/_cdf_tk/client/api/infield.py +114 -17
- cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +15 -7
- cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
- cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +15 -18
- cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
- cognite_toolkit/_cdf_tk/client/api/{location_filters.py → legacy/location_filters.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/{search_config.py → legacy/search_config.py} +5 -1
- cognite_toolkit/_cdf_tk/client/api/migration.py +177 -4
- cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
- cognite_toolkit/_cdf_tk/client/api/search.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/streams.py +88 -0
- cognite_toolkit/_cdf_tk/client/api/three_d.py +384 -0
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +37 -33
- cognite_toolkit/_cdf_tk/client/data_classes/charts_data.py +95 -213
- cognite_toolkit/_cdf_tk/client/data_classes/infield.py +32 -18
- cognite_toolkit/_cdf_tk/client/data_classes/instance_api.py +18 -13
- cognite_toolkit/_cdf_tk/client/data_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/data_classes/{canvas.py → legacy/canvas.py} +47 -4
- cognite_toolkit/_cdf_tk/client/data_classes/{charts.py → legacy/charts.py} +3 -3
- cognite_toolkit/_cdf_tk/client/data_classes/{migration.py → legacy/migration.py} +10 -2
- cognite_toolkit/_cdf_tk/client/data_classes/streams.py +90 -0
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +112 -0
- cognite_toolkit/_cdf_tk/client/testing.py +42 -18
- cognite_toolkit/_cdf_tk/commands/__init__.py +7 -6
- cognite_toolkit/_cdf_tk/commands/_changes.py +3 -42
- cognite_toolkit/_cdf_tk/commands/_download.py +21 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py +0 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +22 -20
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +140 -92
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +108 -26
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +448 -45
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +6 -6
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +52 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +377 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/selectors.py +9 -4
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +36 -39
- cognite_toolkit/_cdf_tk/commands/_questionary_style.py +16 -0
- cognite_toolkit/_cdf_tk/commands/_upload.py +109 -86
- cognite_toolkit/_cdf_tk/commands/about.py +221 -0
- cognite_toolkit/_cdf_tk/commands/auth.py +19 -12
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +16 -62
- cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +241 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_input.py +85 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +27 -0
- cognite_toolkit/_cdf_tk/commands/clean.py +63 -16
- cognite_toolkit/_cdf_tk/commands/deploy.py +20 -17
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +10 -8
- cognite_toolkit/_cdf_tk/commands/init.py +225 -3
- cognite_toolkit/_cdf_tk/commands/modules.py +20 -44
- cognite_toolkit/_cdf_tk/commands/pull.py +6 -19
- cognite_toolkit/_cdf_tk/commands/resources.py +179 -0
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/constants.py +20 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +19 -5
- cognite_toolkit/_cdf_tk/cruds/_base_cruds.py +14 -70
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +10 -19
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +4 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/agent.py +11 -9
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +45 -44
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +5 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +206 -67
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +6 -18
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +126 -35
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +7 -28
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +23 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +4 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -16
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +5 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +5 -11
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +16 -45
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +94 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/three_d_model.py +3 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +75 -32
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -40
- cognite_toolkit/_cdf_tk/cruds/_worker.py +24 -36
- cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +16 -36
- cognite_toolkit/_cdf_tk/plugins.py +2 -1
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +12 -0
- cognite_toolkit/_cdf_tk/resource_classes/functions.py +3 -1
- cognite_toolkit/_cdf_tk/resource_classes/infield_cdm_location_config.py +109 -0
- cognite_toolkit/_cdf_tk/resource_classes/migration.py +8 -17
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/streams.py +29 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
- cognite_toolkit/_cdf_tk/storageio/__init__.py +9 -21
- cognite_toolkit/_cdf_tk/storageio/_annotations.py +19 -16
- cognite_toolkit/_cdf_tk/storageio/_applications.py +340 -28
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +67 -104
- cognite_toolkit/_cdf_tk/storageio/_base.py +61 -29
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +276 -20
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +435 -0
- cognite_toolkit/_cdf_tk/storageio/_instances.py +35 -3
- cognite_toolkit/_cdf_tk/storageio/_raw.py +26 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +71 -4
- cognite_toolkit/_cdf_tk/storageio/selectors/_base.py +14 -2
- cognite_toolkit/_cdf_tk/storageio/selectors/_canvas.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_charts.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_datapoints.py +23 -3
- cognite_toolkit/_cdf_tk/storageio/selectors/_file_content.py +164 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
- cognite_toolkit/_cdf_tk/tk_warnings/other.py +4 -0
- cognite_toolkit/_cdf_tk/tracker.py +2 -2
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/dtype_conversion.py +9 -3
- cognite_toolkit/_cdf_tk/utils/fileio/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/utils/fileio/_base.py +5 -1
- cognite_toolkit/_cdf_tk/utils/fileio/_readers.py +112 -20
- cognite_toolkit/_cdf_tk/utils/fileio/_writers.py +15 -15
- cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_client.py +285 -18
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +56 -4
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +247 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +60 -18
- cognite_toolkit/_cdf_tk/utils/sql_parser.py +2 -3
- cognite_toolkit/_cdf_tk/utils/useful_types.py +6 -2
- cognite_toolkit/_cdf_tk/validation.py +83 -1
- 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 +5 -4
- cognite_toolkit/_version.py +1 -1
- cognite_toolkit/config.dev.yaml +13 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/METADATA +24 -24
- cognite_toolkit-0.7.39.dist-info/RECORD +322 -0
- cognite_toolkit-0.7.39.dist-info/WHEEL +4 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/entry_points.txt +1 -0
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/commands/_migrate/canvas.py +0 -201
- cognite_toolkit/_cdf_tk/commands/dump_data.py +0 -489
- cognite_toolkit/_cdf_tk/commands/featureflag.py +0 -27
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- cognite_toolkit/_cdf_tk/utils/table_writers.py +0 -434
- cognite_toolkit-0.6.97.dist-info/RECORD +0 -306
- cognite_toolkit-0.6.97.dist-info/WHEEL +0 -4
- cognite_toolkit-0.6.97.dist-info/licenses/LICENSE +0 -18
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/api/legacy}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{apm_config_v1.py → legacy/apm_config_v1.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extendable_cognite_file.py → legacy/extendable_cognite_file.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetadata.py → legacy/extended_filemetadata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetdata.py → legacy/extended_filemetdata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_timeseries.py → legacy/extended_timeseries.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{functions.py → legacy/functions.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{graphql_data_models.py → legacy/graphql_data_models.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{instances.py → legacy/instances.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{location_filters.py → legacy/location_filters.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{pending_instances_ids.py → legacy/pending_instances_ids.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{project.py → legacy/project.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{raw.py → legacy/raw.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{robotics.py → legacy/robotics.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{search_config.py → legacy/search_config.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{sequences.py → legacy/sequences.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{streamlit_.py → legacy/streamlit_.py} +0 -0
- /cognite_toolkit/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
# limitations under the License.
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
import random
|
|
30
|
+
import time
|
|
29
31
|
import warnings
|
|
30
32
|
from collections import defaultdict
|
|
31
33
|
from collections.abc import Callable, Hashable, Iterable, Sequence
|
|
@@ -43,9 +45,7 @@ from cognite.client.data_classes import (
|
|
|
43
45
|
TransformationSchedule,
|
|
44
46
|
TransformationScheduleList,
|
|
45
47
|
TransformationScheduleWrite,
|
|
46
|
-
TransformationScheduleWriteList,
|
|
47
48
|
TransformationWrite,
|
|
48
|
-
TransformationWriteList,
|
|
49
49
|
)
|
|
50
50
|
from cognite.client.data_classes.capabilities import (
|
|
51
51
|
Capability,
|
|
@@ -58,7 +58,6 @@ from cognite.client.data_classes.data_modeling.ids import (
|
|
|
58
58
|
from cognite.client.data_classes.transformations import NonceCredentials
|
|
59
59
|
from cognite.client.data_classes.transformations.notifications import (
|
|
60
60
|
TransformationNotificationWrite,
|
|
61
|
-
TransformationNotificationWriteList,
|
|
62
61
|
)
|
|
63
62
|
from cognite.client.exceptions import CogniteAPIError, CogniteAuthError, CogniteDuplicatedError, CogniteNotFoundError
|
|
64
63
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
@@ -66,7 +65,7 @@ from rich import print
|
|
|
66
65
|
from rich.console import Console
|
|
67
66
|
|
|
68
67
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
69
|
-
from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawTable
|
|
68
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawTable
|
|
70
69
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
71
70
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
72
71
|
from cognite_toolkit._cdf_tk.exceptions import (
|
|
@@ -82,7 +81,7 @@ from cognite_toolkit._cdf_tk.resource_classes import (
|
|
|
82
81
|
TransformationScheduleYAML,
|
|
83
82
|
TransformationYAML,
|
|
84
83
|
)
|
|
85
|
-
from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning
|
|
84
|
+
from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning, MediumSeverityWarning
|
|
86
85
|
from cognite_toolkit._cdf_tk.utils import (
|
|
87
86
|
calculate_secure_hash,
|
|
88
87
|
humanize_collection,
|
|
@@ -103,18 +102,10 @@ from .raw import RawDatabaseCRUD, RawTableCRUD
|
|
|
103
102
|
|
|
104
103
|
|
|
105
104
|
@final
|
|
106
|
-
class TransformationCRUD(
|
|
107
|
-
ResourceCRUD[str, TransformationWrite, Transformation, TransformationWriteList, TransformationList]
|
|
108
|
-
):
|
|
105
|
+
class TransformationCRUD(ResourceCRUD[str, TransformationWrite, Transformation]):
|
|
109
106
|
folder_name = "transformations"
|
|
110
|
-
filename_pattern = (
|
|
111
|
-
# Matches all yaml files except file names whose stem contain *.schedule. or .Notification
|
|
112
|
-
r"^(?!.*schedule.*|.*\.notification$).*$"
|
|
113
|
-
)
|
|
114
107
|
resource_cls = Transformation
|
|
115
108
|
resource_write_cls = TransformationWrite
|
|
116
|
-
list_cls = TransformationList
|
|
117
|
-
list_write_cls = TransformationWriteList
|
|
118
109
|
kind = "Transformation"
|
|
119
110
|
yaml_cls = TransformationYAML
|
|
120
111
|
dependencies = frozenset(
|
|
@@ -354,6 +345,16 @@ class TransformationCRUD(
|
|
|
354
345
|
if "authentication" in local:
|
|
355
346
|
# The hash added to the beginning of the query detects the change in the authentication
|
|
356
347
|
dumped["authentication"] = local["authentication"]
|
|
348
|
+
cdf_destination = dumped.get("destination", {})
|
|
349
|
+
local_destination = local.get("destination", {})
|
|
350
|
+
if isinstance(cdf_destination, dict) and isinstance(local_destination, dict):
|
|
351
|
+
if cdf_destination.get("instanceSpace") is None and "instanceSpace" not in local_destination:
|
|
352
|
+
cdf_destination.pop("instanceSpace", None)
|
|
353
|
+
if not dumped.get("query") and "query" not in local:
|
|
354
|
+
dumped.pop("query", None)
|
|
355
|
+
if dumped.get("conflictMode") == "upsert" and "conflictMode" not in local:
|
|
356
|
+
# Default set from server side.
|
|
357
|
+
dumped.pop("conflictMode", None)
|
|
357
358
|
return dumped
|
|
358
359
|
|
|
359
360
|
def split_resource(
|
|
@@ -427,16 +428,70 @@ class TransformationCRUD(
|
|
|
427
428
|
if error := self._create_auth_creation_error(chunk):
|
|
428
429
|
raise error from e
|
|
429
430
|
raise e
|
|
430
|
-
|
|
431
|
+
except CogniteAPIError as e:
|
|
432
|
+
if "Failed to bind session using nonce" in e.message and len(chunk) > 1:
|
|
433
|
+
results.extend(self._execute_one_by_one(chunk, api_call))
|
|
434
|
+
else:
|
|
435
|
+
raise
|
|
436
|
+
else:
|
|
437
|
+
results.extend(chunk_results)
|
|
438
|
+
return results
|
|
439
|
+
|
|
440
|
+
def _execute_one_by_one(
|
|
441
|
+
self,
|
|
442
|
+
chunk: Sequence[TransformationWrite],
|
|
443
|
+
api_call: Callable[[Sequence[TransformationWrite]], TransformationList],
|
|
444
|
+
) -> TransformationList:
|
|
445
|
+
MediumSeverityWarning(
|
|
446
|
+
f"Failed to create {len(chunk)} transformations in a batch due to nonce binding error. "
|
|
447
|
+
"Trying to recover by creating them one by one."
|
|
448
|
+
).print_warning(console=self.client.console)
|
|
449
|
+
# Retry one by one
|
|
450
|
+
failed_ids: list[str] = []
|
|
451
|
+
success_count = 0
|
|
452
|
+
delay = 0.3
|
|
453
|
+
self._sleep_with_jitter(delay, delay + 0.3)
|
|
454
|
+
results = TransformationList([])
|
|
455
|
+
for item in chunk:
|
|
456
|
+
try:
|
|
457
|
+
recovered = api_call([item])
|
|
458
|
+
except CogniteAPIError as e:
|
|
459
|
+
if "Failed to bind session using nonce" in e.message:
|
|
460
|
+
failed_ids.append(item.external_id or "<missing>")
|
|
461
|
+
self._sleep_with_jitter(delay, delay + 0.3)
|
|
462
|
+
else:
|
|
463
|
+
raise
|
|
464
|
+
else:
|
|
465
|
+
results.extend(recovered)
|
|
466
|
+
success_count += 1
|
|
467
|
+
message = f" [bold]RECOVERY COMPLETE:[/] Successfully created {success_count:,} transformations"
|
|
468
|
+
if failed_ids:
|
|
469
|
+
message += f", failed to create {len(failed_ids):,} transformations: {humanize_collection(failed_ids)}"
|
|
470
|
+
else:
|
|
471
|
+
message += "."
|
|
472
|
+
if failed_ids:
|
|
473
|
+
HighSeverityWarning(message).print_warning(include_timestamp=True, console=self.client.console)
|
|
474
|
+
else:
|
|
475
|
+
self.client.console.print(message)
|
|
431
476
|
return results
|
|
432
477
|
|
|
478
|
+
@staticmethod
|
|
479
|
+
def _sleep_with_jitter(base_delay: float, max_delay: float) -> None:
|
|
480
|
+
"""Sleeps for a random duration between base_delay and max_delay (inclusive)."""
|
|
481
|
+
sleep_time = random.uniform(base_delay, max_delay)
|
|
482
|
+
time.sleep(sleep_time)
|
|
483
|
+
|
|
433
484
|
def _update_nonce(self, items: Sequence[TransformationWrite]) -> None:
|
|
434
485
|
for item in items:
|
|
435
486
|
if not item.external_id:
|
|
436
487
|
raise ToolkitRequiredValueError("Transformation must have external_id set.")
|
|
437
|
-
if
|
|
488
|
+
if item.source_nonce is None and (
|
|
489
|
+
read_credentials := self._authentication_by_id_operation.get((item.external_id, "read"))
|
|
490
|
+
):
|
|
438
491
|
item.source_nonce = self._create_nonce(read_credentials)
|
|
439
|
-
if
|
|
492
|
+
if item.destination_nonce is None and (
|
|
493
|
+
write_credentials := self._authentication_by_id_operation.get((item.external_id, "write"))
|
|
494
|
+
):
|
|
440
495
|
item.destination_nonce = self._create_nonce(write_credentials)
|
|
441
496
|
|
|
442
497
|
def _create_nonce(self, credentials: OidcCredentials | ClientCredentials) -> NonceCredentials:
|
|
@@ -483,17 +538,11 @@ class TransformationScheduleCRUD(
|
|
|
483
538
|
str,
|
|
484
539
|
TransformationScheduleWrite,
|
|
485
540
|
TransformationSchedule,
|
|
486
|
-
TransformationScheduleWriteList,
|
|
487
|
-
TransformationScheduleList,
|
|
488
541
|
]
|
|
489
542
|
):
|
|
490
543
|
folder_name = "transformations"
|
|
491
|
-
# Matches all yaml files whose stem contains *schedule or *TransformationSchedule.
|
|
492
|
-
filename_pattern = r"^.*schedule$"
|
|
493
544
|
resource_cls = TransformationSchedule
|
|
494
545
|
resource_write_cls = TransformationScheduleWrite
|
|
495
|
-
list_cls = TransformationScheduleList
|
|
496
|
-
list_write_cls = TransformationScheduleWriteList
|
|
497
546
|
kind = "Schedule"
|
|
498
547
|
yaml_cls = TransformationScheduleYAML
|
|
499
548
|
dependencies = frozenset({TransformationCRUD})
|
|
@@ -543,7 +592,7 @@ class TransformationScheduleCRUD(
|
|
|
543
592
|
def retrieve(self, ids: SequenceNotStr[str]) -> TransformationScheduleList:
|
|
544
593
|
return self.client.transformations.schedules.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
545
594
|
|
|
546
|
-
def update(self, items:
|
|
595
|
+
def update(self, items: Sequence[TransformationScheduleWrite]) -> TransformationScheduleList:
|
|
547
596
|
return self.client.transformations.schedules.update(items, mode="replace")
|
|
548
597
|
|
|
549
598
|
def delete(self, ids: str | SequenceNotStr[str] | None) -> int:
|
|
@@ -581,17 +630,11 @@ class TransformationNotificationCRUD(
|
|
|
581
630
|
str,
|
|
582
631
|
TransformationNotificationWrite,
|
|
583
632
|
TransformationNotification,
|
|
584
|
-
TransformationNotificationWriteList,
|
|
585
|
-
TransformationNotificationList,
|
|
586
633
|
]
|
|
587
634
|
):
|
|
588
635
|
folder_name = "transformations"
|
|
589
|
-
# Matches all yaml files whose stem ends with *Notification.
|
|
590
|
-
filename_pattern = r"^.*Notification$"
|
|
591
636
|
resource_cls = TransformationNotification
|
|
592
637
|
resource_write_cls = TransformationNotificationWrite
|
|
593
|
-
list_cls = TransformationNotificationList
|
|
594
|
-
list_write_cls = TransformationNotificationWriteList
|
|
595
638
|
kind = "Notification"
|
|
596
639
|
dependencies = frozenset({TransformationCRUD})
|
|
597
640
|
_doc_url = "Transformation-Notifications/operation/createTransformationNotifications"
|
|
@@ -638,7 +681,7 @@ class TransformationNotificationCRUD(
|
|
|
638
681
|
dumped["transformationExternalId"] = local["transformationExternalId"]
|
|
639
682
|
return dumped
|
|
640
683
|
|
|
641
|
-
def create(self, items:
|
|
684
|
+
def create(self, items: Sequence[TransformationNotificationWrite]) -> TransformationNotificationList:
|
|
642
685
|
return self.client.transformations.notifications.create(items)
|
|
643
686
|
|
|
644
687
|
def retrieve(self, ids: SequenceNotStr[str]) -> TransformationNotificationList:
|
|
@@ -669,7 +712,7 @@ class TransformationNotificationCRUD(
|
|
|
669
712
|
|
|
670
713
|
return retrieved
|
|
671
714
|
|
|
672
|
-
def update(self, items:
|
|
715
|
+
def update(self, items: Sequence[TransformationNotificationWrite]) -> TransformationNotificationList:
|
|
673
716
|
# Note that since a notification is identified by the combination of transformationExternalId and destination,
|
|
674
717
|
# which is the entire object, an update should never happen. However, implementing just in case.
|
|
675
718
|
item_by_id = {self.get_id(item): item for item in items}
|
|
@@ -22,24 +22,23 @@ from typing import Any, final
|
|
|
22
22
|
from cognite.client.data_classes import (
|
|
23
23
|
ClientCredentials,
|
|
24
24
|
Workflow,
|
|
25
|
-
WorkflowList,
|
|
26
25
|
WorkflowTrigger,
|
|
27
|
-
WorkflowTriggerList,
|
|
28
26
|
WorkflowTriggerUpsert,
|
|
29
|
-
WorkflowTriggerUpsertList,
|
|
30
27
|
WorkflowUpsert,
|
|
31
|
-
WorkflowUpsertList,
|
|
32
28
|
WorkflowVersion,
|
|
33
29
|
WorkflowVersionId,
|
|
34
|
-
WorkflowVersionList,
|
|
35
30
|
WorkflowVersionUpsert,
|
|
36
|
-
WorkflowVersionUpsertList,
|
|
37
31
|
)
|
|
38
32
|
from cognite.client.data_classes.capabilities import (
|
|
39
33
|
Capability,
|
|
40
34
|
WorkflowOrchestrationAcl,
|
|
41
35
|
)
|
|
42
|
-
from cognite.client.data_classes.workflows import
|
|
36
|
+
from cognite.client.data_classes.workflows import (
|
|
37
|
+
SubworkflowReferenceParameters,
|
|
38
|
+
WorkflowList,
|
|
39
|
+
WorkflowTriggerList,
|
|
40
|
+
WorkflowVersionList,
|
|
41
|
+
)
|
|
43
42
|
from cognite.client.exceptions import CogniteAuthError, CogniteNotFoundError
|
|
44
43
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
45
44
|
from rich import print
|
|
@@ -75,13 +74,10 @@ from .transformation import TransformationCRUD
|
|
|
75
74
|
|
|
76
75
|
|
|
77
76
|
@final
|
|
78
|
-
class WorkflowCRUD(ResourceCRUD[str, WorkflowUpsert, Workflow
|
|
77
|
+
class WorkflowCRUD(ResourceCRUD[str, WorkflowUpsert, Workflow]):
|
|
79
78
|
folder_name = "workflows"
|
|
80
|
-
filename_pattern = r"^.*Workflow$"
|
|
81
79
|
resource_cls = Workflow
|
|
82
80
|
resource_write_cls = WorkflowUpsert
|
|
83
|
-
list_cls = WorkflowList
|
|
84
|
-
list_write_cls = WorkflowUpsertList
|
|
85
81
|
kind = "Workflow"
|
|
86
82
|
dependencies = frozenset(
|
|
87
83
|
{
|
|
@@ -140,18 +136,14 @@ class WorkflowCRUD(ResourceCRUD[str, WorkflowUpsert, Workflow, WorkflowUpsertLis
|
|
|
140
136
|
dumped["dataSetExternalId"] = self.client.lookup.data_sets.external_id(data_set_id)
|
|
141
137
|
return dumped
|
|
142
138
|
|
|
143
|
-
def retrieve(self, ids: SequenceNotStr[str]) ->
|
|
139
|
+
def retrieve(self, ids: SequenceNotStr[str]) -> Sequence[Workflow]:
|
|
144
140
|
return self.client.workflows.retrieve(external_id=ids, ignore_unknown_ids=True)
|
|
145
141
|
|
|
146
|
-
def
|
|
147
|
-
|
|
148
|
-
return self.client.workflows.upsert(upserts)
|
|
142
|
+
def create(self, items: Sequence[WorkflowUpsert]) -> WorkflowList:
|
|
143
|
+
return self.client.workflows.upsert(items)
|
|
149
144
|
|
|
150
|
-
def
|
|
151
|
-
return self.
|
|
152
|
-
|
|
153
|
-
def update(self, items: WorkflowUpsertList) -> WorkflowList:
|
|
154
|
-
return self._upsert(items)
|
|
145
|
+
def update(self, items: Sequence[WorkflowUpsert]) -> WorkflowList:
|
|
146
|
+
return self.client.workflows.upsert(items)
|
|
155
147
|
|
|
156
148
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
157
149
|
successes = 0
|
|
@@ -192,17 +184,10 @@ class WorkflowCRUD(ResourceCRUD[str, WorkflowUpsert, Workflow, WorkflowUpsertLis
|
|
|
192
184
|
|
|
193
185
|
|
|
194
186
|
@final
|
|
195
|
-
class WorkflowVersionCRUD(
|
|
196
|
-
ResourceCRUD[
|
|
197
|
-
WorkflowVersionId, WorkflowVersionUpsert, WorkflowVersion, WorkflowVersionUpsertList, WorkflowVersionList
|
|
198
|
-
]
|
|
199
|
-
):
|
|
187
|
+
class WorkflowVersionCRUD(ResourceCRUD[WorkflowVersionId, WorkflowVersionUpsert, WorkflowVersion]):
|
|
200
188
|
folder_name = "workflows"
|
|
201
|
-
filename_pattern = r"^.*WorkflowVersion$"
|
|
202
189
|
resource_cls = WorkflowVersion
|
|
203
190
|
resource_write_cls = WorkflowVersionUpsert
|
|
204
|
-
list_cls = WorkflowVersionList
|
|
205
|
-
list_write_cls = WorkflowVersionUpsertList
|
|
206
191
|
kind = "WorkflowVersion"
|
|
207
192
|
dependencies = frozenset({WorkflowCRUD})
|
|
208
193
|
parent_resource = frozenset({WorkflowCRUD})
|
|
@@ -398,16 +383,16 @@ class WorkflowVersionCRUD(
|
|
|
398
383
|
return WorkflowVersionList([])
|
|
399
384
|
return self.client.workflows.versions.retrieve(workflow_external_id=list(ids), ignore_unknown_ids=True)
|
|
400
385
|
|
|
401
|
-
def _upsert(self, items:
|
|
386
|
+
def _upsert(self, items: Sequence[WorkflowVersionUpsert]) -> WorkflowVersionList:
|
|
402
387
|
return self.client.workflows.versions.upsert(items)
|
|
403
388
|
|
|
404
|
-
def create(self, items:
|
|
389
|
+
def create(self, items: Sequence[WorkflowVersionUpsert]) -> WorkflowVersionList:
|
|
405
390
|
upserted: list[WorkflowVersion] = []
|
|
406
391
|
for item in self.topological_sort(items):
|
|
407
392
|
upserted.extend(self.client.workflows.versions.upsert([item]))
|
|
408
393
|
return WorkflowVersionList(upserted)
|
|
409
394
|
|
|
410
|
-
def update(self, items:
|
|
395
|
+
def update(self, items: Sequence[WorkflowVersionUpsert]) -> WorkflowVersionList:
|
|
411
396
|
return self._upsert(items)
|
|
412
397
|
|
|
413
398
|
def delete(self, ids: SequenceNotStr[WorkflowVersionId]) -> int:
|
|
@@ -467,15 +452,10 @@ class WorkflowVersionCRUD(
|
|
|
467
452
|
|
|
468
453
|
|
|
469
454
|
@final
|
|
470
|
-
class WorkflowTriggerCRUD(
|
|
471
|
-
ResourceCRUD[str, WorkflowTriggerUpsert, WorkflowTrigger, WorkflowTriggerUpsertList, WorkflowTriggerList]
|
|
472
|
-
):
|
|
455
|
+
class WorkflowTriggerCRUD(ResourceCRUD[str, WorkflowTriggerUpsert, WorkflowTrigger]):
|
|
473
456
|
folder_name = "workflows"
|
|
474
|
-
filename_pattern = r"^.*WorkflowTrigger$"
|
|
475
457
|
resource_cls = WorkflowTrigger
|
|
476
458
|
resource_write_cls = WorkflowTriggerUpsert
|
|
477
|
-
list_cls = WorkflowTriggerList
|
|
478
|
-
list_write_cls = WorkflowTriggerUpsertList
|
|
479
459
|
kind = "WorkflowTrigger"
|
|
480
460
|
dependencies = frozenset({WorkflowCRUD, WorkflowVersionCRUD, GroupResourceScopedCRUD, GroupAllScopedCRUD})
|
|
481
461
|
parent_resource = frozenset({WorkflowCRUD})
|
|
@@ -522,10 +502,10 @@ class WorkflowTriggerCRUD(
|
|
|
522
502
|
WorkflowOrchestrationAcl.Scope.All(),
|
|
523
503
|
)
|
|
524
504
|
|
|
525
|
-
def create(self, items:
|
|
505
|
+
def create(self, items: Sequence[WorkflowTriggerUpsert]) -> WorkflowTriggerList:
|
|
526
506
|
return self._upsert(items)
|
|
527
507
|
|
|
528
|
-
def _upsert(self, items:
|
|
508
|
+
def _upsert(self, items: Sequence[WorkflowTriggerUpsert]) -> WorkflowTriggerList:
|
|
529
509
|
created = WorkflowTriggerList([])
|
|
530
510
|
for item in items:
|
|
531
511
|
created.append(self._upsert_item(item))
|
|
@@ -545,7 +525,7 @@ class WorkflowTriggerCRUD(
|
|
|
545
525
|
lookup = set(ids)
|
|
546
526
|
return WorkflowTriggerList([trigger for trigger in all_triggers if trigger.external_id in lookup])
|
|
547
527
|
|
|
548
|
-
def update(self, items:
|
|
528
|
+
def update(self, items: Sequence[WorkflowTriggerUpsert]) -> WorkflowTriggerList:
|
|
549
529
|
return self._upsert(items)
|
|
550
530
|
|
|
551
531
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import warnings
|
|
3
|
-
from collections.abc import Hashable
|
|
3
|
+
from collections.abc import Hashable, Sequence
|
|
4
4
|
from copy import deepcopy
|
|
5
|
-
from dataclasses import dataclass
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from typing import TYPE_CHECKING, Any, Generic, cast
|
|
8
8
|
|
|
@@ -14,39 +14,29 @@ from yaml import YAMLError
|
|
|
14
14
|
|
|
15
15
|
from cognite_toolkit._cdf_tk.constants import TABLE_FORMATS
|
|
16
16
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitWrongResourceError, ToolkitYAMLFormatError
|
|
17
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
17
18
|
from cognite_toolkit._cdf_tk.tk_warnings import EnvironmentVariableMissingWarning, catch_warnings
|
|
18
19
|
from cognite_toolkit._cdf_tk.utils import to_diff
|
|
19
20
|
|
|
20
21
|
from . import FunctionCRUD
|
|
21
|
-
from ._base_cruds import
|
|
22
|
-
T_ID,
|
|
23
|
-
ResourceCRUD,
|
|
24
|
-
T_ResourceRequest,
|
|
25
|
-
T_ResourceRequestList,
|
|
26
|
-
T_ResourceResponse,
|
|
27
|
-
T_ResourceResponseList,
|
|
28
|
-
)
|
|
22
|
+
from ._base_cruds import T_ID, ResourceCRUD, T_ResourceRequest, T_ResourceResponse
|
|
29
23
|
|
|
30
24
|
if TYPE_CHECKING:
|
|
31
25
|
from cognite_toolkit._cdf_tk.data_classes._module_directories import ReadModule
|
|
32
26
|
|
|
33
27
|
|
|
34
28
|
@dataclass
|
|
35
|
-
class CategorizedResources(Generic[T_ID,
|
|
36
|
-
to_create:
|
|
37
|
-
to_update:
|
|
38
|
-
to_delete: list[T_ID]
|
|
39
|
-
unchanged:
|
|
29
|
+
class CategorizedResources(Generic[T_ID, T_ResourceRequest]):
|
|
30
|
+
to_create: list[T_ResourceRequest] = field(default_factory=list)
|
|
31
|
+
to_update: list[T_ResourceRequest] = field(default_factory=list)
|
|
32
|
+
to_delete: list[T_ID] = field(default_factory=list)
|
|
33
|
+
unchanged: list[T_ResourceRequest] = field(default_factory=list)
|
|
40
34
|
|
|
41
35
|
|
|
42
|
-
class ResourceWorker(
|
|
43
|
-
Generic[T_ID, T_ResourceRequest, T_ResourceResponse, T_ResourceRequestList, T_ResourceResponseList]
|
|
44
|
-
):
|
|
36
|
+
class ResourceWorker(Generic[T_ID, T_ResourceRequest, T_ResourceResponse]):
|
|
45
37
|
def __init__(
|
|
46
38
|
self,
|
|
47
|
-
loader: ResourceCRUD[
|
|
48
|
-
T_ID, T_ResourceRequest, T_ResourceResponse, T_ResourceRequestList, T_ResourceResponseList
|
|
49
|
-
],
|
|
39
|
+
loader: ResourceCRUD[T_ID, T_ResourceRequest, T_ResourceResponse],
|
|
50
40
|
action: str,
|
|
51
41
|
):
|
|
52
42
|
self.loader = loader
|
|
@@ -58,12 +48,16 @@ class ResourceWorker(
|
|
|
58
48
|
) -> list[Path]:
|
|
59
49
|
filepaths = self.loader.find_files(directory)
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
if not Flags.v08.is_enabled():
|
|
52
|
+
for read_module in read_modules or []:
|
|
53
|
+
if resource_dir := read_module.resource_dir_path(self.loader.folder_name):
|
|
54
|
+
# As of 05/11/24, Asset support csv and parquet files in addition to YAML.
|
|
55
|
+
# These table formats are not built, i.e., no variable replacement is done,
|
|
56
|
+
# so we load them directly from the source module.
|
|
57
|
+
table_files = [
|
|
58
|
+
file for file in self.loader.find_files(resource_dir) if file.suffix in TABLE_FORMATS
|
|
59
|
+
]
|
|
60
|
+
filepaths.extend(table_files)
|
|
67
61
|
|
|
68
62
|
if not sort:
|
|
69
63
|
return filepaths
|
|
@@ -104,7 +98,6 @@ class ResourceWorker(
|
|
|
104
98
|
self.validate_access(local_by_id, is_dry_run)
|
|
105
99
|
|
|
106
100
|
# Lookup the existing resources in CDF
|
|
107
|
-
cdf_resources: T_ResourceResponseList
|
|
108
101
|
cdf_resources = self.loader.retrieve(list(local_by_id.keys()))
|
|
109
102
|
return self.categorize_resources(local_by_id, cdf_resources, force_update, verbose)
|
|
110
103
|
|
|
@@ -165,16 +158,11 @@ class ResourceWorker(
|
|
|
165
158
|
def categorize_resources(
|
|
166
159
|
self,
|
|
167
160
|
local_by_id: dict[T_ID, tuple[dict[str, Any], T_ResourceRequest]],
|
|
168
|
-
cdf_resources:
|
|
161
|
+
cdf_resources: Sequence[T_ResourceResponse],
|
|
169
162
|
force_update: bool,
|
|
170
163
|
verbose: bool,
|
|
171
|
-
) -> CategorizedResources[T_ID,
|
|
172
|
-
resources: CategorizedResources[T_ID,
|
|
173
|
-
to_create=self.loader.list_write_cls([]),
|
|
174
|
-
to_update=self.loader.list_write_cls([]),
|
|
175
|
-
to_delete=[],
|
|
176
|
-
unchanged=self.loader.list_write_cls([]),
|
|
177
|
-
)
|
|
164
|
+
) -> CategorizedResources[T_ID, T_ResourceRequest]:
|
|
165
|
+
resources: CategorizedResources[T_ID, T_ResourceRequest] = CategorizedResources()
|
|
178
166
|
cdf_resource_by_id = {self.loader.get_id(resource): resource for resource in cdf_resources}
|
|
179
167
|
for identifier, (local_dict, local_resource) in local_by_id.items():
|
|
180
168
|
cdf_resource = cdf_resource_by_id.get(identifier)
|
|
@@ -22,21 +22,13 @@ class Flags(Enum):
|
|
|
22
22
|
description="Enables the import sub application",
|
|
23
23
|
)
|
|
24
24
|
GRAPHQL = FlagMetadata(
|
|
25
|
-
visible=
|
|
25
|
+
visible=False,
|
|
26
26
|
description="Enables the support for deploying data models as GraphQL schemas",
|
|
27
27
|
)
|
|
28
28
|
MODULE_REPEAT = FlagMetadata(
|
|
29
29
|
visible=True,
|
|
30
30
|
description="Enables the support for repeating modules in the config file",
|
|
31
31
|
)
|
|
32
|
-
AGENTS = FlagMetadata(
|
|
33
|
-
visible=True,
|
|
34
|
-
description="Enables support for Atlas Agents and Agent Tools",
|
|
35
|
-
)
|
|
36
|
-
DUMP_EXTENDED = FlagMetadata(
|
|
37
|
-
visible=True,
|
|
38
|
-
description="Enables support for the dumping Location Filters.",
|
|
39
|
-
)
|
|
40
32
|
PROFILE = FlagMetadata(
|
|
41
33
|
visible=True,
|
|
42
34
|
description="Enables support for the profile command",
|
|
@@ -45,45 +37,29 @@ class Flags(Enum):
|
|
|
45
37
|
visible=True,
|
|
46
38
|
description="Enables support for Infield configs",
|
|
47
39
|
)
|
|
48
|
-
DUMP_DATA = FlagMetadata(
|
|
49
|
-
visible=True,
|
|
50
|
-
description="Splits the dump command in dump data and dump config",
|
|
51
|
-
)
|
|
52
|
-
EXIT_ON_WARNING = FlagMetadata(
|
|
53
|
-
visible=True,
|
|
54
|
-
description="Enables the exit on warning feature during the build command",
|
|
55
|
-
)
|
|
56
40
|
MIGRATE = FlagMetadata(
|
|
57
41
|
visible=True,
|
|
58
42
|
description="Enables the migrate command",
|
|
59
43
|
)
|
|
60
|
-
|
|
61
|
-
visible=True,
|
|
62
|
-
description="Enables the support for external libraries in the config file",
|
|
63
|
-
)
|
|
64
|
-
PURGE_INSTANCES = FlagMetadata(
|
|
44
|
+
STREAMS = FlagMetadata(
|
|
65
45
|
visible=True,
|
|
66
|
-
description="Enables the
|
|
46
|
+
description="Enables the support for the streams resources",
|
|
67
47
|
)
|
|
68
|
-
|
|
69
|
-
visible=
|
|
70
|
-
description="Enables
|
|
48
|
+
v08 = FlagMetadata(
|
|
49
|
+
visible=False,
|
|
50
|
+
description="Enables features planned for Cognite Toolkit version 0.8.0",
|
|
71
51
|
)
|
|
72
|
-
|
|
52
|
+
CREATE = FlagMetadata(
|
|
73
53
|
visible=True,
|
|
74
|
-
description="Enables the
|
|
54
|
+
description="Enables the support for the resources create command under dev plugin",
|
|
75
55
|
)
|
|
76
|
-
|
|
56
|
+
EXTEND_DOWNLOAD = FlagMetadata(
|
|
77
57
|
visible=True,
|
|
78
|
-
description="Enables
|
|
58
|
+
description="Enables extended download to support downloading file content and datapoints",
|
|
79
59
|
)
|
|
80
|
-
|
|
60
|
+
EXTEND_UPLOAD = FlagMetadata(
|
|
81
61
|
visible=True,
|
|
82
|
-
description="Enables
|
|
83
|
-
)
|
|
84
|
-
v07 = FlagMetadata(
|
|
85
|
-
visible=False,
|
|
86
|
-
description="Enables features planned for Cognite Toolkit version 0.7.0",
|
|
62
|
+
description="Enables extended upload to support uploading individual files",
|
|
87
63
|
)
|
|
88
64
|
|
|
89
65
|
def is_enabled(self) -> bool:
|
|
@@ -95,3 +71,7 @@ class FeatureFlag:
|
|
|
95
71
|
@lru_cache(typed=True)
|
|
96
72
|
def is_enabled(flag: Flags) -> bool:
|
|
97
73
|
return CDFToml.load().alpha_flags.get(clean_name(flag.name), False)
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def flush() -> None:
|
|
77
|
+
FeatureFlag.is_enabled.cache_clear()
|
|
@@ -17,7 +17,8 @@ class Plugin:
|
|
|
17
17
|
class Plugins(Enum):
|
|
18
18
|
run = Plugin("run", "plugin for Run command to execute Python scripts in CDF")
|
|
19
19
|
dump = Plugin("dump", "plugin for Dump command to retrieve Asset resources from CDF")
|
|
20
|
-
|
|
20
|
+
dev = Plugin("dev", "plugin for commands to develop modules in CDF")
|
|
21
|
+
data = Plugin("data", "plugin for Data command to manage data in CDF")
|
|
21
22
|
|
|
22
23
|
@staticmethod
|
|
23
24
|
def list() -> dict[str, bool]:
|
|
@@ -27,6 +27,7 @@ from .hosted_extractor_destination import HostedExtractorDestinationYAML
|
|
|
27
27
|
from .hosted_extractor_job import HostedExtractorJobYAML
|
|
28
28
|
from .hosted_extractor_mapping import HostedExtractorMappingYAML
|
|
29
29
|
from .hosted_extractor_source import HostedExtractorSourceYAML
|
|
30
|
+
from .infield_cdm_location_config import InFieldCDMLocationConfigYAML
|
|
30
31
|
from .infield_location_config import InfieldLocationConfigYAML
|
|
31
32
|
from .infield_v1 import InfieldV1YAML
|
|
32
33
|
from .instance import EdgeYAML, NodeYAML
|
|
@@ -41,6 +42,7 @@ from .securitycategories import SecurityCategoriesYAML
|
|
|
41
42
|
from .sequence import SequenceRowYAML, SequenceYAML
|
|
42
43
|
from .space import SpaceYAML
|
|
43
44
|
from .streamlit_ import StreamlitYAML
|
|
45
|
+
from .streams import StreamYAML
|
|
44
46
|
from .threedmodels import ThreeDModelYAML
|
|
45
47
|
from .timeseries import TimeSeriesYAML
|
|
46
48
|
from .transformation_notification import TransformationNotificationYAML
|
|
@@ -75,6 +77,7 @@ __all__ = [
|
|
|
75
77
|
"HostedExtractorJobYAML",
|
|
76
78
|
"HostedExtractorMappingYAML",
|
|
77
79
|
"HostedExtractorSourceYAML",
|
|
80
|
+
"InFieldCDMLocationConfigYAML",
|
|
78
81
|
"InfieldLocationConfigYAML",
|
|
79
82
|
"InfieldV1YAML",
|
|
80
83
|
"LabelsYAML",
|
|
@@ -92,6 +95,7 @@ __all__ = [
|
|
|
92
95
|
"SequenceRowYAML",
|
|
93
96
|
"SequenceYAML",
|
|
94
97
|
"SpaceYAML",
|
|
98
|
+
"StreamYAML",
|
|
95
99
|
"StreamlitYAML",
|
|
96
100
|
"TableYAML",
|
|
97
101
|
"ThreeDModelYAML",
|
|
@@ -510,6 +510,18 @@ class LegacyGenericsAcl(Capability):
|
|
|
510
510
|
scope: AllScope
|
|
511
511
|
|
|
512
512
|
|
|
513
|
+
class StreamsAcl(Capability):
|
|
514
|
+
_capability_name = "streamsAcl"
|
|
515
|
+
actions: list[Literal["READ", "CREATE", "DELETE"]]
|
|
516
|
+
scope: AllScope
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
class StreamRecordsAcl(Capability):
|
|
520
|
+
_capability_name = "streamRecordsAcl"
|
|
521
|
+
actions: list[Literal["READ", "WRITE"]]
|
|
522
|
+
scope: AllScope | SpaceIDScope
|
|
523
|
+
|
|
524
|
+
|
|
513
525
|
_CAPABILITY_CLASS_BY_NAME: MappingProxyType[str, type[Capability]] = MappingProxyType(
|
|
514
526
|
{c._capability_name: c for c in Capability.__subclasses__()}
|
|
515
527
|
)
|
|
@@ -44,7 +44,9 @@ class FunctionsYAML(ToolkitResource):
|
|
|
44
44
|
)
|
|
45
45
|
cpu: float | None = Field(default=None, description="Number of CPU cores per function.")
|
|
46
46
|
memory: float | None = Field(default=None, description="Memory per function measured in GB.")
|
|
47
|
-
runtime: Literal["py39", "py310", "py311"] | None = Field(
|
|
47
|
+
runtime: Literal["py39", "py310", "py311", "py312"] | None = Field(
|
|
48
|
+
default="py311", description="Runtime of the function."
|
|
49
|
+
)
|
|
48
50
|
metadata: dict[str, str] | None = Field(
|
|
49
51
|
default=None, description="Custom, application-specific metadata.", max_length=16
|
|
50
52
|
)
|