cognite-toolkit 0.7.39__py3-none-any.whl → 0.7.51__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. cognite_toolkit/_cdf_tk/apps/_download_app.py +1 -1
  2. cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
  3. cognite_toolkit/_cdf_tk/apps/_migrate_app.py +6 -6
  4. cognite_toolkit/_cdf_tk/builders/_function.py +81 -9
  5. cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
  6. cognite_toolkit/_cdf_tk/client/_resource_base.py +187 -0
  7. cognite_toolkit/_cdf_tk/client/_toolkit_client.py +37 -5
  8. cognite_toolkit/_cdf_tk/client/api/agents.py +107 -0
  9. cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -0
  10. cognite_toolkit/_cdf_tk/client/api/assets.py +130 -0
  11. cognite_toolkit/_cdf_tk/client/api/containers.py +132 -0
  12. cognite_toolkit/_cdf_tk/client/api/data_models.py +137 -0
  13. cognite_toolkit/_cdf_tk/client/api/datasets.py +141 -0
  14. cognite_toolkit/_cdf_tk/client/api/events.py +129 -0
  15. cognite_toolkit/_cdf_tk/client/api/extraction_pipelines.py +148 -0
  16. cognite_toolkit/_cdf_tk/client/api/filemetadata.py +176 -0
  17. cognite_toolkit/_cdf_tk/client/api/function_schedules.py +115 -0
  18. cognite_toolkit/_cdf_tk/client/api/functions.py +113 -0
  19. cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py +167 -0
  20. cognite_toolkit/_cdf_tk/client/api/groups.py +121 -0
  21. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_destinations.py +131 -0
  22. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_jobs.py +122 -0
  23. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_mappings.py +129 -0
  24. cognite_toolkit/_cdf_tk/client/api/hosted_extractor_sources.py +136 -0
  25. cognite_toolkit/_cdf_tk/client/api/hosted_extractors.py +23 -0
  26. cognite_toolkit/_cdf_tk/client/api/infield.py +8 -8
  27. cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
  28. cognite_toolkit/_cdf_tk/client/api/labels.py +125 -0
  29. cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py +3 -3
  30. cognite_toolkit/_cdf_tk/client/api/legacy/charts.py +1 -1
  31. cognite_toolkit/_cdf_tk/client/api/legacy/extended_data_modeling.py +1 -1
  32. cognite_toolkit/_cdf_tk/client/api/legacy/extended_files.py +2 -2
  33. cognite_toolkit/_cdf_tk/client/api/legacy/extended_functions.py +1 -1
  34. cognite_toolkit/_cdf_tk/client/api/legacy/extended_raw.py +1 -1
  35. cognite_toolkit/_cdf_tk/client/api/legacy/extended_timeseries.py +2 -2
  36. cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +1 -1
  37. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/capabilities.py +1 -1
  38. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/data_postprocessing.py +1 -1
  39. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/frames.py +1 -1
  40. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/locations.py +1 -1
  41. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/maps.py +1 -1
  42. cognite_toolkit/_cdf_tk/client/api/legacy/robotics/robots.py +1 -1
  43. cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +1 -1
  44. cognite_toolkit/_cdf_tk/client/api/location_filters.py +177 -0
  45. cognite_toolkit/_cdf_tk/client/api/migration.py +1 -1
  46. cognite_toolkit/_cdf_tk/client/api/project.py +2 -2
  47. cognite_toolkit/_cdf_tk/client/api/raw.py +204 -0
  48. cognite_toolkit/_cdf_tk/client/api/relationships.py +133 -0
  49. cognite_toolkit/_cdf_tk/client/api/robotics.py +19 -0
  50. cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +127 -0
  51. cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +138 -0
  52. cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +122 -0
  53. cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +127 -0
  54. cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +122 -0
  55. cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +122 -0
  56. cognite_toolkit/_cdf_tk/client/api/search_config.py +101 -0
  57. cognite_toolkit/_cdf_tk/client/api/security_categories.py +94 -0
  58. cognite_toolkit/_cdf_tk/client/api/sequences.py +133 -0
  59. cognite_toolkit/_cdf_tk/client/api/simulator_models.py +154 -0
  60. cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
  61. cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -0
  62. cognite_toolkit/_cdf_tk/client/api/streams.py +65 -57
  63. cognite_toolkit/_cdf_tk/client/api/three_d.py +300 -283
  64. cognite_toolkit/_cdf_tk/client/api/timeseries.py +137 -0
  65. cognite_toolkit/_cdf_tk/client/api/token.py +1 -1
  66. cognite_toolkit/_cdf_tk/client/api/transformations.py +146 -0
  67. cognite_toolkit/_cdf_tk/client/api/views.py +139 -0
  68. cognite_toolkit/_cdf_tk/client/api/workflow_triggers.py +128 -0
  69. cognite_toolkit/_cdf_tk/client/api/workflow_versions.py +138 -0
  70. cognite_toolkit/_cdf_tk/client/api/workflows.py +119 -0
  71. cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +10 -0
  72. cognite_toolkit/_cdf_tk/client/cdf_client/api.py +358 -0
  73. cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +38 -0
  74. cognite_toolkit/_cdf_tk/{utils → client}/http_client/__init__.py +9 -7
  75. cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +23 -14
  76. cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +12 -2
  77. cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +151 -0
  78. cognite_toolkit/_cdf_tk/client/http_client/_exception.py +13 -0
  79. cognite_toolkit/_cdf_tk/client/http_client/_item_classes.py +118 -0
  80. cognite_toolkit/_cdf_tk/client/request_classes/base.py +19 -0
  81. cognite_toolkit/_cdf_tk/client/request_classes/filters.py +113 -0
  82. cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
  83. cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +130 -0
  84. cognite_toolkit/_cdf_tk/client/resource_classes/annotation.py +79 -0
  85. cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
  86. cognite_toolkit/_cdf_tk/client/resource_classes/asset.py +47 -0
  87. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/charts_data.py +1 -1
  88. cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
  89. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +168 -0
  90. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_constraints.py +37 -0
  91. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_container.py +50 -0
  92. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_model.py +73 -0
  93. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_types.py +116 -0
  94. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_indexes.py +26 -0
  95. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +154 -0
  96. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_references.py +86 -0
  97. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_space.py +26 -0
  98. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view.py +143 -0
  99. cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view_property.py +152 -0
  100. cognite_toolkit/_cdf_tk/client/resource_classes/dataset.py +35 -0
  101. cognite_toolkit/_cdf_tk/client/resource_classes/event.py +40 -0
  102. cognite_toolkit/_cdf_tk/client/resource_classes/extraction_pipeline.py +59 -0
  103. cognite_toolkit/_cdf_tk/client/resource_classes/filemetadata.py +52 -0
  104. cognite_toolkit/_cdf_tk/client/resource_classes/function.py +53 -0
  105. cognite_toolkit/_cdf_tk/client/resource_classes/function_schedule.py +65 -0
  106. cognite_toolkit/_cdf_tk/client/resource_classes/graphql_data_model.py +40 -0
  107. cognite_toolkit/_cdf_tk/client/resource_classes/group/__init__.py +187 -0
  108. cognite_toolkit/_cdf_tk/client/resource_classes/group/_constants.py +2 -0
  109. cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py +653 -0
  110. cognite_toolkit/_cdf_tk/client/resource_classes/group/capability.py +56 -0
  111. cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +63 -0
  112. cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py +166 -0
  113. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_destination.py +34 -0
  114. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_job.py +134 -0
  115. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_mapping.py +72 -0
  116. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/__init__.py +63 -0
  117. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_auth.py +63 -0
  118. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_base.py +26 -0
  119. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_certificate.py +20 -0
  120. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_eventhub.py +31 -0
  121. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_kafka.py +53 -0
  122. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_mqtt.py +36 -0
  123. cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_rest.py +49 -0
  124. cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +59 -0
  125. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/infield.py +1 -1
  126. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/instance_api.py +35 -1
  127. cognite_toolkit/_cdf_tk/client/resource_classes/label.py +27 -0
  128. cognite_toolkit/_cdf_tk/client/resource_classes/legacy/__init__.py +0 -0
  129. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/canvas.py +48 -15
  130. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/charts.py +1 -1
  131. cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +84 -0
  132. cognite_toolkit/_cdf_tk/client/resource_classes/raw.py +44 -0
  133. cognite_toolkit/_cdf_tk/client/resource_classes/relationship.py +49 -0
  134. cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
  135. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/__init__.py +37 -0
  136. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_capability.py +53 -0
  137. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_common.py +34 -0
  138. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_data_post_processing.py +49 -0
  139. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_frame.py +46 -0
  140. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_location.py +36 -0
  141. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +65 -0
  142. cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +58 -0
  143. cognite_toolkit/_cdf_tk/client/resource_classes/search_config.py +54 -0
  144. cognite_toolkit/_cdf_tk/client/resource_classes/securitycategory.py +24 -0
  145. cognite_toolkit/_cdf_tk/client/resource_classes/sequence.py +45 -0
  146. cognite_toolkit/_cdf_tk/client/resource_classes/sequence_rows.py +56 -0
  147. cognite_toolkit/_cdf_tk/client/resource_classes/simulator_model.py +50 -0
  148. cognite_toolkit/_cdf_tk/client/resource_classes/streamlit_.py +71 -0
  149. cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/streams.py +9 -26
  150. cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +135 -0
  151. cognite_toolkit/_cdf_tk/client/resource_classes/timeseries.py +52 -0
  152. cognite_toolkit/_cdf_tk/client/resource_classes/transformation.py +140 -0
  153. cognite_toolkit/_cdf_tk/client/resource_classes/workflow.py +27 -0
  154. cognite_toolkit/_cdf_tk/client/resource_classes/workflow_trigger.py +63 -0
  155. cognite_toolkit/_cdf_tk/client/resource_classes/workflow_version.py +155 -0
  156. cognite_toolkit/_cdf_tk/client/testing.py +31 -2
  157. cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
  158. cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +22 -15
  159. cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
  160. cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +11 -10
  161. cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +148 -57
  162. cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
  163. cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +22 -39
  164. cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +29 -27
  165. cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
  166. cognite_toolkit/_cdf_tk/commands/_purge.py +8 -8
  167. cognite_toolkit/_cdf_tk/commands/_upload.py +1 -1
  168. cognite_toolkit/_cdf_tk/commands/build_cmd.py +12 -2
  169. cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py +138 -0
  170. cognite_toolkit/_cdf_tk/commands/build_v2/_modules_parser.py +163 -0
  171. cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +83 -96
  172. cognite_toolkit/_cdf_tk/commands/build_v2/{build_input.py → build_parameters.py} +8 -22
  173. cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_modules.py +27 -0
  174. cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_resource.py +22 -0
  175. cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
  176. cognite_toolkit/_cdf_tk/commands/pull.py +97 -2
  177. cognite_toolkit/_cdf_tk/commands/run.py +1 -1
  178. cognite_toolkit/_cdf_tk/cruds/__init__.py +16 -6
  179. cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +9 -5
  180. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
  181. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +6 -2
  182. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +70 -89
  183. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
  184. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
  185. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
  186. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +14 -7
  187. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
  188. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +1 -1
  189. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
  190. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -3
  191. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
  192. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +6 -1
  193. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +5 -4
  194. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
  195. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +122 -0
  196. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +15 -31
  197. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +42 -47
  198. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +1 -1
  199. cognite_toolkit/_cdf_tk/data_classes/__init__.py +3 -0
  200. cognite_toolkit/_cdf_tk/data_classes/_issues.py +36 -0
  201. cognite_toolkit/_cdf_tk/data_classes/_module_directories.py +2 -1
  202. cognite_toolkit/_cdf_tk/data_classes/_tracking_info.py +4 -0
  203. cognite_toolkit/_cdf_tk/feature_flags.py +8 -0
  204. cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
  205. cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +6 -0
  206. cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
  207. cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
  208. cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +13 -4
  209. cognite_toolkit/_cdf_tk/storageio/_applications.py +53 -15
  210. cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +117 -107
  211. cognite_toolkit/_cdf_tk/storageio/_base.py +3 -1
  212. cognite_toolkit/_cdf_tk/storageio/_datapoints.py +7 -7
  213. cognite_toolkit/_cdf_tk/storageio/_file_content.py +64 -54
  214. cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
  215. cognite_toolkit/_cdf_tk/storageio/_raw.py +1 -1
  216. cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
  217. cognite_toolkit/_cdf_tk/tk_warnings/__init__.py +2 -0
  218. cognite_toolkit/_cdf_tk/tk_warnings/fileread.py +20 -0
  219. cognite_toolkit/_cdf_tk/utils/__init__.py +11 -1
  220. cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
  221. cognite_toolkit/_cdf_tk/utils/interactive_select.py +8 -6
  222. cognite_toolkit/_cdf_tk/utils/modules.py +7 -0
  223. cognite_toolkit/_cdf_tk/utils/pip_validator.py +96 -0
  224. cognite_toolkit/_cdf_tk/utils/useful_types.py +4 -7
  225. cognite_toolkit/_cdf_tk/utils/useful_types2.py +14 -0
  226. cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
  227. cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
  228. cognite_toolkit/_resources/cdf.toml +1 -1
  229. cognite_toolkit/_version.py +1 -1
  230. {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
  231. cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
  232. {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
  233. cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -30
  234. cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -67
  235. cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -112
  236. cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +0 -27
  237. cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -247
  238. cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
  239. cognite_toolkit-0.7.39.dist-info/RECORD +0 -322
  240. /cognite_toolkit/_cdf_tk/{utils → client}/http_client/_tracker.py +0 -0
  241. /cognite_toolkit/_cdf_tk/client/{data_classes → request_classes}/__init__.py +0 -0
  242. /cognite_toolkit/_cdf_tk/client/{data_classes/legacy → resource_classes}/__init__.py +0 -0
  243. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/capabilities.py +0 -0
  244. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/apm_config_v1.py +0 -0
  245. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extendable_cognite_file.py +0 -0
  246. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetadata.py +0 -0
  247. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetdata.py +0 -0
  248. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_timeseries.py +0 -0
  249. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/functions.py +0 -0
  250. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/graphql_data_models.py +0 -0
  251. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/instances.py +0 -0
  252. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/location_filters.py +0 -0
  253. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/migration.py +0 -0
  254. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/pending_instances_ids.py +0 -0
  255. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/project.py +0 -0
  256. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/raw.py +0 -0
  257. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/robotics.py +0 -0
  258. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/search_config.py +0 -0
  259. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/sequences.py +0 -0
  260. /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/streamlit_.py +0 -0
  261. {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
@@ -5,10 +5,19 @@ from cognite.client.data_classes import Annotation
5
5
  from cognite.client.data_classes.data_modeling import EdgeId, InstanceApply, NodeId
6
6
 
7
7
  from cognite_toolkit._cdf_tk.client import ToolkitClient
8
- from cognite_toolkit._cdf_tk.client.data_classes.legacy.pending_instances_ids import PendingInstanceId
9
- from cognite_toolkit._cdf_tk.client.data_classes.three_d import (
8
+ from cognite_toolkit._cdf_tk.client.http_client import (
9
+ FailedResponse,
10
+ HTTPClient,
11
+ HTTPMessage,
12
+ ItemsRequest,
13
+ RequestMessage2,
14
+ SuccessResponseItems,
15
+ ToolkitAPIError,
16
+ )
17
+ from cognite_toolkit._cdf_tk.client.resource_classes.legacy.pending_instances_ids import PendingInstanceId
18
+ from cognite_toolkit._cdf_tk.client.resource_classes.three_d import (
19
+ AssetMappingClassicResponse,
10
20
  AssetMappingDMRequest,
11
- AssetMappingResponse,
12
21
  ThreeDModelResponse,
13
22
  )
14
23
  from cognite_toolkit._cdf_tk.commands._migrate.data_classes import ThreeDMigrationRequest
@@ -29,21 +38,12 @@ from cognite_toolkit._cdf_tk.storageio.selectors import (
29
38
  )
30
39
  from cognite_toolkit._cdf_tk.tk_warnings import MediumSeverityWarning
31
40
  from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
32
- from cognite_toolkit._cdf_tk.utils.http_client import (
33
- FailedResponse,
34
- HTTPClient,
35
- HTTPMessage,
36
- ItemsRequest,
37
- SimpleBodyRequest,
38
- SuccessResponseItems,
39
- ToolkitAPIError,
40
- )
41
41
  from cognite_toolkit._cdf_tk.utils.useful_types import (
42
42
  AssetCentricKindExtended,
43
43
  AssetCentricType,
44
44
  JsonVal,
45
- T_AssetCentricResource,
46
45
  )
46
+ from cognite_toolkit._cdf_tk.utils.useful_types2 import T_AssetCentricResource
47
47
 
48
48
  from .data_classes import (
49
49
  AnnotationMapping,
@@ -78,7 +78,7 @@ class AssetCentricMigrationIO(
78
78
  self.skip_linking = skip_linking
79
79
 
80
80
  def as_id(self, item: AssetCentricMapping) -> str:
81
- return f"{item.mapping.resource_type}_{item.mapping.id}"
81
+ return str(item.mapping.as_asset_centric_id())
82
82
 
83
83
  def stream_data(self, selector: AssetCentricMigrationSelector, limit: int | None = None) -> Iterator[Page]:
84
84
  if isinstance(selector, MigrationCSVFileSelector):
@@ -181,7 +181,7 @@ class AssetCentricMigrationIO(
181
181
 
182
182
  pending_instance_id_endpoint = self.PENDING_INSTANCE_ID_ENDPOINT_BY_KIND[selector.kind]
183
183
  results: list[HTTPMessage] = []
184
- to_upload = self.link_asset_centric(data_chunk, http_client, results, pending_instance_id_endpoint)
184
+ to_upload = self.link_asset_centric(data_chunk, http_client, pending_instance_id_endpoint)
185
185
  if to_upload:
186
186
  results.extend(list(super().upload_items(to_upload, http_client, None)))
187
187
  return results
@@ -191,7 +191,6 @@ class AssetCentricMigrationIO(
191
191
  cls,
192
192
  data_chunk: Sequence[UploadItem[InstanceApply]],
193
193
  http_client: HTTPClient,
194
- results: list[HTTPMessage],
195
194
  pending_instance_id_endpoint: str,
196
195
  ) -> Sequence[UploadItem[InstanceApply]]:
197
196
  """Links asset-centric resources to their (uncreated) instances using the pending-instance-ids endpoint."""
@@ -212,7 +211,6 @@ class AssetCentricMigrationIO(
212
211
  for res in batch_results:
213
212
  if isinstance(res, SuccessResponseItems):
214
213
  successful_linked.update(res.ids)
215
- results.extend(batch_results)
216
214
  to_upload = [item for item in data_chunk if item.source_id in successful_linked]
217
215
  return to_upload
218
216
 
@@ -393,7 +391,7 @@ class ThreeDMigrationIO(UploadableStorageIO[ThreeDSelector, ThreeDModelResponse,
393
391
  self.data_model_type = data_model_type
394
392
 
395
393
  def as_id(self, item: ThreeDModelResponse) -> str:
396
- return f"{item.name}_{item.id!s}"
394
+ return item.name
397
395
 
398
396
  def _is_selected(self, item: ThreeDModelResponse, included_models: set[int] | None) -> bool:
399
397
  return self._is_correct_type(item) and (included_models is None or item.id in included_models)
@@ -415,7 +413,7 @@ class ThreeDMigrationIO(UploadableStorageIO[ThreeDSelector, ThreeDModelResponse,
415
413
  total = 0
416
414
  while True:
417
415
  request_limit = min(self.DOWNLOAD_LIMIT, limit - total) if limit is not None else self.DOWNLOAD_LIMIT
418
- response = self.client.tool.three_d.models.iterate(
416
+ response = self.client.tool.three_d.models_classic.paginate(
419
417
  published=published, include_revision_info=True, limit=request_limit, cursor=cursor
420
418
  )
421
419
  items = [item for item in response.items if self._is_selected(item, included_models)]
@@ -466,18 +464,20 @@ class ThreeDMigrationIO(UploadableStorageIO[ThreeDSelector, ThreeDModelResponse,
466
464
  for data in data_chunk:
467
465
  if data.source_id not in success_ids:
468
466
  continue
469
- revision = http_client.request_with_retries(
470
- message=SimpleBodyRequest(
467
+ revision = http_client.request_single_retries(
468
+ message=RequestMessage2(
471
469
  endpoint_url=self.client.config.create_api_url(self.REVISION_ENDPOINT),
472
470
  method="POST",
473
471
  body_content={"items": [data.item.revision.dump(camel_case=True)]},
474
472
  )
475
473
  )
476
- results.extend(revision.as_item_responses(data.source_id))
474
+ results.append(revision.as_item_response(data.source_id))
477
475
  return results
478
476
 
479
477
 
480
- class ThreeDAssetMappingMigrationIO(UploadableStorageIO[ThreeDSelector, AssetMappingResponse, AssetMappingDMRequest]):
478
+ class ThreeDAssetMappingMigrationIO(
479
+ UploadableStorageIO[ThreeDSelector, AssetMappingClassicResponse, AssetMappingDMRequest]
480
+ ):
481
481
  KIND = "3DMigrationAssetMapping"
482
482
  SUPPORTED_DOWNLOAD_FORMATS = frozenset({".ndjson"})
483
483
  SUPPORTED_COMPRESSIONS = frozenset({".gz"})
@@ -493,10 +493,12 @@ class ThreeDAssetMappingMigrationIO(UploadableStorageIO[ThreeDSelector, AssetMap
493
493
  # We can only migrate asset mappings for 3D models that are already migrated to data modeling.
494
494
  self._3D_io = ThreeDMigrationIO(client, data_model_type="data modeling")
495
495
 
496
- def as_id(self, item: AssetMappingResponse) -> str:
496
+ def as_id(self, item: AssetMappingClassicResponse) -> str:
497
497
  return f"AssetMapping_{item.model_id!s}_{item.revision_id!s}_{item.asset_id!s}"
498
498
 
499
- def stream_data(self, selector: ThreeDSelector, limit: int | None = None) -> Iterable[Page[AssetMappingResponse]]:
499
+ def stream_data(
500
+ self, selector: ThreeDSelector, limit: int | None = None
501
+ ) -> Iterable[Page[AssetMappingClassicResponse]]:
500
502
  total = 0
501
503
  for three_d_page in self._3D_io.stream_data(selector, None):
502
504
  for model in three_d_page.items:
@@ -510,7 +512,7 @@ class ThreeDAssetMappingMigrationIO(UploadableStorageIO[ThreeDSelector, AssetMap
510
512
  )
511
513
  if limit is not None and total >= limit:
512
514
  return
513
- response = self.client.tool.three_d.asset_mappings.iterate(
515
+ response = self.client.tool.three_d.asset_mappings_classic.paginate(
514
516
  model_id=model.id,
515
517
  revision_id=model.last_revision_info.revision_id,
516
518
  cursor=cursor,
@@ -562,6 +564,6 @@ class ThreeDAssetMappingMigrationIO(UploadableStorageIO[ThreeDSelector, AssetMap
562
564
  raise NotImplementedError("Deserializing 3D Asset Mappings from JSON is not supported.")
563
565
 
564
566
  def data_to_json_chunk(
565
- self, data_chunk: Sequence[AssetMappingResponse], selector: ThreeDSelector | None = None
567
+ self, data_chunk: Sequence[AssetMappingClassicResponse], selector: ThreeDSelector | None = None
566
568
  ) -> list[dict[str, JsonVal]]:
567
569
  raise NotImplementedError("Serializing 3D Asset Mappings to JSON is not supported.")
@@ -21,7 +21,7 @@ from rich.spinner import Spinner
21
21
  from rich.table import Table
22
22
 
23
23
  from cognite_toolkit._cdf_tk.client import ToolkitClient
24
- from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawProfileResults, RawTable
24
+ from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawProfileResults, RawTable
25
25
  from cognite_toolkit._cdf_tk.constants import MAX_ROW_ITERATION_RUN_QUERY
26
26
  from cognite_toolkit._cdf_tk.exceptions import ToolkitMissingDependencyError, ToolkitThrottledError, ToolkitValueError
27
27
  from cognite_toolkit._cdf_tk.utils.aggregators import (
@@ -16,7 +16,14 @@ from rich.console import Console
16
16
  from rich.panel import Panel
17
17
 
18
18
  from cognite_toolkit._cdf_tk.client import ToolkitClient
19
- from cognite_toolkit._cdf_tk.client.data_classes.instance_api import TypedInstanceIdentifier
19
+ from cognite_toolkit._cdf_tk.client.http_client import (
20
+ HTTPClient,
21
+ ItemsRequest,
22
+ ItemsRequest2,
23
+ ItemsSuccessResponse2,
24
+ SuccessResponseItems,
25
+ )
26
+ from cognite_toolkit._cdf_tk.client.resource_classes.instance_api import TypedInstanceIdentifier
20
27
  from cognite_toolkit._cdf_tk.cruds import (
21
28
  AssetCRUD,
22
29
  ContainerCRUD,
@@ -59,13 +66,6 @@ from cognite_toolkit._cdf_tk.utils.aggregators import (
59
66
  SequenceAggregator,
60
67
  TimeSeriesAggregator,
61
68
  )
62
- from cognite_toolkit._cdf_tk.utils.http_client import (
63
- HTTPClient,
64
- ItemsRequest,
65
- ItemsRequest2,
66
- ItemsSuccessResponse2,
67
- SuccessResponseItems,
68
- )
69
69
  from cognite_toolkit._cdf_tk.utils.producer_worker import ProducerWorkerExecutor
70
70
  from cognite_toolkit._cdf_tk.utils.useful_types import JsonVal
71
71
  from cognite_toolkit._cdf_tk.utils.validate_access import ValidateAccess
@@ -9,6 +9,7 @@ from cognite.client.data_classes.data_modeling import (
9
9
  from rich.console import Console
10
10
 
11
11
  from cognite_toolkit._cdf_tk.client import ToolkitClient
12
+ from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemMessage, SuccessResponseItems
12
13
  from cognite_toolkit._cdf_tk.constants import DATA_MANIFEST_SUFFIX, DATA_RESOURCE_DIR
13
14
  from cognite_toolkit._cdf_tk.cruds import ViewCRUD
14
15
  from cognite_toolkit._cdf_tk.exceptions import ToolkitValueError
@@ -24,7 +25,6 @@ from cognite_toolkit._cdf_tk.storageio.selectors._instances import InstanceSpace
24
25
  from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning, MediumSeverityWarning, ToolkitWarning
25
26
  from cognite_toolkit._cdf_tk.utils.auth import EnvironmentVariables
26
27
  from cognite_toolkit._cdf_tk.utils.fileio import MultiFileReader
27
- from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient, ItemMessage, SuccessResponseItems
28
28
  from cognite_toolkit._cdf_tk.utils.producer_worker import ProducerWorkerExecutor
29
29
  from cognite_toolkit._cdf_tk.utils.progress_tracker import ProgressTracker
30
30
  from cognite_toolkit._cdf_tk.utils.useful_types import JsonVal
@@ -11,10 +11,10 @@ from rich import print
11
11
  from rich.panel import Panel
12
12
  from rich.progress import track
13
13
 
14
- from cognite_toolkit._cdf_tk.builders import Builder, create_builder
14
+ from cognite_toolkit._cdf_tk.builders import Builder, FunctionBuilder, create_builder
15
15
  from cognite_toolkit._cdf_tk.cdf_toml import CDFToml
16
16
  from cognite_toolkit._cdf_tk.client import ToolkitClient
17
- from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase
17
+ from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawDatabase
18
18
  from cognite_toolkit._cdf_tk.commands._base import ToolkitCommand
19
19
  from cognite_toolkit._cdf_tk.constants import (
20
20
  _RUNNING_IN_BROWSER,
@@ -33,6 +33,7 @@ from cognite_toolkit._cdf_tk.cruds import (
33
33
  DataSetsCRUD,
34
34
  ExtractionPipelineConfigCRUD,
35
35
  FileCRUD,
36
+ FunctionCRUD,
36
37
  LocationFilterCRUD,
37
38
  NodeCRUD,
38
39
  RawDatabaseCRUD,
@@ -415,6 +416,15 @@ class BuildCommand(ToolkitCommand):
415
416
 
416
417
  build_resources_by_folder[resource_name].extend(built_resources)
417
418
 
419
+ # Collect validation metrics from FunctionBuilder
420
+ if resource_name == FunctionCRUD.folder_name and isinstance(builder, FunctionBuilder):
421
+ self._additional_tracking_info.function_validation_count += builder.validation_count
422
+ self._additional_tracking_info.function_validation_failures += builder.validation_failures
423
+ self._additional_tracking_info.function_validation_credential_errors += (
424
+ builder.validation_credential_errors
425
+ )
426
+ self._additional_tracking_info.function_validation_time_ms += builder.validation_time_ms
427
+
418
428
  return build_resources_by_folder
419
429
 
420
430
  def _get_builder(self, build_dir: Path, resource_name: str) -> Builder:
@@ -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
+ ]