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
cognite_toolkit/_cdf.py
CHANGED
|
@@ -27,6 +27,7 @@ from cognite_toolkit._cdf_tk.apps import (
|
|
|
27
27
|
DataApp,
|
|
28
28
|
DevApp,
|
|
29
29
|
DumpApp,
|
|
30
|
+
ImportApp,
|
|
30
31
|
LandingApp,
|
|
31
32
|
MigrateApp,
|
|
32
33
|
ModulesApp,
|
|
@@ -42,7 +43,7 @@ from cognite_toolkit._cdf_tk.constants import HINT_LEAD_TEXT, URL, USE_SENTRY
|
|
|
42
43
|
from cognite_toolkit._cdf_tk.exceptions import (
|
|
43
44
|
ToolkitError,
|
|
44
45
|
)
|
|
45
|
-
from cognite_toolkit._cdf_tk.feature_flags import
|
|
46
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
46
47
|
from cognite_toolkit._cdf_tk.plugins import Plugins
|
|
47
48
|
from cognite_toolkit._cdf_tk.tracker import Tracker
|
|
48
49
|
from cognite_toolkit._cdf_tk.utils import (
|
|
@@ -108,6 +109,9 @@ if Flags.PROFILE.is_enabled():
|
|
|
108
109
|
if Flags.MIGRATE.is_enabled():
|
|
109
110
|
_app.add_typer(MigrateApp(**default_typer_kws), name="migrate")
|
|
110
111
|
|
|
112
|
+
if Flags.IMPORT_CMD.is_enabled():
|
|
113
|
+
_app.add_typer(ImportApp(**default_typer_kws), name="import")
|
|
114
|
+
|
|
111
115
|
if Plugins.data.value.is_enabled():
|
|
112
116
|
_app.add_typer(DataApp(**default_typer_kws), name="data")
|
|
113
117
|
|
|
@@ -126,11 +130,6 @@ def app() -> NoReturn:
|
|
|
126
130
|
# --- Main entry point ---
|
|
127
131
|
# Users run 'app()' directly, but that doesn't allow us to control excepton handling:
|
|
128
132
|
try:
|
|
129
|
-
if FeatureFlag.is_enabled(Flags.IMPORT_CMD):
|
|
130
|
-
from cognite_toolkit._cdf_tk.prototypes.import_app import import_app
|
|
131
|
-
|
|
132
|
-
_app.add_typer(import_app, name="import")
|
|
133
|
-
|
|
134
133
|
_app()
|
|
135
134
|
except ToolkitError as err:
|
|
136
135
|
if "--verbose" in sys.argv:
|
|
@@ -4,6 +4,7 @@ from ._data_app import DataApp
|
|
|
4
4
|
from ._dev_app import DevApp
|
|
5
5
|
from ._download_app import DownloadApp
|
|
6
6
|
from ._dump_app import DumpApp
|
|
7
|
+
from ._import_app import ImportApp
|
|
7
8
|
from ._landing_app import LandingApp
|
|
8
9
|
from ._migrate_app import MigrateApp
|
|
9
10
|
from ._modules_app import ModulesApp
|
|
@@ -20,6 +21,7 @@ __all__ = [
|
|
|
20
21
|
"DevApp",
|
|
21
22
|
"DownloadApp",
|
|
22
23
|
"DumpApp",
|
|
24
|
+
"ImportApp",
|
|
23
25
|
"LandingApp",
|
|
24
26
|
"MigrateApp",
|
|
25
27
|
"ModulesApp",
|
|
@@ -13,8 +13,10 @@ from rich.panel import Panel
|
|
|
13
13
|
from cognite_toolkit._cdf_tk.cdf_toml import CDFToml
|
|
14
14
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
15
15
|
from cognite_toolkit._cdf_tk.commands import BuildCommand, CleanCommand, DeployCommand
|
|
16
|
+
from cognite_toolkit._cdf_tk.commands.build_v2.build_cmd import BuildCommand as BuildCommandV2
|
|
16
17
|
from cognite_toolkit._cdf_tk.commands.clean import AVAILABLE_DATA_TYPES
|
|
17
18
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitFileNotFoundError
|
|
19
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
18
20
|
from cognite_toolkit._cdf_tk.utils import get_cicd_environment
|
|
19
21
|
from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
|
|
20
22
|
from cognite_toolkit._version import __version__ as current_version
|
|
@@ -207,7 +209,11 @@ class CoreApp(typer.Typer):
|
|
|
207
209
|
if exit_on_warning:
|
|
208
210
|
print_warning = False
|
|
209
211
|
|
|
210
|
-
cmd =
|
|
212
|
+
cmd = (
|
|
213
|
+
BuildCommandV2(print_warning=print_warning)
|
|
214
|
+
if Flags.v08.is_enabled()
|
|
215
|
+
else BuildCommand(print_warning=print_warning)
|
|
216
|
+
)
|
|
211
217
|
cmd.run(
|
|
212
218
|
lambda: cmd.execute(
|
|
213
219
|
verbose,
|
|
@@ -7,7 +7,7 @@ import typer
|
|
|
7
7
|
from questionary import Choice
|
|
8
8
|
from rich import print
|
|
9
9
|
|
|
10
|
-
from cognite_toolkit._cdf_tk.client.
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawTable
|
|
11
11
|
from cognite_toolkit._cdf_tk.commands import DownloadCommand
|
|
12
12
|
from cognite_toolkit._cdf_tk.constants import DATA_DEFAULT_DIR
|
|
13
13
|
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
@@ -616,7 +616,7 @@ class DownloadApp(typer.Typer):
|
|
|
616
616
|
file_format = AssetCentricFormats.ndjson
|
|
617
617
|
files = client.files.list(data_set_external_ids=data_sets, limit=limit)
|
|
618
618
|
selector = FileIdentifierSelector(
|
|
619
|
-
identifiers=tuple([FileInternalID(internal_id=file.id) for file in files])
|
|
619
|
+
identifiers=tuple([FileInternalID(internal_id=file.id) for file in files])
|
|
620
620
|
)
|
|
621
621
|
selectors = [selector]
|
|
622
622
|
io = FileContentIO(client, output_dir / sanitize_filename(selector.group))
|
|
@@ -6,7 +6,7 @@ from cognite.client.data_classes import WorkflowVersionId
|
|
|
6
6
|
from cognite.client.data_classes.data_modeling import DataModelId, ViewId
|
|
7
7
|
from rich import print
|
|
8
8
|
|
|
9
|
-
from cognite_toolkit._cdf_tk.client.
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.search_config import ViewId as SearchConfigViewId
|
|
10
10
|
from cognite_toolkit._cdf_tk.commands import DumpResourceCommand
|
|
11
11
|
from cognite_toolkit._cdf_tk.commands.dump_resource import (
|
|
12
12
|
AgentFinder,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
7
|
+
from cognite_toolkit._cdf_tk.commands._import_cmd import ImportTransformationCLI
|
|
8
|
+
from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ImportApp(typer.Typer):
|
|
12
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
13
|
+
super().__init__(*args, **kwargs)
|
|
14
|
+
self.callback(invoke_without_command=True)(self.main)
|
|
15
|
+
self.command("transformation-cli")(self.transformation_cli)
|
|
16
|
+
|
|
17
|
+
def main(self, ctx: typer.Context) -> None:
|
|
18
|
+
"""PREVIEW FEATURE Import resources into Cognite-Toolkit."""
|
|
19
|
+
if ctx.invoked_subcommand is None:
|
|
20
|
+
print("Use [bold yellow]cdf-tk import --help[/] for more information.")
|
|
21
|
+
return None
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def transformation_cli(
|
|
25
|
+
source: Path = typer.Argument(..., help="Path to the transformation CLI manifest directory or files."),
|
|
26
|
+
destination: Path = typer.Argument(..., help="Path to the destination directory."),
|
|
27
|
+
overwrite: bool = typer.Option(False, help="Overwrite destination if it already exists."),
|
|
28
|
+
flatten: bool = typer.Option(False, help="Flatten the directory structure."),
|
|
29
|
+
clean: bool = typer.Option(False, help="Remove the source directory after import."),
|
|
30
|
+
verbose: bool = typer.Option(False, help="Turn on to get more verbose output when running the command"),
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Import transformation CLI manifests into Cognite-Toolkit modules."""
|
|
33
|
+
|
|
34
|
+
# We are lazy loading the client as we only need it if we need to look up dataset ids.
|
|
35
|
+
# This is to ensure the command can be executed without a client if the user does not need to look up dataset ids.
|
|
36
|
+
# (which is likely 99% of the time)
|
|
37
|
+
def get_client() -> ToolkitClient:
|
|
38
|
+
return EnvironmentVariables.create_from_environment().get_client()
|
|
39
|
+
|
|
40
|
+
cmd = ImportTransformationCLI(print_warning=True, get_client=get_client)
|
|
41
|
+
cmd.execute(source, destination, overwrite, flatten, clean, verbose=verbose)
|
|
@@ -15,10 +15,18 @@ from cognite_toolkit._cdf_tk.commands._migrate.creators import (
|
|
|
15
15
|
InstanceSpaceCreator,
|
|
16
16
|
SourceSystemCreator,
|
|
17
17
|
)
|
|
18
|
-
from cognite_toolkit._cdf_tk.commands._migrate.data_mapper import
|
|
18
|
+
from cognite_toolkit._cdf_tk.commands._migrate.data_mapper import (
|
|
19
|
+
AssetCentricMapper,
|
|
20
|
+
CanvasMapper,
|
|
21
|
+
ChartMapper,
|
|
22
|
+
ThreeDAssetMapper,
|
|
23
|
+
ThreeDMapper,
|
|
24
|
+
)
|
|
19
25
|
from cognite_toolkit._cdf_tk.commands._migrate.migration_io import (
|
|
20
26
|
AnnotationMigrationIO,
|
|
21
27
|
AssetCentricMigrationIO,
|
|
28
|
+
ThreeDAssetMappingMigrationIO,
|
|
29
|
+
ThreeDMigrationIO,
|
|
22
30
|
)
|
|
23
31
|
from cognite_toolkit._cdf_tk.commands._migrate.selectors import (
|
|
24
32
|
AssetCentricMigrationSelector,
|
|
@@ -26,7 +34,11 @@ from cognite_toolkit._cdf_tk.commands._migrate.selectors import (
|
|
|
26
34
|
MigrationCSVFileSelector,
|
|
27
35
|
)
|
|
28
36
|
from cognite_toolkit._cdf_tk.storageio import CanvasIO, ChartIO
|
|
29
|
-
from cognite_toolkit._cdf_tk.storageio.selectors import
|
|
37
|
+
from cognite_toolkit._cdf_tk.storageio.selectors import (
|
|
38
|
+
CanvasExternalIdSelector,
|
|
39
|
+
ChartExternalIdSelector,
|
|
40
|
+
ThreeDModelIdSelector,
|
|
41
|
+
)
|
|
30
42
|
from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
|
|
31
43
|
from cognite_toolkit._cdf_tk.utils.cli_args import parse_view_str
|
|
32
44
|
from cognite_toolkit._cdf_tk.utils.interactive_select import (
|
|
@@ -36,6 +48,7 @@ from cognite_toolkit._cdf_tk.utils.interactive_select import (
|
|
|
36
48
|
InteractiveCanvasSelect,
|
|
37
49
|
InteractiveChartSelect,
|
|
38
50
|
ResourceViewMappingInteractiveSelect,
|
|
51
|
+
ThreeDInteractiveSelect,
|
|
39
52
|
)
|
|
40
53
|
from cognite_toolkit._cdf_tk.utils.useful_types import AssetCentricKind
|
|
41
54
|
|
|
@@ -56,6 +69,8 @@ class MigrateApp(typer.Typer):
|
|
|
56
69
|
self.command("annotations")(self.annotations)
|
|
57
70
|
self.command("canvas")(self.canvas)
|
|
58
71
|
self.command("charts")(self.charts)
|
|
72
|
+
self.command("3d")(self.three_d)
|
|
73
|
+
self.command("3d-mappings")(self.three_d_asset_mapping)
|
|
59
74
|
# Uncomment when infield v2 config migration is ready
|
|
60
75
|
# self.command("infield-configs")(self.infield_configs)
|
|
61
76
|
|
|
@@ -853,13 +868,13 @@ class MigrateApp(typer.Typer):
|
|
|
853
868
|
"performed to select the Canvas to migrate."
|
|
854
869
|
),
|
|
855
870
|
] = None,
|
|
856
|
-
|
|
871
|
+
allow_missing_ref: Annotated[
|
|
857
872
|
bool,
|
|
858
873
|
typer.Option(
|
|
859
|
-
"--
|
|
860
|
-
"-
|
|
861
|
-
help="If set, the
|
|
862
|
-
"If not set, the migration will
|
|
874
|
+
"--allow-missing-ref",
|
|
875
|
+
"-a",
|
|
876
|
+
help="If set, the command will migrate Canvases that reference resources that have not been migrated to data modeling. "
|
|
877
|
+
"If not set, the migration will fail if any referenced resource are missing.",
|
|
863
878
|
),
|
|
864
879
|
] = False,
|
|
865
880
|
log_dir: Annotated[
|
|
@@ -911,7 +926,7 @@ class MigrateApp(typer.Typer):
|
|
|
911
926
|
lambda: cmd.migrate(
|
|
912
927
|
selected=selector,
|
|
913
928
|
data=CanvasIO(client, exclude_existing_version=True),
|
|
914
|
-
mapper=CanvasMapper(client, dry_run=dry_run, skip_on_missing_ref=
|
|
929
|
+
mapper=CanvasMapper(client, dry_run=dry_run, skip_on_missing_ref=not allow_missing_ref),
|
|
915
930
|
log_dir=log_dir,
|
|
916
931
|
dry_run=dry_run,
|
|
917
932
|
verbose=verbose,
|
|
@@ -980,6 +995,166 @@ class MigrateApp(typer.Typer):
|
|
|
980
995
|
)
|
|
981
996
|
)
|
|
982
997
|
|
|
998
|
+
@staticmethod
|
|
999
|
+
def three_d(
|
|
1000
|
+
ctx: typer.Context,
|
|
1001
|
+
id: Annotated[
|
|
1002
|
+
list[int] | None,
|
|
1003
|
+
typer.Argument(
|
|
1004
|
+
help="The ID of the 3D Model to migrate. If not provided, an interactive selection will be "
|
|
1005
|
+
"performed to select the 3D Models to migrate."
|
|
1006
|
+
),
|
|
1007
|
+
] = None,
|
|
1008
|
+
log_dir: Annotated[
|
|
1009
|
+
Path,
|
|
1010
|
+
typer.Option(
|
|
1011
|
+
"--log-dir",
|
|
1012
|
+
"-l",
|
|
1013
|
+
help="Path to the directory where migration logs will be stored.",
|
|
1014
|
+
),
|
|
1015
|
+
] = Path(f"migration_logs_{TODAY}"),
|
|
1016
|
+
dry_run: Annotated[
|
|
1017
|
+
bool,
|
|
1018
|
+
typer.Option(
|
|
1019
|
+
"--dry-run",
|
|
1020
|
+
"-d",
|
|
1021
|
+
help="If set, the migration will not be executed, but only a report of "
|
|
1022
|
+
"what would be done is printed. This is useful for checking that all resources referenced by the 3D Models "
|
|
1023
|
+
"have been migrated to the new data modeling resources in CDF.",
|
|
1024
|
+
),
|
|
1025
|
+
] = False,
|
|
1026
|
+
verbose: Annotated[
|
|
1027
|
+
bool,
|
|
1028
|
+
typer.Option(
|
|
1029
|
+
"--verbose",
|
|
1030
|
+
"-v",
|
|
1031
|
+
help="Turn on to get more verbose output when running the command",
|
|
1032
|
+
),
|
|
1033
|
+
] = False,
|
|
1034
|
+
) -> None:
|
|
1035
|
+
"""Migrate 3D Models from Asset-Centric to data modeling in CDF.
|
|
1036
|
+
|
|
1037
|
+
This command expects that the CogniteMigration data model is already deployed, and that the Mapping view
|
|
1038
|
+
is populated with the mapping from Asset-Centric resources to the new data modeling resources.
|
|
1039
|
+
"""
|
|
1040
|
+
client = EnvironmentVariables.create_from_environment().get_client()
|
|
1041
|
+
selected_ids: list[int]
|
|
1042
|
+
if id:
|
|
1043
|
+
selected_ids = id
|
|
1044
|
+
else:
|
|
1045
|
+
selected_models = ThreeDInteractiveSelect(client, "migrate").select_three_d_models("classic")
|
|
1046
|
+
selected_ids = [model.id for model in selected_models]
|
|
1047
|
+
|
|
1048
|
+
cmd = MigrationCommand()
|
|
1049
|
+
cmd.run(
|
|
1050
|
+
lambda: cmd.migrate(
|
|
1051
|
+
selected=ThreeDModelIdSelector(ids=tuple(selected_ids)),
|
|
1052
|
+
data=ThreeDMigrationIO(client),
|
|
1053
|
+
mapper=ThreeDMapper(client),
|
|
1054
|
+
log_dir=log_dir,
|
|
1055
|
+
dry_run=dry_run,
|
|
1056
|
+
verbose=verbose,
|
|
1057
|
+
)
|
|
1058
|
+
)
|
|
1059
|
+
|
|
1060
|
+
@staticmethod
|
|
1061
|
+
def three_d_asset_mapping(
|
|
1062
|
+
ctx: typer.Context,
|
|
1063
|
+
model_id: Annotated[
|
|
1064
|
+
list[int] | None,
|
|
1065
|
+
typer.Argument(
|
|
1066
|
+
help="The IDs of the 3D model to migrate asset mappings for. If not provided, an interactive selection will be "
|
|
1067
|
+
"performed to select the."
|
|
1068
|
+
),
|
|
1069
|
+
] = None,
|
|
1070
|
+
object_3D_space: Annotated[
|
|
1071
|
+
str | None,
|
|
1072
|
+
typer.Option(
|
|
1073
|
+
"--object-3d-space",
|
|
1074
|
+
"-o",
|
|
1075
|
+
help="The instance space to ceate the 3D object nodes in.",
|
|
1076
|
+
),
|
|
1077
|
+
] = None,
|
|
1078
|
+
cad_node_space: Annotated[
|
|
1079
|
+
str | None,
|
|
1080
|
+
typer.Option(
|
|
1081
|
+
"--cad-node-space",
|
|
1082
|
+
"-c",
|
|
1083
|
+
help="The instance space to create the CAD node nodes in.",
|
|
1084
|
+
),
|
|
1085
|
+
] = None,
|
|
1086
|
+
log_dir: Annotated[
|
|
1087
|
+
Path,
|
|
1088
|
+
typer.Option(
|
|
1089
|
+
"--log-dir",
|
|
1090
|
+
"-l",
|
|
1091
|
+
help="Path to the directory where migration logs will be stored.",
|
|
1092
|
+
),
|
|
1093
|
+
] = Path(f"migration_logs_{TODAY}"),
|
|
1094
|
+
dry_run: Annotated[
|
|
1095
|
+
bool,
|
|
1096
|
+
typer.Option(
|
|
1097
|
+
"--dry-run",
|
|
1098
|
+
"-d",
|
|
1099
|
+
help="If set, the migration will not be executed, but only a report of what would be done is printed.",
|
|
1100
|
+
),
|
|
1101
|
+
] = False,
|
|
1102
|
+
verbose: Annotated[
|
|
1103
|
+
bool,
|
|
1104
|
+
typer.Option(
|
|
1105
|
+
"--verbose",
|
|
1106
|
+
"-v",
|
|
1107
|
+
help="Turn on to get more verbose output when running the command",
|
|
1108
|
+
),
|
|
1109
|
+
] = False,
|
|
1110
|
+
) -> None:
|
|
1111
|
+
"""Migrate 3D Model Asset Mappings from Asset-Centric to data modeling in CDF.
|
|
1112
|
+
|
|
1113
|
+
This command expects that the selected 3D model has already been migrated to data modeling.
|
|
1114
|
+
"""
|
|
1115
|
+
client = EnvironmentVariables.create_from_environment().get_client()
|
|
1116
|
+
selected_ids: list[int]
|
|
1117
|
+
if model_id is not None:
|
|
1118
|
+
selected_ids = model_id
|
|
1119
|
+
else:
|
|
1120
|
+
# Interactive selection
|
|
1121
|
+
selected_models = ThreeDInteractiveSelect(client, "migrate").select_three_d_models("dm")
|
|
1122
|
+
selected_ids = [model.id for model in selected_models]
|
|
1123
|
+
space_selector = DataModelingSelect(client, "migrate")
|
|
1124
|
+
object_3D_space = space_selector.select_instance_space(
|
|
1125
|
+
multiselect=False,
|
|
1126
|
+
message="In which instance space do you want to create the 3D Object nodes?",
|
|
1127
|
+
include_empty=False,
|
|
1128
|
+
)
|
|
1129
|
+
cad_node_space = space_selector.select_instance_space(
|
|
1130
|
+
multiselect=False,
|
|
1131
|
+
message="In which instance space do you want to create the CAD Node nodes?",
|
|
1132
|
+
include_empty=False,
|
|
1133
|
+
)
|
|
1134
|
+
dry_run = questionary.confirm("Do you want to perform a dry run?", default=dry_run).ask()
|
|
1135
|
+
verbose = questionary.confirm("Do you want verbose output?", default=verbose).ask()
|
|
1136
|
+
if any(res is None for res in [dry_run, verbose]):
|
|
1137
|
+
raise typer.Abort()
|
|
1138
|
+
|
|
1139
|
+
if object_3D_space is None or cad_node_space is None:
|
|
1140
|
+
raise typer.BadParameter(
|
|
1141
|
+
"--object-3d-space and --cad-node-space are required when specifying IDs directly."
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
cmd = MigrationCommand()
|
|
1145
|
+
cmd.run(
|
|
1146
|
+
lambda: cmd.migrate(
|
|
1147
|
+
selected=ThreeDModelIdSelector(ids=tuple(selected_ids)),
|
|
1148
|
+
data=ThreeDAssetMappingMigrationIO(
|
|
1149
|
+
client, object_3D_space=object_3D_space, cad_node_space=cad_node_space
|
|
1150
|
+
),
|
|
1151
|
+
mapper=ThreeDAssetMapper(client),
|
|
1152
|
+
log_dir=log_dir,
|
|
1153
|
+
dry_run=dry_run,
|
|
1154
|
+
verbose=verbose,
|
|
1155
|
+
)
|
|
1156
|
+
)
|
|
1157
|
+
|
|
983
1158
|
@staticmethod
|
|
984
1159
|
def infield_configs(
|
|
985
1160
|
ctx: typer.Context,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import shutil
|
|
2
|
+
import time
|
|
2
3
|
from collections.abc import Callable, Iterable, Sequence
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
3
6
|
|
|
4
7
|
from cognite_toolkit._cdf_tk.builders import Builder
|
|
5
8
|
from cognite_toolkit._cdf_tk.cruds import FunctionCRUD
|
|
@@ -10,21 +13,74 @@ from cognite_toolkit._cdf_tk.data_classes import (
|
|
|
10
13
|
ModuleLocation,
|
|
11
14
|
)
|
|
12
15
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitFileExistsError, ToolkitNotADirectoryError, ToolkitValueError
|
|
16
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
13
17
|
from cognite_toolkit._cdf_tk.tk_warnings import (
|
|
14
18
|
FileReadWarning,
|
|
19
|
+
FunctionRequirementsValidationWarning,
|
|
15
20
|
HighSeverityWarning,
|
|
16
21
|
LowSeverityWarning,
|
|
17
22
|
MediumSeverityWarning,
|
|
18
23
|
ToolkitWarning,
|
|
19
24
|
WarningList,
|
|
20
25
|
)
|
|
26
|
+
from cognite_toolkit._cdf_tk.utils import validate_requirements_with_pip
|
|
27
|
+
|
|
28
|
+
# Maximum number of error lines to display in warnings
|
|
29
|
+
_MAX_ERROR_LINES = 3
|
|
21
30
|
|
|
22
31
|
|
|
23
32
|
class FunctionBuilder(Builder):
|
|
24
33
|
_resource_folder = FunctionCRUD.folder_name
|
|
25
34
|
|
|
35
|
+
def __init__(self, build_dir: Path, warn: Callable[[ToolkitWarning], None]) -> None:
|
|
36
|
+
super().__init__(build_dir, warn=warn)
|
|
37
|
+
# Metrics for telemetry
|
|
38
|
+
self.validation_count = 0
|
|
39
|
+
self.validation_failures = 0
|
|
40
|
+
self.validation_credential_errors = 0
|
|
41
|
+
self.validation_time_ms = 0
|
|
42
|
+
|
|
43
|
+
def _validate_function_requirements(
|
|
44
|
+
self,
|
|
45
|
+
requirements_txt: Path,
|
|
46
|
+
raw_function: dict[str, Any],
|
|
47
|
+
filepath: Path,
|
|
48
|
+
external_id: str,
|
|
49
|
+
) -> FunctionRequirementsValidationWarning | None:
|
|
50
|
+
"""Validate function requirements.txt using pip dry-run."""
|
|
51
|
+
start_time = time.time()
|
|
52
|
+
validation_result = validate_requirements_with_pip(
|
|
53
|
+
requirements_txt_path=requirements_txt,
|
|
54
|
+
index_url=raw_function.get("indexUrl"),
|
|
55
|
+
extra_index_urls=raw_function.get("extraIndexUrls"),
|
|
56
|
+
)
|
|
57
|
+
elapsed_ms = int((time.time() - start_time) * 1000)
|
|
58
|
+
self.validation_count += 1
|
|
59
|
+
self.validation_time_ms += elapsed_ms
|
|
60
|
+
|
|
61
|
+
if validation_result.success:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
self.validation_failures += 1
|
|
65
|
+
if validation_result.is_credential_error:
|
|
66
|
+
self.validation_credential_errors += 1
|
|
67
|
+
|
|
68
|
+
error_detail = validation_result.error_message or "Unknown error"
|
|
69
|
+
relevant_lines = [line for line in error_detail.strip().split("\n") if line.strip()][-_MAX_ERROR_LINES:]
|
|
70
|
+
error_detail = "\n ".join(relevant_lines)
|
|
71
|
+
|
|
72
|
+
return FunctionRequirementsValidationWarning(
|
|
73
|
+
filepath=filepath,
|
|
74
|
+
function_external_id=external_id,
|
|
75
|
+
error_details=error_detail,
|
|
76
|
+
is_credential_error=validation_result.is_credential_error,
|
|
77
|
+
)
|
|
78
|
+
|
|
26
79
|
def build(
|
|
27
|
-
self,
|
|
80
|
+
self,
|
|
81
|
+
source_files: list[BuildSourceFile],
|
|
82
|
+
module: ModuleLocation,
|
|
83
|
+
console: Callable[[str], None] | None = None,
|
|
28
84
|
) -> Iterable[BuildDestinationFile | Sequence[ToolkitWarning]]:
|
|
29
85
|
for source_file in source_files:
|
|
30
86
|
if source_file.loaded is None:
|
|
@@ -55,7 +111,9 @@ class FunctionBuilder(Builder):
|
|
|
55
111
|
)
|
|
56
112
|
|
|
57
113
|
def validate_directory(
|
|
58
|
-
self,
|
|
114
|
+
self,
|
|
115
|
+
built_resources: BuiltResourceList,
|
|
116
|
+
module: ModuleLocation,
|
|
59
117
|
) -> WarningList[ToolkitWarning]:
|
|
60
118
|
warnings = WarningList[ToolkitWarning]()
|
|
61
119
|
has_config_files = any(resource.kind == FunctionCRUD.kind for resource in built_resources)
|
|
@@ -74,7 +132,7 @@ class FunctionBuilder(Builder):
|
|
|
74
132
|
f"was not found in {required_location.as_posix()!r}. "
|
|
75
133
|
f"The file {yaml_source_path.as_posix()!r} is currently "
|
|
76
134
|
f"considered part of the Function's artifacts and "
|
|
77
|
-
f"will not be processed by the Toolkit."
|
|
135
|
+
f"will not be processed by the Toolkit.",
|
|
78
136
|
)
|
|
79
137
|
warnings.append(warning)
|
|
80
138
|
return warnings
|
|
@@ -93,28 +151,42 @@ class FunctionBuilder(Builder):
|
|
|
93
151
|
warnings.append(
|
|
94
152
|
HighSeverityWarning(
|
|
95
153
|
f"Function in {source_file.source.path.as_posix()!r} has no externalId defined. "
|
|
96
|
-
f"This is used to match the function to the function directory."
|
|
97
|
-
)
|
|
154
|
+
f"This is used to match the function to the function directory.",
|
|
155
|
+
),
|
|
98
156
|
)
|
|
99
157
|
continue
|
|
100
158
|
if not function_path:
|
|
101
159
|
warnings.append(
|
|
102
160
|
MediumSeverityWarning(
|
|
103
|
-
f"Function {external_id} in {source_file.source.path.as_posix()!r} has no function_path defined."
|
|
104
|
-
)
|
|
161
|
+
f"Function {external_id} in {source_file.source.path.as_posix()!r} has no function_path defined.",
|
|
162
|
+
),
|
|
105
163
|
)
|
|
106
164
|
|
|
107
165
|
function_directory = source_file.source.path.with_name(external_id)
|
|
108
166
|
|
|
109
167
|
if not function_directory.is_dir():
|
|
110
168
|
raise ToolkitNotADirectoryError(
|
|
111
|
-
f"Function directory not found for externalId {external_id} defined in {source_file.source.path.as_posix()!r}."
|
|
169
|
+
f"Function directory not found for externalId {external_id} defined in {source_file.source.path.as_posix()!r}.",
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# Validate requirements.txt if present and feature is enabled
|
|
173
|
+
if (
|
|
174
|
+
Flags.FUNCTION_REQUIREMENTS_VALIDATION.is_enabled()
|
|
175
|
+
and (requirements_txt := function_directory / "requirements.txt").exists()
|
|
176
|
+
):
|
|
177
|
+
warning = self._validate_function_requirements(
|
|
178
|
+
requirements_txt,
|
|
179
|
+
raw_function,
|
|
180
|
+
source_file.source.path,
|
|
181
|
+
external_id,
|
|
112
182
|
)
|
|
183
|
+
if warning:
|
|
184
|
+
warnings.append(warning)
|
|
113
185
|
|
|
114
186
|
destination = self.build_dir / self.resource_folder / external_id
|
|
115
187
|
if destination.exists():
|
|
116
188
|
raise ToolkitFileExistsError(
|
|
117
|
-
f"Function {external_id!r} is duplicated. If this is unexpected, ensure you have a clean build directory."
|
|
189
|
+
f"Function {external_id!r} is duplicated. If this is unexpected, ensure you have a clean build directory.",
|
|
118
190
|
)
|
|
119
191
|
shutil.copytree(function_directory, destination, ignore=shutil.ignore_patterns("__pycache__"))
|
|
120
192
|
|
|
@@ -3,7 +3,7 @@ from collections.abc import Callable, Iterable, Sequence
|
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
5
|
from cognite_toolkit._cdf_tk.builders import Builder
|
|
6
|
-
from cognite_toolkit._cdf_tk.client.
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawDatabase
|
|
7
7
|
from cognite_toolkit._cdf_tk.cruds import RawDatabaseCRUD, RawTableCRUD, ResourceCRUD
|
|
8
8
|
from cognite_toolkit._cdf_tk.data_classes import (
|
|
9
9
|
BuildDestinationFile,
|