cognite-toolkit 0.7.39__py3-none-any.whl → 0.7.51__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/apps/_download_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +6 -6
- cognite_toolkit/_cdf_tk/builders/_function.py +81 -9
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/_resource_base.py +187 -0
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +37 -5
- cognite_toolkit/_cdf_tk/client/api/agents.py +107 -0
- cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/assets.py +130 -0
- cognite_toolkit/_cdf_tk/client/api/containers.py +132 -0
- cognite_toolkit/_cdf_tk/client/api/data_models.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/datasets.py +141 -0
- cognite_toolkit/_cdf_tk/client/api/events.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/extraction_pipelines.py +148 -0
- cognite_toolkit/_cdf_tk/client/api/filemetadata.py +176 -0
- cognite_toolkit/_cdf_tk/client/api/function_schedules.py +115 -0
- cognite_toolkit/_cdf_tk/client/api/functions.py +113 -0
- cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py +167 -0
- cognite_toolkit/_cdf_tk/client/api/groups.py +121 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_destinations.py +131 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_jobs.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_mappings.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_sources.py +136 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractors.py +23 -0
- cognite_toolkit/_cdf_tk/client/api/infield.py +8 -8
- cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/labels.py +125 -0
- cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py +3 -3
- cognite_toolkit/_cdf_tk/client/api/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_data_modeling.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_files.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_functions.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_timeseries.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/robots.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +177 -0
- cognite_toolkit/_cdf_tk/client/api/migration.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/project.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/raw.py +204 -0
- cognite_toolkit/_cdf_tk/client/api/relationships.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/robotics.py +19 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/search_config.py +101 -0
- cognite_toolkit/_cdf_tk/client/api/security_categories.py +94 -0
- cognite_toolkit/_cdf_tk/client/api/sequences.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/simulator_models.py +154 -0
- cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -0
- cognite_toolkit/_cdf_tk/client/api/streams.py +65 -57
- cognite_toolkit/_cdf_tk/client/api/three_d.py +300 -283
- cognite_toolkit/_cdf_tk/client/api/timeseries.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/token.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/transformations.py +146 -0
- cognite_toolkit/_cdf_tk/client/api/views.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_triggers.py +128 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_versions.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/workflows.py +119 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +10 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +358 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +38 -0
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/__init__.py +9 -7
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +23 -14
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +12 -2
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +151 -0
- cognite_toolkit/_cdf_tk/client/http_client/_exception.py +13 -0
- cognite_toolkit/_cdf_tk/client/http_client/_item_classes.py +118 -0
- cognite_toolkit/_cdf_tk/client/request_classes/base.py +19 -0
- cognite_toolkit/_cdf_tk/client/request_classes/filters.py +113 -0
- cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +130 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/annotation.py +79 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/asset.py +47 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/charts_data.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +168 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_constraints.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_container.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_model.py +73 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_types.py +116 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_indexes.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +154 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_references.py +86 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_space.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view.py +143 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view_property.py +152 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/dataset.py +35 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/event.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/extraction_pipeline.py +59 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/filemetadata.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function_schedule.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/graphql_data_model.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/__init__.py +187 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/_constants.py +2 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py +653 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/capability.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py +166 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_destination.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_job.py +134 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_mapping.py +72 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/__init__.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_auth.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_base.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_certificate.py +20 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_eventhub.py +31 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_kafka.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_mqtt.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_rest.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +59 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/infield.py +1 -1
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/instance_api.py +35 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/label.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/canvas.py +48 -15
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +84 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/raw.py +44 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/relationship.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/__init__.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_capability.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_common.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_data_post_processing.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_frame.py +46 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_location.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +58 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/search_config.py +54 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/securitycategory.py +24 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence.py +45 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence_rows.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/simulator_model.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/streamlit_.py +71 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/streams.py +9 -26
- cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +135 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/timeseries.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/transformation.py +140 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_trigger.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_version.py +155 -0
- cognite_toolkit/_cdf_tk/client/testing.py +31 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +22 -15
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +11 -10
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +148 -57
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +22 -39
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +29 -27
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +8 -8
- cognite_toolkit/_cdf_tk/commands/_upload.py +1 -1
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +12 -2
- cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py +138 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/_modules_parser.py +163 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +83 -96
- cognite_toolkit/_cdf_tk/commands/build_v2/{build_input.py → build_parameters.py} +8 -22
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_modules.py +27 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_resource.py +22 -0
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
- cognite_toolkit/_cdf_tk/commands/pull.py +97 -2
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +16 -6
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +9 -5
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +6 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +70 -89
- 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 +14 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -3
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +6 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +5 -4
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +122 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +15 -31
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +42 -47
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +1 -1
- cognite_toolkit/_cdf_tk/data_classes/__init__.py +3 -0
- cognite_toolkit/_cdf_tk/data_classes/_issues.py +36 -0
- cognite_toolkit/_cdf_tk/data_classes/_module_directories.py +2 -1
- cognite_toolkit/_cdf_tk/data_classes/_tracking_info.py +4 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +8 -0
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +6 -0
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +13 -4
- cognite_toolkit/_cdf_tk/storageio/_applications.py +53 -15
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +117 -107
- cognite_toolkit/_cdf_tk/storageio/_base.py +3 -1
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +7 -7
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +64 -54
- cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
- cognite_toolkit/_cdf_tk/tk_warnings/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/tk_warnings/fileread.py +20 -0
- cognite_toolkit/_cdf_tk/utils/__init__.py +11 -1
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +8 -6
- cognite_toolkit/_cdf_tk/utils/modules.py +7 -0
- cognite_toolkit/_cdf_tk/utils/pip_validator.py +96 -0
- cognite_toolkit/_cdf_tk/utils/useful_types.py +4 -7
- cognite_toolkit/_cdf_tk/utils/useful_types2.py +14 -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.39.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
- cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -30
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -67
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -112
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +0 -27
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -247
- cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
- cognite_toolkit-0.7.39.dist-info/RECORD +0 -322
- /cognite_toolkit/_cdf_tk/{utils → client}/http_client/_tracker.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → request_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes/legacy → resource_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/capabilities.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/apm_config_v1.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extendable_cognite_file.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetadata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetdata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_timeseries.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/functions.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/graphql_data_models.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/instances.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/location_filters.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/migration.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/pending_instances_ids.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/project.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/raw.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/robotics.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/search_config.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/sequences.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/streamlit_.py +0 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from itertools import groupby
|
|
1
3
|
from pathlib import Path
|
|
2
|
-
from typing import Any, Literal
|
|
4
|
+
from typing import Any, Literal
|
|
3
5
|
|
|
4
6
|
from rich import print
|
|
5
7
|
from rich.panel import Panel
|
|
@@ -7,39 +9,29 @@ from rich.panel import Panel
|
|
|
7
9
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
8
10
|
from cognite_toolkit._cdf_tk.commands._base import ToolkitCommand
|
|
9
11
|
from cognite_toolkit._cdf_tk.commands.build_cmd import BuildCommand as OldBuildCommand
|
|
10
|
-
from cognite_toolkit._cdf_tk.commands.build_v2.
|
|
11
|
-
from cognite_toolkit._cdf_tk.commands.build_v2.
|
|
12
|
-
from cognite_toolkit._cdf_tk.data_classes import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
BuiltModuleList,
|
|
16
|
-
ModuleDirectories,
|
|
17
|
-
)
|
|
12
|
+
from cognite_toolkit._cdf_tk.commands.build_v2._modules_parser import ModulesParser
|
|
13
|
+
from cognite_toolkit._cdf_tk.commands.build_v2.build_parameters import BuildParameters
|
|
14
|
+
from cognite_toolkit._cdf_tk.commands.build_v2.data_classes._modules import Module
|
|
15
|
+
from cognite_toolkit._cdf_tk.data_classes import BuildConfigYAML, BuildVariables, BuiltModuleList
|
|
16
|
+
from cognite_toolkit._cdf_tk.data_classes._issues import Issue, IssueList
|
|
18
17
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitError
|
|
19
|
-
from cognite_toolkit._cdf_tk.hints import verify_module_directory
|
|
20
18
|
from cognite_toolkit._cdf_tk.tk_warnings import ToolkitWarning, WarningList
|
|
21
19
|
from cognite_toolkit._cdf_tk.utils.file import safe_rmtree
|
|
22
|
-
from cognite_toolkit._cdf_tk.validation import validate_module_selection, validate_modules_variables
|
|
23
20
|
from cognite_toolkit._version import __version__
|
|
24
21
|
|
|
25
22
|
|
|
26
|
-
class BuildWarnings(TypedDict):
|
|
27
|
-
warning: ToolkitWarning
|
|
28
|
-
location: list[Path]
|
|
29
|
-
|
|
30
|
-
|
|
31
23
|
class BuildCommand(ToolkitCommand):
|
|
32
24
|
def __init__(self, print_warning: bool = True, skip_tracking: bool = False, silent: bool = False) -> None:
|
|
33
25
|
super().__init__(print_warning, skip_tracking, silent)
|
|
34
|
-
self.issues =
|
|
26
|
+
self.issues = IssueList()
|
|
35
27
|
|
|
36
28
|
def execute(
|
|
37
29
|
self,
|
|
38
30
|
verbose: bool,
|
|
39
|
-
|
|
31
|
+
base_dir: Path,
|
|
40
32
|
build_dir: Path,
|
|
41
33
|
selected: list[str | Path] | None,
|
|
42
|
-
|
|
34
|
+
build_env: str | None,
|
|
43
35
|
no_clean: bool,
|
|
44
36
|
client: ToolkitClient | None = None,
|
|
45
37
|
on_error: Literal["continue", "raise"] = "continue",
|
|
@@ -51,30 +43,48 @@ class BuildCommand(ToolkitCommand):
|
|
|
51
43
|
self.verbose = verbose
|
|
52
44
|
self.on_error = on_error
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
build_parameters = BuildParameters.load(
|
|
47
|
+
organization_dir=base_dir,
|
|
48
|
+
build_dir=build_dir,
|
|
49
|
+
build_env_name=build_env,
|
|
50
|
+
client=client,
|
|
51
|
+
user_selected=selected,
|
|
52
|
+
)
|
|
61
53
|
|
|
62
54
|
# Print the build input.
|
|
63
55
|
if self.verbose:
|
|
64
|
-
self._print_build_input(
|
|
56
|
+
self._print_build_input(build_parameters)
|
|
65
57
|
|
|
66
|
-
#
|
|
67
|
-
if
|
|
68
|
-
self.
|
|
58
|
+
# Tracking the project and cluster for the build.
|
|
59
|
+
if build_parameters.client:
|
|
60
|
+
self._additional_tracking_info.project = build_parameters.client.config.project
|
|
61
|
+
self._additional_tracking_info.cluster = build_parameters.client.config.cdf_cluster
|
|
62
|
+
|
|
63
|
+
# Load modules
|
|
64
|
+
modules_parser = ModulesParser(organization_dir=base_dir, selected=selected)
|
|
65
|
+
module_paths = modules_parser.parse()
|
|
66
|
+
module_loading_issues = modules_parser.issues
|
|
67
|
+
if module_loading_issues:
|
|
68
|
+
self.issues.extend(module_loading_issues)
|
|
69
|
+
self._print_or_log_issues_by_category(self.issues)
|
|
70
|
+
raise ToolkitError("Module loading issues encountered. Cannot continue. See above for details.")
|
|
71
|
+
|
|
72
|
+
# Load modules
|
|
73
|
+
if module_paths:
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
# modules = [Module.load(path) for path in module_paths]
|
|
77
|
+
# for module in modules:
|
|
78
|
+
# continue
|
|
69
79
|
|
|
70
80
|
# Logistics: clean and create build directory
|
|
71
|
-
if prepare_issues := self._prepare_target_directory(
|
|
81
|
+
if prepare_issues := self._prepare_target_directory(build_dir, not no_clean):
|
|
72
82
|
self.issues.extend(prepare_issues)
|
|
73
83
|
|
|
74
84
|
# Compile the configuration and variables,
|
|
75
85
|
# check syntax on module and resource level
|
|
76
86
|
# for any "compilation errors and warnings"
|
|
77
|
-
built_modules, build_integrity_issues = self._build_configuration(
|
|
87
|
+
built_modules, build_integrity_issues = self._build_configuration(build_parameters)
|
|
78
88
|
if build_integrity_issues:
|
|
79
89
|
self.issues.extend(build_integrity_issues)
|
|
80
90
|
|
|
@@ -83,84 +93,48 @@ class BuildCommand(ToolkitCommand):
|
|
|
83
93
|
self.issues.extend(build_quality_issues)
|
|
84
94
|
|
|
85
95
|
# Finally, print warnings grouped by category/code and location.
|
|
86
|
-
self.
|
|
96
|
+
self._print_or_log_issues_by_category(self.issues)
|
|
87
97
|
|
|
88
98
|
return built_modules
|
|
89
99
|
|
|
90
|
-
def _print_build_input(self,
|
|
100
|
+
def _print_build_input(self, build_input: BuildParameters) -> None:
|
|
91
101
|
print(
|
|
92
102
|
Panel(
|
|
93
|
-
f"Building {
|
|
94
|
-
f" - Environment name {
|
|
95
|
-
f" - Config '{
|
|
103
|
+
f"Building {build_input.organization_dir!s}:\n - Toolkit Version '{__version__!s}'\n"
|
|
104
|
+
f" - Environment name {build_input.build_env_name!r}, validation-type {build_input.config.environment.validation_type!r}.\n"
|
|
105
|
+
f" - Config '{build_input.config.filepath!s}'",
|
|
96
106
|
expand=False,
|
|
97
107
|
)
|
|
98
108
|
)
|
|
99
109
|
|
|
100
|
-
def _prepare_target_directory(self,
|
|
110
|
+
def _prepare_target_directory(self, build_dir: Path, clean: bool = False) -> IssueList:
|
|
101
111
|
"""
|
|
102
112
|
Directory logistics
|
|
103
113
|
"""
|
|
104
|
-
issues =
|
|
105
|
-
if
|
|
114
|
+
issues = IssueList()
|
|
115
|
+
if build_dir.exists() and any(build_dir.iterdir()):
|
|
106
116
|
if not clean:
|
|
107
117
|
raise ToolkitError("Build directory is not empty. Run without --no-clean to remove existing files.")
|
|
108
118
|
|
|
109
119
|
if self.verbose:
|
|
110
|
-
issues.append(
|
|
111
|
-
safe_rmtree(
|
|
112
|
-
|
|
120
|
+
issues.append(Issue(code="BUILD_001"))
|
|
121
|
+
safe_rmtree(build_dir)
|
|
122
|
+
build_dir.mkdir(parents=True, exist_ok=True)
|
|
113
123
|
return issues
|
|
114
124
|
|
|
115
|
-
def
|
|
116
|
-
issues =
|
|
117
|
-
#
|
|
118
|
-
# and at least one is selected
|
|
119
|
-
verify_module_directory(input.organization_dir, input.build_env_name)
|
|
120
|
-
|
|
121
|
-
# Validate module selection
|
|
122
|
-
user_selected_modules = input.config.environment.get_selected_modules({})
|
|
123
|
-
module_warnings = validate_module_selection(
|
|
124
|
-
modules=input.modules,
|
|
125
|
-
config=input.config,
|
|
126
|
-
packages={},
|
|
127
|
-
selected_modules=user_selected_modules,
|
|
128
|
-
organization_dir=input.organization_dir,
|
|
129
|
-
)
|
|
130
|
-
if module_warnings:
|
|
131
|
-
issues.extend(BuildIssueList.from_warning_list(module_warnings))
|
|
132
|
-
|
|
133
|
-
# Validate variables. Note: this looks for non-replaced template
|
|
134
|
-
# variables <.*?> and can be improved in the future.
|
|
135
|
-
# Keeping for reference.
|
|
136
|
-
variables_warnings = validate_modules_variables(input.variables, input.config.filepath)
|
|
137
|
-
if variables_warnings:
|
|
138
|
-
issues.extend(BuildIssueList.from_warning_list(variables_warnings))
|
|
139
|
-
|
|
140
|
-
# Track LOC of managed configuration
|
|
141
|
-
# Note: _track is not implemented yet, so we skip it for now
|
|
142
|
-
# self._track(input)
|
|
143
|
-
|
|
144
|
-
return issues
|
|
145
|
-
|
|
146
|
-
def _build_configuration(self, input: BuildInput) -> tuple[BuiltModuleList, BuildIssueList]:
|
|
147
|
-
issues = BuildIssueList()
|
|
148
|
-
# Use input.modules.selected directly (it's already a ModuleDirectories)
|
|
149
|
-
if not input.modules.selected:
|
|
150
|
-
return BuiltModuleList(), issues
|
|
151
|
-
|
|
152
|
-
# first collect variables into practical lookup
|
|
153
|
-
# TODO: parallelism is not implemented yet. I'm sure there are optimizations to be had here, but we'll focus on process parallelism since we believe loading yaml and file i/O are the biggest bottlenecks.
|
|
125
|
+
def _build_configuration(self, build_input: BuildParameters) -> tuple[BuiltModuleList, IssueList]:
|
|
126
|
+
issues = IssueList()
|
|
127
|
+
# Use build_input.modules directly (it is already filtered by selection)
|
|
154
128
|
|
|
155
129
|
old_build_command = OldBuildCommand(print_warning=False, skip_tracking=False)
|
|
156
130
|
built_modules = old_build_command.build_config(
|
|
157
|
-
build_dir=
|
|
158
|
-
organization_dir=
|
|
159
|
-
config=
|
|
131
|
+
build_dir=build_input.build_dir,
|
|
132
|
+
organization_dir=build_input.organization_dir,
|
|
133
|
+
config=build_input.config,
|
|
160
134
|
packages={},
|
|
161
135
|
clean=False,
|
|
162
136
|
verbose=self.verbose,
|
|
163
|
-
client=
|
|
137
|
+
client=build_input.client,
|
|
164
138
|
progress_bar=False,
|
|
165
139
|
on_error=self.on_error,
|
|
166
140
|
)
|
|
@@ -172,29 +146,42 @@ class BuildCommand(ToolkitCommand):
|
|
|
172
146
|
# Always convert warnings to issues, even if the list appears empty
|
|
173
147
|
# (WarningList might have custom __bool__ behavior)
|
|
174
148
|
if old_build_command.warning_list:
|
|
175
|
-
converted_issues =
|
|
149
|
+
converted_issues = IssueList.from_warning_list(old_build_command.warning_list)
|
|
176
150
|
issues.extend(converted_issues)
|
|
177
151
|
return built_modules, issues
|
|
178
152
|
|
|
179
|
-
def _verify_build_quality(self, built_modules: BuiltModuleList) ->
|
|
180
|
-
issues =
|
|
153
|
+
def _verify_build_quality(self, built_modules: BuiltModuleList) -> IssueList:
|
|
154
|
+
issues = IssueList()
|
|
181
155
|
return issues
|
|
182
156
|
|
|
183
|
-
def _write(self,
|
|
157
|
+
def _write(self, build_input: BuildParameters) -> None:
|
|
184
158
|
# Write the build to the build directory.
|
|
185
159
|
# Track lines of code built.
|
|
186
160
|
raise NotImplementedError()
|
|
187
161
|
|
|
188
|
-
def _track(self,
|
|
162
|
+
def _track(self, build_input: BuildParameters) -> None:
|
|
189
163
|
raise NotImplementedError()
|
|
190
164
|
|
|
191
|
-
def
|
|
192
|
-
|
|
165
|
+
def _print_or_log_issues_by_category(self, issues: IssueList) -> None:
|
|
166
|
+
issues_sorted = sorted(issues, key=self._issue_sort_key)
|
|
167
|
+
for code, grouped_issues in groupby(issues_sorted, key=lambda issue: issue.code or ""):
|
|
168
|
+
print(f"[bold]{code}[/]")
|
|
169
|
+
for issue in grouped_issues:
|
|
170
|
+
message = issue.message or ""
|
|
171
|
+
print(f" - {message}")
|
|
172
|
+
|
|
173
|
+
def _issue_sort_key(self, issue: Issue) -> tuple[str, str]:
|
|
174
|
+
code = issue.code or ""
|
|
175
|
+
if not issue.message:
|
|
176
|
+
return code, ""
|
|
177
|
+
match = re.search(r"'([^']+)'", issue.message)
|
|
178
|
+
path = match.group(1) if match else issue.message
|
|
179
|
+
return code, path
|
|
193
180
|
|
|
194
181
|
# Delegate to old BuildCommand for backward compatibility with tests
|
|
195
182
|
def build_modules(
|
|
196
183
|
self,
|
|
197
|
-
modules:
|
|
184
|
+
modules: list[Module],
|
|
198
185
|
build_dir: Path,
|
|
199
186
|
variables: BuildVariables,
|
|
200
187
|
verbose: bool = False,
|
|
@@ -204,10 +191,10 @@ class BuildCommand(ToolkitCommand):
|
|
|
204
191
|
"""Delegate to old BuildCommand for backward compatibility."""
|
|
205
192
|
old_cmd = OldBuildCommand()
|
|
206
193
|
|
|
207
|
-
built_modules = old_cmd.build_modules(modules, build_dir, variables, verbose, progress_bar, on_error)
|
|
194
|
+
built_modules = old_cmd.build_modules(modules, build_dir, variables, verbose, progress_bar, on_error) # type: ignore[arg-type]
|
|
208
195
|
self._additional_tracking_info.package_ids.update(old_cmd._additional_tracking_info.package_ids)
|
|
209
196
|
self._additional_tracking_info.module_ids.update(old_cmd._additional_tracking_info.module_ids)
|
|
210
|
-
self.issues.extend(
|
|
197
|
+
self.issues.extend(IssueList.from_warning_list(old_cmd.warning_list or WarningList[ToolkitWarning]()))
|
|
211
198
|
return built_modules
|
|
212
199
|
|
|
213
200
|
def build_config(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
from functools import cached_property
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
|
|
5
4
|
if sys.version_info >= (3, 11):
|
|
@@ -13,14 +12,12 @@ from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
|
13
12
|
from cognite_toolkit._cdf_tk.constants import DEFAULT_ENV
|
|
14
13
|
from cognite_toolkit._cdf_tk.data_classes import (
|
|
15
14
|
BuildConfigYAML,
|
|
16
|
-
BuildVariables,
|
|
17
|
-
ModuleDirectories,
|
|
18
15
|
)
|
|
19
16
|
from cognite_toolkit._cdf_tk.tk_warnings import ToolkitWarning, WarningList
|
|
20
17
|
from cognite_toolkit._cdf_tk.utils.modules import parse_user_selected_modules
|
|
21
18
|
|
|
22
19
|
|
|
23
|
-
class
|
|
20
|
+
class BuildParameters(BaseModel):
|
|
24
21
|
"""Input to the build process."""
|
|
25
22
|
|
|
26
23
|
# need this until we turn BuildConfigYaml and ToolkitClient into Pydantic models
|
|
@@ -31,8 +28,8 @@ class BuildInput(BaseModel):
|
|
|
31
28
|
build_env_name: str
|
|
32
29
|
config: BuildConfigYAML
|
|
33
30
|
client: ToolkitClient | None = None
|
|
34
|
-
selected: list[str | Path] | None = None
|
|
35
31
|
warnings: WarningList[ToolkitWarning] | None = None
|
|
32
|
+
user_selected: list[str | Path] | None = None
|
|
36
33
|
|
|
37
34
|
@classmethod
|
|
38
35
|
def load(
|
|
@@ -41,24 +38,24 @@ class BuildInput(BaseModel):
|
|
|
41
38
|
build_dir: Path,
|
|
42
39
|
build_env_name: str | None,
|
|
43
40
|
client: ToolkitClient | None,
|
|
44
|
-
|
|
41
|
+
user_selected: list[str | Path] | None = None,
|
|
45
42
|
) -> Self:
|
|
46
43
|
resolved_org_dir = Path.cwd() if organization_dir in {Path("."), Path("./")} else organization_dir
|
|
47
44
|
resolved_env = build_env_name or DEFAULT_ENV
|
|
48
|
-
config, warnings = cls._load_config(resolved_org_dir, resolved_env,
|
|
45
|
+
config, warnings = cls._load_config(resolved_org_dir, resolved_env, user_selected)
|
|
49
46
|
return cls(
|
|
50
47
|
organization_dir=resolved_org_dir,
|
|
51
48
|
build_dir=build_dir,
|
|
52
49
|
build_env_name=resolved_env,
|
|
53
50
|
config=config,
|
|
54
51
|
client=client,
|
|
55
|
-
selected=selected,
|
|
56
52
|
warnings=warnings,
|
|
53
|
+
user_selected=user_selected,
|
|
57
54
|
)
|
|
58
55
|
|
|
59
56
|
@classmethod
|
|
60
57
|
def _load_config(
|
|
61
|
-
cls, organization_dir: Path, build_env_name: str,
|
|
58
|
+
cls, organization_dir: Path, build_env_name: str, user_selected: list[str | Path] | None
|
|
62
59
|
) -> tuple[BuildConfigYAML, WarningList[ToolkitWarning]]:
|
|
63
60
|
warnings: WarningList[ToolkitWarning] = WarningList[ToolkitWarning]()
|
|
64
61
|
if (organization_dir / BuildConfigYAML.get_filename(build_env_name or DEFAULT_ENV)).exists():
|
|
@@ -66,20 +63,9 @@ class BuildInput(BaseModel):
|
|
|
66
63
|
else:
|
|
67
64
|
# Loads the default environment
|
|
68
65
|
config = BuildConfigYAML.load_default(organization_dir)
|
|
69
|
-
if
|
|
70
|
-
config.environment.selected = parse_user_selected_modules(
|
|
66
|
+
if user_selected:
|
|
67
|
+
config.environment.selected = list(set(parse_user_selected_modules(list(user_selected), organization_dir)))
|
|
71
68
|
config.set_environment_variables()
|
|
72
69
|
if environment_warning := config.validate_environment():
|
|
73
70
|
warnings.append(environment_warning)
|
|
74
71
|
return config, warnings
|
|
75
|
-
|
|
76
|
-
@cached_property
|
|
77
|
-
def modules(self) -> ModuleDirectories:
|
|
78
|
-
user_selected_modules = self.config.environment.get_selected_modules({})
|
|
79
|
-
return ModuleDirectories.load(self.organization_dir, user_selected_modules)
|
|
80
|
-
|
|
81
|
-
@cached_property
|
|
82
|
-
def variables(self) -> BuildVariables:
|
|
83
|
-
return BuildVariables.load_raw(
|
|
84
|
-
self.config.variables, self.modules.available_paths, self.modules.selected.available_paths
|
|
85
|
-
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
|
+
|
|
6
|
+
from cognite_toolkit._cdf_tk.data_classes._module_toml import ModuleToml
|
|
7
|
+
|
|
8
|
+
if sys.version_info >= (3, 11):
|
|
9
|
+
from typing import Self
|
|
10
|
+
else:
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Module(BaseModel):
|
|
15
|
+
model_config = ConfigDict(
|
|
16
|
+
frozen=True,
|
|
17
|
+
validate_assignment=True,
|
|
18
|
+
arbitrary_types_allowed=True,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
path: Path
|
|
22
|
+
definition: ModuleToml | None = None
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def load(cls, path: Path) -> Self:
|
|
26
|
+
definition = ModuleToml.load(path / ModuleToml.filename) if (path / ModuleToml.filename).exists() else None
|
|
27
|
+
return cls(path=path, definition=definition)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
|
+
|
|
6
|
+
if sys.version_info >= (3, 11):
|
|
7
|
+
from typing import Self
|
|
8
|
+
else:
|
|
9
|
+
from typing_extensions import Self
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Resource(BaseModel):
|
|
13
|
+
model_config = ConfigDict(
|
|
14
|
+
frozen=True,
|
|
15
|
+
validate_assignment=True,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
path: Path
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def load(cls, path: Path) -> Self:
|
|
22
|
+
return cls(path=path)
|
|
@@ -52,10 +52,10 @@ from rich.console import Console
|
|
|
52
52
|
from rich.panel import Panel
|
|
53
53
|
|
|
54
54
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
55
|
-
from cognite_toolkit._cdf_tk.client.
|
|
56
|
-
from cognite_toolkit._cdf_tk.client.
|
|
57
|
-
from cognite_toolkit._cdf_tk.client.
|
|
58
|
-
from cognite_toolkit._cdf_tk.client.
|
|
55
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.location_filters import LocationFilterList
|
|
56
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.search_config import SearchConfigList
|
|
57
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.search_config import ViewId as SearchConfigViewId
|
|
58
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.streamlit_ import Streamlit, StreamlitList
|
|
59
59
|
from cognite_toolkit._cdf_tk.cruds import (
|
|
60
60
|
AgentCRUD,
|
|
61
61
|
ContainerCRUD,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import itertools
|
|
3
|
+
import json
|
|
3
4
|
import re
|
|
4
5
|
import sys
|
|
5
6
|
import tempfile
|
|
@@ -28,6 +29,7 @@ from cognite_toolkit._cdf_tk.cruds import (
|
|
|
28
29
|
HostedExtractorSourceCRUD,
|
|
29
30
|
ResourceCRUD,
|
|
30
31
|
StreamlitCRUD,
|
|
32
|
+
ViewCRUD,
|
|
31
33
|
)
|
|
32
34
|
from cognite_toolkit._cdf_tk.data_classes import (
|
|
33
35
|
BuildEnvironment,
|
|
@@ -643,6 +645,44 @@ class PullCommand(ToolkitCommand):
|
|
|
643
645
|
loader: ResourceCRUD[T_ID, T_ResourceRequest, T_ResourceResponse],
|
|
644
646
|
source_file: Path,
|
|
645
647
|
) -> tuple[str, dict[Path, str]]:
|
|
648
|
+
"""Convert resource data from CDF into YAML file content ready to be written to disk.
|
|
649
|
+
|
|
650
|
+
This method takes the raw CDF resource data and transforms it back into a properly
|
|
651
|
+
formatted YAML file that preserves:
|
|
652
|
+
- Template variables (e.g., {{ variable_name }}) instead of their resolved values
|
|
653
|
+
- YAML comments from the original source file
|
|
654
|
+
- The original key ordering in dictionaries
|
|
655
|
+
|
|
656
|
+
The transformation process:
|
|
657
|
+
1. Replace all template variables with unique placeholders
|
|
658
|
+
2. Load source YAML content while preserving comments
|
|
659
|
+
3. Update the resource data with placeholder values where variables were used
|
|
660
|
+
4. Dump the updated data back to YAML format
|
|
661
|
+
5. Replace placeholders with the original template variable syntax
|
|
662
|
+
6. Restore the YAML comments
|
|
663
|
+
|
|
664
|
+
Args:
|
|
665
|
+
source: The original YAML file content as a string.
|
|
666
|
+
to_write: A mapping from resource identifiers to their updated data dictionaries
|
|
667
|
+
pulled from CDF.
|
|
668
|
+
resources: The list of built resources containing build variables and metadata.
|
|
669
|
+
environment_variables: A mapping of environment variable names to their values,
|
|
670
|
+
used to resolve variables like ${VAR_NAME} in template values.
|
|
671
|
+
loader: The ResourceCRUD loader instance for this resource type.
|
|
672
|
+
source_file: The path to the source file being processed.
|
|
673
|
+
|
|
674
|
+
Returns:
|
|
675
|
+
A tuple containing:
|
|
676
|
+
- The final YAML content string ready to be written to disk.
|
|
677
|
+
- A dictionary mapping extra file paths to their content (for resources
|
|
678
|
+
that have additional files, like SQL queries for transformations).
|
|
679
|
+
|
|
680
|
+
Raises:
|
|
681
|
+
ValueError: If the loaded YAML structure doesn't match between the original
|
|
682
|
+
and placeholder versions.
|
|
683
|
+
ToolkitMissingResourceError: If a resource identifier is not found in the
|
|
684
|
+
to_write or resources mappings.
|
|
685
|
+
"""
|
|
646
686
|
# 1. Replace all variables with placeholders
|
|
647
687
|
# 2. Load source and keep the comments
|
|
648
688
|
# 3. Update the to_write dict with the placeholders
|
|
@@ -762,9 +802,22 @@ class PullCommand(ToolkitCommand):
|
|
|
762
802
|
|
|
763
803
|
|
|
764
804
|
class ResourceReplacer:
|
|
765
|
-
"""Replaces values in a local resource
|
|
805
|
+
"""Replaces values in a local resource dictionary with the updated values from CDF.
|
|
766
806
|
|
|
767
807
|
The local resource dict order is maintained. In addition, placeholders are used for variables.
|
|
808
|
+
|
|
809
|
+
This class is responsible for merging CDF resource values back into local configuration files
|
|
810
|
+
while preserving:
|
|
811
|
+
- The original key ordering in dictionaries
|
|
812
|
+
- Template variable placeholders (e.g., {{ variable_name }})
|
|
813
|
+
- Comments and formatting where possible
|
|
814
|
+
|
|
815
|
+
Args:
|
|
816
|
+
value_by_placeholder: A mapping from placeholder strings to their corresponding
|
|
817
|
+
BuildVariable objects. Placeholders are temporary substitutes for template
|
|
818
|
+
variables during processing.
|
|
819
|
+
loader: The ResourceCRUD loader instance used to determine how to diff lists
|
|
820
|
+
and handle resource-specific logic.
|
|
768
821
|
"""
|
|
769
822
|
|
|
770
823
|
def __init__(self, value_by_placeholder: dict[str, BuildVariable], loader: ResourceCRUD) -> None:
|
|
@@ -777,7 +830,49 @@ class ResourceReplacer:
|
|
|
777
830
|
placeholder: dict[str, Any],
|
|
778
831
|
to_write: dict[str, Any],
|
|
779
832
|
) -> dict[str, Any]:
|
|
780
|
-
|
|
833
|
+
"""Replace values in a local resource dict with updated values from CDF.
|
|
834
|
+
|
|
835
|
+
Merges the CDF resource values into the local configuration while maintaining
|
|
836
|
+
the original dictionary key ordering and preserving template variable placeholders.
|
|
837
|
+
|
|
838
|
+
Args:
|
|
839
|
+
current: The current local resource dictionary with resolved variable values.
|
|
840
|
+
This represents the source file content after template variables have
|
|
841
|
+
been substituted with their actual values.
|
|
842
|
+
placeholder: The local resource dictionary with placeholder strings instead
|
|
843
|
+
of resolved values. Used to identify which values contain template
|
|
844
|
+
variables that should be preserved.
|
|
845
|
+
to_write: The resource dictionary from CDF containing the updated values
|
|
846
|
+
to merge into the local configuration.
|
|
847
|
+
|
|
848
|
+
Returns:
|
|
849
|
+
A new dictionary with CDF values merged in, maintaining the original key
|
|
850
|
+
order from `current`. Template variables are preserved as placeholders
|
|
851
|
+
(to be converted back to {{ variable }} syntax by the caller). New keys
|
|
852
|
+
from CDF are appended at the end, and removed keys are omitted.
|
|
853
|
+
|
|
854
|
+
Raises:
|
|
855
|
+
ToolkitValueError: If a list variable has changed and cannot be updated,
|
|
856
|
+
or if there's a type mismatch between local and CDF values.
|
|
857
|
+
"""
|
|
858
|
+
has_stringified_view_filter = False
|
|
859
|
+
if isinstance(self._loader, ViewCRUD):
|
|
860
|
+
# view.filter are recursive nested dicts that are complex. To avoid issues with comparing
|
|
861
|
+
# lists inside the filters, we stringify them before processing such that they are compared
|
|
862
|
+
# as strings.
|
|
863
|
+
processed = []
|
|
864
|
+
for d in (current, placeholder, to_write):
|
|
865
|
+
if isinstance(d.get("filter"), dict):
|
|
866
|
+
d = d.copy()
|
|
867
|
+
d["filter"] = json.dumps(d["filter"])
|
|
868
|
+
has_stringified_view_filter = True
|
|
869
|
+
processed.append(d)
|
|
870
|
+
current, placeholder, to_write = processed
|
|
871
|
+
output = self._replace_dict(current, placeholder, to_write, tuple())
|
|
872
|
+
if has_stringified_view_filter and "filter" in output:
|
|
873
|
+
# Special case for ViewCRUD where the filter is stringified in CDF
|
|
874
|
+
output["filter"] = json.loads(output["filter"])
|
|
875
|
+
return output
|
|
781
876
|
|
|
782
877
|
def _replace_dict(
|
|
783
878
|
self,
|
|
@@ -30,7 +30,7 @@ from rich.progress import Progress
|
|
|
30
30
|
from rich.table import Table
|
|
31
31
|
|
|
32
32
|
from cognite_toolkit._cdf_tk.client import ToolkitClient, ToolkitClientConfig
|
|
33
|
-
from cognite_toolkit._cdf_tk.client.
|
|
33
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.functions import FunctionScheduleID
|
|
34
34
|
from cognite_toolkit._cdf_tk.constants import _RUNNING_IN_BROWSER
|
|
35
35
|
from cognite_toolkit._cdf_tk.cruds import FunctionCRUD, FunctionScheduleCRUD, WorkflowVersionCRUD
|
|
36
36
|
from cognite_toolkit._cdf_tk.cruds._resource_cruds.workflow import WorkflowTriggerCRUD
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import itertools
|
|
15
|
+
from collections import defaultdict
|
|
15
16
|
from typing import Literal, TypeAlias
|
|
16
17
|
|
|
17
18
|
from cognite_toolkit._cdf_tk.feature_flags import FeatureFlag, Flags
|
|
@@ -60,6 +61,7 @@ from ._resource_cruds import (
|
|
|
60
61
|
SecurityCategoryCRUD,
|
|
61
62
|
SequenceCRUD,
|
|
62
63
|
SequenceRowCRUD,
|
|
64
|
+
SimulatorModelCRUD,
|
|
63
65
|
SpaceCRUD,
|
|
64
66
|
StreamCRUD,
|
|
65
67
|
StreamlitCRUD,
|
|
@@ -86,26 +88,31 @@ if not FeatureFlag.is_enabled(Flags.MIGRATE):
|
|
|
86
88
|
_EXCLUDED_CRUDS.add(ResourceViewMappingCRUD)
|
|
87
89
|
if not FeatureFlag.is_enabled(Flags.STREAMS):
|
|
88
90
|
_EXCLUDED_CRUDS.add(StreamCRUD)
|
|
91
|
+
if not FeatureFlag.is_enabled(Flags.SIMULATORS):
|
|
92
|
+
_EXCLUDED_CRUDS.add(SimulatorModelCRUD)
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
CRUDS_BY_FOLDER_NAME:
|
|
94
|
+
CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA: defaultdict[str, list[type[Loader]]] = defaultdict(list)
|
|
95
|
+
CRUDS_BY_FOLDER_NAME: defaultdict[str, list[type[Loader]]] = defaultdict(list)
|
|
92
96
|
for _loader in itertools.chain(
|
|
93
97
|
ResourceCRUD.__subclasses__(),
|
|
94
98
|
ResourceContainerCRUD.__subclasses__(),
|
|
95
99
|
DataCRUD.__subclasses__(),
|
|
96
100
|
GroupCRUD.__subclasses__(),
|
|
97
101
|
):
|
|
98
|
-
if _loader in [ResourceCRUD, ResourceContainerCRUD, DataCRUD, GroupCRUD]
|
|
102
|
+
if _loader in [ResourceCRUD, ResourceContainerCRUD, DataCRUD, GroupCRUD]:
|
|
99
103
|
# Skipping base classes
|
|
100
104
|
continue
|
|
101
|
-
if _loader.folder_name not in CRUDS_BY_FOLDER_NAME: # type: ignore[attr-defined]
|
|
102
|
-
CRUDS_BY_FOLDER_NAME[_loader.folder_name] = [] # type: ignore[attr-defined]
|
|
103
105
|
# MyPy bug: https://github.com/python/mypy/issues/4717
|
|
104
|
-
|
|
106
|
+
CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA[_loader.folder_name].append(_loader) # type: ignore[arg-type, attr-defined]
|
|
107
|
+
|
|
108
|
+
if _loader not in _EXCLUDED_CRUDS:
|
|
109
|
+
CRUDS_BY_FOLDER_NAME[_loader.folder_name].append(_loader) # type: ignore[arg-type, attr-defined]
|
|
105
110
|
del _loader # cleanup module namespace
|
|
106
111
|
|
|
112
|
+
|
|
107
113
|
# For backwards compatibility
|
|
108
114
|
CRUDS_BY_FOLDER_NAME["data_models"] = CRUDS_BY_FOLDER_NAME["data_modeling"] # Todo: Remove in v1.0
|
|
115
|
+
CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA["data_models"] = CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA["data_modeling"]
|
|
109
116
|
RESOURCE_CRUD_BY_FOLDER_NAME = {
|
|
110
117
|
folder_name: cruds
|
|
111
118
|
for folder_name, loaders in CRUDS_BY_FOLDER_NAME.items()
|
|
@@ -142,6 +149,7 @@ ResourceTypes: TypeAlias = Literal[
|
|
|
142
149
|
"functions",
|
|
143
150
|
"raw",
|
|
144
151
|
"robotics",
|
|
152
|
+
"simulators",
|
|
145
153
|
"streams",
|
|
146
154
|
"streamlit",
|
|
147
155
|
"workflows",
|
|
@@ -163,6 +171,7 @@ __all__ = [
|
|
|
163
171
|
"RESOURCE_CRUD_CONTAINER_LIST",
|
|
164
172
|
"RESOURCE_CRUD_LIST",
|
|
165
173
|
"RESOURCE_DATA_CRUD_LIST",
|
|
174
|
+
"_EXCLUDED_CRUDS",
|
|
166
175
|
"AgentCRUD",
|
|
167
176
|
"AssetCRUD",
|
|
168
177
|
"CogniteFileCRUD",
|
|
@@ -209,6 +218,7 @@ __all__ = [
|
|
|
209
218
|
"SecurityCategoryCRUD",
|
|
210
219
|
"SequenceCRUD",
|
|
211
220
|
"SequenceRowCRUD",
|
|
221
|
+
"SimulatorModelCRUD",
|
|
212
222
|
"SpaceCRUD",
|
|
213
223
|
"StreamlitCRUD",
|
|
214
224
|
"ThreeDModelCRUD",
|