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.
Files changed (281) hide show
  1. cognite_toolkit/_cdf.py +5 -6
  2. cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
  3. cognite_toolkit/_cdf_tk/apps/_core_app.py +7 -1
  4. cognite_toolkit/_cdf_tk/apps/_download_app.py +2 -2
  5. cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
  6. cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
  7. cognite_toolkit/_cdf_tk/apps/_migrate_app.py +183 -8
  8. cognite_toolkit/_cdf_tk/builders/_function.py +81 -9
  9. cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
  10. cognite_toolkit/_cdf_tk/client/_resource_base.py +187 -0
  11. cognite_toolkit/_cdf_tk/client/_toolkit_client.py +44 -12
  12. cognite_toolkit/_cdf_tk/client/api/agents.py +107 -0
  13. cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -0
  14. cognite_toolkit/_cdf_tk/client/api/assets.py +130 -0
  15. cognite_toolkit/_cdf_tk/client/api/containers.py +132 -0
  16. cognite_toolkit/_cdf_tk/client/api/data_models.py +137 -0
  17. cognite_toolkit/_cdf_tk/client/api/datasets.py +141 -0
  18. cognite_toolkit/_cdf_tk/client/api/events.py +129 -0
  19. cognite_toolkit/_cdf_tk/client/api/extraction_pipelines.py +148 -0
  20. cognite_toolkit/_cdf_tk/client/api/filemetadata.py +176 -0
  21. cognite_toolkit/_cdf_tk/client/api/function_schedules.py +115 -0
  22. cognite_toolkit/_cdf_tk/client/api/functions.py +113 -0
  23. cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py +167 -0
  24. cognite_toolkit/_cdf_tk/client/api/groups.py +121 -0
  25. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_destinations.py +131 -0
  26. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_jobs.py +122 -0
  27. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_mappings.py +129 -0
  28. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_sources.py +136 -0
  29. cognite_toolkit/_cdf_tk/client/api/hosted_extractors.py +23 -0
  30. cognite_toolkit/_cdf_tk/client/api/infield.py +40 -35
  31. cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
  32. cognite_toolkit/_cdf_tk/client/api/labels.py +125 -0
  33. cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +16 -8
  34. cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
  35. cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
  36. cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
  37. cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +9 -9
  38. cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
  39. cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
  40. cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +112 -0
  41. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
  42. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
  43. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
  44. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
  45. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
  46. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
  47. cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
  48. cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +53 -0
  49. cognite_toolkit/_cdf_tk/client/api/location_filters.py +140 -75
  50. cognite_toolkit/_cdf_tk/client/api/migration.py +2 -3
  51. cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
  52. cognite_toolkit/_cdf_tk/client/api/raw.py +204 -0
  53. cognite_toolkit/_cdf_tk/client/api/relationships.py +133 -0
  54. cognite_toolkit/_cdf_tk/client/api/robotics.py +19 -0
  55. cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +127 -0
  56. cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +138 -0
  57. cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +122 -0
  58. cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +127 -0
  59. cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +122 -0
  60. cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +122 -0
  61. cognite_toolkit/_cdf_tk/client/api/search.py +2 -2
  62. cognite_toolkit/_cdf_tk/client/api/search_config.py +83 -31
  63. cognite_toolkit/_cdf_tk/client/api/security_categories.py +94 -0
  64. cognite_toolkit/_cdf_tk/client/api/sequences.py +133 -0
  65. cognite_toolkit/_cdf_tk/client/api/simulator_models.py +154 -0
  66. cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
  67. cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -0
  68. cognite_toolkit/_cdf_tk/client/api/streams.py +68 -56
  69. cognite_toolkit/_cdf_tk/client/api/three_d.py +385 -34
  70. cognite_toolkit/_cdf_tk/client/api/timeseries.py +137 -0
  71. cognite_toolkit/_cdf_tk/client/api/token.py +1 -1
  72. cognite_toolkit/_cdf_tk/client/api/transformations.py +146 -0
  73. cognite_toolkit/_cdf_tk/client/api/views.py +139 -0
  74. cognite_toolkit/_cdf_tk/client/api/workflow_triggers.py +128 -0
  75. cognite_toolkit/_cdf_tk/client/api/workflow_versions.py +138 -0
  76. cognite_toolkit/_cdf_tk/client/api/workflows.py +119 -0
  77. cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +10 -0
  78. cognite_toolkit/_cdf_tk/client/cdf_client/api.py +358 -0
  79. cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +38 -0
  80. cognite_toolkit/_cdf_tk/{utils → client}/http_client/__init__.py +30 -0
  81. cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +26 -16
  82. cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +18 -2
  83. cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +151 -0
  84. cognite_toolkit/_cdf_tk/client/http_client/_exception.py +13 -0
  85. cognite_toolkit/_cdf_tk/client/http_client/_item_classes.py +118 -0
  86. cognite_toolkit/_cdf_tk/{utils → client}/http_client/_tracker.py +5 -2
  87. cognite_toolkit/_cdf_tk/client/request_classes/base.py +19 -0
  88. cognite_toolkit/_cdf_tk/client/request_classes/filters.py +113 -0
  89. cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
  90. cognite_toolkit/_cdf_tk/client/resource_classes/__init__.py +0 -0
  91. cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +130 -0
  92. cognite_toolkit/_cdf_tk/client/resource_classes/annotation.py +79 -0
  93. cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
  94. cognite_toolkit/_cdf_tk/client/resource_classes/asset.py +47 -0
  95. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/charts_data.py +1 -1
  96. cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
  97. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +168 -0
  98. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_constraints.py +37 -0
  99. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_container.py +50 -0
  100. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_model.py +73 -0
  101. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_types.py +116 -0
  102. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_indexes.py +26 -0
  103. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +154 -0
  104. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_references.py +86 -0
  105. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_space.py +26 -0
  106. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view.py +143 -0
  107. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view_property.py +152 -0
  108. cognite_toolkit/_cdf_tk/client/resource_classes/dataset.py +35 -0
  109. cognite_toolkit/_cdf_tk/client/resource_classes/event.py +40 -0
  110. cognite_toolkit/_cdf_tk/client/resource_classes/extraction_pipeline.py +59 -0
  111. cognite_toolkit/_cdf_tk/client/resource_classes/filemetadata.py +52 -0
  112. cognite_toolkit/_cdf_tk/client/resource_classes/function.py +53 -0
  113. cognite_toolkit/_cdf_tk/client/resource_classes/function_schedule.py +65 -0
  114. cognite_toolkit/_cdf_tk/client/resource_classes/graphql_data_model.py +40 -0
  115. cognite_toolkit/_cdf_tk/client/resource_classes/group/__init__.py +187 -0
  116. cognite_toolkit/_cdf_tk/client/resource_classes/group/_constants.py +2 -0
  117. cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py +653 -0
  118. cognite_toolkit/_cdf_tk/client/resource_classes/group/capability.py +56 -0
  119. cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +63 -0
  120. cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py +166 -0
  121. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_destination.py +34 -0
  122. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_job.py +134 -0
  123. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_mapping.py +72 -0
  124. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/__init__.py +63 -0
  125. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_auth.py +63 -0
  126. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_base.py +26 -0
  127. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_certificate.py +20 -0
  128. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_eventhub.py +31 -0
  129. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_kafka.py +53 -0
  130. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_mqtt.py +36 -0
  131. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_rest.py +49 -0
  132. cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +59 -0
  133. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/infield.py +1 -1
  134. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/instance_api.py +53 -14
  135. cognite_toolkit/_cdf_tk/client/resource_classes/label.py +27 -0
  136. cognite_toolkit/_cdf_tk/client/resource_classes/legacy/__init__.py +0 -0
  137. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/canvas.py +48 -15
  138. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/charts.py +1 -1
  139. cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +84 -0
  140. cognite_toolkit/_cdf_tk/client/resource_classes/raw.py +44 -0
  141. cognite_toolkit/_cdf_tk/client/resource_classes/relationship.py +49 -0
  142. cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
  143. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/__init__.py +37 -0
  144. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_capability.py +53 -0
  145. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_common.py +34 -0
  146. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_data_post_processing.py +49 -0
  147. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_frame.py +46 -0
  148. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_location.py +36 -0
  149. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +65 -0
  150. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +58 -0
  151. cognite_toolkit/_cdf_tk/client/resource_classes/search_config.py +54 -0
  152. cognite_toolkit/_cdf_tk/client/resource_classes/securitycategory.py +24 -0
  153. cognite_toolkit/_cdf_tk/client/resource_classes/sequence.py +45 -0
  154. cognite_toolkit/_cdf_tk/client/resource_classes/sequence_rows.py +56 -0
  155. cognite_toolkit/_cdf_tk/client/resource_classes/simulator_model.py +50 -0
  156. cognite_toolkit/_cdf_tk/client/resource_classes/streamlit_.py +71 -0
  157. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/streams.py +9 -26
  158. cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +135 -0
  159. cognite_toolkit/_cdf_tk/client/resource_classes/timeseries.py +52 -0
  160. cognite_toolkit/_cdf_tk/client/resource_classes/transformation.py +140 -0
  161. cognite_toolkit/_cdf_tk/client/resource_classes/workflow.py +27 -0
  162. cognite_toolkit/_cdf_tk/client/resource_classes/workflow_trigger.py +63 -0
  163. cognite_toolkit/_cdf_tk/client/resource_classes/workflow_version.py +155 -0
  164. cognite_toolkit/_cdf_tk/client/testing.py +54 -17
  165. cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
  166. cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
  167. cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +29 -16
  168. cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
  169. cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +38 -6
  170. cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +262 -36
  171. cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
  172. cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
  173. cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +39 -38
  174. cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +227 -8
  175. cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
  176. cognite_toolkit/_cdf_tk/commands/_purge.py +14 -16
  177. cognite_toolkit/_cdf_tk/commands/_upload.py +1 -1
  178. cognite_toolkit/_cdf_tk/commands/build_cmd.py +12 -2
  179. cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
  180. cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py +138 -0
  181. cognite_toolkit/_cdf_tk/commands/build_v2/_modules_parser.py +163 -0
  182. cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +228 -0
  183. cognite_toolkit/_cdf_tk/commands/build_v2/build_parameters.py +71 -0
  184. cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_modules.py +27 -0
  185. cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_resource.py +22 -0
  186. cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
  187. cognite_toolkit/_cdf_tk/commands/pull.py +97 -2
  188. cognite_toolkit/_cdf_tk/commands/run.py +1 -1
  189. cognite_toolkit/_cdf_tk/cruds/__init__.py +16 -6
  190. cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +9 -5
  191. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
  192. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +6 -2
  193. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +70 -89
  194. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
  195. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
  196. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
  197. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +34 -25
  198. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
  199. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +14 -2
  200. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
  201. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -3
  202. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
  203. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +6 -1
  204. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +5 -4
  205. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
  206. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +122 -0
  207. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +15 -31
  208. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +42 -47
  209. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +49 -14
  210. cognite_toolkit/_cdf_tk/data_classes/__init__.py +3 -0
  211. cognite_toolkit/_cdf_tk/data_classes/_issues.py +36 -0
  212. cognite_toolkit/_cdf_tk/data_classes/_module_directories.py +2 -1
  213. cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
  214. cognite_toolkit/_cdf_tk/data_classes/_tracking_info.py +4 -0
  215. cognite_toolkit/_cdf_tk/feature_flags.py +8 -0
  216. cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
  217. cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +6 -0
  218. cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
  219. cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
  220. cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +173 -5
  221. cognite_toolkit/_cdf_tk/storageio/_applications.py +53 -15
  222. cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +117 -107
  223. cognite_toolkit/_cdf_tk/storageio/_base.py +3 -1
  224. cognite_toolkit/_cdf_tk/storageio/_datapoints.py +7 -7
  225. cognite_toolkit/_cdf_tk/storageio/_file_content.py +65 -56
  226. cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
  227. cognite_toolkit/_cdf_tk/storageio/_raw.py +1 -1
  228. cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
  229. cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +10 -1
  230. cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
  231. cognite_toolkit/_cdf_tk/tk_warnings/__init__.py +2 -0
  232. cognite_toolkit/_cdf_tk/tk_warnings/fileread.py +20 -0
  233. cognite_toolkit/_cdf_tk/utils/__init__.py +11 -1
  234. cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
  235. cognite_toolkit/_cdf_tk/utils/interactive_select.py +53 -4
  236. cognite_toolkit/_cdf_tk/utils/modules.py +7 -0
  237. cognite_toolkit/_cdf_tk/utils/pip_validator.py +96 -0
  238. cognite_toolkit/_cdf_tk/utils/useful_types.py +4 -7
  239. cognite_toolkit/_cdf_tk/utils/useful_types2.py +14 -0
  240. cognite_toolkit/_cdf_tk/validation.py +4 -0
  241. cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
  242. cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
  243. cognite_toolkit/_resources/cdf.toml +1 -1
  244. cognite_toolkit/_version.py +1 -1
  245. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
  246. cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
  247. {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
  248. cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
  249. cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -17
  250. cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -87
  251. cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -47
  252. cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
  253. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -187
  254. cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
  255. cognite_toolkit-0.7.30.dist-info/RECORD +0 -316
  256. /cognite_toolkit/_cdf_tk/client/{data_classes → api/legacy}/__init__.py +0 -0
  257. /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
  258. /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
  259. /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
  260. /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
  261. /cognite_toolkit/_cdf_tk/{prototypes/commands → client/request_classes}/__init__.py +0 -0
  262. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/capabilities.py +0 -0
  263. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/apm_config_v1.py +0 -0
  264. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/extendable_cognite_file.py +0 -0
  265. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/extended_filemetadata.py +0 -0
  266. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/extended_filemetdata.py +0 -0
  267. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/extended_timeseries.py +0 -0
  268. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/functions.py +0 -0
  269. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/graphql_data_models.py +0 -0
  270. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/instances.py +0 -0
  271. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/location_filters.py +0 -0
  272. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/migration.py +0 -0
  273. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/pending_instances_ids.py +0 -0
  274. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/project.py +0 -0
  275. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/raw.py +0 -0
  276. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/robotics.py +0 -0
  277. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/search_config.py +0 -0
  278. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/sequences.py +0 -0
  279. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes/legacy}/streamlit_.py +0 -0
  280. /cognite_toolkit/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
  281. {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 FeatureFlag, Flags
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 = BuildCommand(print_warning=print_warning)
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.data_classes.raw import RawTable
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]) # type: ignore[call-arg]
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.data_classes.search_config import ViewId as SearchConfigViewId
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 AssetCentricMapper, CanvasMapper, ChartMapper
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 CanvasExternalIdSelector, ChartExternalIdSelector
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
- skip_on_missing_ref: Annotated[
871
+ allow_missing_ref: Annotated[
857
872
  bool,
858
873
  typer.Option(
859
- "--skip-on-missing-ref",
860
- "-s",
861
- help="If set, the migration will skip Canvases that reference resources that have not been migrated to data modeling. "
862
- "If not set, the migration will continue but the result will exclude the missing references.",
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=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, source_files: list[BuildSourceFile], module: ModuleLocation, console: Callable[[str], None] | None = None
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, built_resources: BuiltResourceList, module: ModuleLocation
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.data_classes.raw import RawDatabase
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,