cognite-toolkit 0.6.97__py3-none-any.whl → 0.6.99__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 +9 -1
- cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +12 -1
- cognite_toolkit/_cdf_tk/apps/_dev_app.py +20 -0
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +2 -0
- cognite_toolkit/_cdf_tk/client/api/streams.py +84 -0
- cognite_toolkit/_cdf_tk/client/data_classes/streams.py +114 -0
- cognite_toolkit/_cdf_tk/client/testing.py +3 -0
- cognite_toolkit/_cdf_tk/commands/clean.py +52 -3
- cognite_toolkit/_cdf_tk/constants.py +3 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +4 -0
- cognite_toolkit/_cdf_tk/plugins.py +1 -0
- cognite_toolkit/_cdf_tk/resource_classes/streams.py +29 -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.6.97.dist-info → cognite_toolkit-0.6.99.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.6.99.dist-info}/RECORD +22 -18
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.6.99.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.6.99.dist-info}/entry_points.txt +0 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.6.99.dist-info}/licenses/LICENSE +0 -0
cognite_toolkit/_cdf.py
CHANGED
|
@@ -25,6 +25,7 @@ from cognite_toolkit._cdf_tk.apps import (
|
|
|
25
25
|
AuthApp,
|
|
26
26
|
CoreApp,
|
|
27
27
|
DataApp,
|
|
28
|
+
DevApp,
|
|
28
29
|
DumpApp,
|
|
29
30
|
LandingApp,
|
|
30
31
|
MigrateApp,
|
|
@@ -89,9 +90,13 @@ user_app = typer.Typer(**default_typer_kws, hidden=True) # type: ignore [arg-ty
|
|
|
89
90
|
landing_app = LandingApp(**default_typer_kws)
|
|
90
91
|
|
|
91
92
|
_app.add_typer(AuthApp(**default_typer_kws), name="auth")
|
|
93
|
+
_app.add_typer(RepoApp(**default_typer_kws), name="repo")
|
|
94
|
+
|
|
95
|
+
|
|
92
96
|
if Plugins.run.value.is_enabled():
|
|
97
|
+
if Flags.v07.is_enabled():
|
|
98
|
+
print("The run plugin is deprecated and will be replaced by the dev plugin in v0.8.0.")
|
|
93
99
|
_app.add_typer(RunApp(**default_typer_kws), name="run")
|
|
94
|
-
_app.add_typer(RepoApp(**default_typer_kws), name="repo")
|
|
95
100
|
|
|
96
101
|
if Plugins.dump.value.is_enabled():
|
|
97
102
|
_app.add_typer(DumpApp(**default_typer_kws), name="dump")
|
|
@@ -99,6 +104,9 @@ if Plugins.dump.value.is_enabled():
|
|
|
99
104
|
if Plugins.purge.value.is_enabled() and not Flags.v07.is_enabled():
|
|
100
105
|
_app.add_typer(PurgeApp(**default_typer_kws), name="purge")
|
|
101
106
|
|
|
107
|
+
if Plugins.dev.value.is_enabled() and Flags.v07.is_enabled():
|
|
108
|
+
_app.add_typer(DevApp(**default_typer_kws), name="dev")
|
|
109
|
+
|
|
102
110
|
if Flags.PROFILE.is_enabled():
|
|
103
111
|
_app.add_typer(ProfileApp(**default_typer_kws), name="profile")
|
|
104
112
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from ._auth_app import AuthApp
|
|
2
2
|
from ._core_app import CoreApp
|
|
3
3
|
from ._data_app import DataApp
|
|
4
|
+
from ._dev_app import DevApp
|
|
4
5
|
from ._download_app import DownloadApp
|
|
5
6
|
from ._dump_app import DumpApp
|
|
6
7
|
from ._landing_app import LandingApp
|
|
@@ -16,6 +17,7 @@ __all__ = [
|
|
|
16
17
|
"AuthApp",
|
|
17
18
|
"CoreApp",
|
|
18
19
|
"DataApp",
|
|
20
|
+
"DevApp",
|
|
19
21
|
"DownloadApp",
|
|
20
22
|
"DumpApp",
|
|
21
23
|
"LandingApp",
|
|
@@ -345,7 +345,16 @@ class CoreApp(typer.Typer):
|
|
|
345
345
|
list[str] | None,
|
|
346
346
|
typer.Option(
|
|
347
347
|
"--include",
|
|
348
|
-
help=f"Specify which resource types to
|
|
348
|
+
help=f"Specify which resource types to clean, supported types: {AVAILABLE_DATA_TYPES}",
|
|
349
|
+
),
|
|
350
|
+
] = None,
|
|
351
|
+
module: Annotated[
|
|
352
|
+
str | None,
|
|
353
|
+
typer.Option(
|
|
354
|
+
"--module",
|
|
355
|
+
"-m",
|
|
356
|
+
help="Specify name or path of the module to clean",
|
|
357
|
+
hidden=not Flags.v07.is_enabled(),
|
|
349
358
|
),
|
|
350
359
|
] = None,
|
|
351
360
|
verbose: Annotated[
|
|
@@ -368,6 +377,8 @@ class CoreApp(typer.Typer):
|
|
|
368
377
|
build_env_name,
|
|
369
378
|
dry_run,
|
|
370
379
|
include,
|
|
380
|
+
module,
|
|
371
381
|
verbose,
|
|
382
|
+
all_modules=True if not Flags.v07.is_enabled() else False,
|
|
372
383
|
)
|
|
373
384
|
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich import print
|
|
5
|
+
|
|
6
|
+
from ._run import RunApp
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DevApp(typer.Typer):
|
|
10
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
11
|
+
super().__init__(*args, **kwargs)
|
|
12
|
+
self.callback(invoke_without_command=True)(self.main)
|
|
13
|
+
self.add_typer(RunApp(*args, **kwargs), name="run")
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def main(ctx: typer.Context) -> None:
|
|
17
|
+
"""Commands to work with development."""
|
|
18
|
+
if ctx.invoked_subcommand is None:
|
|
19
|
+
print("Use [bold yellow]cdf dev --help[/] for more information.")
|
|
20
|
+
return None
|
|
@@ -19,6 +19,7 @@ from .api.migration import MigrationAPI
|
|
|
19
19
|
from .api.project import ProjectAPI
|
|
20
20
|
from .api.robotics import RoboticsAPI
|
|
21
21
|
from .api.search import SearchAPI
|
|
22
|
+
from .api.streams import StreamsAPI
|
|
22
23
|
from .api.token import TokenAPI
|
|
23
24
|
from .api.verify import VerifyAPI
|
|
24
25
|
from .config import ToolkitClientConfig
|
|
@@ -47,6 +48,7 @@ class ToolkitClient(CogniteClient):
|
|
|
47
48
|
self.charts = ChartsAPI(self._config, self._API_VERSION, self)
|
|
48
49
|
self.project = ProjectAPI(config=toolkit_config, cognite_client=self)
|
|
49
50
|
self.infield = InfieldAPI(http_client, self.console)
|
|
51
|
+
self.streams = StreamsAPI(http_client, self.console)
|
|
50
52
|
|
|
51
53
|
@property
|
|
52
54
|
def config(self) -> ToolkitClientConfig:
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.data_classes.api_classes import PagedResponse
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.data_classes.streams import StreamRequest, StreamResponse
|
|
7
|
+
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient, ItemsRequest, ParamRequest
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StreamsAPI:
|
|
11
|
+
ENDPOINT = "/streams"
|
|
12
|
+
|
|
13
|
+
def __init__(self, http_client: HTTPClient, console: Console) -> None:
|
|
14
|
+
self._http_client = http_client
|
|
15
|
+
self._console = console
|
|
16
|
+
self._config = http_client.config
|
|
17
|
+
|
|
18
|
+
def create(self, items: Sequence[StreamRequest]) -> list[StreamResponse]:
|
|
19
|
+
"""Create one or more streams.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
items: Sequence of StreamRequest items to create.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
List of created StreamResponse items.
|
|
26
|
+
"""
|
|
27
|
+
responses = self._http_client.request_with_retries(
|
|
28
|
+
ItemsRequest(
|
|
29
|
+
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
30
|
+
method="POST",
|
|
31
|
+
items=list(items),
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
responses.raise_for_status()
|
|
35
|
+
return PagedResponse[StreamResponse].model_validate(responses.get_first_body()).items
|
|
36
|
+
|
|
37
|
+
def delete(self, external_id: str) -> None:
|
|
38
|
+
"""Delete stream using its external ID.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
external_id: External ID of the stream to delete.
|
|
42
|
+
"""
|
|
43
|
+
responses = self._http_client.request_with_retries(
|
|
44
|
+
ParamRequest(
|
|
45
|
+
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
46
|
+
method="DELETE",
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
responses.raise_for_status()
|
|
50
|
+
|
|
51
|
+
def list(self) -> list[StreamResponse]:
|
|
52
|
+
"""List streams.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
StreamResponseList containing the listed streams.
|
|
56
|
+
"""
|
|
57
|
+
responses = self._http_client.request_with_retries(
|
|
58
|
+
ParamRequest(
|
|
59
|
+
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
60
|
+
method="GET",
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
responses.raise_for_status()
|
|
64
|
+
return PagedResponse[StreamResponse].model_validate(responses.get_first_body()).items
|
|
65
|
+
|
|
66
|
+
def retrieve(self, external_id: str, include_statistics: bool = True) -> StreamResponse:
|
|
67
|
+
"""Retrieve a stream by its external ID.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
external_id: External ID of the stream to retrieve.
|
|
71
|
+
include_statistics: Whether to include usage statistics in the response.
|
|
72
|
+
Returns:
|
|
73
|
+
StreamResponse item.
|
|
74
|
+
"""
|
|
75
|
+
responses = self._http_client.request_with_retries(
|
|
76
|
+
ParamRequest(
|
|
77
|
+
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
78
|
+
method="GET",
|
|
79
|
+
parameters={"includeStatistics": include_statistics},
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
responses.raise_for_status()
|
|
83
|
+
response_body = responses.get_first_body()
|
|
84
|
+
return StreamResponse.model_validate(response_body)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from collections import UserList
|
|
3
|
+
from typing import Any, Literal
|
|
4
|
+
|
|
5
|
+
from cognite.client import CogniteClient
|
|
6
|
+
|
|
7
|
+
from cognite_toolkit._cdf_tk.constants import StreamTemplateName
|
|
8
|
+
from cognite_toolkit._cdf_tk.protocols import ResourceRequestListProtocol, ResourceResponseListProtocol
|
|
9
|
+
|
|
10
|
+
from .base import BaseModelObject, RequestResource, ResponseResource
|
|
11
|
+
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import Self
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import Self
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class StreamRequest(RequestResource):
|
|
19
|
+
"""Stream request resource class."""
|
|
20
|
+
|
|
21
|
+
external_id: str
|
|
22
|
+
settings: dict[Literal["template"], dict[Literal["name"], StreamTemplateName]]
|
|
23
|
+
|
|
24
|
+
def as_id(self) -> str:
|
|
25
|
+
return self.external_id
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class StreamRequestList(UserList[StreamRequest], ResourceRequestListProtocol):
|
|
29
|
+
"""List of Stream request resources."""
|
|
30
|
+
|
|
31
|
+
_RESOURCE = StreamRequest
|
|
32
|
+
items: list[StreamRequest]
|
|
33
|
+
|
|
34
|
+
def __init__(self, initlist: list[StreamRequest] | None = None, **_: Any) -> None:
|
|
35
|
+
super().__init__(initlist or [])
|
|
36
|
+
|
|
37
|
+
def dump(self, camel_case: bool = True) -> list[dict[str, Any]]:
|
|
38
|
+
return [item.dump(camel_case) for item in self.items]
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def load(cls, data: list[dict[str, Any]], cognite_client: CogniteClient | None = None) -> "StreamRequestList":
|
|
42
|
+
items = [StreamRequest.model_validate(item) for item in data]
|
|
43
|
+
return cls(items)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class LifecycleObject(BaseModelObject):
|
|
47
|
+
"""Lifecycle object."""
|
|
48
|
+
|
|
49
|
+
hot_phase_duration: str | None = None
|
|
50
|
+
data_deleted_after: str | None = None
|
|
51
|
+
retained_after_soft_delete: str
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ResourceUsage(BaseModelObject):
|
|
55
|
+
"""Resource quota with provisioned and consumed values."""
|
|
56
|
+
|
|
57
|
+
provisioned: int
|
|
58
|
+
consumed: int | None = None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class LimitsObject(BaseModelObject):
|
|
62
|
+
"""Limits object."""
|
|
63
|
+
|
|
64
|
+
max_records_total: ResourceUsage
|
|
65
|
+
max_giga_bytes_total: ResourceUsage
|
|
66
|
+
max_filtering_interval: str | None = None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class StreamSettings(BaseModelObject):
|
|
70
|
+
"""Stream settings object."""
|
|
71
|
+
|
|
72
|
+
lifecycle: LifecycleObject
|
|
73
|
+
limits: LimitsObject
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class StreamResponse(ResponseResource["StreamRequest"]):
|
|
77
|
+
"""Stream response resource class."""
|
|
78
|
+
|
|
79
|
+
external_id: str
|
|
80
|
+
created_time: int
|
|
81
|
+
created_from_template: StreamTemplateName | None = None
|
|
82
|
+
type: Literal["Mutable", "Immutable"] | None = None
|
|
83
|
+
settings: StreamSettings | None = None
|
|
84
|
+
|
|
85
|
+
def as_request_resource(self) -> StreamRequest:
|
|
86
|
+
template_name = self.created_from_template or "BasicArchive"
|
|
87
|
+
return StreamRequest(
|
|
88
|
+
external_id=self.external_id,
|
|
89
|
+
settings={"template": {"name": template_name}},
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def as_write(self) -> Self:
|
|
93
|
+
return self
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class StreamResponseList(UserList[StreamResponse], ResourceResponseListProtocol):
|
|
97
|
+
"""List of Stream response resources."""
|
|
98
|
+
|
|
99
|
+
_RESOURCE = StreamResponse
|
|
100
|
+
data: list[StreamResponse]
|
|
101
|
+
|
|
102
|
+
def __init__(self, initlist: list[StreamResponse] | None = None, **_: Any) -> None:
|
|
103
|
+
super().__init__(initlist or [])
|
|
104
|
+
|
|
105
|
+
def dump(self, camel_case: bool = True) -> list[dict[str, Any]]:
|
|
106
|
+
return [item.dump(camel_case) for item in self.data]
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def load(cls, data: list[dict[str, Any]], cognite_client: CogniteClient | None = None) -> "StreamResponseList":
|
|
110
|
+
items = [StreamResponse.model_validate(item) for item in data]
|
|
111
|
+
return cls(items)
|
|
112
|
+
|
|
113
|
+
def as_write(self) -> Self:
|
|
114
|
+
return self
|
|
@@ -45,6 +45,7 @@ from .api.robotics.locations import LocationsAPI as RoboticsLocationsAPI
|
|
|
45
45
|
from .api.robotics.maps import MapsAPI
|
|
46
46
|
from .api.search import SearchAPI
|
|
47
47
|
from .api.search_config import SearchConfigurationsAPI
|
|
48
|
+
from .api.streams import StreamsAPI
|
|
48
49
|
from .api.token import TokenAPI
|
|
49
50
|
from .api.verify import VerifyAPI
|
|
50
51
|
|
|
@@ -117,6 +118,8 @@ class ToolkitClientMock(CogniteClientMock):
|
|
|
117
118
|
self.time_series.data.synthetic = MagicMock(spec_set=SyntheticDatapointsAPI)
|
|
118
119
|
self.time_series.subscriptions = MagicMock(spec_set=DatapointsSubscriptionAPI)
|
|
119
120
|
|
|
121
|
+
self.streams = MagicMock(spec=StreamsAPI)
|
|
122
|
+
|
|
120
123
|
# This is a helper API, not a real API.
|
|
121
124
|
self.token = TokenAPI(self)
|
|
122
125
|
self.verify = MagicMock(spec_set=VerifyAPI)
|
|
@@ -2,6 +2,7 @@ import traceback
|
|
|
2
2
|
from graphlib import TopologicalSorter
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
+
import questionary
|
|
5
6
|
from cognite.client.exceptions import CogniteAPIError, CogniteNotFoundError
|
|
6
7
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
8
|
from rich import print
|
|
@@ -40,8 +41,10 @@ from cognite_toolkit._cdf_tk.data_classes import (
|
|
|
40
41
|
from cognite_toolkit._cdf_tk.data_classes._module_directories import ReadModule
|
|
41
42
|
from cognite_toolkit._cdf_tk.exceptions import (
|
|
42
43
|
ToolkitCleanResourceError,
|
|
44
|
+
ToolkitMissingModuleError,
|
|
43
45
|
ToolkitNotADirectoryError,
|
|
44
46
|
ToolkitValidationError,
|
|
47
|
+
ToolkitValueError,
|
|
45
48
|
)
|
|
46
49
|
from cognite_toolkit._cdf_tk.tk_warnings import (
|
|
47
50
|
LowSeverityWarning,
|
|
@@ -185,6 +188,23 @@ class CleanCommand(ToolkitCommand):
|
|
|
185
188
|
self._verbose_print_drop(resource_drop_count, resource_ids, loader, dry_run)
|
|
186
189
|
return nr_of_dropped
|
|
187
190
|
|
|
191
|
+
def _interactive_module_selection(self, built_modules: list[ReadModule] | None) -> list[ReadModule] | None:
|
|
192
|
+
if not built_modules:
|
|
193
|
+
return None
|
|
194
|
+
choices = [
|
|
195
|
+
questionary.Choice(title=built_module.dir.name, value=built_module) for built_module in built_modules
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
selected_modules = questionary.checkbox(
|
|
199
|
+
"Which modules would you like to clean?",
|
|
200
|
+
instruction="Use arrow up/down, press space to select item(s) and enter to save",
|
|
201
|
+
choices=choices,
|
|
202
|
+
).ask()
|
|
203
|
+
|
|
204
|
+
if not selected_modules:
|
|
205
|
+
return None
|
|
206
|
+
return selected_modules
|
|
207
|
+
|
|
188
208
|
def _verbose_print_drop(
|
|
189
209
|
self, drop_count: int, resource_ids: SequenceNotStr[T_ID], loader: ResourceContainerCRUD, dry_run: bool
|
|
190
210
|
) -> None:
|
|
@@ -204,6 +224,11 @@ class CleanCommand(ToolkitCommand):
|
|
|
204
224
|
# Count is not supported
|
|
205
225
|
print(f" {prefix} all {loader.item_name} from {loader.display_name}: {_print_ids_or_length(resource_ids)}.")
|
|
206
226
|
|
|
227
|
+
def _select_modules(self, clean_state: BuildEnvironment, module_str: str | None) -> list[ReadModule] | None:
|
|
228
|
+
if module_str:
|
|
229
|
+
return [module for module in clean_state.read_modules if module.dir.name == module_str]
|
|
230
|
+
return self._interactive_module_selection(clean_state.read_modules)
|
|
231
|
+
|
|
207
232
|
def execute(
|
|
208
233
|
self,
|
|
209
234
|
env_vars: EnvironmentVariables,
|
|
@@ -211,7 +236,9 @@ class CleanCommand(ToolkitCommand):
|
|
|
211
236
|
build_env_name: str | None,
|
|
212
237
|
dry_run: bool,
|
|
213
238
|
include: list[str] | None,
|
|
239
|
+
module_str: str | None,
|
|
214
240
|
verbose: bool,
|
|
241
|
+
all_modules: bool = False,
|
|
215
242
|
) -> None:
|
|
216
243
|
if not build_dir.exists():
|
|
217
244
|
raise ToolkitNotADirectoryError(
|
|
@@ -245,9 +272,31 @@ class CleanCommand(ToolkitCommand):
|
|
|
245
272
|
)
|
|
246
273
|
|
|
247
274
|
if not build_dir.is_dir():
|
|
248
|
-
raise ToolkitNotADirectoryError(f"'{build_dir}'. Did you forget to run `cdf
|
|
275
|
+
raise ToolkitNotADirectoryError(f"'{build_dir}'. Did you forget to run `cdf build` first?")
|
|
276
|
+
|
|
277
|
+
selected_modules: list[ReadModule]
|
|
278
|
+
if all_modules:
|
|
279
|
+
selected_modules = clean_state.read_modules or []
|
|
280
|
+
if not selected_modules:
|
|
281
|
+
raise ToolkitValueError("No modules available to clean.")
|
|
282
|
+
elif module_str:
|
|
283
|
+
selected_modules = [module for module in clean_state.read_modules if module.dir.name == module_str]
|
|
284
|
+
if not selected_modules:
|
|
285
|
+
available_module_names = {module.dir.name for module in clean_state.read_modules}
|
|
286
|
+
raise ToolkitMissingModuleError(
|
|
287
|
+
f"No modules matched the selection: {module_str}. Available modules: {sorted(available_module_names)}"
|
|
288
|
+
)
|
|
289
|
+
else:
|
|
290
|
+
selected_modules = self._interactive_module_selection(clean_state.read_modules) or []
|
|
291
|
+
if not selected_modules:
|
|
292
|
+
raise ToolkitValueError(
|
|
293
|
+
"No module specified with the --module option and no modules selected interactively."
|
|
294
|
+
)
|
|
249
295
|
|
|
250
|
-
|
|
296
|
+
selected_resource_folders = {
|
|
297
|
+
resource_folder for module in selected_modules for resource_folder in module.resource_directories
|
|
298
|
+
}
|
|
299
|
+
selected_loaders = self.get_selected_loaders(build_dir, selected_resource_folders, include)
|
|
251
300
|
|
|
252
301
|
results = DeployResults([], "clean", dry_run=dry_run)
|
|
253
302
|
|
|
@@ -274,7 +323,7 @@ class CleanCommand(ToolkitCommand):
|
|
|
274
323
|
result = self.clean_resources(
|
|
275
324
|
loader,
|
|
276
325
|
env_vars=env_vars,
|
|
277
|
-
read_modules=
|
|
326
|
+
read_modules=selected_modules,
|
|
278
327
|
drop=True,
|
|
279
328
|
dry_run=dry_run,
|
|
280
329
|
drop_data=True,
|
|
@@ -169,3 +169,6 @@ DATA_MANIFEST_STEM = "Manifest"
|
|
|
169
169
|
# Migration Constants
|
|
170
170
|
MISSING_INSTANCE_SPACE = "<InstanceSpaceMissing>"
|
|
171
171
|
MISSING_EXTERNAL_ID = "INTERNAL_ID_project_{project}_id_{id}"
|
|
172
|
+
|
|
173
|
+
# Stream Template names
|
|
174
|
+
StreamTemplateName: TypeAlias = Literal["ImmutableTestStream", "BasicArchive", "BasicLiveData"]
|
|
@@ -85,6 +85,10 @@ class Flags(Enum):
|
|
|
85
85
|
visible=False,
|
|
86
86
|
description="Enables features planned for Cognite Toolkit version 0.7.0",
|
|
87
87
|
)
|
|
88
|
+
STREAMS = FlagMetadata(
|
|
89
|
+
visible=True,
|
|
90
|
+
description="Enables the support for the streams resources",
|
|
91
|
+
)
|
|
88
92
|
|
|
89
93
|
def is_enabled(self) -> bool:
|
|
90
94
|
return FeatureFlag.is_enabled(self)
|
|
@@ -18,6 +18,7 @@ class Plugins(Enum):
|
|
|
18
18
|
run = Plugin("run", "plugin for Run command to execute Python scripts in CDF")
|
|
19
19
|
dump = Plugin("dump", "plugin for Dump command to retrieve Asset resources from CDF")
|
|
20
20
|
purge = Plugin("purge", "plugin for Purge command to remove datasets and spaces from CDF")
|
|
21
|
+
dev = Plugin("dev", "plugin for commands to develop modules in CDF")
|
|
21
22
|
|
|
22
23
|
@staticmethod
|
|
23
24
|
def list() -> dict[str, bool]:
|
|
@@ -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
|
+
)
|
|
@@ -4,7 +4,7 @@ default_env = "<DEFAULT_ENV_PLACEHOLDER>"
|
|
|
4
4
|
[modules]
|
|
5
5
|
# This is the version of the modules. It should not be changed manually.
|
|
6
6
|
# It will be updated by the 'cdf modules upgrade' command.
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.99"
|
|
8
8
|
|
|
9
9
|
[alpha_flags]
|
|
10
10
|
external-libraries = true
|
cognite_toolkit/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.6.
|
|
1
|
+
__version__ = "0.6.99"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite_toolkit
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.99
|
|
4
4
|
Summary: Official Cognite Data Fusion tool for project templates and configuration deployment
|
|
5
5
|
Project-URL: Homepage, https://docs.cognite.com/cdf/deploy/cdf_toolkit/
|
|
6
6
|
Project-URL: Changelog, https://github.com/cognitedata/toolkit/releases
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
cognite_toolkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cognite_toolkit/_cdf.py,sha256=
|
|
3
|
-
cognite_toolkit/_version.py,sha256=
|
|
2
|
+
cognite_toolkit/_cdf.py,sha256=0abeQr1Tfk4lkGaoXyrnFC28wDSlR_8UGrh10noGduQ,6085
|
|
3
|
+
cognite_toolkit/_version.py,sha256=DGUWwS-X7ixNBRDUnfXC2eo0mUpmTRgxl2RYLstcKAM,23
|
|
4
4
|
cognite_toolkit/_cdf_tk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite_toolkit/_cdf_tk/cdf_toml.py,sha256=IjmzNVLxsOV6tsMDgmJmXsy-LQru-8IEQdFzGW5DxVk,8117
|
|
6
|
-
cognite_toolkit/_cdf_tk/constants.py,sha256=
|
|
6
|
+
cognite_toolkit/_cdf_tk/constants.py,sha256=t5TZdf0ltCLSDEs0eUVEV9LK5-nXPW00NF85L5EkngU,6485
|
|
7
7
|
cognite_toolkit/_cdf_tk/exceptions.py,sha256=xG0jMwi5A20nvPvyo6sCyz_cyKycynPyIzpYiGR4gcU,6064
|
|
8
|
-
cognite_toolkit/_cdf_tk/feature_flags.py,sha256=
|
|
8
|
+
cognite_toolkit/_cdf_tk/feature_flags.py,sha256=XMIZIOjPCdnH42SupUOETf_0d11TgKPZSfjCKnLoDJo,3017
|
|
9
9
|
cognite_toolkit/_cdf_tk/hints.py,sha256=UI1ymi2T5wCcYOpEbKbVaDnlyFReFy8TDtMVt-5E1h8,6493
|
|
10
|
-
cognite_toolkit/_cdf_tk/plugins.py,sha256=
|
|
10
|
+
cognite_toolkit/_cdf_tk/plugins.py,sha256=JwaN_jrrky1PXBJ3tRpZ22cIcD01EB46WVFgp_bK-fQ,856
|
|
11
11
|
cognite_toolkit/_cdf_tk/protocols.py,sha256=Lc8XnBfmDZN6dwmSopmK7cFE9a9jZ2zdUryEeCXn27I,3052
|
|
12
12
|
cognite_toolkit/_cdf_tk/tracker.py,sha256=ybazaYDMgrtmAaCEb1nlKAQzjcN352-U-om4NBGV328,5965
|
|
13
13
|
cognite_toolkit/_cdf_tk/validation.py,sha256=KFdPgnNIbVM0yjFF0cqmpBB8MI8e-U-YbBYrP4IiClE,8441
|
|
14
|
-
cognite_toolkit/_cdf_tk/apps/__init__.py,sha256=
|
|
14
|
+
cognite_toolkit/_cdf_tk/apps/__init__.py,sha256=KKmhbpvPKTwqQS2g_XqAC2yvtPsvdl8wV5TgJA3zqhs,702
|
|
15
15
|
cognite_toolkit/_cdf_tk/apps/_auth_app.py,sha256=ER7uYb3ViwsHMXiQEZpyhwU6TIjKaB9aEy32VI4MPpg,3397
|
|
16
|
-
cognite_toolkit/_cdf_tk/apps/_core_app.py,sha256=
|
|
16
|
+
cognite_toolkit/_cdf_tk/apps/_core_app.py,sha256=Xlhdv2MoCs2kBk0kgJixiy8ouCfixUWXuK3crEXAqB0,14032
|
|
17
17
|
cognite_toolkit/_cdf_tk/apps/_data_app.py,sha256=rFnTcUBAuoFcTQCjxwqZGG0HjUMGdYTFyBGXxWg5gXE,824
|
|
18
|
+
cognite_toolkit/_cdf_tk/apps/_dev_app.py,sha256=q8DBr4BAK33AwsHW3gAWZWSjSaQRuCisqPbsBjmYSxk,589
|
|
18
19
|
cognite_toolkit/_cdf_tk/apps/_download_app.py,sha256=faAuhFYn7eQ_uzP3BNmnXeaeeoyZR1JvRZx2ATKrsao,16691
|
|
19
20
|
cognite_toolkit/_cdf_tk/apps/_dump_app.py,sha256=Ec0aEqbKwCkxni09i06rfY31qZUyOVwbbvo7MHh4cf8,39056
|
|
20
21
|
cognite_toolkit/_cdf_tk/apps/_landing_app.py,sha256=tV8hpqxLm2YgqB-TWieheK7ucN-JhQVtN13V3Zth6Os,386
|
|
@@ -36,10 +37,10 @@ cognite_toolkit/_cdf_tk/builders/_streamlit.py,sha256=8Pu_zgyKZjbAsPWywjzB2KWD7h
|
|
|
36
37
|
cognite_toolkit/_cdf_tk/builders/_transformation.py,sha256=STB42zhzOW5M_-b8cKOQ_cegnr7FtMoMxZ87gPLXft4,4723
|
|
37
38
|
cognite_toolkit/_cdf_tk/client/__init__.py,sha256=a6rQXDGfW2g7K5WwrOW5oakh1TdFlBjUVjf9wusOox8,135
|
|
38
39
|
cognite_toolkit/_cdf_tk/client/_constants.py,sha256=COUGcea37mDF2sf6MGqJXWmecTY_6aCImslxXrYW1I0,73
|
|
39
|
-
cognite_toolkit/_cdf_tk/client/_toolkit_client.py,sha256=
|
|
40
|
+
cognite_toolkit/_cdf_tk/client/_toolkit_client.py,sha256=InfVdwtj5WA9hfa2kUr4sdhTCBhE08aDlVg2_QMKP5k,2928
|
|
40
41
|
cognite_toolkit/_cdf_tk/client/api_client.py,sha256=CQdD_gfDqQkz5OYHrTnKvBvEvzHPdHDB1BkZPWRoahg,440
|
|
41
42
|
cognite_toolkit/_cdf_tk/client/config.py,sha256=weMR43z-gqHMn-Jqvfmh_nJ0HbgEdyeCGtISuEf3OuY,4269
|
|
42
|
-
cognite_toolkit/_cdf_tk/client/testing.py,sha256=
|
|
43
|
+
cognite_toolkit/_cdf_tk/client/testing.py,sha256=5ZZI4k9efHlBH97zvV-gmYiHtG9wSqXJ57TGoN_F4RY,6313
|
|
43
44
|
cognite_toolkit/_cdf_tk/client/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
45
|
cognite_toolkit/_cdf_tk/client/api/canvas.py,sha256=i2NwyhvmklTPx3e-yd4lvSxyn6JEjSpv8WXa1SxtmV8,8789
|
|
45
46
|
cognite_toolkit/_cdf_tk/client/api/charts.py,sha256=t-VOrRGwpjmYUtUqGObQWYwGb5gOHVp4cHZBm8ZVGn0,4953
|
|
@@ -57,6 +58,7 @@ cognite_toolkit/_cdf_tk/client/api/migration.py,sha256=eIKcUAXHblL0vL9UzyZgifnL4
|
|
|
57
58
|
cognite_toolkit/_cdf_tk/client/api/project.py,sha256=Hj0uDCLyPofG-T4626EdeoRRtBaovhU-SMAQ7VWJ1M4,1063
|
|
58
59
|
cognite_toolkit/_cdf_tk/client/api/search.py,sha256=L4cDPip7pJVP7bEgAiSOjqINIHg8AULNBtR29G5khEQ,612
|
|
59
60
|
cognite_toolkit/_cdf_tk/client/api/search_config.py,sha256=31rPCSOnzfiLv8FKU6F3tF9ZesEV8moSlbnkFPNh13g,1824
|
|
61
|
+
cognite_toolkit/_cdf_tk/client/api/streams.py,sha256=4u5jRdbhxKbVR8OLURyVwehHgoejFxArjUAGni78PNY,3015
|
|
60
62
|
cognite_toolkit/_cdf_tk/client/api/token.py,sha256=8SiA44Dwsx0j_X8lgIxl2rdNCQSdEiSfoD_4ybxMtFA,5131
|
|
61
63
|
cognite_toolkit/_cdf_tk/client/api/verify.py,sha256=-x6z6lMaOZG91adi0m9NtJ4wIQgoZURbzluPALXM-ps,3730
|
|
62
64
|
cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py,sha256=6xDSr24_IkLRx_kAKU0_e6_sqnxVWcQChnML_NJqnIQ,56
|
|
@@ -94,6 +96,7 @@ cognite_toolkit/_cdf_tk/client/data_classes/robotics.py,sha256=1hlcuFANJW_uRwJsp
|
|
|
94
96
|
cognite_toolkit/_cdf_tk/client/data_classes/search_config.py,sha256=Reo_rcFrwk_sWEtIGd87UNgD0k3Zy8f52XIjkiPxGG8,8155
|
|
95
97
|
cognite_toolkit/_cdf_tk/client/data_classes/sequences.py,sha256=02d34fPcJ1H7U5ZnCCfOi36z5WJ4WnRfCWwkp99mW2E,6234
|
|
96
98
|
cognite_toolkit/_cdf_tk/client/data_classes/streamlit_.py,sha256=nEk00FH3i-px2r6ql4kk1VVL4sytjUn0_sTkEdDSHVc,6746
|
|
99
|
+
cognite_toolkit/_cdf_tk/client/data_classes/streams.py,sha256=LjOrah8UmGk_N-m07INkVcn2u59DjX0-REGeDsW6E8E,3414
|
|
97
100
|
cognite_toolkit/_cdf_tk/client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
101
|
cognite_toolkit/_cdf_tk/client/utils/_concurrency.py,sha256=3GtQbKDaosyKHEt-KzxKK9Yie4TvZPdoou2vUk6dUa8,2298
|
|
99
102
|
cognite_toolkit/_cdf_tk/client/utils/_http_client.py,sha256=oXNKrIaizG4WiSAhL_kSCHAuL4aaaEhCU4pOJGxh6Xs,483
|
|
@@ -109,7 +112,7 @@ cognite_toolkit/_cdf_tk/commands/_utils.py,sha256=UxMJW5QYKts4om5n6x2Tq2ihvfO9gW
|
|
|
109
112
|
cognite_toolkit/_cdf_tk/commands/_virtual_env.py,sha256=GFAid4hplixmj9_HkcXqU5yCLj-fTXm4cloGD6U2swY,2180
|
|
110
113
|
cognite_toolkit/_cdf_tk/commands/auth.py,sha256=N6JgtF0_Qoh-xM8VlBb_IK1n0Lo5I7bIkIHmXm1l7ug,31638
|
|
111
114
|
cognite_toolkit/_cdf_tk/commands/build_cmd.py,sha256=k2_BhmTJRXuB640-g4hFsN2tD58b-aujk6kFn400qsc,30516
|
|
112
|
-
cognite_toolkit/_cdf_tk/commands/clean.py,sha256=
|
|
115
|
+
cognite_toolkit/_cdf_tk/commands/clean.py,sha256=KDcUn1MEpvk_K7WqQPBiZcIlGV61JVG6D0DcYUXj7BM,16567
|
|
113
116
|
cognite_toolkit/_cdf_tk/commands/collect.py,sha256=zBMKhhvjOpuASMnwP0eeHRI02tANcvFEZgv0CQO1ECc,627
|
|
114
117
|
cognite_toolkit/_cdf_tk/commands/deploy.py,sha256=R185y7oFr3yhh10RSPE81dpYX346ghVYOrVEF-JKaaI,23020
|
|
115
118
|
cognite_toolkit/_cdf_tk/commands/dump_data.py,sha256=8l4M2kqV4DjiV5js5s7EbFVNxV0Np4ld8ogw19vaJp0,21804
|
|
@@ -215,6 +218,7 @@ cognite_toolkit/_cdf_tk/resource_classes/securitycategories.py,sha256=6cGCj_3Hs9
|
|
|
215
218
|
cognite_toolkit/_cdf_tk/resource_classes/sequence.py,sha256=WU_iarU34vtmt9eXEa5YfwdanBnAR7clMJwQi6yMByg,3356
|
|
216
219
|
cognite_toolkit/_cdf_tk/resource_classes/space.py,sha256=jC3-6xUhcfglNoW4P3kkmD6duNa5S6YrZlDseOBJXUo,971
|
|
217
220
|
cognite_toolkit/_cdf_tk/resource_classes/streamlit_.py,sha256=1ncfwoBZqj4V-dOkHnj6BFHzyDhnbakSsPoBWlQF74o,1095
|
|
221
|
+
cognite_toolkit/_cdf_tk/resource_classes/streams.py,sha256=wCKjTuGm5XQdsbxuYfg0xMGu5wBbWajgI2Kg1Xt8jU0,828
|
|
218
222
|
cognite_toolkit/_cdf_tk/resource_classes/threedmodels.py,sha256=pDlCKXCpSnupb4kO-0dHWDzNGzak73tHfjvM2-AtKnE,519
|
|
219
223
|
cognite_toolkit/_cdf_tk/resource_classes/timeseries.py,sha256=wVlXR6tsmC-xmCnF4d17CpITr4fhpHcN9wCdvKhlIy8,458
|
|
220
224
|
cognite_toolkit/_cdf_tk/resource_classes/transformation_destination.py,sha256=AjfGS0JTGGG7aqUiezxtaiv_dBp-QMvHLwulXUIW8sA,6525
|
|
@@ -294,13 +298,13 @@ cognite_toolkit/_repo_files/.gitignore,sha256=ip9kf9tcC5OguF4YF4JFEApnKYw0nG0vPi
|
|
|
294
298
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/README.md,sha256=OLA0D7yCX2tACpzvkA0IfkgQ4_swSd-OlJ1tYcTBpsA,240
|
|
295
299
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/deploy-pipeline.yml,sha256=brULcs8joAeBC_w_aoWjDDUHs3JheLMIR9ajPUK96nc,693
|
|
296
300
|
cognite_toolkit/_repo_files/AzureDevOps/.devops/dry-run-pipeline.yml,sha256=OBFDhFWK1mlT4Dc6mDUE2Es834l8sAlYG50-5RxRtHk,723
|
|
297
|
-
cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=
|
|
298
|
-
cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=
|
|
299
|
-
cognite_toolkit/_resources/cdf.toml,sha256=
|
|
301
|
+
cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml,sha256=la3qBRtQQqa-FDTjMALDT2DXgVP6Bu9FYTby1X32WXg,667
|
|
302
|
+
cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml,sha256=SUEUhsROq20e30svUJ9oPoQaKuc5QiY2rMvdgitQUDw,2430
|
|
303
|
+
cognite_toolkit/_resources/cdf.toml,sha256=cD1UBfSEeuaW5Sf1FCL3h1exyJNwOi87rLqU-NMqpZc,487
|
|
300
304
|
cognite_toolkit/demo/__init__.py,sha256=-m1JoUiwRhNCL18eJ6t7fZOL7RPfowhCuqhYFtLgrss,72
|
|
301
305
|
cognite_toolkit/demo/_base.py,sha256=6xKBUQpXZXGQ3fJ5f7nj7oT0s2n7OTAGIa17ZlKHZ5U,8052
|
|
302
|
-
cognite_toolkit-0.6.
|
|
303
|
-
cognite_toolkit-0.6.
|
|
304
|
-
cognite_toolkit-0.6.
|
|
305
|
-
cognite_toolkit-0.6.
|
|
306
|
-
cognite_toolkit-0.6.
|
|
306
|
+
cognite_toolkit-0.6.99.dist-info/METADATA,sha256=4Fui-pU97C-Chi5IpDPFuMTk5nuLZbySZ1GyKYVgiV0,4501
|
|
307
|
+
cognite_toolkit-0.6.99.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
308
|
+
cognite_toolkit-0.6.99.dist-info/entry_points.txt,sha256=JlR7MH1_UMogC3QOyN4-1l36VbrCX9xUdQoHGkuJ6-4,83
|
|
309
|
+
cognite_toolkit-0.6.99.dist-info/licenses/LICENSE,sha256=CW0DRcx5tL-pCxLEN7ts2S9g2sLRAsWgHVEX4SN9_Mc,752
|
|
310
|
+
cognite_toolkit-0.6.99.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|