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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .base import BaseModelResource, ToolkitResource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FeatureToggles(BaseModelResource):
|
|
7
|
+
"""Feature toggles for InField location configuration."""
|
|
8
|
+
|
|
9
|
+
three_d: bool | None = None
|
|
10
|
+
trends: bool | None = None
|
|
11
|
+
documents: bool | None = None
|
|
12
|
+
workorders: bool | None = None
|
|
13
|
+
notifications: bool | None = None
|
|
14
|
+
media: bool | None = None
|
|
15
|
+
template_checklist_flow: bool | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AccessManagement(BaseModelResource):
|
|
19
|
+
"""Access management configuration."""
|
|
20
|
+
|
|
21
|
+
template_admins: list[str] | None = None # list of CDF group external IDs
|
|
22
|
+
checklist_admins: list[str] | None = None # list of CDF group external IDs
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DataFilterPath(BaseModelResource):
|
|
26
|
+
"""Path reference for data filters."""
|
|
27
|
+
|
|
28
|
+
space: str
|
|
29
|
+
external_id: str
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class DataFilter(BaseModelResource):
|
|
33
|
+
"""Data filter configuration for a resource type."""
|
|
34
|
+
|
|
35
|
+
path: DataFilterPath | None = None
|
|
36
|
+
instance_spaces: list[str] | None = None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class DataFilters(BaseModelResource):
|
|
40
|
+
"""Data filters configuration."""
|
|
41
|
+
|
|
42
|
+
files: DataFilter | None = None
|
|
43
|
+
assets: DataFilter | None = None
|
|
44
|
+
operations: DataFilter | None = None
|
|
45
|
+
time_series: DataFilter | None = None
|
|
46
|
+
notifications: DataFilter | None = None
|
|
47
|
+
maintenance_orders: DataFilter | None = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class DataStorage(BaseModelResource):
|
|
51
|
+
"""Data storage configuration."""
|
|
52
|
+
|
|
53
|
+
root_location: DataFilterPath | None = None
|
|
54
|
+
app_instance_space: str | None = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ViewMapping(BaseModelResource):
|
|
58
|
+
"""View mapping configuration."""
|
|
59
|
+
|
|
60
|
+
space: str
|
|
61
|
+
version: str
|
|
62
|
+
external_id: str
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ViewMappings(BaseModelResource):
|
|
66
|
+
"""View mappings configuration."""
|
|
67
|
+
|
|
68
|
+
asset: ViewMapping | None = None
|
|
69
|
+
operation: ViewMapping | None = None
|
|
70
|
+
notification: ViewMapping | None = None
|
|
71
|
+
maintenance_order: ViewMapping | None = None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Discipline(BaseModelResource):
|
|
75
|
+
"""Discipline configuration."""
|
|
76
|
+
|
|
77
|
+
name: str
|
|
78
|
+
external_id: str
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class InFieldCDMLocationConfigYAML(ToolkitResource):
|
|
82
|
+
"""Properties for InFieldCDMLocationConfig node.
|
|
83
|
+
|
|
84
|
+
Fields:
|
|
85
|
+
- space: The space of the InField CDM location configuration
|
|
86
|
+
- external_id: The external ID of the InField CDM location configuration
|
|
87
|
+
- name: The name of the location configuration
|
|
88
|
+
- description: The description of the location configuration
|
|
89
|
+
- feature_toggles: Feature toggles configuration
|
|
90
|
+
- access_management: Access management configuration
|
|
91
|
+
- data_filters: Data filters configuration for various resource types
|
|
92
|
+
- data_storage: Data storage configuration
|
|
93
|
+
- view_mappings: View mappings configuration
|
|
94
|
+
- disciplines: List of disciplines
|
|
95
|
+
- data_exploration_config: Data exploration configuration
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
space: str
|
|
99
|
+
external_id: str
|
|
100
|
+
|
|
101
|
+
name: str | None = None
|
|
102
|
+
description: str | None = None
|
|
103
|
+
feature_toggles: FeatureToggles | None = None
|
|
104
|
+
access_management: AccessManagement | None = None
|
|
105
|
+
data_filters: DataFilters | None = None
|
|
106
|
+
data_storage: DataStorage | None = None
|
|
107
|
+
view_mappings: ViewMappings | None = None
|
|
108
|
+
disciplines: list[Discipline] | None = None
|
|
109
|
+
data_exploration_config: dict[str, Any] | None = None
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import re
|
|
2
1
|
from typing import Literal
|
|
3
2
|
|
|
4
|
-
from pydantic import Field
|
|
3
|
+
from pydantic import Field
|
|
5
4
|
|
|
6
|
-
from cognite_toolkit._cdf_tk.
|
|
5
|
+
from cognite_toolkit._cdf_tk.constants import INSTANCE_EXTERNAL_ID_PATTERN
|
|
7
6
|
|
|
8
7
|
from .base import ToolkitResource
|
|
9
8
|
from .view_field_definitions import ViewReference
|
|
10
9
|
|
|
11
|
-
JSON_PATH_PATTERN = re.compile(
|
|
12
|
-
r"^([a-zA-Z_][a-zA-Z0-9_]*|\[\d+\])(\.[a-zA-Z_][a-zA-Z0-9_]*|\[\d+\]|\[\'[^\']*\'\]|\[\"[^\"]*\"\])*$"
|
|
13
|
-
)
|
|
14
|
-
|
|
15
10
|
|
|
16
11
|
class ResourceViewMappingYAML(ToolkitResource):
|
|
12
|
+
external_id: str = Field(
|
|
13
|
+
description="External-id of the mapping.",
|
|
14
|
+
min_length=1,
|
|
15
|
+
max_length=256,
|
|
16
|
+
pattern=INSTANCE_EXTERNAL_ID_PATTERN,
|
|
17
|
+
)
|
|
17
18
|
resource_type: Literal["asset", "event", "file", "timeSeries", "sequence", "assetAnnotation", "fileAnnotation"] = (
|
|
18
19
|
Field(
|
|
19
20
|
description="The type of the resource to map to the view.",
|
|
@@ -25,13 +26,3 @@ class ResourceViewMappingYAML(ToolkitResource):
|
|
|
25
26
|
property_mapping: dict[str, str] = Field(
|
|
26
27
|
description="A dictionary mapping from resource property to view property.",
|
|
27
28
|
)
|
|
28
|
-
|
|
29
|
-
@field_validator("property_mapping")
|
|
30
|
-
@classmethod
|
|
31
|
-
def validate_json_paths(cls, value: dict[str, str]) -> dict[str, str]:
|
|
32
|
-
if not isinstance(value, dict):
|
|
33
|
-
return value
|
|
34
|
-
not_matching_keys = [k for k in value.keys() if not re.match(JSON_PATH_PATTERN, k)]
|
|
35
|
-
if not_matching_keys:
|
|
36
|
-
raise ValueError(f"Invalid JSON paths: {humanize_collection(not_matching_keys)}")
|
|
37
|
-
return value
|
|
@@ -2,7 +2,7 @@ from typing import ClassVar
|
|
|
2
2
|
|
|
3
3
|
from pydantic import Field
|
|
4
4
|
|
|
5
|
-
from cognite_toolkit._cdf_tk.client.data_classes.search_config import SearchConfigWrite
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import SearchConfigWrite
|
|
6
6
|
|
|
7
7
|
from .base import BaseModelResource, ToolkitResource
|
|
8
8
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.constants import StreamTemplateName
|
|
6
|
+
|
|
7
|
+
from .base import BaseModelResource, ToolkitResource
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StreamSettings(BaseModelResource):
|
|
11
|
+
"""Stream settings resource class."""
|
|
12
|
+
|
|
13
|
+
template: dict[Literal["name"], StreamTemplateName] = Field(
|
|
14
|
+
description="Reference to a template which should be used to define initial settings for the stream."
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class StreamYAML(ToolkitResource):
|
|
19
|
+
"""Stream YAML resource class."""
|
|
20
|
+
|
|
21
|
+
external_id: str = Field(
|
|
22
|
+
description="The external ID of the stream.",
|
|
23
|
+
min_length=1,
|
|
24
|
+
max_length=100,
|
|
25
|
+
pattern="^[a-z]([a-z0-9_-]{0,98}[a-z0-9])?$",
|
|
26
|
+
)
|
|
27
|
+
settings: StreamSettings = Field(
|
|
28
|
+
description="Stream settings which should be applied to a stream.",
|
|
29
|
+
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from typing import Annotated, Literal
|
|
2
3
|
|
|
3
4
|
from cognite.client.data_classes import WorkflowVersionUpsert
|
|
4
5
|
from pydantic import Field, JsonValue
|
|
@@ -6,18 +7,141 @@ from pydantic import Field, JsonValue
|
|
|
6
7
|
from .base import BaseModelResource, ToolkitResource
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
class WorkflowVersionId(BaseModelResource):
|
|
11
|
+
workflow_external_id: str = Field(
|
|
12
|
+
max_length=255,
|
|
13
|
+
description="Identifier for a workflow. Must be unique for the project. No trailing or leading whitespace and no null characters allowed.",
|
|
14
|
+
)
|
|
15
|
+
version: str = Field(
|
|
16
|
+
max_length=255,
|
|
17
|
+
description="Identifier for a version. Must be unique for the workflow. No trailing or leading whitespace and no null characters allowed.",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CogniteFunctionRef(BaseModelResource):
|
|
22
|
+
external_id: str = Field(
|
|
23
|
+
description="The external id of the Cognite Function in the project. This can be either a function external ID or a reference like ${myTaskExternalId.output.someKey}"
|
|
24
|
+
)
|
|
25
|
+
data: str | JsonValue | None = Field(
|
|
26
|
+
None, description="Input data that will be passed to the Cognite Function. Limited to 100KB in size."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class FunctionTaskParameters(BaseModelResource):
|
|
31
|
+
function: CogniteFunctionRef
|
|
32
|
+
is_async_complete: bool = Field(
|
|
33
|
+
False, description="Defines if the execution of the task should be completed asynchronously."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class TransformationRef(BaseModelResource):
|
|
38
|
+
external_id: str = Field(
|
|
39
|
+
description="The external id of the Transformation in the project. This can be either a transformation external ID or a reference like ${myTaskExternalId.output.someKey}"
|
|
40
|
+
)
|
|
41
|
+
concurrency_policy: Literal["fail", "waitForCurrent", "restartAfterCurrent"] = Field(
|
|
42
|
+
"fail",
|
|
43
|
+
description="""Determines the behavior of the task if the Transformation is already running.
|
|
44
|
+
|
|
45
|
+
fail: The task fails if another instance of the Transformation is currently running.
|
|
46
|
+
waitForCurrent: The task will pause and wait for the already running Transformation to complete. Once completed, the task is completed. This mode is useful for preventing redundant Transformation runs.
|
|
47
|
+
restartAfterCurrent: The task waits for the ongoing Transformation to finish. After completion, the task restarts the Transformation. This mode ensures that the most recent data can be used by following tasks.""",
|
|
48
|
+
)
|
|
49
|
+
use_transformation_credentials: bool = Field(
|
|
50
|
+
False,
|
|
51
|
+
description="If set to true, the transformation will run using the client credentials configured on the transformation. If set to false, the transformation will run using the client credentials used to trigger the workflow.",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class TransformationTaskParameters(BaseModelResource):
|
|
56
|
+
transformation: TransformationRef
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CDFRequest(BaseModelResource):
|
|
60
|
+
resource_path: str = Field(
|
|
61
|
+
description="The path of the request. The path should be prefixed by {cluster}.cognitedata.com/api/v1/project/{project} based on the relevant cluster and project. It can also contain references like ${myTaskExternalId.output.someKey}"
|
|
62
|
+
)
|
|
63
|
+
method: Literal["POST", "GET", "PUT"] | str = Field(
|
|
64
|
+
description="The HTTP method of the request. It can also be a reference like ${myTaskExternalId.output.someKey}"
|
|
65
|
+
)
|
|
66
|
+
query_parameters: dict[str, JsonValue] | str | None = Field(
|
|
67
|
+
None,
|
|
68
|
+
description="The query parameters of the request. It can also be a reference like ${myTaskExternalId.output.someKey}",
|
|
69
|
+
)
|
|
70
|
+
body: JsonValue | str | None = Field(
|
|
71
|
+
None, description="The body of the request. It can also be a reference like ${myTaskExternalId.output.someKey}"
|
|
72
|
+
)
|
|
73
|
+
request_timeout_in_millis: float | str | None = Field(
|
|
74
|
+
None,
|
|
75
|
+
description="The timeout for the request in milliseconds. It can also be a reference like ${myTaskExternalId.output.someKey}",
|
|
76
|
+
)
|
|
77
|
+
cdf_version_header: Literal["alpha", "beta"] | str | None = Field(
|
|
78
|
+
None, description="The Cognite Data Fusion version header to use for the request."
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class CDFTaskParameters(BaseModelResource):
|
|
83
|
+
cdf_request: CDFRequest
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class DynamicRef(BaseModelResource):
|
|
87
|
+
tasks: str = Field(
|
|
88
|
+
description="A Reference is an expression that allows dynamically injecting input to a task during execution. References can be used to reference the input of the Workflow, the output of a previous task in the Workflow, or the input of a previous task in the Workflow. Note that the injected value must be valid in the context of the property it is injected into. Example Task reference: ${myTaskExternalId.output.someKey} Example Workflow input reference: ${workflow.input.myKey}"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class DynamicTaskParameters(BaseModelResource):
|
|
93
|
+
dynamic: DynamicRef = Field(description="Reference to another task to use as the definition for this task.")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class SubworkflowRef(BaseModelResource):
|
|
97
|
+
tasks: "WorkflowVersionId | list[Task]" = Field(
|
|
98
|
+
description="Reference to the subworkflow to execute. This can be either a reference to an existing workflow version or an inline definition of tasks."
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class SubworkflowTaskParameters(BaseModelResource):
|
|
103
|
+
subworkflow: SubworkflowRef = Field(description="Reference to the subworkflow to execute.")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class SimulatorInputUnit(BaseModelResource):
|
|
107
|
+
name: str = Field(description="Name of the unit.")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class SimulatorInput(BaseModelResource):
|
|
111
|
+
reference_id: str = Field(description="Reference id of the value to override.")
|
|
112
|
+
value: str | int | float | list[str] | list[int] | list[float] = Field(
|
|
113
|
+
description="Override the value used for a simulation run."
|
|
114
|
+
)
|
|
115
|
+
unit: SimulatorInputUnit | None = Field(None, description="Override the unit of the value")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class SimulationRef(BaseModelResource):
|
|
119
|
+
routine_external_id: str = Field(description="The external id of the routine to be executed.")
|
|
120
|
+
run_time: int | None = Field(
|
|
121
|
+
None,
|
|
122
|
+
description="Run time in milliseconds. Reference timestamp used for data pre-processing and data sampling.",
|
|
123
|
+
)
|
|
124
|
+
inputs: list[SimulatorInput] | None = Field(
|
|
125
|
+
None, description="List of inputs to be provided to the simulation.", max_length=200
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class SimulationTaskParameters(BaseModelResource):
|
|
130
|
+
simulation: SimulationRef = Field(description="Reference to the simulation to execute.")
|
|
131
|
+
|
|
132
|
+
|
|
9
133
|
class TaskId(BaseModelResource):
|
|
10
134
|
external_id: str = Field(
|
|
11
135
|
max_length=255, description="The external ID provided by the client. Must be unique for the resource type."
|
|
12
136
|
)
|
|
13
137
|
|
|
14
138
|
|
|
15
|
-
class TaskDefinition(BaseModelResource):
|
|
139
|
+
class TaskDefinition(BaseModelResource, ABC):
|
|
16
140
|
external_id: str = Field(
|
|
17
141
|
max_length=255,
|
|
18
142
|
description="Identifier for the task. Must be unique within the version. No trailing or leading whitespace and no null characters allowed.",
|
|
19
143
|
)
|
|
20
|
-
type:
|
|
144
|
+
type: str
|
|
21
145
|
name: str | None = Field(
|
|
22
146
|
default=None,
|
|
23
147
|
max_length=255,
|
|
@@ -28,7 +152,6 @@ class TaskDefinition(BaseModelResource):
|
|
|
28
152
|
max_length=500,
|
|
29
153
|
description="Description of the intention of the task",
|
|
30
154
|
)
|
|
31
|
-
parameters: JsonValue = Field()
|
|
32
155
|
retries: int = Field(
|
|
33
156
|
3,
|
|
34
157
|
ge=0,
|
|
@@ -52,13 +175,49 @@ class TaskDefinition(BaseModelResource):
|
|
|
52
175
|
)
|
|
53
176
|
|
|
54
177
|
|
|
178
|
+
class FunctionTask(TaskDefinition):
|
|
179
|
+
type: Literal["function"] = "function"
|
|
180
|
+
parameters: FunctionTaskParameters
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class TransformationTask(TaskDefinition):
|
|
184
|
+
type: Literal["transformation"] = "transformation"
|
|
185
|
+
parameters: TransformationTaskParameters
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class CDFTask(TaskDefinition):
|
|
189
|
+
type: Literal["cdfRequest"] = "cdfRequest"
|
|
190
|
+
parameters: CDFTaskParameters
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class DynamicTask(TaskDefinition):
|
|
194
|
+
type: Literal["dynamic"] = "dynamic"
|
|
195
|
+
parameters: DynamicTaskParameters
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class SubworkflowTask(TaskDefinition):
|
|
199
|
+
type: Literal["subworkflow"] = "subworkflow"
|
|
200
|
+
parameters: SubworkflowTaskParameters
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class SimulationTask(TaskDefinition):
|
|
204
|
+
type: Literal["simulation"] = "simulation"
|
|
205
|
+
parameters: SimulationTaskParameters
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Task = Annotated[
|
|
209
|
+
FunctionTask | TransformationTask | CDFTask | DynamicTask | SubworkflowTask | SimulationTask,
|
|
210
|
+
Field(discriminator="type"),
|
|
211
|
+
]
|
|
212
|
+
|
|
213
|
+
|
|
55
214
|
class WorkflowDefinition(BaseModelResource):
|
|
56
215
|
description: str | None = Field(
|
|
57
216
|
default=None,
|
|
58
217
|
max_length=500,
|
|
59
218
|
description="The description of the workflow version.",
|
|
60
219
|
)
|
|
61
|
-
tasks: list[
|
|
220
|
+
tasks: list[Task]
|
|
62
221
|
|
|
63
222
|
|
|
64
223
|
class WorkflowVersionYAML(ToolkitResource):
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
1
|
from cognite_toolkit._cdf_tk.utils._auxiliary import get_concrete_subclasses
|
|
4
|
-
from cognite_toolkit._cdf_tk.utils.fileio import COMPRESSION_BY_SUFFIX
|
|
5
2
|
|
|
6
|
-
from ._annotations import
|
|
3
|
+
from ._annotations import AnnotationIO
|
|
7
4
|
from ._applications import CanvasIO, ChartIO
|
|
8
5
|
from ._asset_centric import (
|
|
6
|
+
AssetCentricIO,
|
|
9
7
|
AssetIO,
|
|
10
|
-
BaseAssetCentricIO,
|
|
11
8
|
EventIO,
|
|
12
9
|
FileMetadataIO,
|
|
13
10
|
HierarchyIO,
|
|
@@ -25,6 +22,7 @@ from ._base import (
|
|
|
25
22
|
)
|
|
26
23
|
from ._data_classes import InstanceIdCSVList, InstanceIdRow, ModelList
|
|
27
24
|
from ._datapoints import DatapointsIO
|
|
25
|
+
from ._file_content import FileContentIO
|
|
28
26
|
from ._instances import InstanceIO
|
|
29
27
|
from ._raw import RawIO
|
|
30
28
|
from .selectors._base import DataSelector
|
|
@@ -34,33 +32,24 @@ STORAGE_IO_CLASSES = get_concrete_subclasses(StorageIO) # type: ignore[type-abs
|
|
|
34
32
|
UPLOAD_IO_CLASSES = get_concrete_subclasses(UploadableStorageIO) # type: ignore[type-abstract]
|
|
35
33
|
|
|
36
34
|
|
|
37
|
-
def get_upload_io(
|
|
35
|
+
def get_upload_io(selector: DataSelector) -> type[UploadableStorageIO]:
|
|
38
36
|
"""Get the appropriate UploadableStorageIO class based on the type of the provided selector."""
|
|
39
37
|
for cls in UPLOAD_IO_CLASSES:
|
|
40
|
-
if
|
|
38
|
+
if isinstance(selector, cls.BASE_SELECTOR) and selector.kind == cls.KIND:
|
|
41
39
|
return cls
|
|
42
|
-
raise ValueError(f"No UploadableStorageIO found for selector of type {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def are_same_kind(kind: str, kind_or_path: str | Path, /) -> bool:
|
|
46
|
-
"""Check if two kinds are the same, ignoring case and compression suffixes."""
|
|
47
|
-
if not isinstance(kind_or_path, Path):
|
|
48
|
-
return kind.casefold() == kind_or_path.casefold()
|
|
49
|
-
stem = kind_or_path.stem
|
|
50
|
-
if kind_or_path.suffix in COMPRESSION_BY_SUFFIX:
|
|
51
|
-
stem = Path(stem).stem
|
|
52
|
-
return stem.lower().endswith(kind.casefold())
|
|
40
|
+
raise ValueError(f"No UploadableStorageIO found for selector of type {type(selector).__name__}")
|
|
53
41
|
|
|
54
42
|
|
|
55
43
|
__all__ = [
|
|
44
|
+
"AnnotationIO",
|
|
45
|
+
"AssetCentricIO",
|
|
56
46
|
"AssetIO",
|
|
57
|
-
"BaseAssetCentricIO",
|
|
58
47
|
"CanvasIO",
|
|
59
48
|
"ChartIO",
|
|
60
49
|
"ConfigurableStorageIO",
|
|
61
50
|
"DatapointsIO",
|
|
62
51
|
"EventIO",
|
|
63
|
-
"
|
|
52
|
+
"FileContentIO",
|
|
64
53
|
"FileMetadataIO",
|
|
65
54
|
"HierarchyIO",
|
|
66
55
|
"InstanceIO",
|
|
@@ -76,6 +65,5 @@ __all__ = [
|
|
|
76
65
|
"TimeSeriesIO",
|
|
77
66
|
"UploadItem",
|
|
78
67
|
"UploadableStorageIO",
|
|
79
|
-
"are_same_kind",
|
|
80
68
|
"get_upload_io",
|
|
81
69
|
]
|
|
@@ -11,7 +11,7 @@ from ._base import Page, StorageIO
|
|
|
11
11
|
from .selectors import AssetCentricSelector
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class AnnotationIO(StorageIO[AssetCentricSelector, Annotation]):
|
|
15
15
|
SUPPORTED_DOWNLOAD_FORMATS = frozenset({".ndjson"})
|
|
16
16
|
SUPPORTED_COMPRESSIONS = frozenset({".gz"})
|
|
17
17
|
CHUNK_SIZE = 1000
|
|
@@ -23,24 +23,27 @@ class FileAnnotationIO(StorageIO[AssetCentricSelector, Annotation]):
|
|
|
23
23
|
project = item._cognite_client.config.project
|
|
24
24
|
return f"INTERNAL_ID_project_{project}_{item.id!s}"
|
|
25
25
|
|
|
26
|
-
def stream_data(self, selector: AssetCentricSelector, limit: int | None = None) -> Iterable[Page]:
|
|
26
|
+
def stream_data(self, selector: AssetCentricSelector, limit: int | None = None) -> Iterable[Page[Annotation]]:
|
|
27
27
|
total = 0
|
|
28
28
|
for file_chunk in FileMetadataIO(self.client).stream_data(selector, None):
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
for annotation_type in ["diagrams.AssetLink", "diagrams.FileLink"]:
|
|
30
|
+
# Todo Support pagination. This is missing in the SDK.
|
|
31
|
+
results = self.client.annotations.list(
|
|
32
|
+
filter=AnnotationFilter(
|
|
33
|
+
annotated_resource_type="file",
|
|
34
|
+
annotated_resource_ids=[{"id": file_metadata.id} for file_metadata in file_chunk.items],
|
|
35
|
+
annotation_type=annotation_type,
|
|
36
|
+
),
|
|
37
|
+
limit=-1,
|
|
34
38
|
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
total
|
|
42
|
-
|
|
43
|
-
break
|
|
39
|
+
if limit is not None and total + len(results) > limit:
|
|
40
|
+
results = results[: limit - total]
|
|
41
|
+
|
|
42
|
+
for chunk in chunker_sequence(results, self.CHUNK_SIZE):
|
|
43
|
+
yield Page(worker_id="main", items=chunk)
|
|
44
|
+
total += len(chunk)
|
|
45
|
+
if limit is not None and total >= limit:
|
|
46
|
+
break
|
|
44
47
|
|
|
45
48
|
def count(self, selector: AssetCentricSelector) -> int | None:
|
|
46
49
|
"""There is no efficient way to count annotations in CDF."""
|