cognite-neat 0.123.24__py3-none-any.whl → 1.0.22__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 (342) hide show
  1. cognite/neat/__init__.py +4 -3
  2. cognite/neat/_client/__init__.py +5 -0
  3. cognite/neat/_client/api.py +8 -0
  4. cognite/neat/_client/client.py +21 -0
  5. cognite/neat/_client/config.py +40 -0
  6. cognite/neat/_client/containers_api.py +138 -0
  7. cognite/neat/_client/data_classes.py +44 -0
  8. cognite/neat/_client/data_model_api.py +115 -0
  9. cognite/neat/_client/init/credentials.py +70 -0
  10. cognite/neat/_client/init/env_vars.py +131 -0
  11. cognite/neat/_client/init/main.py +51 -0
  12. cognite/neat/_client/spaces_api.py +115 -0
  13. cognite/neat/_client/statistics_api.py +24 -0
  14. cognite/neat/_client/views_api.py +144 -0
  15. cognite/neat/_config.py +266 -0
  16. cognite/neat/_data_model/_analysis.py +571 -0
  17. cognite/neat/_data_model/_constants.py +74 -0
  18. cognite/neat/_data_model/_identifiers.py +61 -0
  19. cognite/neat/_data_model/_shared.py +41 -0
  20. cognite/neat/_data_model/_snapshot.py +134 -0
  21. cognite/neat/_data_model/deployer/_differ.py +140 -0
  22. cognite/neat/_data_model/deployer/_differ_container.py +360 -0
  23. cognite/neat/_data_model/deployer/_differ_data_model.py +54 -0
  24. cognite/neat/_data_model/deployer/_differ_space.py +9 -0
  25. cognite/neat/_data_model/deployer/_differ_view.py +299 -0
  26. cognite/neat/_data_model/deployer/data_classes.py +644 -0
  27. cognite/neat/_data_model/deployer/deployer.py +431 -0
  28. cognite/neat/_data_model/exporters/__init__.py +15 -0
  29. cognite/neat/_data_model/exporters/_api_exporter.py +37 -0
  30. cognite/neat/_data_model/exporters/_base.py +24 -0
  31. cognite/neat/_data_model/exporters/_table_exporter/exporter.py +128 -0
  32. cognite/neat/_data_model/exporters/_table_exporter/workbook.py +409 -0
  33. cognite/neat/_data_model/exporters/_table_exporter/writer.py +480 -0
  34. cognite/neat/_data_model/importers/__init__.py +5 -0
  35. cognite/neat/_data_model/importers/_api_importer.py +166 -0
  36. cognite/neat/_data_model/importers/_base.py +16 -0
  37. cognite/neat/_data_model/importers/_table_importer/data_classes.py +344 -0
  38. cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
  39. cognite/neat/_data_model/importers/_table_importer/reader.py +1102 -0
  40. cognite/neat/_data_model/importers/_table_importer/source.py +94 -0
  41. cognite/neat/_data_model/models/conceptual/_base.py +18 -0
  42. cognite/neat/_data_model/models/conceptual/_concept.py +67 -0
  43. cognite/neat/_data_model/models/conceptual/_data_model.py +51 -0
  44. cognite/neat/_data_model/models/conceptual/_properties.py +104 -0
  45. cognite/neat/_data_model/models/conceptual/_property.py +105 -0
  46. cognite/neat/_data_model/models/dms/__init__.py +206 -0
  47. cognite/neat/_data_model/models/dms/_base.py +31 -0
  48. cognite/neat/_data_model/models/dms/_constants.py +48 -0
  49. cognite/neat/_data_model/models/dms/_constraints.py +42 -0
  50. cognite/neat/_data_model/models/dms/_container.py +159 -0
  51. cognite/neat/_data_model/models/dms/_data_model.py +95 -0
  52. cognite/neat/_data_model/models/dms/_data_types.py +195 -0
  53. cognite/neat/_data_model/models/dms/_http.py +28 -0
  54. cognite/neat/_data_model/models/dms/_indexes.py +30 -0
  55. cognite/neat/_data_model/models/dms/_limits.py +96 -0
  56. cognite/neat/_data_model/models/dms/_references.py +141 -0
  57. cognite/neat/_data_model/models/dms/_schema.py +18 -0
  58. cognite/neat/_data_model/models/dms/_space.py +48 -0
  59. cognite/neat/_data_model/models/dms/_types.py +17 -0
  60. cognite/neat/_data_model/models/dms/_view_filter.py +310 -0
  61. cognite/neat/_data_model/models/dms/_view_property.py +235 -0
  62. cognite/neat/_data_model/models/dms/_views.py +216 -0
  63. cognite/neat/_data_model/models/entities/__init__.py +50 -0
  64. cognite/neat/_data_model/models/entities/_base.py +101 -0
  65. cognite/neat/_data_model/models/entities/_constants.py +22 -0
  66. cognite/neat/_data_model/models/entities/_data_types.py +144 -0
  67. cognite/neat/_data_model/models/entities/_identifiers.py +61 -0
  68. cognite/neat/_data_model/models/entities/_parser.py +226 -0
  69. cognite/neat/_data_model/validation/dms/__init__.py +75 -0
  70. cognite/neat/_data_model/validation/dms/_ai_readiness.py +381 -0
  71. cognite/neat/_data_model/validation/dms/_base.py +25 -0
  72. cognite/neat/_data_model/validation/dms/_connections.py +681 -0
  73. cognite/neat/_data_model/validation/dms/_consistency.py +58 -0
  74. cognite/neat/_data_model/validation/dms/_containers.py +199 -0
  75. cognite/neat/_data_model/validation/dms/_limits.py +368 -0
  76. cognite/neat/_data_model/validation/dms/_orchestrator.py +70 -0
  77. cognite/neat/_data_model/validation/dms/_views.py +164 -0
  78. cognite/neat/_exceptions.py +68 -0
  79. cognite/neat/_issues.py +68 -0
  80. cognite/neat/_session/__init__.py +3 -0
  81. cognite/neat/_session/_html/_render.py +30 -0
  82. cognite/neat/_session/_html/static/__init__.py +8 -0
  83. cognite/neat/_session/_html/static/deployment.css +476 -0
  84. cognite/neat/_session/_html/static/deployment.js +181 -0
  85. cognite/neat/_session/_html/static/issues.css +211 -0
  86. cognite/neat/_session/_html/static/issues.js +168 -0
  87. cognite/neat/_session/_html/static/shared.css +186 -0
  88. cognite/neat/_session/_html/templates/__init__.py +4 -0
  89. cognite/neat/_session/_html/templates/deployment.html +80 -0
  90. cognite/neat/_session/_html/templates/issues.html +45 -0
  91. cognite/neat/_session/_issues.py +81 -0
  92. cognite/neat/_session/_physical.py +294 -0
  93. cognite/neat/_session/_result/__init__.py +3 -0
  94. cognite/neat/_session/_result/_deployment/__init__.py +0 -0
  95. cognite/neat/_session/_result/_deployment/_physical/__init__.py +0 -0
  96. cognite/neat/_session/_result/_deployment/_physical/_changes.py +196 -0
  97. cognite/neat/_session/_result/_deployment/_physical/_statistics.py +180 -0
  98. cognite/neat/_session/_result/_deployment/_physical/serializer.py +35 -0
  99. cognite/neat/_session/_result/_result.py +31 -0
  100. cognite/neat/_session/_session.py +81 -0
  101. cognite/neat/_session/_usage_analytics/__init__.py +0 -0
  102. cognite/neat/_session/_usage_analytics/_collector.py +131 -0
  103. cognite/neat/_session/_usage_analytics/_constants.py +23 -0
  104. cognite/neat/_session/_usage_analytics/_storage.py +240 -0
  105. cognite/neat/_session/_wrappers.py +101 -0
  106. cognite/neat/_state_machine/__init__.py +10 -0
  107. cognite/neat/_state_machine/_base.py +37 -0
  108. cognite/neat/_state_machine/_states.py +52 -0
  109. cognite/neat/_store/__init__.py +3 -0
  110. cognite/neat/_store/_provenance.py +88 -0
  111. cognite/neat/_store/_store.py +220 -0
  112. cognite/neat/_utils/__init__.py +0 -0
  113. cognite/neat/_utils/_reader.py +194 -0
  114. cognite/neat/_utils/auxiliary.py +49 -0
  115. cognite/neat/_utils/collection.py +11 -0
  116. cognite/neat/_utils/http_client/__init__.py +39 -0
  117. cognite/neat/_utils/http_client/_client.py +245 -0
  118. cognite/neat/_utils/http_client/_config.py +19 -0
  119. cognite/neat/_utils/http_client/_data_classes.py +294 -0
  120. cognite/neat/_utils/http_client/_tracker.py +31 -0
  121. cognite/neat/_utils/repo.py +19 -0
  122. cognite/neat/_utils/text.py +71 -0
  123. cognite/neat/_utils/useful_types.py +37 -0
  124. cognite/neat/_utils/validation.py +154 -0
  125. cognite/neat/_v0/__init__.py +0 -0
  126. cognite/neat/_v0/core/__init__.py +0 -0
  127. cognite/neat/_v0/core/_client/_api/__init__.py +0 -0
  128. cognite/neat/{core → _v0/core}/_client/_api/data_modeling_loaders.py +8 -7
  129. cognite/neat/{core → _v0/core}/_client/_api/neat_instances.py +5 -5
  130. cognite/neat/{core → _v0/core}/_client/_api/schema.py +5 -5
  131. cognite/neat/{core → _v0/core}/_client/_api/statistics.py +3 -3
  132. cognite/neat/{core → _v0/core}/_client/_api_client.py +1 -1
  133. cognite/neat/_v0/core/_client/data_classes/__init__.py +0 -0
  134. cognite/neat/{core → _v0/core}/_client/data_classes/schema.py +4 -4
  135. cognite/neat/{core → _v0/core}/_client/testing.py +1 -1
  136. cognite/neat/{core → _v0/core}/_constants.py +5 -3
  137. cognite/neat/_v0/core/_data_model/__init__.py +0 -0
  138. cognite/neat/{core → _v0/core}/_data_model/_constants.py +7 -0
  139. cognite/neat/{core → _v0/core}/_data_model/_shared.py +4 -4
  140. cognite/neat/{core → _v0/core}/_data_model/analysis/_base.py +8 -8
  141. cognite/neat/{core → _v0/core}/_data_model/exporters/__init__.py +1 -2
  142. cognite/neat/{core → _v0/core}/_data_model/exporters/_base.py +7 -7
  143. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2dms.py +9 -9
  144. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2excel.py +12 -12
  145. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2instance_template.py +4 -4
  146. cognite/neat/{core/_data_model/exporters/_data_model2ontology.py → _v0/core/_data_model/exporters/_data_model2semantic_model.py} +126 -116
  147. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
  148. cognite/neat/{core → _v0/core}/_data_model/importers/_base.py +5 -5
  149. cognite/neat/{core → _v0/core}/_data_model/importers/_base_file_reader.py +2 -2
  150. cognite/neat/{core → _v0/core}/_data_model/importers/_dict2data_model.py +5 -5
  151. cognite/neat/{core → _v0/core}/_data_model/importers/_dms2data_model.py +18 -15
  152. cognite/neat/{core → _v0/core}/_data_model/importers/_graph2data_model.py +12 -12
  153. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_base.py +12 -12
  154. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
  155. cognite/neat/_v0/core/_data_model/importers/_rdf/_owl2data_model.py +144 -0
  156. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_shared.py +17 -13
  157. cognite/neat/{core → _v0/core}/_data_model/importers/_spreadsheet2data_model.py +92 -12
  158. cognite/neat/{core → _v0/core}/_data_model/models/__init__.py +3 -3
  159. cognite/neat/{core → _v0/core}/_data_model/models/_base_verified.py +5 -5
  160. cognite/neat/{core → _v0/core}/_data_model/models/_import_contexts.py +1 -1
  161. cognite/neat/{core → _v0/core}/_data_model/models/_types.py +5 -5
  162. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_unverified.py +16 -10
  163. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_validation.py +12 -12
  164. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_verified.py +9 -9
  165. cognite/neat/{core → _v0/core}/_data_model/models/data_types.py +14 -4
  166. cognite/neat/{core → _v0/core}/_data_model/models/entities/__init__.py +6 -0
  167. cognite/neat/_v0/core/_data_model/models/entities/_loaders.py +155 -0
  168. cognite/neat/{core → _v0/core}/_data_model/models/entities/_multi_value.py +2 -2
  169. cognite/neat/_v0/core/_data_model/models/entities/_restrictions.py +230 -0
  170. cognite/neat/{core → _v0/core}/_data_model/models/entities/_single_value.py +121 -16
  171. cognite/neat/{core → _v0/core}/_data_model/models/entities/_types.py +10 -0
  172. cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.py +5 -5
  173. cognite/neat/{core → _v0/core}/_data_model/models/physical/__init__.py +1 -1
  174. cognite/neat/{core → _v0/core}/_data_model/models/physical/_exporter.py +26 -19
  175. cognite/neat/{core → _v0/core}/_data_model/models/physical/_unverified.py +133 -37
  176. cognite/neat/{core → _v0/core}/_data_model/models/physical/_validation.py +24 -20
  177. cognite/neat/{core → _v0/core}/_data_model/models/physical/_verified.py +95 -24
  178. cognite/neat/{core → _v0/core}/_data_model/transformers/_base.py +4 -4
  179. cognite/neat/{core → _v0/core}/_data_model/transformers/_converters.py +35 -28
  180. cognite/neat/{core → _v0/core}/_data_model/transformers/_mapping.py +7 -7
  181. cognite/neat/{core → _v0/core}/_data_model/transformers/_union_conceptual.py +5 -5
  182. cognite/neat/{core → _v0/core}/_data_model/transformers/_verification.py +7 -7
  183. cognite/neat/_v0/core/_instances/__init__.py +0 -0
  184. cognite/neat/{core → _v0/core}/_instances/_tracking/base.py +1 -1
  185. cognite/neat/{core → _v0/core}/_instances/_tracking/log.py +1 -1
  186. cognite/neat/{core → _v0/core}/_instances/extractors/__init__.py +3 -2
  187. cognite/neat/{core → _v0/core}/_instances/extractors/_base.py +6 -6
  188. cognite/neat/_v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
  189. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_base.py +7 -7
  190. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_classic.py +12 -12
  191. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_relationships.py +3 -3
  192. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_sequences.py +2 -2
  193. cognite/neat/{core → _v0/core}/_instances/extractors/_dict.py +6 -3
  194. cognite/neat/{core → _v0/core}/_instances/extractors/_dms.py +6 -6
  195. cognite/neat/{core → _v0/core}/_instances/extractors/_dms_graph.py +11 -11
  196. cognite/neat/{core → _v0/core}/_instances/extractors/_mock_graph_generator.py +10 -10
  197. cognite/neat/{core → _v0/core}/_instances/extractors/_raw.py +3 -3
  198. cognite/neat/{core → _v0/core}/_instances/extractors/_rdf_file.py +7 -7
  199. cognite/neat/{core → _v0/core}/_instances/loaders/_base.py +5 -5
  200. cognite/neat/{core → _v0/core}/_instances/loaders/_rdf2dms.py +17 -17
  201. cognite/neat/{core → _v0/core}/_instances/loaders/_rdf_to_instance_space.py +11 -11
  202. cognite/neat/{core → _v0/core}/_instances/queries/_select.py +29 -3
  203. cognite/neat/{core → _v0/core}/_instances/queries/_update.py +1 -1
  204. cognite/neat/{core → _v0/core}/_instances/transformers/_base.py +4 -4
  205. cognite/neat/{core → _v0/core}/_instances/transformers/_classic_cdf.py +6 -6
  206. cognite/neat/{core → _v0/core}/_instances/transformers/_prune_graph.py +4 -4
  207. cognite/neat/{core → _v0/core}/_instances/transformers/_rdfpath.py +1 -1
  208. cognite/neat/{core → _v0/core}/_instances/transformers/_value_type.py +4 -4
  209. cognite/neat/{core → _v0/core}/_issues/_base.py +5 -5
  210. cognite/neat/{core → _v0/core}/_issues/_contextmanagers.py +1 -1
  211. cognite/neat/{core → _v0/core}/_issues/_factory.py +3 -3
  212. cognite/neat/{core → _v0/core}/_issues/errors/__init__.py +1 -1
  213. cognite/neat/{core → _v0/core}/_issues/errors/_external.py +1 -1
  214. cognite/neat/{core → _v0/core}/_issues/errors/_general.py +1 -1
  215. cognite/neat/{core → _v0/core}/_issues/errors/_properties.py +1 -1
  216. cognite/neat/{core → _v0/core}/_issues/errors/_resources.py +2 -2
  217. cognite/neat/{core → _v0/core}/_issues/errors/_wrapper.py +7 -3
  218. cognite/neat/{core → _v0/core}/_issues/warnings/__init__.py +1 -1
  219. cognite/neat/{core → _v0/core}/_issues/warnings/_external.py +1 -1
  220. cognite/neat/{core → _v0/core}/_issues/warnings/_general.py +1 -1
  221. cognite/neat/{core → _v0/core}/_issues/warnings/_models.py +2 -2
  222. cognite/neat/{core → _v0/core}/_issues/warnings/_properties.py +2 -2
  223. cognite/neat/{core → _v0/core}/_issues/warnings/_resources.py +1 -1
  224. cognite/neat/{core → _v0/core}/_issues/warnings/user_modeling.py +1 -1
  225. cognite/neat/{core → _v0/core}/_store/_data_model.py +12 -12
  226. cognite/neat/{core → _v0/core}/_store/_instance.py +43 -10
  227. cognite/neat/{core → _v0/core}/_store/_provenance.py +3 -3
  228. cognite/neat/{core → _v0/core}/_store/exceptions.py +4 -4
  229. cognite/neat/_v0/core/_utils/__init__.py +0 -0
  230. cognite/neat/{core → _v0/core}/_utils/auth.py +22 -12
  231. cognite/neat/{core → _v0/core}/_utils/auxiliary.py +1 -1
  232. cognite/neat/{core → _v0/core}/_utils/collection_.py +2 -2
  233. cognite/neat/{core → _v0/core}/_utils/graph_transformations_report.py +1 -1
  234. cognite/neat/{core → _v0/core}/_utils/rdf_.py +1 -1
  235. cognite/neat/{core → _v0/core}/_utils/reader/_base.py +1 -1
  236. cognite/neat/{core → _v0/core}/_utils/spreadsheet.py +18 -4
  237. cognite/neat/{core → _v0/core}/_utils/text.py +1 -1
  238. cognite/neat/{core → _v0/core}/_utils/upload.py +3 -3
  239. cognite/neat/{session → _v0}/engine/_load.py +1 -1
  240. cognite/neat/_v0/plugins/__init__.py +4 -0
  241. cognite/neat/_v0/plugins/_base.py +9 -0
  242. cognite/neat/_v0/plugins/_data_model.py +48 -0
  243. cognite/neat/{plugins → _v0/plugins}/_issues.py +1 -1
  244. cognite/neat/{plugins → _v0/plugins}/_manager.py +7 -16
  245. cognite/neat/{session → _v0/session}/_base.py +13 -15
  246. cognite/neat/{session → _v0/session}/_collector.py +1 -1
  247. cognite/neat/_v0/session/_diff.py +51 -0
  248. cognite/neat/{session → _v0/session}/_drop.py +3 -3
  249. cognite/neat/{session → _v0/session}/_explore.py +2 -2
  250. cognite/neat/{session → _v0/session}/_fix.py +2 -2
  251. cognite/neat/{session → _v0/session}/_inspect.py +3 -3
  252. cognite/neat/{session → _v0/session}/_mapping.py +3 -3
  253. cognite/neat/{session → _v0/session}/_plugin.py +4 -5
  254. cognite/neat/{session → _v0/session}/_prepare.py +8 -8
  255. cognite/neat/{session → _v0/session}/_read.py +34 -21
  256. cognite/neat/{session → _v0/session}/_set.py +8 -8
  257. cognite/neat/{session → _v0/session}/_show.py +5 -5
  258. cognite/neat/{session → _v0/session}/_state.py +10 -10
  259. cognite/neat/{session → _v0/session}/_subset.py +4 -4
  260. cognite/neat/{session → _v0/session}/_template.py +11 -11
  261. cognite/neat/{session → _v0/session}/_to.py +12 -12
  262. cognite/neat/{session → _v0/session}/_wizard.py +1 -1
  263. cognite/neat/{session → _v0/session}/exceptions.py +5 -5
  264. cognite/neat/_version.py +1 -1
  265. cognite/neat/legacy.py +6 -0
  266. cognite_neat-1.0.22.dist-info/METADATA +123 -0
  267. cognite_neat-1.0.22.dist-info/RECORD +329 -0
  268. cognite_neat-1.0.22.dist-info/WHEEL +4 -0
  269. cognite/neat/core/_data_model/importers/_rdf/_owl2data_model.py +0 -91
  270. cognite/neat/core/_data_model/models/entities/_loaders.py +0 -75
  271. cognite/neat/plugins/__init__.py +0 -3
  272. cognite/neat/plugins/data_model/importers/__init__.py +0 -5
  273. cognite/neat/plugins/data_model/importers/_base.py +0 -28
  274. cognite/neat/session/_session/_data_model/__init__.py +0 -3
  275. cognite/neat/session/_session/_data_model/_read.py +0 -193
  276. cognite/neat/session/_session/_data_model/_routes.py +0 -45
  277. cognite/neat/session/_session/_data_model/_show.py +0 -147
  278. cognite/neat/session/_session/_data_model/_write.py +0 -335
  279. cognite_neat-0.123.24.dist-info/METADATA +0 -144
  280. cognite_neat-0.123.24.dist-info/RECORD +0 -201
  281. cognite_neat-0.123.24.dist-info/WHEEL +0 -4
  282. cognite_neat-0.123.24.dist-info/licenses/LICENSE +0 -201
  283. /cognite/neat/{core → _client/init}/__init__.py +0 -0
  284. /cognite/neat/{core/_client/_api → _data_model}/__init__.py +0 -0
  285. /cognite/neat/{core/_client/data_classes → _data_model/deployer}/__init__.py +0 -0
  286. /cognite/neat/{core/_data_model → _data_model/exporters/_table_exporter}/__init__.py +0 -0
  287. /cognite/neat/{core/_instances → _data_model/importers/_table_importer}/__init__.py +0 -0
  288. /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models}/__init__.py +0 -0
  289. /cognite/neat/{core/_utils → _data_model/models/conceptual}/__init__.py +0 -0
  290. /cognite/neat/{plugins/data_model → _data_model/validation}/__init__.py +0 -0
  291. /cognite/neat/{session/_session → _session/_html}/__init__.py +0 -0
  292. /cognite/neat/{core → _v0/core}/_client/__init__.py +0 -0
  293. /cognite/neat/{core → _v0/core}/_client/data_classes/data_modeling.py +0 -0
  294. /cognite/neat/{core → _v0/core}/_client/data_classes/neat_sequence.py +0 -0
  295. /cognite/neat/{core → _v0/core}/_client/data_classes/statistics.py +0 -0
  296. /cognite/neat/{core → _v0/core}/_config.py +0 -0
  297. /cognite/neat/{core → _v0/core}/_data_model/analysis/__init__.py +0 -0
  298. /cognite/neat/{core → _v0/core}/_data_model/catalog/__init__.py +0 -0
  299. /cognite/neat/{core → _v0/core}/_data_model/catalog/classic_model.xlsx +0 -0
  300. /cognite/neat/{core → _v0/core}/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
  301. /cognite/neat/{core → _v0/core}/_data_model/catalog/hello_world_pump.xlsx +0 -0
  302. /cognite/neat/{core → _v0/core}/_data_model/importers/__init__.py +0 -0
  303. /cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/__init__.py +0 -0
  304. /cognite/neat/{core → _v0/core}/_data_model/models/_base_unverified.py +0 -0
  305. /cognite/neat/{core → _v0/core}/_data_model/models/conceptual/__init__.py +0 -0
  306. /cognite/neat/{core → _v0/core}/_data_model/models/entities/_constants.py +0 -0
  307. /cognite/neat/{core → _v0/core}/_data_model/models/entities/_wrapped.py +0 -0
  308. /cognite/neat/{core → _v0/core}/_data_model/models/mapping/__init__.py +0 -0
  309. /cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.yaml +0 -0
  310. /cognite/neat/{core → _v0/core}/_data_model/transformers/__init__.py +0 -0
  311. /cognite/neat/{core → _v0/core}/_instances/_shared.py +0 -0
  312. /cognite/neat/{core → _v0/core}/_instances/_tracking/__init__.py +0 -0
  313. /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
  314. /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44.xml +0 -0
  315. /cognite/neat/{core → _v0/core}/_instances/examples/__init__.py +0 -0
  316. /cognite/neat/{core → _v0/core}/_instances/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
  317. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_assets.py +0 -0
  318. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_data_sets.py +0 -0
  319. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_events.py +0 -0
  320. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_files.py +0 -0
  321. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_labels.py +0 -0
  322. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_timeseries.py +0 -0
  323. /cognite/neat/{core → _v0/core}/_instances/loaders/__init__.py +0 -0
  324. /cognite/neat/{core → _v0/core}/_instances/queries/__init__.py +0 -0
  325. /cognite/neat/{core → _v0/core}/_instances/queries/_base.py +0 -0
  326. /cognite/neat/{core → _v0/core}/_instances/queries/_queries.py +0 -0
  327. /cognite/neat/{core → _v0/core}/_instances/transformers/__init__.py +0 -0
  328. /cognite/neat/{core → _v0/core}/_issues/__init__.py +0 -0
  329. /cognite/neat/{core → _v0/core}/_issues/formatters.py +0 -0
  330. /cognite/neat/{core → _v0/core}/_shared.py +0 -0
  331. /cognite/neat/{core → _v0/core}/_store/__init__.py +0 -0
  332. /cognite/neat/{core → _v0/core}/_utils/io_.py +0 -0
  333. /cognite/neat/{core → _v0/core}/_utils/reader/__init__.py +0 -0
  334. /cognite/neat/{core → _v0/core}/_utils/tarjan.py +0 -0
  335. /cognite/neat/{core → _v0/core}/_utils/time_.py +0 -0
  336. /cognite/neat/{core → _v0/core}/_utils/xml_.py +0 -0
  337. /cognite/neat/{session → _v0}/engine/__init__.py +0 -0
  338. /cognite/neat/{session → _v0}/engine/_import.py +0 -0
  339. /cognite/neat/{session → _v0}/engine/_interface.py +0 -0
  340. /cognite/neat/{session → _v0/session}/__init__.py +0 -0
  341. /cognite/neat/{session → _v0/session}/_experimental.py +0 -0
  342. /cognite/neat/{session → _v0/session}/_state/README.md +0 -0
@@ -0,0 +1,115 @@
1
+ from __future__ import annotations
2
+
3
+ from cognite.neat._data_model.models.dms import DataModelBody, SpaceRequest, SpaceResponse
4
+ from cognite.neat._data_model.models.dms._references import SpaceReference
5
+ from cognite.neat._utils.http_client import ItemIDBody, ItemsRequest, ParametersRequest
6
+ from cognite.neat._utils.useful_types import PrimitiveType
7
+
8
+ from .api import NeatAPI
9
+ from .data_classes import PagedResponse
10
+
11
+
12
+ class SpacesAPI(NeatAPI):
13
+ ENDPOINT = "/models/spaces"
14
+
15
+ def apply(self, spaces: list[SpaceRequest]) -> list[SpaceResponse]:
16
+ """Apply (create or update) spaces in CDF.
17
+
18
+ Args:
19
+ spaces: List of SpaceRequest objects to apply.
20
+ Returns:
21
+ List of SpaceResponse objects.
22
+ """
23
+ if not spaces:
24
+ return []
25
+ if len(spaces) > 100:
26
+ raise ValueError("Cannot apply more than 100 spaces at once.")
27
+ result = self._http_client.request_with_retries(
28
+ ItemsRequest(
29
+ endpoint_url=self._config.create_api_url(self.ENDPOINT),
30
+ method="POST",
31
+ body=DataModelBody(items=spaces),
32
+ )
33
+ )
34
+ result.raise_for_status()
35
+ result = PagedResponse[SpaceResponse].model_validate_json(result.success_response.body)
36
+ return result.items
37
+
38
+ def retrieve(self, spaces: list[SpaceReference]) -> list[SpaceResponse]:
39
+ """Retrieve spaces by their identifiers.
40
+
41
+ Args:
42
+ spaces: List of space identifiers to retrieve.
43
+
44
+ Returns:
45
+ List of SpaceResponse objects.
46
+ """
47
+ if not spaces:
48
+ return []
49
+ if len(spaces) > 1000:
50
+ raise ValueError("Cannot retrieve more than 1000 spaces at once.")
51
+
52
+ result = self._http_client.request_with_retries(
53
+ ItemsRequest(
54
+ endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/byids"),
55
+ method="POST",
56
+ body=ItemIDBody(items=spaces),
57
+ )
58
+ )
59
+ result.raise_for_status()
60
+ result = PagedResponse[SpaceResponse].model_validate_json(result.success_response.body)
61
+ return result.items
62
+
63
+ def delete(self, spaces: list[SpaceReference]) -> list[SpaceReference]:
64
+ """Delete spaces by their identifiers.
65
+
66
+ Args:
67
+ spaces: List of space identifiers to delete.
68
+ Returns:
69
+ List of SpaceReference objects representing the deleted spaces.
70
+ """
71
+ if not spaces:
72
+ return []
73
+ if len(spaces) > 100:
74
+ raise ValueError("Cannot delete more than 100 spaces at once.")
75
+ result = self._http_client.request_with_retries(
76
+ ItemsRequest(
77
+ endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/delete"),
78
+ method="POST",
79
+ body=ItemIDBody(items=spaces),
80
+ )
81
+ )
82
+ result.raise_for_status()
83
+ result = PagedResponse[SpaceReference].model_validate_json(result.success_response.body)
84
+ return result.items
85
+
86
+ def list(
87
+ self,
88
+ include_global: bool = False,
89
+ limit: int = 10,
90
+ ) -> list[SpaceResponse]:
91
+ """List spaces in CDF Project.
92
+
93
+ Args:
94
+ include_global: If True, include global spaces.
95
+ limit: Maximum number of spaces to return. Max is 1000.
96
+
97
+ Returns:
98
+ List of SpaceResponse objects.
99
+ """
100
+ if limit > 1000:
101
+ raise ValueError("Pagination is not (yet) supported for listing spaces. The maximum limit is 1000.")
102
+ parameters: dict[str, PrimitiveType] = {
103
+ "includeGlobal": include_global,
104
+ "limit": limit,
105
+ }
106
+ result = self._http_client.request_with_retries(
107
+ ParametersRequest(
108
+ endpoint_url=self._config.create_api_url(self.ENDPOINT),
109
+ method="GET",
110
+ parameters=parameters,
111
+ )
112
+ )
113
+ result.raise_for_status()
114
+ result = PagedResponse[SpaceResponse].model_validate_json(result.success_response.body)
115
+ return result.items
@@ -0,0 +1,24 @@
1
+ from cognite.neat._client.api import NeatAPI
2
+ from cognite.neat._client.data_classes import StatisticsResponse
3
+ from cognite.neat._utils.http_client import ParametersRequest
4
+
5
+
6
+ class StatisticsAPI(NeatAPI):
7
+ def project(self) -> StatisticsResponse:
8
+ """Retrieve project-wide usage data and limits.
9
+
10
+ Returns:
11
+ StatisticsResponse object.
12
+ """
13
+
14
+ result = self._http_client.request_with_retries(
15
+ ParametersRequest(
16
+ endpoint_url=self._config.create_api_url("/models/statistics"),
17
+ method="GET",
18
+ parameters=None,
19
+ )
20
+ )
21
+
22
+ result.raise_for_status()
23
+ result = StatisticsResponse.model_validate_json(result.success_response.body)
24
+ return result
@@ -0,0 +1,144 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+
5
+ from cognite.neat._data_model.models.dms import DataModelBody, ViewReference, ViewRequest, ViewResponse
6
+ from cognite.neat._utils.collection import chunker_sequence
7
+ from cognite.neat._utils.http_client import ItemIDBody, ItemsRequest, ParametersRequest
8
+ from cognite.neat._utils.useful_types import PrimitiveType
9
+
10
+ from .api import NeatAPI
11
+ from .data_classes import PagedResponse
12
+
13
+
14
+ class ViewsAPI(NeatAPI):
15
+ ENDPOINT = "/models/views"
16
+ LIST_REQUEST_LIMIT = 1000
17
+
18
+ def apply(self, items: Sequence[ViewRequest]) -> list[ViewResponse]:
19
+ """Create or update views in CDF Project.
20
+ Args:
21
+ items: List of ViewRequest objects to create or update.
22
+ Returns:
23
+ List of ViewResponse objects.
24
+ """
25
+ if not items:
26
+ return []
27
+ if len(items) > 100:
28
+ raise ValueError("Cannot apply more than 100 views at once.")
29
+ result = self._http_client.request_with_retries(
30
+ ItemsRequest(
31
+ endpoint_url=self._config.create_api_url(self.ENDPOINT),
32
+ method="POST",
33
+ body=DataModelBody(items=items),
34
+ )
35
+ )
36
+ result.raise_for_status()
37
+ result = PagedResponse[ViewResponse].model_validate_json(result.success_response.body)
38
+ return result.items
39
+
40
+ def retrieve(
41
+ self,
42
+ items: list[ViewReference],
43
+ include_inherited_properties: bool = True,
44
+ ) -> list[ViewResponse]:
45
+ """Retrieve views by their identifiers.
46
+
47
+ Args:
48
+ items: List of (space, external_id, version) tuples identifying the views to retrieve.
49
+ include_inherited_properties: If True, include properties inherited from parent views.
50
+
51
+ Returns:
52
+ List of ViewResponse objects.
53
+ """
54
+ results: list[ViewResponse] = []
55
+ for chunk in chunker_sequence(items, 100):
56
+ batch = self._http_client.request_with_retries(
57
+ ItemsRequest(
58
+ endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/byids"),
59
+ method="POST",
60
+ body=ItemIDBody(items=chunk),
61
+ parameters={"includeInheritedProperties": include_inherited_properties},
62
+ )
63
+ )
64
+ batch.raise_for_status()
65
+ result = PagedResponse[ViewResponse].model_validate_json(batch.success_response.body)
66
+ results.extend(result.items)
67
+ return results
68
+
69
+ def delete(self, items: list[ViewReference]) -> list[ViewReference]:
70
+ """Delete views by their identifiers.
71
+
72
+ Args:
73
+ items: List of (space, external_id, version) tuples identifying the views to delete.
74
+ """
75
+ if not items:
76
+ return []
77
+ if len(items) > 100:
78
+ raise ValueError("Cannot delete more than 100 views at once.")
79
+
80
+ result = self._http_client.request_with_retries(
81
+ ItemsRequest(
82
+ endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/delete"),
83
+ method="POST",
84
+ body=ItemIDBody(items=items),
85
+ )
86
+ )
87
+ result.raise_for_status()
88
+ result = PagedResponse[ViewReference].model_validate_json(result.success_response.body)
89
+ return result.items
90
+
91
+ def list(
92
+ self,
93
+ space: str | None = None,
94
+ all_versions: bool = False,
95
+ include_inherited_properties: bool = True,
96
+ include_global: bool = False,
97
+ limit: int | None = 10,
98
+ ) -> list[ViewResponse]:
99
+ """List views in CDF Project.
100
+
101
+ Args:
102
+ space: If specified, only views in this space are returned.
103
+ all_versions: If True, return all versions. If False, only return the latest version.
104
+ include_inherited_properties: If True, include properties inherited from parent views.
105
+ include_global: If True, include global views.
106
+ limit: Maximum number of views to return. If None, return all views.
107
+
108
+ Returns:
109
+ List of ViewResponse objects.
110
+ """
111
+ if limit is not None and limit < 0:
112
+ raise ValueError("Limit must be non-negative.")
113
+ elif limit is not None and limit == 0:
114
+ return []
115
+ parameters: dict[str, PrimitiveType] = {
116
+ "allVersions": all_versions,
117
+ "includeInheritedProperties": include_inherited_properties,
118
+ "includeGlobal": include_global,
119
+ }
120
+ if space is not None:
121
+ parameters["space"] = space
122
+ cursor: str | None = None
123
+ view_responses: list[ViewResponse] = []
124
+ while True:
125
+ if cursor is not None:
126
+ parameters["cursor"] = cursor
127
+ if limit is None:
128
+ parameters["limit"] = self.LIST_REQUEST_LIMIT
129
+ else:
130
+ parameters["limit"] = min(self.LIST_REQUEST_LIMIT, limit - len(view_responses))
131
+ result = self._http_client.request_with_retries(
132
+ ParametersRequest(
133
+ endpoint_url=self._config.create_api_url(self.ENDPOINT),
134
+ method="GET",
135
+ parameters=parameters,
136
+ )
137
+ )
138
+ result.raise_for_status()
139
+ result = PagedResponse[ViewResponse].model_validate_json(result.success_response.body)
140
+ view_responses.extend(result.items)
141
+ cursor = result.next_cursor
142
+ if cursor is None or (limit is not None and len(view_responses) >= limit):
143
+ break
144
+ return view_responses
@@ -0,0 +1,266 @@
1
+ import sys
2
+ from pathlib import Path
3
+ from typing import Any, Literal, TypeAlias
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+ from cognite.neat._exceptions import UserInputError
8
+ from cognite.neat._issues import ConsistencyError, ModelSyntaxError
9
+ from cognite.neat._utils.text import humanize_collection
10
+ from cognite.neat._utils.useful_types import ModusOperandi
11
+
12
+ if sys.version_info >= (3, 11):
13
+ import tomllib as tomli # Python 3.11+
14
+ else:
15
+ import tomli # type: ignore
16
+
17
+ # Public profiles
18
+ PredefinedProfile: TypeAlias = Literal["legacy-additive", "legacy-rebuild", "deep-additive", "deep-rebuild"]
19
+
20
+ # Private profiles only
21
+ _PrivateProfiles: TypeAlias = Literal["no-validation-additive", "no-validation-rebuild"]
22
+
23
+ # All profiles (union of public and private)
24
+ _AllProfiles: TypeAlias = PredefinedProfile | _PrivateProfiles
25
+
26
+
27
+ class ConfigModel(BaseModel):
28
+ model_config = ConfigDict(populate_by_name=True, validate_assignment=True)
29
+
30
+
31
+ class ValidationConfig(ConfigModel):
32
+ """Validation configuration."""
33
+
34
+ exclude: list[str] = Field(default_factory=list)
35
+ override: bool = Field(False, description="If enabled, all validators are skipped.")
36
+
37
+ def can_run_validator(self, code: str, issue_type: type) -> bool:
38
+ """
39
+ Check if a specific validator should run.
40
+
41
+ Args:
42
+ code: Validation code (e.g., "NEAT-DMS-CONTAINER-001")
43
+ issue_type: Issue type (e.g., ModelSyntaxError, ConsistencyError, Recommendation)
44
+
45
+ Returns:
46
+ True if validator should run, False otherwise
47
+ """
48
+
49
+ is_excluded = self._is_excluded(code, self.exclude)
50
+
51
+ if issue_type in [ModelSyntaxError, ConsistencyError] and is_excluded and not self.override:
52
+ print(f"Validator {code} was excluded however it is a critical validator and will still run.")
53
+ return True
54
+ else:
55
+ return not is_excluded
56
+
57
+ @classmethod
58
+ def _is_excluded(cls, code: str, patterns: list[str]) -> bool:
59
+ """Check if code matches any pattern (supports wildcards)."""
60
+ for pattern in patterns:
61
+ if "*" in pattern:
62
+ # Split both pattern and code by hyphens
63
+ pattern_parts = pattern.split("-")
64
+ code_parts = code.split("-")
65
+
66
+ # Pattern must have same or fewer parts than code
67
+ if len(pattern_parts) > len(code_parts):
68
+ continue
69
+
70
+ # Check if all pattern parts match (allowing wildcards)
71
+ match = True
72
+ for p_part, c_part in zip(pattern_parts, code_parts, strict=False):
73
+ if p_part != "*" and p_part != c_part:
74
+ match = False
75
+ break
76
+
77
+ if match:
78
+ return True
79
+ elif code == pattern:
80
+ return True
81
+
82
+ return False
83
+
84
+ def __str__(self) -> str:
85
+ """Human-readable configuration summary."""
86
+ if not self.exclude:
87
+ return "All validators enabled"
88
+ return f"Excluded Rules: {', '.join(self.exclude)}"
89
+
90
+
91
+ class ModelingConfig(ConfigModel):
92
+ """Modeling configuration."""
93
+
94
+ mode: ModusOperandi = "additive"
95
+
96
+
97
+ class AlphaFlagConfig(ConfigModel):
98
+ """Alpha feature flags configuration."""
99
+
100
+ fix_validation_issues: bool = Field(
101
+ default=False,
102
+ description="If enabled, Neat will attempt to automatically fix certain validation issues in the data model.",
103
+ )
104
+ enable_experimental_validators: bool = Field(
105
+ default=False,
106
+ description="If enabled, Neat will run experimental validators that are still in alpha stage.",
107
+ )
108
+
109
+ def __setattr__(self, key: str, value: Any) -> None:
110
+ """Set attribute value or raise AttributeError."""
111
+ if key in self.model_fields:
112
+ super().__setattr__(key, value)
113
+ else:
114
+ available_flags = humanize_collection(type(self).model_fields.keys())
115
+ raise UserInputError(f"Alpha flag '{key}' not found. Available flags: {available_flags}.")
116
+
117
+ def _repr_html_(self) -> str:
118
+ """HTML representation for Jupyter notebooks."""
119
+ lines = ["<b>Alpha Feature Flags:</b>"]
120
+ for field_name, field in type(self).model_fields.items():
121
+ value = getattr(self, field_name)
122
+ display = "Enabled" if value else "Disabled"
123
+ lines.append(f"<li><b>{field_name}</b>: {display} - {field.description}</li>")
124
+ return "<ul>" + "\n".join(lines) + "</ul>"
125
+
126
+
127
+ class NeatConfig(ConfigModel):
128
+ """NeatSession configuration."""
129
+
130
+ profile: str
131
+ validation: ValidationConfig
132
+ modeling: ModelingConfig
133
+ alpha: AlphaFlagConfig = Field(default_factory=AlphaFlagConfig)
134
+
135
+ def __str__(self) -> str:
136
+ """Human-readable configuration summary."""
137
+ lines = [
138
+ f"Profile: {self.profile}",
139
+ f"Modeling Mode: {self.modeling.mode}",
140
+ f"Validation: {self.validation}",
141
+ ]
142
+ return "\n".join(lines)
143
+
144
+ @classmethod
145
+ def create_predefined(cls, profile: PredefinedProfile = "legacy-additive") -> "NeatConfig":
146
+ """Create NeatConfig from internal profiles.
147
+
148
+ Args:
149
+ profile: Profile name to use. Defaults to "legacy-additive".
150
+
151
+ !!! note "Predefined Profiles"
152
+ The following predefined profiles are available:
153
+
154
+ - `legacy-additive`: Additive modeling with legacy validation rules.
155
+ - `legacy-rebuild`: Rebuild modeling with legacy validation rules.
156
+ - `deep-additive`: Additive modeling with deep validation rules.
157
+ - `deep-rebuild`: Rebuild modeling with deep validation rules.
158
+ """
159
+ available_profiles = internal_profiles()
160
+ if profile not in available_profiles:
161
+ raise UserInputError(
162
+ f"Profile {profile!r} not found. Available predefined profiles: "
163
+ f"{humanize_collection(available_profiles.keys())}."
164
+ )
165
+ return available_profiles[profile]
166
+
167
+
168
+ def internal_profiles() -> dict[_AllProfiles, NeatConfig]:
169
+ """Get internal NeatConfig profile by name."""
170
+ return {
171
+ "legacy-additive": NeatConfig(
172
+ profile="legacy-additive",
173
+ modeling=ModelingConfig(mode="additive"),
174
+ validation=ValidationConfig(
175
+ exclude=[
176
+ "NEAT-DMS-AI-READINESS-*",
177
+ "NEAT-DMS-CONNECTIONS-002",
178
+ "NEAT-DMS-CONNECTIONS-REVERSE-007",
179
+ "NEAT-DMS-CONNECTIONS-REVERSE-008",
180
+ "NEAT-DMS-CONSISTENCY-001",
181
+ ]
182
+ ),
183
+ ),
184
+ "legacy-rebuild": NeatConfig(
185
+ profile="legacy-rebuild",
186
+ modeling=ModelingConfig(mode="rebuild"),
187
+ validation=ValidationConfig(
188
+ exclude=[
189
+ "NEAT-DMS-AI-READINESS-*",
190
+ "NEAT-DMS-CONNECTIONS-002",
191
+ "NEAT-DMS-CONNECTIONS-REVERSE-007",
192
+ "NEAT-DMS-CONNECTIONS-REVERSE-008",
193
+ "NEAT-DMS-CONSISTENCY-001",
194
+ ]
195
+ ),
196
+ ),
197
+ "deep-additive": NeatConfig(
198
+ profile="deep-additive",
199
+ modeling=ModelingConfig(mode="additive"),
200
+ validation=ValidationConfig(exclude=[]),
201
+ ),
202
+ "deep-rebuild": NeatConfig(
203
+ profile="deep-rebuild",
204
+ modeling=ModelingConfig(mode="rebuild"),
205
+ validation=ValidationConfig(exclude=[]),
206
+ ),
207
+ "no-validation-rebuild": NeatConfig(
208
+ profile="no-validation-rebuild",
209
+ modeling=ModelingConfig(mode="rebuild"),
210
+ validation=ValidationConfig(exclude=["*"], override=True),
211
+ ),
212
+ "no-validation-additive": NeatConfig(
213
+ profile="no-validation-additive",
214
+ modeling=ModelingConfig(mode="additive"),
215
+ validation=ValidationConfig(exclude=["*"], override=True),
216
+ ),
217
+ }
218
+
219
+
220
+ def get_neat_config_from_file(config_file_name: str, profile: str) -> NeatConfig:
221
+ """Get NeatConfig from file or internal profiles.
222
+
223
+ Args:
224
+ config_file_name: Path to configuration file.
225
+ profile: Profile name to use.
226
+ Returns:
227
+ NeatConfig instance.
228
+ """
229
+
230
+ if not config_file_name.endswith(".toml"):
231
+ raise ValueError("config_file_name must end with '.toml'")
232
+
233
+ file_path = Path.cwd() / config_file_name
234
+
235
+ if file_path.exists():
236
+ with file_path.open("rb") as f:
237
+ toml = tomli.load(f)
238
+
239
+ if "tool" in toml and "neat" in toml["tool"]:
240
+ data = toml["tool"]["neat"]
241
+ elif "neat" in toml:
242
+ data = toml["neat"]
243
+ else:
244
+ raise ValueError("No [tool.neat] or [neat] section found in the configuration file.")
245
+
246
+ toml_profile = data.get("profile")
247
+ toml_profiles = data.get("profiles")
248
+ hardcoded_profiles = internal_profiles()
249
+
250
+ if toml_profile and toml_profile in hardcoded_profiles:
251
+ raise ValueError(f"Internal profile '{toml_profile}' cannot be used in external configuration file.")
252
+
253
+ if toml_profiles and any(p in hardcoded_profiles for p in toml_profiles.keys()):
254
+ raise ValueError(
255
+ "Internal profiles cannot be redefined in external configuration file: "
256
+ f"{set(hardcoded_profiles.keys()).intersection(toml_profiles.keys())}"
257
+ )
258
+
259
+ if toml_profile and profile == toml_profile:
260
+ return NeatConfig(**data)
261
+ elif (built_in_profiles := data.get("profiles")) and profile in built_in_profiles:
262
+ return NeatConfig(profile=profile, **data["profiles"][profile])
263
+ else:
264
+ raise ValueError(f"Profile '{profile}' not found in configuration file.")
265
+ else:
266
+ raise FileNotFoundError(f"Configuration file '{file_path}' not found.")