cognite-toolkit 0.7.43__py3-none-any.whl → 0.7.45__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_tk/client/_toolkit_client.py +6 -0
- cognite_toolkit/_cdf_tk/client/api/assets.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/events.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/filemetadata.py +150 -0
- cognite_toolkit/_cdf_tk/client/api/raw.py +174 -0
- cognite_toolkit/_cdf_tk/client/api/simulator_models.py +128 -0
- cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/timeseries.py +2 -2
- cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +2 -1
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +114 -8
- cognite_toolkit/_cdf_tk/client/data_classes/annotation.py +79 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +13 -3
- cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/__init__.py +16 -0
- cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_instance.py +143 -0
- cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_references.py +8 -0
- cognite_toolkit/_cdf_tk/client/data_classes/dataset.py +35 -0
- cognite_toolkit/_cdf_tk/client/data_classes/extraction_pipeline.py +59 -0
- cognite_toolkit/_cdf_tk/client/data_classes/filemetadata.py +7 -1
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_destination.py +34 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_job.py +134 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_mapping.py +72 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/__init__.py +63 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_auth.py +63 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_base.py +26 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_certificate.py +20 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_eventhub.py +31 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_kafka.py +53 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_mqtt.py +36 -0
- cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_rest.py +49 -0
- cognite_toolkit/_cdf_tk/client/data_classes/identifiers.py +8 -0
- cognite_toolkit/_cdf_tk/client/data_classes/label.py +27 -0
- cognite_toolkit/_cdf_tk/client/data_classes/raw.py +3 -2
- cognite_toolkit/_cdf_tk/client/data_classes/securitycategory.py +24 -0
- cognite_toolkit/_cdf_tk/client/data_classes/sequence.py +45 -0
- cognite_toolkit/_cdf_tk/client/data_classes/transformation.py +140 -0
- cognite_toolkit/_cdf_tk/client/data_classes/workflow.py +27 -0
- cognite_toolkit/_cdf_tk/client/data_classes/workflow_trigger.py +63 -0
- cognite_toolkit/_cdf_tk/client/data_classes/workflow_version.py +155 -0
- cognite_toolkit/_cdf_tk/client/testing.py +5 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +4 -3
- cognite_toolkit/_cdf_tk/cruds/__init__.py +5 -1
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +7 -3
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +56 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +119 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +4 -0
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +34 -29
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +22 -19
- 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.43.dist-info → cognite_toolkit-0.7.45.dist-info}/METADATA +11 -1
- {cognite_toolkit-0.7.43.dist-info → cognite_toolkit-0.7.45.dist-info}/RECORD +57 -30
- {cognite_toolkit-0.7.43.dist-info → cognite_toolkit-0.7.45.dist-info}/WHEEL +1 -1
- {cognite_toolkit-0.7.43.dist-info → cognite_toolkit-0.7.45.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from typing import ClassVar, Literal
|
|
2
|
+
|
|
3
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import (
|
|
4
|
+
BaseModelObject,
|
|
5
|
+
RequestUpdateable,
|
|
6
|
+
ResponseResource,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from .identifiers import ExternalId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SequenceColumn(BaseModelObject):
|
|
13
|
+
external_id: str
|
|
14
|
+
name: str | None = None
|
|
15
|
+
description: str | None = None
|
|
16
|
+
metadata: dict[str, str] | None = None
|
|
17
|
+
value_type: Literal["STRING", "DOUBLE", "LONG"] | None = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Sequence(BaseModelObject):
|
|
21
|
+
external_id: str | None = None
|
|
22
|
+
name: str | None = None
|
|
23
|
+
description: str | None = None
|
|
24
|
+
asset_id: int | None = None
|
|
25
|
+
data_set_id: int | None = None
|
|
26
|
+
metadata: dict[str, str] | None = None
|
|
27
|
+
columns: list[SequenceColumn]
|
|
28
|
+
|
|
29
|
+
def as_id(self) -> ExternalId:
|
|
30
|
+
if self.external_id is None:
|
|
31
|
+
raise ValueError("Cannot convert Sequence to ExternalId when external_id is None")
|
|
32
|
+
return ExternalId(external_id=self.external_id)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SequenceRequest(Sequence, RequestUpdateable):
|
|
36
|
+
container_fields: ClassVar[frozenset[str]] = frozenset({"metadata", "columns"})
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class SequenceResponse(Sequence, ResponseResource[SequenceRequest]):
|
|
40
|
+
id: int
|
|
41
|
+
created_time: int
|
|
42
|
+
last_updated_time: int
|
|
43
|
+
|
|
44
|
+
def as_request_resource(self) -> SequenceRequest:
|
|
45
|
+
return SequenceRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from typing import Annotated, ClassVar, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, JsonValue
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import (
|
|
6
|
+
BaseModelObject,
|
|
7
|
+
RequestUpdateable,
|
|
8
|
+
ResponseResource,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from .identifiers import ExternalId
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class NonceCredentials(BaseModelObject):
|
|
15
|
+
nonce: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DestinationDefinition(BaseModelObject):
|
|
19
|
+
type: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DataModelInfo(BaseModelObject):
|
|
23
|
+
space: str
|
|
24
|
+
external_id: str
|
|
25
|
+
version: str
|
|
26
|
+
destination_type: str
|
|
27
|
+
destination_relationship_from_type: str | None = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ViewInfo(BaseModelObject):
|
|
31
|
+
space: str
|
|
32
|
+
external_id: str
|
|
33
|
+
version: str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class EdgeType(BaseModelObject):
|
|
37
|
+
space: str
|
|
38
|
+
external_id: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class AssetCentricDataSource(DestinationDefinition):
|
|
42
|
+
type: Literal[
|
|
43
|
+
"assets",
|
|
44
|
+
"events",
|
|
45
|
+
"asset_hierarchy",
|
|
46
|
+
"datapoints",
|
|
47
|
+
"string_datapoints",
|
|
48
|
+
"timeseries",
|
|
49
|
+
"sequences",
|
|
50
|
+
"files",
|
|
51
|
+
"labels",
|
|
52
|
+
"relationships",
|
|
53
|
+
"data_sets",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class DataModelSource(DestinationDefinition):
|
|
58
|
+
type: Literal["instances"] = "instances"
|
|
59
|
+
data_model: DataModelInfo
|
|
60
|
+
instance_space: str | None = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ViewDataSource(DestinationDefinition):
|
|
64
|
+
type: Literal["nodes", "edges"]
|
|
65
|
+
view: ViewInfo
|
|
66
|
+
edge_type: EdgeType | None = None
|
|
67
|
+
instance_space: str | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class RawDataSource(DestinationDefinition):
|
|
71
|
+
type: Literal["raw_tables"] = "raw_tables"
|
|
72
|
+
database: str
|
|
73
|
+
table: str
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class SequenceRowDataSource(DestinationDefinition):
|
|
77
|
+
type: Literal["sequence_rows"] = "sequence_rows"
|
|
78
|
+
external_id: str
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Destination = Annotated[
|
|
82
|
+
AssetCentricDataSource | DataModelSource | ViewDataSource | RawDataSource | SequenceRowDataSource,
|
|
83
|
+
Field(discriminator="type"),
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class BlockedInfo(BaseModelObject):
|
|
88
|
+
reason: str
|
|
89
|
+
created_time: int
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class SessionInfo(BaseModelObject):
|
|
93
|
+
client_id: str
|
|
94
|
+
session_id: str
|
|
95
|
+
project_name: str
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class Transformation(BaseModelObject):
|
|
99
|
+
external_id: str
|
|
100
|
+
name: str
|
|
101
|
+
ignore_null_fields: bool
|
|
102
|
+
data_set_id: int | None = None
|
|
103
|
+
tags: list[str] | None = None
|
|
104
|
+
|
|
105
|
+
def as_id(self) -> ExternalId:
|
|
106
|
+
return ExternalId(external_id=self.external_id)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class TransformationRequest(Transformation, RequestUpdateable):
|
|
110
|
+
container_fields: ClassVar[frozenset[str]] = frozenset({"tags"})
|
|
111
|
+
non_nullable_fields: ClassVar[frozenset[str]] = frozenset({"is_public", "query", "destination"})
|
|
112
|
+
query: str | None = None
|
|
113
|
+
conflict_mode: str | None = None
|
|
114
|
+
destination: Destination | None = None
|
|
115
|
+
source_nonce: NonceCredentials | None = None
|
|
116
|
+
destination_nonce: NonceCredentials | None = None
|
|
117
|
+
is_public: bool | None = None
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class TransformationResponse(Transformation, ResponseResource[TransformationRequest]):
|
|
121
|
+
id: int
|
|
122
|
+
created_time: int
|
|
123
|
+
last_updated_time: int
|
|
124
|
+
query: str
|
|
125
|
+
is_public: bool
|
|
126
|
+
conflict_mode: str
|
|
127
|
+
destination: Destination
|
|
128
|
+
blocked: BlockedInfo | None = None
|
|
129
|
+
owner: str
|
|
130
|
+
owner_is_current_user: bool
|
|
131
|
+
has_source_oidc_credentials: bool
|
|
132
|
+
has_destination_oidc_credentials: bool
|
|
133
|
+
source_session: SessionInfo | None = None
|
|
134
|
+
destination_session: SessionInfo | None = None
|
|
135
|
+
last_finished_job: dict[str, JsonValue] | None = None
|
|
136
|
+
running_job: dict[str, JsonValue] | None = None
|
|
137
|
+
schedule: dict[str, JsonValue] | None = None
|
|
138
|
+
|
|
139
|
+
def as_request_resource(self) -> TransformationRequest:
|
|
140
|
+
return TransformationRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import (
|
|
2
|
+
BaseModelObject,
|
|
3
|
+
RequestResource,
|
|
4
|
+
ResponseResource,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
from .identifiers import ExternalId
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Workflow(BaseModelObject):
|
|
11
|
+
external_id: str
|
|
12
|
+
description: str | None = None
|
|
13
|
+
data_set_id: int | None = None
|
|
14
|
+
|
|
15
|
+
def as_id(self) -> ExternalId:
|
|
16
|
+
return ExternalId(external_id=self.external_id)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class WorkflowRequest(Workflow, RequestResource): ...
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class WorkflowResponse(Workflow, ResponseResource[WorkflowRequest]):
|
|
23
|
+
created_time: int
|
|
24
|
+
last_updated_time: int
|
|
25
|
+
|
|
26
|
+
def as_request_resource(self) -> WorkflowRequest:
|
|
27
|
+
return WorkflowRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from typing import Annotated, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, JsonValue
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import (
|
|
6
|
+
BaseModelObject,
|
|
7
|
+
RequestResource,
|
|
8
|
+
ResponseResource,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from .identifiers import ExternalId
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TriggerRuleDefinition(BaseModelObject):
|
|
15
|
+
trigger_type: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ScheduleTriggerRule(BaseModelObject):
|
|
19
|
+
trigger_type: Literal["schedule"] = "schedule"
|
|
20
|
+
cron_expression: str
|
|
21
|
+
timezone: str | None = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class DataModelingTriggerRule(BaseModelObject):
|
|
25
|
+
trigger_type: Literal["dataModeling"] = "dataModeling"
|
|
26
|
+
data_modeling_query: JsonValue
|
|
27
|
+
batch_size: int
|
|
28
|
+
batch_timeout: int
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
TriggerRule = Annotated[
|
|
32
|
+
ScheduleTriggerRule | DataModelingTriggerRule,
|
|
33
|
+
Field(discriminator="trigger_type"),
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class NonceCredentials(BaseModelObject):
|
|
38
|
+
nonce: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class WorkflowTrigger(BaseModelObject):
|
|
42
|
+
external_id: str
|
|
43
|
+
trigger_rule: TriggerRule
|
|
44
|
+
workflow_external_id: str
|
|
45
|
+
workflow_version: str
|
|
46
|
+
input: JsonValue | None = None
|
|
47
|
+
metadata: dict[str, str] | None = None
|
|
48
|
+
|
|
49
|
+
def as_id(self) -> ExternalId:
|
|
50
|
+
return ExternalId(external_id=self.external_id)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class WorkflowTriggerRequest(WorkflowTrigger, RequestResource):
|
|
54
|
+
authentication: NonceCredentials
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class WorkflowTriggerResponse(WorkflowTrigger, ResponseResource[WorkflowTriggerRequest]):
|
|
58
|
+
created_time: int
|
|
59
|
+
last_updated_time: int
|
|
60
|
+
is_paused: bool
|
|
61
|
+
|
|
62
|
+
def as_request_resource(self) -> WorkflowTriggerRequest:
|
|
63
|
+
return WorkflowTriggerRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
from typing import Annotated, Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, JsonValue, field_validator
|
|
4
|
+
from pydantic_core.core_schema import ValidationInfo
|
|
5
|
+
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.data_classes.base import (
|
|
7
|
+
BaseModelObject,
|
|
8
|
+
RequestResource,
|
|
9
|
+
ResponseResource,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from .identifiers import Identifier, WorkflowVersionId
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TaskId(Identifier):
|
|
16
|
+
external_id: str
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
return f"externalId='{self.external_id}'"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TaskParameterDefinition(BaseModelObject):
|
|
23
|
+
type: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CogniteFunctionRef(BaseModelObject):
|
|
27
|
+
external_id: str
|
|
28
|
+
data: JsonValue | str | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class FunctionTaskParameters(TaskParameterDefinition):
|
|
32
|
+
type: Literal["function"] = Field("function", exclude=True)
|
|
33
|
+
function: CogniteFunctionRef
|
|
34
|
+
is_async_complete: bool | None = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class TransformationRef(BaseModelObject):
|
|
38
|
+
external_id: str
|
|
39
|
+
concurrency_policy: Literal["fail", "waitForCurrent", "restartAfterCurrent"] | None = None
|
|
40
|
+
use_transformation_credentials: bool | None = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class TransformationTaskParameters(TaskParameterDefinition):
|
|
44
|
+
type: Literal["transformation"] = Field("transformation", exclude=True)
|
|
45
|
+
transformation: TransformationRef
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class CDFRequest(BaseModelObject):
|
|
49
|
+
resource_path: str
|
|
50
|
+
method: str
|
|
51
|
+
query_parameters: JsonValue | str | None = None
|
|
52
|
+
body: JsonValue | str | None = None
|
|
53
|
+
request_timeout_in_millis: float | str | None = None
|
|
54
|
+
cdf_version_header: str | None = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class CDFTaskParameters(TaskParameterDefinition):
|
|
58
|
+
type: Literal["cdf"] = Field("cdf", exclude=True)
|
|
59
|
+
cdf_request: CDFRequest
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class DynamicRef(BaseModelObject):
|
|
63
|
+
tasks: str
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class DynamicTaskParameters(TaskParameterDefinition):
|
|
67
|
+
type: Literal["dynamic"] = Field("dynamic", exclude=True)
|
|
68
|
+
dynamic: DynamicRef
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class SubworkflowRef(BaseModelObject):
|
|
72
|
+
tasks: "list[Task]"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class SubworkflowTaskParameters(TaskParameterDefinition):
|
|
76
|
+
type: Literal["subworkflow"] = Field("subworkflow", exclude=True)
|
|
77
|
+
subworkflow: WorkflowVersionId | SubworkflowRef
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class SimulatorInputUnit(BaseModelObject):
|
|
81
|
+
name: str
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class SimulatorInput(BaseModelObject):
|
|
85
|
+
reference_id: str
|
|
86
|
+
value: str | int | float | list[str] | list[int] | list[float]
|
|
87
|
+
unit: SimulatorInputUnit | None = None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class SimulationRef(BaseModelObject):
|
|
91
|
+
routine_external_id: str
|
|
92
|
+
run_time: int | None = None
|
|
93
|
+
inputs: list[SimulatorInput] | None = None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class SimulationTaskParameters(TaskParameterDefinition):
|
|
97
|
+
type: Literal["simulation"] = Field("simulation", exclude=True)
|
|
98
|
+
simulation: SimulationRef
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Parameter = Annotated[
|
|
102
|
+
FunctionTaskParameters
|
|
103
|
+
| TransformationTaskParameters
|
|
104
|
+
| CDFTaskParameters
|
|
105
|
+
| DynamicTaskParameters
|
|
106
|
+
| SubworkflowTaskParameters
|
|
107
|
+
| SimulationTaskParameters,
|
|
108
|
+
Field(discriminator="type"),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class Task(BaseModelObject):
|
|
113
|
+
external_id: str
|
|
114
|
+
type: str
|
|
115
|
+
name: str | None = None
|
|
116
|
+
description: str | None = None
|
|
117
|
+
retries: int | None = None
|
|
118
|
+
timeout: int | None = None
|
|
119
|
+
on_failure: Literal["abortWorkflow", "skipTask"] = "abortWorkflow"
|
|
120
|
+
depends_on: list[TaskId] | None = None
|
|
121
|
+
parameters: Parameter | None = None
|
|
122
|
+
|
|
123
|
+
@field_validator("parameters", mode="before")
|
|
124
|
+
@classmethod
|
|
125
|
+
def move_type_to_field(cls, value: Any, info: ValidationInfo) -> Any:
|
|
126
|
+
if not isinstance(value, dict) or "type" not in info.data:
|
|
127
|
+
return value
|
|
128
|
+
value = dict(value)
|
|
129
|
+
value["type"] = info.data["type"]
|
|
130
|
+
return value
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class WorkflowDefinition(BaseModelObject):
|
|
134
|
+
description: str | None = None
|
|
135
|
+
tasks: list[Task]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class WorkflowVersion(BaseModelObject):
|
|
139
|
+
workflow_external_id: str
|
|
140
|
+
version: str
|
|
141
|
+
workflow_definition: WorkflowDefinition
|
|
142
|
+
|
|
143
|
+
def as_id(self) -> WorkflowVersionId:
|
|
144
|
+
return WorkflowVersionId(workflow_external_id=self.workflow_external_id, version=self.version)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class WorkflowVersionRequest(WorkflowVersion, RequestResource): ...
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class WorkflowVersionResponse(WorkflowVersion, ResponseResource[WorkflowVersionRequest]):
|
|
151
|
+
created_time: int
|
|
152
|
+
last_updated_time: int
|
|
153
|
+
|
|
154
|
+
def as_request_resource(self) -> WorkflowVersionRequest:
|
|
155
|
+
return WorkflowVersionRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -7,12 +7,14 @@ from cognite.client._api.datapoints import DatapointsAPI
|
|
|
7
7
|
from cognite.client._api.datapoints_subscriptions import DatapointsSubscriptionAPI
|
|
8
8
|
from cognite.client._api.functions import FunctionCallsAPI, FunctionSchedulesAPI
|
|
9
9
|
from cognite.client._api.raw import RawDatabasesAPI, RawRowsAPI, RawTablesAPI
|
|
10
|
+
from cognite.client._api.simulators import SimulatorModelsAPI, SimulatorsAPI
|
|
10
11
|
from cognite.client._api.synthetic_time_series import SyntheticDatapointsAPI
|
|
11
12
|
from cognite.client.testing import CogniteClientMock
|
|
12
13
|
from rich.console import Console
|
|
13
14
|
|
|
14
15
|
from cognite_toolkit._cdf_tk.client._toolkit_client import ToolkitClient
|
|
15
16
|
from cognite_toolkit._cdf_tk.client.api.assets import AssetsAPI
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.api.filemetadata import FileMetadataAPI
|
|
16
18
|
from cognite_toolkit._cdf_tk.client.api.legacy.canvas import CanvasAPI, IndustrialCanvasAPI
|
|
17
19
|
from cognite_toolkit._cdf_tk.client.api.legacy.charts import ChartsAPI
|
|
18
20
|
from cognite_toolkit._cdf_tk.client.api.legacy.dml import DMLAPI
|
|
@@ -143,7 +145,10 @@ class ToolkitClientMock(CogniteClientMock):
|
|
|
143
145
|
self.tool.three_d.models = MagicMock(spec_set=ThreeDModelAPI)
|
|
144
146
|
self.tool.assets = MagicMock(spec_set=AssetsAPI)
|
|
145
147
|
self.tool.timeseries = MagicMock(spec_set=TimeSeriesAPI)
|
|
148
|
+
self.tool.filemetadata = MagicMock(spec_set=FileMetadataAPI)
|
|
146
149
|
self.tool.events = MagicMock(spec_set=EventsAPI)
|
|
150
|
+
self.tool.simulators = MagicMock(spec=SimulatorsAPI)
|
|
151
|
+
self.tool.simulators.models = MagicMock(spec_set=SimulatorModelsAPI)
|
|
147
152
|
|
|
148
153
|
self.streams = MagicMock(spec=StreamsAPI)
|
|
149
154
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from collections.abc import Iterable, Mapping, Set
|
|
2
2
|
from typing import Any, ClassVar, cast
|
|
3
3
|
|
|
4
|
-
from cognite.client.data_classes import Annotation
|
|
4
|
+
from cognite.client.data_classes import Annotation
|
|
5
5
|
from cognite.client.data_classes.data_modeling import (
|
|
6
6
|
DirectRelation,
|
|
7
7
|
DirectRelationReference,
|
|
@@ -18,6 +18,7 @@ from cognite.client.utils._identifier import InstanceId
|
|
|
18
18
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
19
19
|
from cognite_toolkit._cdf_tk.client.data_classes.asset import AssetResponse
|
|
20
20
|
from cognite_toolkit._cdf_tk.client.data_classes.event import EventResponse
|
|
21
|
+
from cognite_toolkit._cdf_tk.client.data_classes.filemetadata import FileMetadataResponse
|
|
21
22
|
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import (
|
|
22
23
|
AssetCentricId,
|
|
23
24
|
ResourceViewMappingApply,
|
|
@@ -117,7 +118,7 @@ class DirectRelationCache:
|
|
|
117
118
|
source_ids.add(resource.source)
|
|
118
119
|
if resource.parent_id is not None:
|
|
119
120
|
asset_ids.add(resource.parent_id)
|
|
120
|
-
elif isinstance(resource,
|
|
121
|
+
elif isinstance(resource, FileMetadataResponse):
|
|
121
122
|
if resource.source:
|
|
122
123
|
source_ids.add(resource.source)
|
|
123
124
|
if resource.asset_ids:
|
|
@@ -248,7 +249,7 @@ def asset_centric_to_dm(
|
|
|
248
249
|
def _lookup_resource_type(resource_type: AssetCentricResourceExtended) -> AssetCentricTypeExtended:
|
|
249
250
|
if isinstance(resource_type, AssetResponse):
|
|
250
251
|
return "asset"
|
|
251
|
-
elif isinstance(resource_type,
|
|
252
|
+
elif isinstance(resource_type, FileMetadataResponse):
|
|
252
253
|
return "file"
|
|
253
254
|
elif isinstance(resource_type, EventResponse):
|
|
254
255
|
return "event"
|
|
@@ -60,6 +60,7 @@ from ._resource_cruds import (
|
|
|
60
60
|
SecurityCategoryCRUD,
|
|
61
61
|
SequenceCRUD,
|
|
62
62
|
SequenceRowCRUD,
|
|
63
|
+
SimulatorModelCRUD,
|
|
63
64
|
SpaceCRUD,
|
|
64
65
|
StreamCRUD,
|
|
65
66
|
StreamlitCRUD,
|
|
@@ -86,7 +87,8 @@ if not FeatureFlag.is_enabled(Flags.MIGRATE):
|
|
|
86
87
|
_EXCLUDED_CRUDS.add(ResourceViewMappingCRUD)
|
|
87
88
|
if not FeatureFlag.is_enabled(Flags.STREAMS):
|
|
88
89
|
_EXCLUDED_CRUDS.add(StreamCRUD)
|
|
89
|
-
|
|
90
|
+
if not FeatureFlag.is_enabled(Flags.SIMULATORS):
|
|
91
|
+
_EXCLUDED_CRUDS.add(SimulatorModelCRUD)
|
|
90
92
|
|
|
91
93
|
CRUDS_BY_FOLDER_NAME: dict[str, list[type[Loader]]] = {}
|
|
92
94
|
for _loader in itertools.chain(
|
|
@@ -142,6 +144,7 @@ ResourceTypes: TypeAlias = Literal[
|
|
|
142
144
|
"functions",
|
|
143
145
|
"raw",
|
|
144
146
|
"robotics",
|
|
147
|
+
"simulators",
|
|
145
148
|
"streams",
|
|
146
149
|
"streamlit",
|
|
147
150
|
"workflows",
|
|
@@ -209,6 +212,7 @@ __all__ = [
|
|
|
209
212
|
"SecurityCategoryCRUD",
|
|
210
213
|
"SequenceCRUD",
|
|
211
214
|
"SequenceRowCRUD",
|
|
215
|
+
"SimulatorModelCRUD",
|
|
212
216
|
"SpaceCRUD",
|
|
213
217
|
"StreamlitCRUD",
|
|
214
218
|
"ThreeDModelCRUD",
|
|
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, cast, final
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
from cognite.client.data_classes import FileMetadataWrite
|
|
8
8
|
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.data_classes.identifiers import ExternalId
|
|
9
10
|
from cognite_toolkit._cdf_tk.client.data_classes.legacy.extendable_cognite_file import ExtendableCogniteFileApply
|
|
10
11
|
from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawTable
|
|
11
12
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
@@ -119,11 +120,14 @@ class FileCRUD(DataCRUD):
|
|
|
119
120
|
if not datafile.exists():
|
|
120
121
|
continue
|
|
121
122
|
|
|
123
|
+
identifier = resource.identifier
|
|
124
|
+
if isinstance(identifier, ExternalId):
|
|
125
|
+
identifier = identifier.external_id
|
|
122
126
|
if dry_run:
|
|
123
|
-
yield f" Would upload file '{datafile!s}' to file with {id_name}={
|
|
127
|
+
yield f" Would upload file '{datafile!s}' to file with {id_name}={identifier!r}", 1
|
|
124
128
|
else:
|
|
125
|
-
self.client.files.upload_content(path=str(datafile), **{id_name:
|
|
126
|
-
yield f" Uploaded file '{datafile!s}' to file with {id_name}={
|
|
129
|
+
self.client.files.upload_content(path=str(datafile), **{id_name: identifier})
|
|
130
|
+
yield f" Uploaded file '{datafile!s}' to file with {id_name}={identifier!r}", 1
|
|
127
131
|
|
|
128
132
|
@staticmethod
|
|
129
133
|
def _read_metadata(
|
|
@@ -35,6 +35,7 @@ from .robotics import (
|
|
|
35
35
|
RoboticMapCRUD,
|
|
36
36
|
RoboticsDataPostProcessingCRUD,
|
|
37
37
|
)
|
|
38
|
+
from .simulators import SimulatorModelCRUD
|
|
38
39
|
from .streams import StreamCRUD
|
|
39
40
|
from .three_d_model import ThreeDModelCRUD
|
|
40
41
|
from .timeseries import DatapointSubscriptionCRUD, TimeSeriesCRUD
|
|
@@ -83,6 +84,7 @@ __all__ = [
|
|
|
83
84
|
"SecurityCategoryCRUD",
|
|
84
85
|
"SequenceCRUD",
|
|
85
86
|
"SequenceRowCRUD",
|
|
87
|
+
"SimulatorModelCRUD",
|
|
86
88
|
"SpaceCRUD",
|
|
87
89
|
"StreamCRUD",
|
|
88
90
|
"StreamlitCRUD",
|