cognite-toolkit 0.7.30__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.py +5 -6
- cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +7 -1
- cognite_toolkit/_cdf_tk/apps/_download_app.py +2 -2
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +183 -8
- 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 +44 -12
- 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 +40 -35
- 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/{canvas.py → legacy/canvas.py} +16 -8
- cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
- cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +9 -9
- cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +112 -0
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +53 -0
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +140 -75
- cognite_toolkit/_cdf_tk/client/api/migration.py +2 -3
- cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
- cognite_toolkit/_cdf_tk/client/api/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.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/search_config.py +83 -31
- 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 +68 -56
- cognite_toolkit/_cdf_tk/client/api/three_d.py +385 -34
- 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 +30 -0
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +26 -16
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +18 -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/{utils → client}/http_client/_tracker.py +5 -2
- 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/__init__.py +0 -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 +53 -14
- 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 +54 -17
- cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +29 -16
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +38 -6
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +262 -36
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +39 -38
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +227 -8
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +14 -16
- 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/__init__.py +0 -0
- 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 +228 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_parameters.py +71 -0
- 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 +34 -25
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +14 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +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 +49 -14
- 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/_module_toml.py +1 -0
- 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 +173 -5
- 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 +65 -56
- 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/storageio/selectors/__init__.py +10 -1
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -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 +53 -4
- 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/_cdf_tk/validation.py +4 -0
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
- cognite_toolkit/_resources/cdf.toml +1 -1
- cognite_toolkit/_version.py +1 -1
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
- cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -17
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -87
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -47
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -187
- cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
- cognite_toolkit-0.7.30.dist-info/RECORD +0 -316
- /cognite_toolkit/_cdf_tk/client/{data_classes → api/legacy}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/request_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/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from cognite_toolkit._cdf_tk.constants import EXCL_FILES, MODULES
|
|
4
|
+
from cognite_toolkit._cdf_tk.cruds import CRUDS_BY_FOLDER_NAME, CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA
|
|
5
|
+
from cognite_toolkit._cdf_tk.data_classes import IssueList
|
|
6
|
+
from cognite_toolkit._cdf_tk.data_classes._issues import ModuleLoadingIssue
|
|
7
|
+
from cognite_toolkit._cdf_tk.exceptions import ToolkitError
|
|
8
|
+
from cognite_toolkit._cdf_tk.utils import humanize_collection, module_path_display_name
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ModulesParser:
|
|
12
|
+
def __init__(self, organization_dir: Path, selected: list[str | Path] | None = None):
|
|
13
|
+
self.organization_dir = organization_dir
|
|
14
|
+
self.selected = selected
|
|
15
|
+
|
|
16
|
+
def parse(self) -> tuple[list[Path], IssueList]:
|
|
17
|
+
modules_root = self.organization_dir / MODULES
|
|
18
|
+
if not modules_root.exists():
|
|
19
|
+
raise ToolkitError(f"Module root directory '{modules_root}' not found")
|
|
20
|
+
|
|
21
|
+
module_paths: list[Path] = []
|
|
22
|
+
excluded_module_paths: list[Path] = []
|
|
23
|
+
issues: IssueList = IssueList()
|
|
24
|
+
for resource_file in self.organization_dir.glob("**/*.y*ml"):
|
|
25
|
+
if resource_file.name in EXCL_FILES:
|
|
26
|
+
continue
|
|
27
|
+
|
|
28
|
+
# Get the module folder for the resource file.
|
|
29
|
+
module_path = self._get_module_path_from_resource_file_path(resource_file)
|
|
30
|
+
if not module_path:
|
|
31
|
+
continue
|
|
32
|
+
|
|
33
|
+
# If the module has already been processed, skip it.
|
|
34
|
+
if module_path in module_paths or module_path in excluded_module_paths:
|
|
35
|
+
continue
|
|
36
|
+
|
|
37
|
+
# Skip the modules that do not match the selection
|
|
38
|
+
if not self._matches_selection(module_path, modules_root, self.selected):
|
|
39
|
+
excluded_module_paths.append(module_path)
|
|
40
|
+
continue
|
|
41
|
+
|
|
42
|
+
module_paths.append(module_path)
|
|
43
|
+
|
|
44
|
+
deepest_module_paths = self._find_modules_with_submodules(module_paths)
|
|
45
|
+
parent_module_paths = set(module_paths) - set(deepest_module_paths)
|
|
46
|
+
if parent_module_paths:
|
|
47
|
+
module_paths = deepest_module_paths
|
|
48
|
+
issues.extend(
|
|
49
|
+
ModuleLoadingIssue(
|
|
50
|
+
message=f"Module {module_path_display_name(self.organization_dir, parent_module_path)!r} is skipped because it has submodules"
|
|
51
|
+
)
|
|
52
|
+
for parent_module_path in parent_module_paths
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
valid_module_paths: list[Path] = []
|
|
56
|
+
for module_path in module_paths:
|
|
57
|
+
valid_module_path, issue = self._check_resource_folder_content(module_path)
|
|
58
|
+
if issue:
|
|
59
|
+
issues.append(issue)
|
|
60
|
+
if valid_module_path:
|
|
61
|
+
valid_module_paths.append(valid_module_path)
|
|
62
|
+
|
|
63
|
+
return valid_module_paths, issues
|
|
64
|
+
|
|
65
|
+
def _get_module_path_from_resource_file_path(self, resource_file: Path) -> Path | None:
|
|
66
|
+
# recognize the module by containing a resource associated by a CRUD.
|
|
67
|
+
# Special case: if the resource folder is a subfolder of a CRUD, return the parent of the subfolder.
|
|
68
|
+
resource_folder = resource_file.parent
|
|
69
|
+
crud = next(iter(CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA.get(resource_folder.name, [])), None)
|
|
70
|
+
if crud:
|
|
71
|
+
# iterate over the parents of the resource folder until we find the module folder.
|
|
72
|
+
# This is to handle the special case of a subfolder of a CRUD, or yamls in for example function subfolders.
|
|
73
|
+
for p in resource_file.parents:
|
|
74
|
+
if p.name == crud.folder_name:
|
|
75
|
+
return p.parent
|
|
76
|
+
if p.name == MODULES:
|
|
77
|
+
return p
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
def _check_resource_folder_content(self, module_path: Path) -> tuple[None | Path, ModuleLoadingIssue | None]:
|
|
81
|
+
resource_folder_names = {d.name for d in module_path.iterdir() if d.is_dir()}
|
|
82
|
+
unrecognized_resource_folder_names = resource_folder_names - CRUDS_BY_FOLDER_NAME.keys()
|
|
83
|
+
|
|
84
|
+
issue = (
|
|
85
|
+
ModuleLoadingIssue(
|
|
86
|
+
message=f"Module {module_path_display_name(self.organization_dir, module_path)!r} contains unrecognized resource folder(s): {humanize_collection(unrecognized_resource_folder_names)}"
|
|
87
|
+
)
|
|
88
|
+
if unrecognized_resource_folder_names
|
|
89
|
+
else None
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
has_valid_resource_folders = bool(resource_folder_names & CRUDS_BY_FOLDER_NAME.keys())
|
|
93
|
+
return (module_path if has_valid_resource_folders else None, issue)
|
|
94
|
+
|
|
95
|
+
def _matches_selection(self, module_path: Path, modules_root: Path, selected: list[str | Path] | None) -> bool:
|
|
96
|
+
if not selected:
|
|
97
|
+
return True
|
|
98
|
+
|
|
99
|
+
rel = module_path.relative_to(modules_root)
|
|
100
|
+
rel_parts = [p.lower() for p in rel.parts]
|
|
101
|
+
if not rel_parts:
|
|
102
|
+
# module_path is the modules_root itself
|
|
103
|
+
return False
|
|
104
|
+
name_lower = rel_parts[-1]
|
|
105
|
+
modules_lower = MODULES.lower()
|
|
106
|
+
|
|
107
|
+
for sel in selected:
|
|
108
|
+
sel_path = Path(sel) if isinstance(sel, str) else sel
|
|
109
|
+
|
|
110
|
+
sel_parts = [p.lower() for p in sel_path.parts]
|
|
111
|
+
if not sel_parts:
|
|
112
|
+
continue
|
|
113
|
+
|
|
114
|
+
if sel_parts[0] == modules_lower:
|
|
115
|
+
sel_parts = sel_parts[1:]
|
|
116
|
+
|
|
117
|
+
if not sel_parts:
|
|
118
|
+
return True
|
|
119
|
+
|
|
120
|
+
if len(sel_parts) == 1 and name_lower == sel_parts[0]:
|
|
121
|
+
return True
|
|
122
|
+
|
|
123
|
+
if rel_parts[: len(sel_parts)] == sel_parts:
|
|
124
|
+
return True
|
|
125
|
+
|
|
126
|
+
return False
|
|
127
|
+
|
|
128
|
+
def _find_modules_with_submodules(self, module_paths: list[Path]) -> list[Path]:
|
|
129
|
+
"""Remove parent modules when they have submodules. Keep only the deepest modules."""
|
|
130
|
+
return [
|
|
131
|
+
module_path
|
|
132
|
+
for module_path in module_paths
|
|
133
|
+
if not any(
|
|
134
|
+
module_path in other_module_path.parents
|
|
135
|
+
for other_module_path in module_paths
|
|
136
|
+
if other_module_path != module_path
|
|
137
|
+
)
|
|
138
|
+
]
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from cognite_toolkit._cdf_tk.constants import EXCL_FILES, MODULES
|
|
4
|
+
from cognite_toolkit._cdf_tk.cruds import CRUDS_BY_FOLDER_NAME, CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA
|
|
5
|
+
from cognite_toolkit._cdf_tk.data_classes import IssueList
|
|
6
|
+
from cognite_toolkit._cdf_tk.data_classes._issues import ModuleLoadingIssue
|
|
7
|
+
from cognite_toolkit._cdf_tk.exceptions import ToolkitError
|
|
8
|
+
from cognite_toolkit._cdf_tk.utils import module_path_display_name
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ModulesParser:
|
|
12
|
+
def __init__(self, organization_dir: Path, selected: list[str | Path] | None = None):
|
|
13
|
+
self.organization_dir = organization_dir
|
|
14
|
+
self.selected = selected
|
|
15
|
+
self.issues = IssueList()
|
|
16
|
+
|
|
17
|
+
def parse(self) -> list[Path]:
|
|
18
|
+
modules_root = self.organization_dir / MODULES
|
|
19
|
+
if not modules_root.exists():
|
|
20
|
+
raise ToolkitError(f"Module root directory '{modules_root.as_posix()}' not found")
|
|
21
|
+
|
|
22
|
+
module_paths: list[Path] = []
|
|
23
|
+
for resource_file in self.organization_dir.glob("**/*.y*ml"):
|
|
24
|
+
if resource_file.name in EXCL_FILES:
|
|
25
|
+
continue
|
|
26
|
+
|
|
27
|
+
# Get the module folder for the resource file.
|
|
28
|
+
module_path = self._get_module_path_from_resource_file_path(resource_file)
|
|
29
|
+
if not module_path:
|
|
30
|
+
continue
|
|
31
|
+
|
|
32
|
+
# If the module has already been processed, skip it.
|
|
33
|
+
if module_path in module_paths:
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
module_paths.append(module_path)
|
|
37
|
+
|
|
38
|
+
deepest_module_paths = self._find_modules_with_submodules(module_paths)
|
|
39
|
+
parent_module_paths = set(module_paths) - set(deepest_module_paths)
|
|
40
|
+
if parent_module_paths:
|
|
41
|
+
module_paths = deepest_module_paths
|
|
42
|
+
self.issues.extend(
|
|
43
|
+
ModuleLoadingIssue(
|
|
44
|
+
message=f"Module {module_path_display_name(self.organization_dir, parent_module_path)!r} is skipped because it has submodules",
|
|
45
|
+
)
|
|
46
|
+
for parent_module_path in parent_module_paths
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
all_module_paths = module_paths
|
|
50
|
+
|
|
51
|
+
if self.selected:
|
|
52
|
+
normalized_selected = self._normalize_selection(self.selected)
|
|
53
|
+
selected_module_paths = [
|
|
54
|
+
module_path
|
|
55
|
+
for module_path in all_module_paths
|
|
56
|
+
if self._matches_selection(module_path, modules_root, normalized_selected)
|
|
57
|
+
]
|
|
58
|
+
for selected_module in self.selected:
|
|
59
|
+
normalized_selected_item = self._normalize_selection([selected_module])
|
|
60
|
+
has_match = any(
|
|
61
|
+
self._matches_selection(found_module, modules_root, normalized_selected_item)
|
|
62
|
+
for found_module in all_module_paths
|
|
63
|
+
)
|
|
64
|
+
if not has_match:
|
|
65
|
+
self.issues.append(
|
|
66
|
+
ModuleLoadingIssue(
|
|
67
|
+
message=f"Module '{selected_module}' not found",
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
module_paths = selected_module_paths
|
|
72
|
+
|
|
73
|
+
valid_module_paths: list[Path] = []
|
|
74
|
+
for module_path in module_paths:
|
|
75
|
+
valid_module_path, issue = self._check_resource_folder_content(module_path)
|
|
76
|
+
if issue:
|
|
77
|
+
self.issues.append(issue)
|
|
78
|
+
if valid_module_path:
|
|
79
|
+
valid_module_paths.append(valid_module_path)
|
|
80
|
+
|
|
81
|
+
return valid_module_paths
|
|
82
|
+
|
|
83
|
+
def _get_module_path_from_resource_file_path(self, resource_file: Path) -> Path | None:
|
|
84
|
+
# recognize the module by traversing the parents of the resource file until we find a CRUD folder
|
|
85
|
+
|
|
86
|
+
for parent in resource_file.parents:
|
|
87
|
+
if parent.name in CRUDS_BY_FOLDER_NAME_INCLUDE_ALPHA:
|
|
88
|
+
# special case: if the crud is FunctionCRUD, the resource file has to be a direct descendent.
|
|
89
|
+
if parent.name == "functions" and resource_file.parent.name != "functions":
|
|
90
|
+
return None
|
|
91
|
+
return parent.parent
|
|
92
|
+
if parent.name == MODULES:
|
|
93
|
+
return parent
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
def _check_resource_folder_content(self, module_path: Path) -> tuple[None | Path, ModuleLoadingIssue | None]:
|
|
97
|
+
resource_folder_names = {d.name for d in module_path.iterdir() if d.is_dir()}
|
|
98
|
+
unrecognized_resource_folder_names = resource_folder_names - CRUDS_BY_FOLDER_NAME.keys()
|
|
99
|
+
|
|
100
|
+
issue = (
|
|
101
|
+
ModuleLoadingIssue(
|
|
102
|
+
message=f"Module {module_path_display_name(self.organization_dir, module_path)!r} contains unrecognized resource folder(s): {', '.join(unrecognized_resource_folder_names)}"
|
|
103
|
+
)
|
|
104
|
+
if unrecognized_resource_folder_names
|
|
105
|
+
else None
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
has_valid_resource_folders = bool(resource_folder_names & CRUDS_BY_FOLDER_NAME.keys())
|
|
109
|
+
return (module_path if has_valid_resource_folders else None, issue)
|
|
110
|
+
|
|
111
|
+
def _matches_selection(
|
|
112
|
+
self, module_path: Path, modules_root: Path, normalized_selected: list[tuple[str, ...]] | None
|
|
113
|
+
) -> bool:
|
|
114
|
+
if not normalized_selected:
|
|
115
|
+
return True
|
|
116
|
+
|
|
117
|
+
rel = module_path.relative_to(modules_root)
|
|
118
|
+
rel_parts = tuple(p.lower() for p in rel.parts)
|
|
119
|
+
if not rel_parts:
|
|
120
|
+
# module_path is the modules_root itself
|
|
121
|
+
return False
|
|
122
|
+
name_lower = rel_parts[-1]
|
|
123
|
+
|
|
124
|
+
for sel_parts in normalized_selected:
|
|
125
|
+
if not sel_parts:
|
|
126
|
+
return True
|
|
127
|
+
|
|
128
|
+
if len(sel_parts) == 1 and name_lower == sel_parts[0]:
|
|
129
|
+
return True
|
|
130
|
+
|
|
131
|
+
if rel_parts[: len(sel_parts)] == sel_parts:
|
|
132
|
+
return True
|
|
133
|
+
|
|
134
|
+
return False
|
|
135
|
+
|
|
136
|
+
def _normalize_selection(self, selected: list[str | Path]) -> list[tuple[str, ...]]:
|
|
137
|
+
normalized: list[tuple[str, ...]] = []
|
|
138
|
+
modules_lower = MODULES.lower()
|
|
139
|
+
for sel in selected:
|
|
140
|
+
if isinstance(sel, Path):
|
|
141
|
+
sel_parts = sel.parts
|
|
142
|
+
else:
|
|
143
|
+
sel_parts = tuple(part for part in str(sel).replace("\\", "/").split("/") if part)
|
|
144
|
+
|
|
145
|
+
sel_parts_lower = tuple(part.lower() for part in sel_parts)
|
|
146
|
+
if sel_parts_lower and sel_parts_lower[0] == modules_lower:
|
|
147
|
+
sel_parts_lower = sel_parts_lower[1:]
|
|
148
|
+
|
|
149
|
+
normalized.append(sel_parts_lower)
|
|
150
|
+
|
|
151
|
+
return normalized
|
|
152
|
+
|
|
153
|
+
def _find_modules_with_submodules(self, module_paths: list[Path]) -> list[Path]:
|
|
154
|
+
"""Remove parent modules when they have submodules. Keep only the deepest modules."""
|
|
155
|
+
return [
|
|
156
|
+
module_path
|
|
157
|
+
for module_path in module_paths
|
|
158
|
+
if not any(
|
|
159
|
+
module_path in other_module_path.parents
|
|
160
|
+
for other_module_path in module_paths
|
|
161
|
+
if other_module_path != module_path
|
|
162
|
+
)
|
|
163
|
+
]
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from itertools import groupby
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any, Literal
|
|
5
|
+
|
|
6
|
+
from rich import print
|
|
7
|
+
from rich.panel import Panel
|
|
8
|
+
|
|
9
|
+
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
10
|
+
from cognite_toolkit._cdf_tk.commands._base import ToolkitCommand
|
|
11
|
+
from cognite_toolkit._cdf_tk.commands.build_cmd import BuildCommand as OldBuildCommand
|
|
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
|
|
17
|
+
from cognite_toolkit._cdf_tk.exceptions import ToolkitError
|
|
18
|
+
from cognite_toolkit._cdf_tk.tk_warnings import ToolkitWarning, WarningList
|
|
19
|
+
from cognite_toolkit._cdf_tk.utils.file import safe_rmtree
|
|
20
|
+
from cognite_toolkit._version import __version__
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BuildCommand(ToolkitCommand):
|
|
24
|
+
def __init__(self, print_warning: bool = True, skip_tracking: bool = False, silent: bool = False) -> None:
|
|
25
|
+
super().__init__(print_warning, skip_tracking, silent)
|
|
26
|
+
self.issues = IssueList()
|
|
27
|
+
|
|
28
|
+
def execute(
|
|
29
|
+
self,
|
|
30
|
+
verbose: bool,
|
|
31
|
+
base_dir: Path,
|
|
32
|
+
build_dir: Path,
|
|
33
|
+
selected: list[str | Path] | None,
|
|
34
|
+
build_env: str | None,
|
|
35
|
+
no_clean: bool,
|
|
36
|
+
client: ToolkitClient | None = None,
|
|
37
|
+
on_error: Literal["continue", "raise"] = "continue",
|
|
38
|
+
) -> BuiltModuleList:
|
|
39
|
+
"""
|
|
40
|
+
Build the resources into deployable artifacts in the build directory.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
self.verbose = verbose
|
|
44
|
+
self.on_error = on_error
|
|
45
|
+
|
|
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
|
+
)
|
|
53
|
+
|
|
54
|
+
# Print the build input.
|
|
55
|
+
if self.verbose:
|
|
56
|
+
self._print_build_input(build_parameters)
|
|
57
|
+
|
|
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
|
|
79
|
+
|
|
80
|
+
# Logistics: clean and create build directory
|
|
81
|
+
if prepare_issues := self._prepare_target_directory(build_dir, not no_clean):
|
|
82
|
+
self.issues.extend(prepare_issues)
|
|
83
|
+
|
|
84
|
+
# Compile the configuration and variables,
|
|
85
|
+
# check syntax on module and resource level
|
|
86
|
+
# for any "compilation errors and warnings"
|
|
87
|
+
built_modules, build_integrity_issues = self._build_configuration(build_parameters)
|
|
88
|
+
if build_integrity_issues:
|
|
89
|
+
self.issues.extend(build_integrity_issues)
|
|
90
|
+
|
|
91
|
+
# This is where we would add any recommendations for the user to improve the build.
|
|
92
|
+
if build_quality_issues := self._verify_build_quality(built_modules):
|
|
93
|
+
self.issues.extend(build_quality_issues)
|
|
94
|
+
|
|
95
|
+
# Finally, print warnings grouped by category/code and location.
|
|
96
|
+
self._print_or_log_issues_by_category(self.issues)
|
|
97
|
+
|
|
98
|
+
return built_modules
|
|
99
|
+
|
|
100
|
+
def _print_build_input(self, build_input: BuildParameters) -> None:
|
|
101
|
+
print(
|
|
102
|
+
Panel(
|
|
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}'",
|
|
106
|
+
expand=False,
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def _prepare_target_directory(self, build_dir: Path, clean: bool = False) -> IssueList:
|
|
111
|
+
"""
|
|
112
|
+
Directory logistics
|
|
113
|
+
"""
|
|
114
|
+
issues = IssueList()
|
|
115
|
+
if build_dir.exists() and any(build_dir.iterdir()):
|
|
116
|
+
if not clean:
|
|
117
|
+
raise ToolkitError("Build directory is not empty. Run without --no-clean to remove existing files.")
|
|
118
|
+
|
|
119
|
+
if self.verbose:
|
|
120
|
+
issues.append(Issue(code="BUILD_001"))
|
|
121
|
+
safe_rmtree(build_dir)
|
|
122
|
+
build_dir.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
return issues
|
|
124
|
+
|
|
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)
|
|
128
|
+
|
|
129
|
+
old_build_command = OldBuildCommand(print_warning=False, skip_tracking=False)
|
|
130
|
+
built_modules = old_build_command.build_config(
|
|
131
|
+
build_dir=build_input.build_dir,
|
|
132
|
+
organization_dir=build_input.organization_dir,
|
|
133
|
+
config=build_input.config,
|
|
134
|
+
packages={},
|
|
135
|
+
clean=False,
|
|
136
|
+
verbose=self.verbose,
|
|
137
|
+
client=build_input.client,
|
|
138
|
+
progress_bar=False,
|
|
139
|
+
on_error=self.on_error,
|
|
140
|
+
)
|
|
141
|
+
# Copy tracking info from old command to self
|
|
142
|
+
self._additional_tracking_info.package_ids.update(old_build_command._additional_tracking_info.package_ids)
|
|
143
|
+
self._additional_tracking_info.module_ids.update(old_build_command._additional_tracking_info.module_ids)
|
|
144
|
+
|
|
145
|
+
# Collect warnings from the old build command and convert to issues
|
|
146
|
+
# Always convert warnings to issues, even if the list appears empty
|
|
147
|
+
# (WarningList might have custom __bool__ behavior)
|
|
148
|
+
if old_build_command.warning_list:
|
|
149
|
+
converted_issues = IssueList.from_warning_list(old_build_command.warning_list)
|
|
150
|
+
issues.extend(converted_issues)
|
|
151
|
+
return built_modules, issues
|
|
152
|
+
|
|
153
|
+
def _verify_build_quality(self, built_modules: BuiltModuleList) -> IssueList:
|
|
154
|
+
issues = IssueList()
|
|
155
|
+
return issues
|
|
156
|
+
|
|
157
|
+
def _write(self, build_input: BuildParameters) -> None:
|
|
158
|
+
# Write the build to the build directory.
|
|
159
|
+
# Track lines of code built.
|
|
160
|
+
raise NotImplementedError()
|
|
161
|
+
|
|
162
|
+
def _track(self, build_input: BuildParameters) -> None:
|
|
163
|
+
raise NotImplementedError()
|
|
164
|
+
|
|
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
|
|
180
|
+
|
|
181
|
+
# Delegate to old BuildCommand for backward compatibility with tests
|
|
182
|
+
def build_modules(
|
|
183
|
+
self,
|
|
184
|
+
modules: list[Module],
|
|
185
|
+
build_dir: Path,
|
|
186
|
+
variables: BuildVariables,
|
|
187
|
+
verbose: bool = False,
|
|
188
|
+
progress_bar: bool = False,
|
|
189
|
+
on_error: Literal["continue", "raise"] = "continue",
|
|
190
|
+
) -> BuiltModuleList:
|
|
191
|
+
"""Delegate to old BuildCommand for backward compatibility."""
|
|
192
|
+
old_cmd = OldBuildCommand()
|
|
193
|
+
|
|
194
|
+
built_modules = old_cmd.build_modules(modules, build_dir, variables, verbose, progress_bar, on_error) # type: ignore[arg-type]
|
|
195
|
+
self._additional_tracking_info.package_ids.update(old_cmd._additional_tracking_info.package_ids)
|
|
196
|
+
self._additional_tracking_info.module_ids.update(old_cmd._additional_tracking_info.module_ids)
|
|
197
|
+
self.issues.extend(IssueList.from_warning_list(old_cmd.warning_list or WarningList[ToolkitWarning]()))
|
|
198
|
+
return built_modules
|
|
199
|
+
|
|
200
|
+
def build_config(
|
|
201
|
+
self,
|
|
202
|
+
build_dir: Path,
|
|
203
|
+
organization_dir: Path,
|
|
204
|
+
config: BuildConfigYAML,
|
|
205
|
+
packages: dict[str, list[str]],
|
|
206
|
+
clean: bool = False,
|
|
207
|
+
verbose: bool = False,
|
|
208
|
+
client: ToolkitClient | None = None,
|
|
209
|
+
progress_bar: bool = False,
|
|
210
|
+
on_error: Literal["continue", "raise"] = "continue",
|
|
211
|
+
) -> BuiltModuleList:
|
|
212
|
+
"""Delegate to old BuildCommand for backward compatibility."""
|
|
213
|
+
old_cmd = OldBuildCommand()
|
|
214
|
+
return old_cmd.build_config(
|
|
215
|
+
build_dir, organization_dir, config, packages, clean, verbose, client, progress_bar, on_error
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
def _replace_variables(
|
|
219
|
+
self,
|
|
220
|
+
resource_files: list[Path],
|
|
221
|
+
variables: BuildVariables,
|
|
222
|
+
resource_name: str,
|
|
223
|
+
module_dir: Path,
|
|
224
|
+
verbose: bool = False,
|
|
225
|
+
) -> list[Any]:
|
|
226
|
+
"""Delegate to old BuildCommand for backward compatibility."""
|
|
227
|
+
old_cmd = OldBuildCommand()
|
|
228
|
+
return old_cmd._replace_variables(resource_files, variables, resource_name, module_dir, verbose)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
if sys.version_info >= (3, 11):
|
|
5
|
+
from typing import Self
|
|
6
|
+
else:
|
|
7
|
+
from typing_extensions import Self
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, ConfigDict
|
|
10
|
+
|
|
11
|
+
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
12
|
+
from cognite_toolkit._cdf_tk.constants import DEFAULT_ENV
|
|
13
|
+
from cognite_toolkit._cdf_tk.data_classes import (
|
|
14
|
+
BuildConfigYAML,
|
|
15
|
+
)
|
|
16
|
+
from cognite_toolkit._cdf_tk.tk_warnings import ToolkitWarning, WarningList
|
|
17
|
+
from cognite_toolkit._cdf_tk.utils.modules import parse_user_selected_modules
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BuildParameters(BaseModel):
|
|
21
|
+
"""Input to the build process."""
|
|
22
|
+
|
|
23
|
+
# need this until we turn BuildConfigYaml and ToolkitClient into Pydantic models
|
|
24
|
+
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
|
|
25
|
+
|
|
26
|
+
organization_dir: Path
|
|
27
|
+
build_dir: Path
|
|
28
|
+
build_env_name: str
|
|
29
|
+
config: BuildConfigYAML
|
|
30
|
+
client: ToolkitClient | None = None
|
|
31
|
+
warnings: WarningList[ToolkitWarning] | None = None
|
|
32
|
+
user_selected: list[str | Path] | None = None
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def load(
|
|
36
|
+
cls,
|
|
37
|
+
organization_dir: Path,
|
|
38
|
+
build_dir: Path,
|
|
39
|
+
build_env_name: str | None,
|
|
40
|
+
client: ToolkitClient | None,
|
|
41
|
+
user_selected: list[str | Path] | None = None,
|
|
42
|
+
) -> Self:
|
|
43
|
+
resolved_org_dir = Path.cwd() if organization_dir in {Path("."), Path("./")} else organization_dir
|
|
44
|
+
resolved_env = build_env_name or DEFAULT_ENV
|
|
45
|
+
config, warnings = cls._load_config(resolved_org_dir, resolved_env, user_selected)
|
|
46
|
+
return cls(
|
|
47
|
+
organization_dir=resolved_org_dir,
|
|
48
|
+
build_dir=build_dir,
|
|
49
|
+
build_env_name=resolved_env,
|
|
50
|
+
config=config,
|
|
51
|
+
client=client,
|
|
52
|
+
warnings=warnings,
|
|
53
|
+
user_selected=user_selected,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def _load_config(
|
|
58
|
+
cls, organization_dir: Path, build_env_name: str, user_selected: list[str | Path] | None
|
|
59
|
+
) -> tuple[BuildConfigYAML, WarningList[ToolkitWarning]]:
|
|
60
|
+
warnings: WarningList[ToolkitWarning] = WarningList[ToolkitWarning]()
|
|
61
|
+
if (organization_dir / BuildConfigYAML.get_filename(build_env_name or DEFAULT_ENV)).exists():
|
|
62
|
+
config = BuildConfigYAML.load_from_directory(organization_dir, build_env_name or DEFAULT_ENV)
|
|
63
|
+
else:
|
|
64
|
+
# Loads the default environment
|
|
65
|
+
config = BuildConfigYAML.load_default(organization_dir)
|
|
66
|
+
if user_selected:
|
|
67
|
+
config.environment.selected = list(set(parse_user_selected_modules(list(user_selected), organization_dir)))
|
|
68
|
+
config.set_environment_variables()
|
|
69
|
+
if environment_warning := config.validate_environment():
|
|
70
|
+
warnings.append(environment_warning)
|
|
71
|
+
return config, warnings
|
|
@@ -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,
|