cognite-toolkit 0.7.30__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 +5 -6
- cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +7 -1
- cognite_toolkit/_cdf_tk/apps/_download_app.py +2 -2
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +177 -2
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +9 -9
- cognite_toolkit/_cdf_tk/client/api/infield.py +38 -33
- 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} +9 -9
- 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 +2 -3
- 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 +21 -17
- cognite_toolkit/_cdf_tk/client/api/three_d.py +343 -9
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +12 -32
- 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} +1 -1
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +65 -0
- cognite_toolkit/_cdf_tk/client/testing.py +24 -16
- cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +8 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +35 -4
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +149 -14
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +19 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +220 -3
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +9 -11
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +1 -1
- 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/dump_resource.py +4 -4
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +2 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +22 -20
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +14 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +49 -14
- cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
- cognite_toolkit/_cdf_tk/storageio/_applications.py +2 -2
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +1 -2
- cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +10 -1
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_client.py +3 -2
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +6 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +67 -7
- cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +51 -4
- cognite_toolkit/_cdf_tk/validation.py +4 -0
- 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.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/RECORD +119 -113
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/WHEEL +1 -1
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- /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/{charts.py → legacy/charts.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/{migration.py → legacy/migration.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
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/entry_points.txt +0 -0
|
@@ -12,17 +12,27 @@ from cognite.client.testing import CogniteClientMock
|
|
|
12
12
|
from rich.console import Console
|
|
13
13
|
|
|
14
14
|
from cognite_toolkit._cdf_tk.client._toolkit_client import ToolkitClient
|
|
15
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.canvas import CanvasAPI, IndustrialCanvasAPI
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.charts import ChartsAPI
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.dml import DMLAPI
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_data_modeling import ExtendedInstancesAPI
|
|
19
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_files import ExtendedFileMetadataAPI
|
|
20
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_functions import ExtendedFunctionsAPI
|
|
21
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_raw import ExtendedRawAPI
|
|
22
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_timeseries import ExtendedTimeSeriesAPI
|
|
23
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.location_filters import LocationFiltersAPI
|
|
24
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.robotics import (
|
|
25
|
+
CapabilitiesAPI,
|
|
26
|
+
DataPostProcessingAPI,
|
|
27
|
+
FramesAPI,
|
|
28
|
+
MapsAPI,
|
|
29
|
+
RoboticsAPI,
|
|
30
|
+
)
|
|
31
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.robotics import LocationsAPI as RoboticsLocationsAPI
|
|
32
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.search_config import SearchConfigurationsAPI
|
|
15
33
|
|
|
16
|
-
from .
|
|
17
|
-
from .api.charts import ChartsAPI
|
|
18
|
-
from .api.dml import DMLAPI
|
|
19
|
-
from .api.extended_data_modeling import ExtendedInstancesAPI
|
|
20
|
-
from .api.extended_files import ExtendedFileMetadataAPI
|
|
21
|
-
from .api.extended_functions import ExtendedFunctionsAPI
|
|
22
|
-
from .api.extended_raw import ExtendedRawAPI
|
|
23
|
-
from .api.extended_timeseries import ExtendedTimeSeriesAPI
|
|
34
|
+
from ._toolkit_client import ToolAPI
|
|
24
35
|
from .api.infield import InfieldAPI, InFieldCDMConfigAPI, InfieldConfigAPI
|
|
25
|
-
from .api.location_filters import LocationFiltersAPI
|
|
26
36
|
from .api.lookup import (
|
|
27
37
|
AssetLookUpAPI,
|
|
28
38
|
DataSetLookUpAPI,
|
|
@@ -44,15 +54,9 @@ from .api.migration import (
|
|
|
44
54
|
ResourceViewMappingAPI,
|
|
45
55
|
)
|
|
46
56
|
from .api.project import ProjectAPI
|
|
47
|
-
from .api.robotics import RoboticsAPI
|
|
48
|
-
from .api.robotics.capabilities import CapabilitiesAPI
|
|
49
|
-
from .api.robotics.data_postprocessing import DataPostProcessingAPI
|
|
50
|
-
from .api.robotics.frames import FramesAPI
|
|
51
|
-
from .api.robotics.locations import LocationsAPI as RoboticsLocationsAPI
|
|
52
|
-
from .api.robotics.maps import MapsAPI
|
|
53
57
|
from .api.search import SearchAPI
|
|
54
|
-
from .api.search_config import SearchConfigurationsAPI
|
|
55
58
|
from .api.streams import StreamsAPI
|
|
59
|
+
from .api.three_d import ThreeDAPI, ThreeDModelAPI
|
|
56
60
|
from .api.token import TokenAPI
|
|
57
61
|
from .api.verify import VerifyAPI
|
|
58
62
|
|
|
@@ -131,6 +135,10 @@ class ToolkitClientMock(CogniteClientMock):
|
|
|
131
135
|
self.time_series.data.synthetic = MagicMock(spec_set=SyntheticDatapointsAPI)
|
|
132
136
|
self.time_series.subscriptions = MagicMock(spec_set=DatapointsSubscriptionAPI)
|
|
133
137
|
|
|
138
|
+
self.tool = MagicMock(spec=ToolAPI)
|
|
139
|
+
self.tool.three_d = MagicMock(spec=ThreeDAPI)
|
|
140
|
+
self.tool.three_d.models = MagicMock(spec_set=ThreeDModelAPI)
|
|
141
|
+
|
|
134
142
|
self.streams = MagicMock(spec=StreamsAPI)
|
|
135
143
|
|
|
136
144
|
# This is a helper API, not a real API.
|
|
@@ -9,13 +9,14 @@ from cognite.client.data_classes.data_modeling import (
|
|
|
9
9
|
MappedProperty,
|
|
10
10
|
NodeApply,
|
|
11
11
|
NodeId,
|
|
12
|
+
ViewId,
|
|
12
13
|
)
|
|
13
14
|
from cognite.client.data_classes.data_modeling.instances import EdgeApply, NodeOrEdgeData, PropertyValueWrite
|
|
14
15
|
from cognite.client.data_classes.data_modeling.views import ViewProperty
|
|
15
16
|
from cognite.client.utils._identifier import InstanceId
|
|
16
17
|
|
|
17
18
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
18
|
-
from cognite_toolkit._cdf_tk.client.data_classes.migration import (
|
|
19
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import (
|
|
19
20
|
AssetCentricId,
|
|
20
21
|
ResourceViewMappingApply,
|
|
21
22
|
)
|
|
@@ -29,7 +30,7 @@ from cognite_toolkit._cdf_tk.utils.useful_types import (
|
|
|
29
30
|
AssetCentricTypeExtended,
|
|
30
31
|
)
|
|
31
32
|
|
|
32
|
-
from .data_model import INSTANCE_SOURCE_VIEW_ID
|
|
33
|
+
from .data_model import COGNITE_MIGRATION_SPACE_ID, INSTANCE_SOURCE_VIEW_ID
|
|
33
34
|
from .issues import ConversionIssue, FailedConversion, InvalidPropertyDataType
|
|
34
35
|
|
|
35
36
|
|
|
@@ -169,6 +170,7 @@ def asset_centric_to_dm(
|
|
|
169
170
|
view_source: ResourceViewMappingApply,
|
|
170
171
|
view_properties: dict[str, ViewProperty],
|
|
171
172
|
direct_relation_cache: DirectRelationCache,
|
|
173
|
+
preferred_consumer_view: ViewId | None = None,
|
|
172
174
|
) -> tuple[NodeApply | EdgeApply | None, ConversionIssue]:
|
|
173
175
|
"""Convert an asset-centric resource to a data model instance.
|
|
174
176
|
|
|
@@ -178,6 +180,7 @@ def asset_centric_to_dm(
|
|
|
178
180
|
view_source (ResourceViewMappingApply): The view source defining how to map the resource to the data model.
|
|
179
181
|
view_properties (dict[str, ViewProperty]): The defined properties referenced in the view source mapping.
|
|
180
182
|
direct_relation_cache (DirectRelationCache): Cache for direct relation references.
|
|
183
|
+
preferred_consumer_view (ViewId | None): The preferred consumer view for the instance.
|
|
181
184
|
|
|
182
185
|
Returns:
|
|
183
186
|
tuple[NodeApply | EdgeApply, ConversionIssue]: A tuple containing the converted NodeApply and any ConversionIssue encountered.
|
|
@@ -213,7 +216,10 @@ def asset_centric_to_dm(
|
|
|
213
216
|
"id": id_,
|
|
214
217
|
"dataSetId": data_set_id,
|
|
215
218
|
"classicExternalId": external_id,
|
|
219
|
+
"resourceViewMapping": {"space": COGNITE_MIGRATION_SPACE_ID, "externalId": view_source.external_id},
|
|
216
220
|
}
|
|
221
|
+
if preferred_consumer_view:
|
|
222
|
+
instance_source_properties["preferredConsumerViewId"] = preferred_consumer_view.dump()
|
|
217
223
|
sources.append(NodeOrEdgeData(source=INSTANCE_SOURCE_VIEW_ID, properties=instance_source_properties))
|
|
218
224
|
|
|
219
225
|
instance: NodeApply | EdgeApply
|
|
@@ -20,7 +20,7 @@ from cognite.client.data_classes.documents import SourceFileProperty
|
|
|
20
20
|
from cognite.client.data_classes.events import EventProperty
|
|
21
21
|
|
|
22
22
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
23
|
-
from cognite_toolkit._cdf_tk.client.data_classes.apm_config_v1 import APMConfig, APMConfigList
|
|
23
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.apm_config_v1 import APMConfig, APMConfigList
|
|
24
24
|
from cognite_toolkit._cdf_tk.cruds import NodeCRUD, ResourceCRUD, SpaceCRUD
|
|
25
25
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitMissingResourceError, ToolkitRequiredValueError
|
|
26
26
|
from cognite_toolkit._cdf_tk.utils import humanize_collection
|
|
@@ -9,11 +9,13 @@ from cognite.client.data_classes._base import (
|
|
|
9
9
|
from cognite.client.data_classes.data_modeling import EdgeId, InstanceApply, NodeId, ViewId
|
|
10
10
|
from cognite.client.utils._identifier import InstanceId
|
|
11
11
|
from cognite.client.utils._text import to_camel_case
|
|
12
|
-
from pydantic import BaseModel, BeforeValidator, field_validator, model_validator
|
|
12
|
+
from pydantic import BaseModel, BeforeValidator, Field, field_validator, model_validator
|
|
13
13
|
|
|
14
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
15
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
16
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
14
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import BaseModelObject, RequestResource
|
|
15
|
+
from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceIdentifier
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.instances import InstanceApplyList
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import AssetCentricId
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.pending_instances_ids import PendingInstanceId
|
|
17
19
|
from cognite_toolkit._cdf_tk.commands._migrate.default_mappings import (
|
|
18
20
|
ASSET_ANNOTATIONS_ID,
|
|
19
21
|
FILE_ANNOTATIONS_ID,
|
|
@@ -261,3 +263,32 @@ class AssetCentricMappingList(
|
|
|
261
263
|
|
|
262
264
|
def as_write(self) -> InstanceApplyList:
|
|
263
265
|
return InstanceApplyList([item.as_write() for item in self])
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
class Model(BaseModelObject):
|
|
269
|
+
instance_id: InstanceIdentifier
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class Thumbnail(BaseModelObject):
|
|
273
|
+
instance_id: InstanceIdentifier
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
class ThreeDRevisionMigrationRequest(RequestResource):
|
|
277
|
+
space: str
|
|
278
|
+
type: Literal["CAD", "PointCloud", "Image360"]
|
|
279
|
+
revision_id: int
|
|
280
|
+
model: Model
|
|
281
|
+
|
|
282
|
+
def as_id(self) -> int:
|
|
283
|
+
return self.revision_id
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class ThreeDMigrationRequest(RequestResource):
|
|
287
|
+
model_id: int
|
|
288
|
+
type: Literal["CAD", "PointCloud", "Image360"]
|
|
289
|
+
space: str
|
|
290
|
+
thumbnail: Thumbnail | None = None
|
|
291
|
+
revision: ThreeDRevisionMigrationRequest = Field(exclude=True)
|
|
292
|
+
|
|
293
|
+
def as_id(self) -> int:
|
|
294
|
+
return self.model_id
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from collections import defaultdict
|
|
3
3
|
from collections.abc import Callable, Sequence
|
|
4
|
-
from typing import Generic, cast
|
|
4
|
+
from typing import Generic, Literal, cast
|
|
5
5
|
from uuid import uuid4
|
|
6
6
|
|
|
7
7
|
from cognite.client.data_classes.data_modeling import (
|
|
@@ -15,38 +15,51 @@ from cognite.client.data_classes.data_modeling import (
|
|
|
15
15
|
from cognite.client.exceptions import CogniteException
|
|
16
16
|
|
|
17
17
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
18
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.data_classes.charts_data import (
|
|
19
|
+
ChartCoreTimeseries,
|
|
20
|
+
ChartSource,
|
|
21
|
+
ChartTimeseries,
|
|
22
|
+
)
|
|
23
|
+
from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceIdentifier
|
|
24
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.canvas import (
|
|
19
25
|
ContainerReferenceApply,
|
|
20
26
|
FdmInstanceContainerReferenceApply,
|
|
21
27
|
IndustrialCanvas,
|
|
22
28
|
IndustrialCanvasApply,
|
|
23
29
|
)
|
|
24
|
-
from cognite_toolkit._cdf_tk.client.data_classes.charts import Chart, ChartWrite
|
|
25
|
-
from cognite_toolkit._cdf_tk.client.data_classes.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.charts import Chart, ChartWrite
|
|
31
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import ResourceViewMappingApply
|
|
32
|
+
from cognite_toolkit._cdf_tk.client.data_classes.three_d import (
|
|
33
|
+
AssetMappingDMRequest,
|
|
34
|
+
AssetMappingResponse,
|
|
35
|
+
NodeReference,
|
|
36
|
+
RevisionStatus,
|
|
37
|
+
ThreeDModelResponse,
|
|
29
38
|
)
|
|
30
|
-
from cognite_toolkit._cdf_tk.client.data_classes.migration import ResourceViewMappingApply
|
|
31
39
|
from cognite_toolkit._cdf_tk.commands._migrate.conversion import DirectRelationCache, asset_centric_to_dm
|
|
32
|
-
from cognite_toolkit._cdf_tk.commands._migrate.data_classes import
|
|
40
|
+
from cognite_toolkit._cdf_tk.commands._migrate.data_classes import (
|
|
41
|
+
Model,
|
|
42
|
+
ThreeDMigrationRequest,
|
|
43
|
+
ThreeDRevisionMigrationRequest,
|
|
44
|
+
)
|
|
33
45
|
from cognite_toolkit._cdf_tk.commands._migrate.default_mappings import create_default_mappings
|
|
34
46
|
from cognite_toolkit._cdf_tk.commands._migrate.issues import (
|
|
35
47
|
CanvasMigrationIssue,
|
|
36
48
|
ChartMigrationIssue,
|
|
37
49
|
ConversionIssue,
|
|
38
50
|
MigrationIssue,
|
|
51
|
+
ThreeDModelMigrationIssue,
|
|
39
52
|
)
|
|
40
|
-
from cognite_toolkit._cdf_tk.commands._migrate.selectors import AssetCentricMigrationSelector
|
|
41
53
|
from cognite_toolkit._cdf_tk.constants import MISSING_INSTANCE_SPACE
|
|
42
54
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitMigrationError, ToolkitValueError
|
|
43
55
|
from cognite_toolkit._cdf_tk.protocols import T_ResourceRequest, T_ResourceResponse
|
|
44
56
|
from cognite_toolkit._cdf_tk.storageio._base import T_Selector
|
|
45
|
-
from cognite_toolkit._cdf_tk.storageio.selectors import CanvasSelector, ChartSelector
|
|
57
|
+
from cognite_toolkit._cdf_tk.storageio.selectors import CanvasSelector, ChartSelector, ThreeDSelector
|
|
46
58
|
from cognite_toolkit._cdf_tk.utils import humanize_collection
|
|
47
|
-
from cognite_toolkit._cdf_tk.utils.useful_types import
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
from cognite_toolkit._cdf_tk.utils.useful_types import T_AssetCentricResourceExtended
|
|
60
|
+
|
|
61
|
+
from .data_classes import AssetCentricMapping
|
|
62
|
+
from .selectors import AssetCentricMigrationSelector
|
|
50
63
|
|
|
51
64
|
|
|
52
65
|
class DataMapper(Generic[T_Selector, T_ResourceResponse, T_ResourceRequest], ABC):
|
|
@@ -134,6 +147,7 @@ class AssetCentricMapper(
|
|
|
134
147
|
view_source=view_source,
|
|
135
148
|
view_properties=view_properties,
|
|
136
149
|
direct_relation_cache=self._direct_relation_cache,
|
|
150
|
+
preferred_consumer_view=mapping.preferred_consumer_view,
|
|
137
151
|
)
|
|
138
152
|
if mapping.instance_id.space == MISSING_INSTANCE_SPACE:
|
|
139
153
|
conversion_issue.missing_instance_space = f"Missing instance space for dataset ID {mapping.data_set_id!r}"
|
|
@@ -383,3 +397,124 @@ class CanvasMapper(DataMapper[CanvasSelector, IndustrialCanvas, IndustrialCanvas
|
|
|
383
397
|
max_width=reference.max_width,
|
|
384
398
|
max_height=reference.max_height,
|
|
385
399
|
)
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
class ThreeDMapper(DataMapper[ThreeDSelector, ThreeDModelResponse, ThreeDMigrationRequest]):
|
|
403
|
+
def __init__(self, client: ToolkitClient) -> None:
|
|
404
|
+
self.client = client
|
|
405
|
+
|
|
406
|
+
def map(
|
|
407
|
+
self, source: Sequence[ThreeDModelResponse]
|
|
408
|
+
) -> Sequence[tuple[ThreeDMigrationRequest | None, MigrationIssue]]:
|
|
409
|
+
self._populate_cache(source)
|
|
410
|
+
output: list[tuple[ThreeDMigrationRequest | None, MigrationIssue]] = []
|
|
411
|
+
for item in source:
|
|
412
|
+
mapped_item, issue = self._map_single_item(item)
|
|
413
|
+
output.append((mapped_item, issue))
|
|
414
|
+
return output
|
|
415
|
+
|
|
416
|
+
def _populate_cache(self, source: Sequence[ThreeDModelResponse]) -> None:
|
|
417
|
+
dataset_ids: set[int] = set()
|
|
418
|
+
for model in source:
|
|
419
|
+
if model.data_set_id is not None:
|
|
420
|
+
dataset_ids.add(model.data_set_id)
|
|
421
|
+
self.client.migration.space_source.retrieve(list(dataset_ids))
|
|
422
|
+
|
|
423
|
+
def _map_single_item(
|
|
424
|
+
self, item: ThreeDModelResponse
|
|
425
|
+
) -> tuple[ThreeDMigrationRequest | None, ThreeDModelMigrationIssue]:
|
|
426
|
+
issue = ThreeDModelMigrationIssue(model_name=item.name, model_id=item.id)
|
|
427
|
+
instance_space: str | None = None
|
|
428
|
+
last_revision_id: int | None = None
|
|
429
|
+
model_type: Literal["CAD", "PointCloud", "Image360"] | None = None
|
|
430
|
+
if item.data_set_id is None:
|
|
431
|
+
issue.error_message.append("3D model is not associated with any dataset.")
|
|
432
|
+
else:
|
|
433
|
+
space_source = self.client.migration.space_source.retrieve(item.data_set_id)
|
|
434
|
+
if space_source is not None:
|
|
435
|
+
instance_space = space_source.instance_space
|
|
436
|
+
if instance_space is None and item.data_set_id is not None:
|
|
437
|
+
issue.error_message.append(f"Missing instance space for dataset ID {item.data_set_id!r}")
|
|
438
|
+
if item.last_revision_info is None:
|
|
439
|
+
issue.error_message.append("3D model has no revisions.")
|
|
440
|
+
else:
|
|
441
|
+
model_type = self._get_type(item.last_revision_info)
|
|
442
|
+
last_revision_id = item.last_revision_info.revision_id
|
|
443
|
+
if last_revision_id is None:
|
|
444
|
+
issue.error_message.append("3D model's last revision has no revision ID.")
|
|
445
|
+
|
|
446
|
+
if model_type is None:
|
|
447
|
+
issue.error_message.append("3D model's last revision has no recognized type.")
|
|
448
|
+
|
|
449
|
+
if instance_space is None or last_revision_id is None or model_type is None or issue.has_issues:
|
|
450
|
+
return None, issue
|
|
451
|
+
|
|
452
|
+
mapped_request = ThreeDMigrationRequest(
|
|
453
|
+
modelId=item.id,
|
|
454
|
+
type=model_type,
|
|
455
|
+
space=instance_space,
|
|
456
|
+
revision=ThreeDRevisionMigrationRequest(
|
|
457
|
+
space=instance_space,
|
|
458
|
+
type=model_type,
|
|
459
|
+
revisionId=last_revision_id,
|
|
460
|
+
model=Model(
|
|
461
|
+
instanceId=InstanceIdentifier(
|
|
462
|
+
space=instance_space,
|
|
463
|
+
external_id=f"cog_3d_model_{item.id!s}",
|
|
464
|
+
)
|
|
465
|
+
),
|
|
466
|
+
),
|
|
467
|
+
)
|
|
468
|
+
return mapped_request, issue
|
|
469
|
+
|
|
470
|
+
@staticmethod
|
|
471
|
+
def _get_type(revision: RevisionStatus) -> Literal["CAD", "PointCloud", "Image360"] | None:
|
|
472
|
+
types = revision.types or []
|
|
473
|
+
if any("gltf-directory" in t for t in types):
|
|
474
|
+
return "CAD"
|
|
475
|
+
elif any("ept-pointcloud" in t for t in types):
|
|
476
|
+
return "PointCloud"
|
|
477
|
+
else:
|
|
478
|
+
return None
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
class ThreeDAssetMapper(DataMapper[ThreeDSelector, AssetMappingResponse, AssetMappingDMRequest]):
|
|
482
|
+
def __init__(self, client: ToolkitClient) -> None:
|
|
483
|
+
self.client = client
|
|
484
|
+
|
|
485
|
+
def map(
|
|
486
|
+
self, source: Sequence[AssetMappingResponse]
|
|
487
|
+
) -> Sequence[tuple[AssetMappingDMRequest | None, MigrationIssue]]:
|
|
488
|
+
output: list[tuple[AssetMappingDMRequest | None, MigrationIssue]] = []
|
|
489
|
+
self._populate_cache(source)
|
|
490
|
+
for item in source:
|
|
491
|
+
mapped_item, issue = self._map_single_item(item)
|
|
492
|
+
output.append((mapped_item, issue))
|
|
493
|
+
return output
|
|
494
|
+
|
|
495
|
+
def _populate_cache(self, source: Sequence[AssetMappingResponse]) -> None:
|
|
496
|
+
asset_ids: set[int] = set()
|
|
497
|
+
for mapping in source:
|
|
498
|
+
if mapping.asset_id is not None:
|
|
499
|
+
asset_ids.add(mapping.asset_id)
|
|
500
|
+
self.client.migration.lookup.assets(list(asset_ids))
|
|
501
|
+
|
|
502
|
+
def _map_single_item(
|
|
503
|
+
self, item: AssetMappingResponse
|
|
504
|
+
) -> tuple[AssetMappingDMRequest | None, ThreeDModelMigrationIssue]:
|
|
505
|
+
issue = ThreeDModelMigrationIssue(model_name=f"AssetMapping_{item.model_id}", model_id=item.model_id)
|
|
506
|
+
asset_instance_id = item.asset_instance_id
|
|
507
|
+
if item.asset_id and asset_instance_id is None:
|
|
508
|
+
asset_node_id = self.client.migration.lookup.assets(item.asset_id)
|
|
509
|
+
if asset_node_id is None:
|
|
510
|
+
issue.error_message.append(f"Missing asset instance for asset ID {item.asset_id!r}")
|
|
511
|
+
return None, issue
|
|
512
|
+
asset_instance_id = NodeReference(space=asset_node_id.space, externalId=asset_node_id.external_id)
|
|
513
|
+
|
|
514
|
+
if asset_instance_id is None:
|
|
515
|
+
issue.error_message.append("Neither assetInstanceId nor assetId provided for mapping.")
|
|
516
|
+
return None, issue
|
|
517
|
+
mapped_request = AssetMappingDMRequest(
|
|
518
|
+
modelId=item.model_id, revisionId=item.revision_id, nodeId=item.node_id, assetInstanceId=asset_instance_id
|
|
519
|
+
)
|
|
520
|
+
return mapped_request, issue
|
|
@@ -4,6 +4,7 @@ from cognite.client.data_classes.data_modeling.containers import BTreeIndex
|
|
|
4
4
|
SPACE = dm.SpaceApply(
|
|
5
5
|
"cognite_migration", description="Space for the asset-centric to data modeling migration", name="cdf_migration"
|
|
6
6
|
)
|
|
7
|
+
COGNITE_MIGRATION_SPACE_ID = SPACE.space
|
|
7
8
|
|
|
8
9
|
RESOURCE_VIEW_MAPPING = dm.ContainerApply(
|
|
9
10
|
space=SPACE.space,
|
|
@@ -2,7 +2,7 @@ from functools import lru_cache
|
|
|
2
2
|
|
|
3
3
|
from cognite.client.data_classes.data_modeling import ViewId
|
|
4
4
|
|
|
5
|
-
from cognite_toolkit._cdf_tk.client.data_classes.migration import ResourceViewMappingApply
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import ResourceViewMappingApply
|
|
6
6
|
|
|
7
7
|
ASSET_ID = "cdf_asset_mapping"
|
|
8
8
|
EVENT_ID = "cdf_event_mapping"
|
|
@@ -6,7 +6,7 @@ from cognite.client.utils._identifier import InstanceId
|
|
|
6
6
|
from cognite.client.utils._text import to_camel_case
|
|
7
7
|
from pydantic import BaseModel, Field, field_serializer
|
|
8
8
|
|
|
9
|
-
from cognite_toolkit._cdf_tk.client.data_classes.migration import AssetCentricId
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import AssetCentricId
|
|
10
10
|
from cognite_toolkit._cdf_tk.utils.useful_types import JsonVal
|
|
11
11
|
|
|
12
12
|
|
|
@@ -30,6 +30,24 @@ class MigrationIssue(MigrationObject):
|
|
|
30
30
|
return True
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
class ThreeDModelMigrationIssue(MigrationIssue):
|
|
34
|
+
"""Represents a 3D model migration issue encountered during migration.
|
|
35
|
+
|
|
36
|
+
Attributes:
|
|
37
|
+
model_external_id (str): The external ID of the 3D model that could not be migrated.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
type: ClassVar[str] = "threeDModelMigration"
|
|
41
|
+
model_name: str
|
|
42
|
+
model_id: int
|
|
43
|
+
error_message: list[str] = Field(default_factory=list)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def has_issues(self) -> bool:
|
|
47
|
+
"""Check if there are any issues recorded in this ThreeDModelMigrationIssue."""
|
|
48
|
+
return bool(self.error_message)
|
|
49
|
+
|
|
50
|
+
|
|
33
51
|
class ChartMigrationIssue(MigrationIssue):
|
|
34
52
|
"""Represents a chart migration issue encountered during migration.
|
|
35
53
|
|