cognite-neat 0.123.2__py3-none-any.whl → 0.127.30__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 (333) hide show
  1. cognite/neat/__init__.py +2 -2
  2. cognite/neat/_client/__init__.py +4 -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 +125 -0
  7. cognite/neat/_client/data_classes.py +44 -0
  8. cognite/neat/_client/data_model_api.py +115 -0
  9. cognite/neat/_client/spaces_api.py +115 -0
  10. cognite/neat/_client/statistics_api.py +24 -0
  11. cognite/neat/_client/views_api.py +129 -0
  12. cognite/neat/_config.py +185 -0
  13. cognite/neat/_data_model/_analysis.py +196 -0
  14. cognite/neat/_data_model/_constants.py +67 -0
  15. cognite/neat/_data_model/_identifiers.py +61 -0
  16. cognite/neat/_data_model/_shared.py +41 -0
  17. cognite/neat/_data_model/deployer/_differ.py +140 -0
  18. cognite/neat/_data_model/deployer/_differ_container.py +360 -0
  19. cognite/neat/_data_model/deployer/_differ_data_model.py +54 -0
  20. cognite/neat/_data_model/deployer/_differ_space.py +9 -0
  21. cognite/neat/_data_model/deployer/_differ_view.py +299 -0
  22. cognite/neat/_data_model/deployer/data_classes.py +529 -0
  23. cognite/neat/_data_model/deployer/deployer.py +401 -0
  24. cognite/neat/_data_model/exporters/__init__.py +15 -0
  25. cognite/neat/_data_model/exporters/_api_exporter.py +37 -0
  26. cognite/neat/_data_model/exporters/_base.py +24 -0
  27. cognite/neat/_data_model/exporters/_table_exporter/exporter.py +128 -0
  28. cognite/neat/_data_model/exporters/_table_exporter/workbook.py +409 -0
  29. cognite/neat/_data_model/exporters/_table_exporter/writer.py +421 -0
  30. cognite/neat/_data_model/importers/__init__.py +5 -0
  31. cognite/neat/_data_model/importers/_api_importer.py +166 -0
  32. cognite/neat/_data_model/importers/_base.py +16 -0
  33. cognite/neat/_data_model/importers/_table_importer/data_classes.py +295 -0
  34. cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
  35. cognite/neat/_data_model/importers/_table_importer/reader.py +1063 -0
  36. cognite/neat/_data_model/importers/_table_importer/source.py +94 -0
  37. cognite/neat/_data_model/models/conceptual/_base.py +18 -0
  38. cognite/neat/_data_model/models/conceptual/_concept.py +67 -0
  39. cognite/neat/_data_model/models/conceptual/_data_model.py +51 -0
  40. cognite/neat/_data_model/models/conceptual/_properties.py +104 -0
  41. cognite/neat/_data_model/models/conceptual/_property.py +105 -0
  42. cognite/neat/_data_model/models/dms/__init__.py +206 -0
  43. cognite/neat/_data_model/models/dms/_base.py +31 -0
  44. cognite/neat/_data_model/models/dms/_constants.py +48 -0
  45. cognite/neat/_data_model/models/dms/_constraints.py +42 -0
  46. cognite/neat/_data_model/models/dms/_container.py +159 -0
  47. cognite/neat/_data_model/models/dms/_data_model.py +95 -0
  48. cognite/neat/_data_model/models/dms/_data_types.py +195 -0
  49. cognite/neat/_data_model/models/dms/_http.py +28 -0
  50. cognite/neat/_data_model/models/dms/_indexes.py +30 -0
  51. cognite/neat/_data_model/models/dms/_limits.py +96 -0
  52. cognite/neat/_data_model/models/dms/_references.py +135 -0
  53. cognite/neat/_data_model/models/dms/_schema.py +18 -0
  54. cognite/neat/_data_model/models/dms/_space.py +48 -0
  55. cognite/neat/_data_model/models/dms/_types.py +17 -0
  56. cognite/neat/_data_model/models/dms/_view_filter.py +282 -0
  57. cognite/neat/_data_model/models/dms/_view_property.py +235 -0
  58. cognite/neat/_data_model/models/dms/_views.py +210 -0
  59. cognite/neat/_data_model/models/entities/__init__.py +50 -0
  60. cognite/neat/_data_model/models/entities/_base.py +101 -0
  61. cognite/neat/_data_model/models/entities/_constants.py +22 -0
  62. cognite/neat/_data_model/models/entities/_data_types.py +144 -0
  63. cognite/neat/_data_model/models/entities/_identifiers.py +61 -0
  64. cognite/neat/_data_model/models/entities/_parser.py +226 -0
  65. cognite/neat/_data_model/validation/dms/__init__.py +75 -0
  66. cognite/neat/_data_model/validation/dms/_ai_readiness.py +364 -0
  67. cognite/neat/_data_model/validation/dms/_base.py +307 -0
  68. cognite/neat/_data_model/validation/dms/_connections.py +638 -0
  69. cognite/neat/_data_model/validation/dms/_consistency.py +57 -0
  70. cognite/neat/_data_model/validation/dms/_containers.py +174 -0
  71. cognite/neat/_data_model/validation/dms/_limits.py +420 -0
  72. cognite/neat/_data_model/validation/dms/_orchestrator.py +222 -0
  73. cognite/neat/_data_model/validation/dms/_views.py +103 -0
  74. cognite/neat/_exceptions.py +56 -0
  75. cognite/neat/_issues.py +68 -0
  76. cognite/neat/_session/__init__.py +3 -0
  77. cognite/neat/_session/_html/_render.py +30 -0
  78. cognite/neat/_session/_html/static/__init__.py +8 -0
  79. cognite/neat/_session/_html/static/deployment.css +303 -0
  80. cognite/neat/_session/_html/static/deployment.js +150 -0
  81. cognite/neat/_session/_html/static/issues.css +211 -0
  82. cognite/neat/_session/_html/static/issues.js +168 -0
  83. cognite/neat/_session/_html/static/shared.css +186 -0
  84. cognite/neat/_session/_html/templates/__init__.py +4 -0
  85. cognite/neat/_session/_html/templates/deployment.html +75 -0
  86. cognite/neat/_session/_html/templates/issues.html +45 -0
  87. cognite/neat/_session/_issues.py +81 -0
  88. cognite/neat/_session/_opt.py +35 -0
  89. cognite/neat/_session/_physical.py +261 -0
  90. cognite/neat/_session/_result.py +236 -0
  91. cognite/neat/_session/_session.py +88 -0
  92. cognite/neat/_session/_usage_analytics/__init__.py +0 -0
  93. cognite/neat/_session/_usage_analytics/_collector.py +131 -0
  94. cognite/neat/_session/_usage_analytics/_constants.py +23 -0
  95. cognite/neat/_session/_usage_analytics/_storage.py +240 -0
  96. cognite/neat/_session/_wrappers.py +82 -0
  97. cognite/neat/_state_machine/__init__.py +10 -0
  98. cognite/neat/_state_machine/_base.py +37 -0
  99. cognite/neat/_state_machine/_states.py +52 -0
  100. cognite/neat/_store/__init__.py +3 -0
  101. cognite/neat/_store/_provenance.py +81 -0
  102. cognite/neat/_store/_store.py +156 -0
  103. cognite/neat/_utils/__init__.py +0 -0
  104. cognite/neat/_utils/_reader.py +194 -0
  105. cognite/neat/_utils/auxiliary.py +39 -0
  106. cognite/neat/_utils/collection.py +11 -0
  107. cognite/neat/_utils/http_client/__init__.py +39 -0
  108. cognite/neat/_utils/http_client/_client.py +245 -0
  109. cognite/neat/_utils/http_client/_config.py +19 -0
  110. cognite/neat/_utils/http_client/_data_classes.py +294 -0
  111. cognite/neat/_utils/http_client/_tracker.py +31 -0
  112. cognite/neat/_utils/text.py +71 -0
  113. cognite/neat/_utils/useful_types.py +37 -0
  114. cognite/neat/_utils/validation.py +154 -0
  115. cognite/neat/_version.py +1 -1
  116. cognite/neat/v0/__init__.py +0 -0
  117. cognite/neat/v0/core/__init__.py +0 -0
  118. cognite/neat/v0/core/_client/_api/__init__.py +0 -0
  119. cognite/neat/{core → v0/core}/_client/_api/data_modeling_loaders.py +86 -7
  120. cognite/neat/{core → v0/core}/_client/_api/neat_instances.py +5 -5
  121. cognite/neat/{core → v0/core}/_client/_api/schema.py +5 -5
  122. cognite/neat/{core → v0/core}/_client/_api/statistics.py +3 -3
  123. cognite/neat/{core → v0/core}/_client/_api_client.py +1 -1
  124. cognite/neat/v0/core/_client/data_classes/__init__.py +0 -0
  125. cognite/neat/{core → v0/core}/_client/data_classes/schema.py +4 -4
  126. cognite/neat/{core → v0/core}/_client/testing.py +1 -1
  127. cognite/neat/{core → v0/core}/_constants.py +10 -3
  128. cognite/neat/v0/core/_data_model/__init__.py +0 -0
  129. cognite/neat/{core → v0/core}/_data_model/_constants.py +9 -6
  130. cognite/neat/{core → v0/core}/_data_model/_shared.py +5 -5
  131. cognite/neat/{core → v0/core}/_data_model/analysis/_base.py +12 -8
  132. cognite/neat/{core → v0/core}/_data_model/exporters/__init__.py +1 -2
  133. cognite/neat/{core → v0/core}/_data_model/exporters/_base.py +7 -7
  134. cognite/neat/{core → v0/core}/_data_model/exporters/_data_model2dms.py +9 -9
  135. cognite/neat/{core → v0/core}/_data_model/exporters/_data_model2excel.py +13 -13
  136. cognite/neat/{core → v0/core}/_data_model/exporters/_data_model2instance_template.py +4 -4
  137. cognite/neat/{core/_data_model/exporters/_data_model2ontology.py → v0/core/_data_model/exporters/_data_model2semantic_model.py} +126 -133
  138. cognite/neat/{core → v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
  139. cognite/neat/{core → v0/core}/_data_model/importers/__init__.py +4 -6
  140. cognite/neat/{core → v0/core}/_data_model/importers/_base.py +5 -5
  141. cognite/neat/{core → v0/core}/_data_model/importers/_base_file_reader.py +2 -2
  142. cognite/neat/{core → v0/core}/_data_model/importers/_dict2data_model.py +6 -6
  143. cognite/neat/{core → v0/core}/_data_model/importers/_dms2data_model.py +19 -16
  144. cognite/neat/v0/core/_data_model/importers/_graph2data_model.py +299 -0
  145. cognite/neat/v0/core/_data_model/importers/_rdf/__init__.py +4 -0
  146. cognite/neat/{core → v0/core}/_data_model/importers/_rdf/_base.py +13 -13
  147. cognite/neat/{core → v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
  148. cognite/neat/v0/core/_data_model/importers/_rdf/_owl2data_model.py +144 -0
  149. cognite/neat/v0/core/_data_model/importers/_rdf/_shared.py +255 -0
  150. cognite/neat/{core → v0/core}/_data_model/importers/_spreadsheet2data_model.py +94 -13
  151. cognite/neat/{core → v0/core}/_data_model/models/__init__.py +3 -3
  152. cognite/neat/{core → v0/core}/_data_model/models/_base_verified.py +5 -5
  153. cognite/neat/v0/core/_data_model/models/_import_contexts.py +82 -0
  154. cognite/neat/{core → v0/core}/_data_model/models/_types.py +5 -5
  155. cognite/neat/{core → v0/core}/_data_model/models/conceptual/_unverified.py +18 -12
  156. cognite/neat/v0/core/_data_model/models/conceptual/_validation.py +308 -0
  157. cognite/neat/{core → v0/core}/_data_model/models/conceptual/_verified.py +13 -11
  158. cognite/neat/{core → v0/core}/_data_model/models/data_types.py +14 -4
  159. cognite/neat/{core → v0/core}/_data_model/models/entities/__init__.py +6 -0
  160. cognite/neat/v0/core/_data_model/models/entities/_loaders.py +155 -0
  161. cognite/neat/{core → v0/core}/_data_model/models/entities/_multi_value.py +2 -2
  162. cognite/neat/v0/core/_data_model/models/entities/_restrictions.py +230 -0
  163. cognite/neat/{core → v0/core}/_data_model/models/entities/_single_value.py +121 -16
  164. cognite/neat/{core → v0/core}/_data_model/models/entities/_types.py +10 -0
  165. cognite/neat/{core → v0/core}/_data_model/models/mapping/_classic2core.py +5 -5
  166. cognite/neat/{core → v0/core}/_data_model/models/physical/__init__.py +1 -1
  167. cognite/neat/{core → v0/core}/_data_model/models/physical/_exporter.py +28 -21
  168. cognite/neat/{core → v0/core}/_data_model/models/physical/_unverified.py +141 -38
  169. cognite/neat/{core → v0/core}/_data_model/models/physical/_validation.py +190 -24
  170. cognite/neat/{core → v0/core}/_data_model/models/physical/_verified.py +135 -15
  171. cognite/neat/{core → v0/core}/_data_model/transformers/__init__.py +2 -0
  172. cognite/neat/{core → v0/core}/_data_model/transformers/_base.py +4 -4
  173. cognite/neat/{core → v0/core}/_data_model/transformers/_converters.py +39 -32
  174. cognite/neat/{core → v0/core}/_data_model/transformers/_mapping.py +7 -7
  175. cognite/neat/v0/core/_data_model/transformers/_union_conceptual.py +208 -0
  176. cognite/neat/{core → v0/core}/_data_model/transformers/_verification.py +7 -7
  177. cognite/neat/v0/core/_instances/__init__.py +0 -0
  178. cognite/neat/{core → v0/core}/_instances/_tracking/base.py +1 -1
  179. cognite/neat/{core → v0/core}/_instances/_tracking/log.py +1 -1
  180. cognite/neat/{core → v0/core}/_instances/extractors/__init__.py +1 -1
  181. cognite/neat/{core → v0/core}/_instances/extractors/_base.py +6 -6
  182. cognite/neat/v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
  183. cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_base.py +7 -7
  184. cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_classic.py +12 -12
  185. cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_relationships.py +3 -3
  186. cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_sequences.py +2 -2
  187. cognite/neat/{core → v0/core}/_instances/extractors/_dict.py +6 -3
  188. cognite/neat/{core → v0/core}/_instances/extractors/_dms.py +6 -6
  189. cognite/neat/{core → v0/core}/_instances/extractors/_dms_graph.py +11 -11
  190. cognite/neat/{core → v0/core}/_instances/extractors/_mock_graph_generator.py +10 -10
  191. cognite/neat/{core → v0/core}/_instances/extractors/_raw.py +3 -3
  192. cognite/neat/{core → v0/core}/_instances/extractors/_rdf_file.py +7 -7
  193. cognite/neat/{core → v0/core}/_instances/loaders/_base.py +5 -5
  194. cognite/neat/{core → v0/core}/_instances/loaders/_rdf2dms.py +17 -17
  195. cognite/neat/{core → v0/core}/_instances/loaders/_rdf_to_instance_space.py +11 -11
  196. cognite/neat/{core → v0/core}/_instances/queries/_select.py +29 -3
  197. cognite/neat/{core → v0/core}/_instances/queries/_update.py +1 -1
  198. cognite/neat/{core → v0/core}/_instances/transformers/_base.py +4 -4
  199. cognite/neat/{core → v0/core}/_instances/transformers/_classic_cdf.py +6 -6
  200. cognite/neat/{core → v0/core}/_instances/transformers/_prune_graph.py +4 -4
  201. cognite/neat/{core → v0/core}/_instances/transformers/_rdfpath.py +1 -1
  202. cognite/neat/{core → v0/core}/_instances/transformers/_value_type.py +4 -4
  203. cognite/neat/{core → v0/core}/_issues/_base.py +11 -6
  204. cognite/neat/{core → v0/core}/_issues/_contextmanagers.py +8 -6
  205. cognite/neat/{core → v0/core}/_issues/_factory.py +11 -8
  206. cognite/neat/{core → v0/core}/_issues/errors/__init__.py +3 -1
  207. cognite/neat/{core → v0/core}/_issues/errors/_external.py +1 -1
  208. cognite/neat/{core → v0/core}/_issues/errors/_general.py +1 -1
  209. cognite/neat/{core → v0/core}/_issues/errors/_properties.py +12 -1
  210. cognite/neat/{core → v0/core}/_issues/errors/_resources.py +2 -2
  211. cognite/neat/{core → v0/core}/_issues/errors/_wrapper.py +7 -3
  212. cognite/neat/{core → v0/core}/_issues/warnings/__init__.py +5 -1
  213. cognite/neat/{core → v0/core}/_issues/warnings/_external.py +1 -1
  214. cognite/neat/{core → v0/core}/_issues/warnings/_general.py +1 -1
  215. cognite/neat/{core → v0/core}/_issues/warnings/_models.py +39 -4
  216. cognite/neat/{core → v0/core}/_issues/warnings/_properties.py +13 -2
  217. cognite/neat/{core → v0/core}/_issues/warnings/_resources.py +1 -1
  218. cognite/neat/{core → v0/core}/_issues/warnings/user_modeling.py +1 -1
  219. cognite/neat/{core → v0/core}/_store/_data_model.py +13 -12
  220. cognite/neat/{core → v0/core}/_store/_instance.py +45 -12
  221. cognite/neat/{core → v0/core}/_store/_provenance.py +3 -3
  222. cognite/neat/{core → v0/core}/_store/exceptions.py +4 -4
  223. cognite/neat/v0/core/_utils/__init__.py +0 -0
  224. cognite/neat/{core → v0/core}/_utils/auth.py +1 -1
  225. cognite/neat/{core → v0/core}/_utils/auxiliary.py +7 -1
  226. cognite/neat/{core → v0/core}/_utils/collection_.py +2 -2
  227. cognite/neat/{core → v0/core}/_utils/graph_transformations_report.py +1 -1
  228. cognite/neat/{core → v0/core}/_utils/rdf_.py +38 -14
  229. cognite/neat/{core → v0/core}/_utils/reader/_base.py +1 -1
  230. cognite/neat/{core → v0/core}/_utils/spreadsheet.py +22 -4
  231. cognite/neat/v0/core/_utils/tarjan.py +44 -0
  232. cognite/neat/{core → v0/core}/_utils/text.py +1 -1
  233. cognite/neat/{core → v0/core}/_utils/upload.py +3 -3
  234. cognite/neat/v0/plugins/__init__.py +4 -0
  235. cognite/neat/v0/plugins/_base.py +9 -0
  236. cognite/neat/v0/plugins/_data_model.py +48 -0
  237. cognite/neat/{plugins → v0/plugins}/_issues.py +1 -1
  238. cognite/neat/{plugins → v0/plugins}/_manager.py +7 -16
  239. cognite/neat/{session → v0/session}/_base.py +13 -10
  240. cognite/neat/{session → v0/session}/_collector.py +1 -1
  241. cognite/neat/v0/session/_diff.py +51 -0
  242. cognite/neat/{session → v0/session}/_drop.py +3 -3
  243. cognite/neat/{session → v0/session}/_explore.py +2 -2
  244. cognite/neat/{session → v0/session}/_fix.py +2 -2
  245. cognite/neat/{session → v0/session}/_inspect.py +3 -3
  246. cognite/neat/{session → v0/session}/_mapping.py +3 -3
  247. cognite/neat/{session → v0/session}/_plugin.py +4 -5
  248. cognite/neat/{session → v0/session}/_prepare.py +8 -8
  249. cognite/neat/{session → v0/session}/_read.py +33 -43
  250. cognite/neat/{session → v0/session}/_set.py +8 -8
  251. cognite/neat/{session → v0/session}/_show.py +5 -5
  252. cognite/neat/{session → v0/session}/_state.py +22 -8
  253. cognite/neat/{session → v0/session}/_subset.py +4 -4
  254. cognite/neat/{session → v0/session}/_template.py +11 -11
  255. cognite/neat/{session → v0/session}/_to.py +12 -12
  256. cognite/neat/{session → v0/session}/_wizard.py +1 -1
  257. cognite/neat/{session → v0/session}/engine/_load.py +1 -1
  258. cognite/neat/{session → v0/session}/exceptions.py +5 -5
  259. cognite/neat/v1.py +3 -0
  260. {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/METADATA +9 -8
  261. cognite_neat-0.127.30.dist-info/RECORD +319 -0
  262. {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/WHEEL +1 -1
  263. cognite/neat/core/_data_model/importers/_dtdl2data_model/__init__.py +0 -3
  264. cognite/neat/core/_data_model/importers/_dtdl2data_model/_unit_lookup.py +0 -224
  265. cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_converter.py +0 -320
  266. cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_importer.py +0 -155
  267. cognite/neat/core/_data_model/importers/_dtdl2data_model/spec.py +0 -363
  268. cognite/neat/core/_data_model/importers/_rdf/__init__.py +0 -5
  269. cognite/neat/core/_data_model/importers/_rdf/_imf2data_model.py +0 -98
  270. cognite/neat/core/_data_model/importers/_rdf/_owl2data_model.py +0 -87
  271. cognite/neat/core/_data_model/importers/_rdf/_shared.py +0 -168
  272. cognite/neat/core/_data_model/models/conceptual/_validation.py +0 -294
  273. cognite/neat/core/_data_model/models/entities/_loaders.py +0 -75
  274. cognite/neat/plugins/__init__.py +0 -3
  275. cognite/neat/plugins/data_model/importers/__init__.py +0 -5
  276. cognite/neat/plugins/data_model/importers/_base.py +0 -28
  277. cognite_neat-0.123.2.dist-info/RECORD +0 -197
  278. /cognite/neat/{core → _data_model}/__init__.py +0 -0
  279. /cognite/neat/{core/_client/_api → _data_model/deployer}/__init__.py +0 -0
  280. /cognite/neat/{core/_client/data_classes → _data_model/exporters/_table_exporter}/__init__.py +0 -0
  281. /cognite/neat/{core/_data_model → _data_model/importers/_table_importer}/__init__.py +0 -0
  282. /cognite/neat/{core/_instances → _data_model/models}/__init__.py +0 -0
  283. /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models/conceptual}/__init__.py +0 -0
  284. /cognite/neat/{core/_utils → _data_model/validation}/__init__.py +0 -0
  285. /cognite/neat/{plugins/data_model → _session/_html}/__init__.py +0 -0
  286. /cognite/neat/{core → v0/core}/_client/__init__.py +0 -0
  287. /cognite/neat/{core → v0/core}/_client/data_classes/data_modeling.py +0 -0
  288. /cognite/neat/{core → v0/core}/_client/data_classes/neat_sequence.py +0 -0
  289. /cognite/neat/{core → v0/core}/_client/data_classes/statistics.py +0 -0
  290. /cognite/neat/{core → v0/core}/_config.py +0 -0
  291. /cognite/neat/{core → v0/core}/_data_model/analysis/__init__.py +0 -0
  292. /cognite/neat/{core → v0/core}/_data_model/catalog/__init__.py +0 -0
  293. /cognite/neat/{core → v0/core}/_data_model/catalog/classic_model.xlsx +0 -0
  294. /cognite/neat/{core → v0/core}/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
  295. /cognite/neat/{core → v0/core}/_data_model/catalog/hello_world_pump.xlsx +0 -0
  296. /cognite/neat/{core → v0/core}/_data_model/models/_base_unverified.py +0 -0
  297. /cognite/neat/{core → v0/core}/_data_model/models/conceptual/__init__.py +0 -0
  298. /cognite/neat/{core → v0/core}/_data_model/models/entities/_constants.py +0 -0
  299. /cognite/neat/{core → v0/core}/_data_model/models/entities/_wrapped.py +0 -0
  300. /cognite/neat/{core → v0/core}/_data_model/models/mapping/__init__.py +0 -0
  301. /cognite/neat/{core → v0/core}/_data_model/models/mapping/_classic2core.yaml +0 -0
  302. /cognite/neat/{core → v0/core}/_instances/_shared.py +0 -0
  303. /cognite/neat/{core → v0/core}/_instances/_tracking/__init__.py +0 -0
  304. /cognite/neat/{core → v0/core}/_instances/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
  305. /cognite/neat/{core → v0/core}/_instances/examples/Knowledge-Graph-Nordic44.xml +0 -0
  306. /cognite/neat/{core → v0/core}/_instances/examples/__init__.py +0 -0
  307. /cognite/neat/{core → v0/core}/_instances/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
  308. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_assets.py +0 -0
  309. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_data_sets.py +0 -0
  310. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_events.py +0 -0
  311. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_files.py +0 -0
  312. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_labels.py +0 -0
  313. /cognite/neat/{core → v0/core}/_instances/extractors/_classic_cdf/_timeseries.py +0 -0
  314. /cognite/neat/{core → v0/core}/_instances/loaders/__init__.py +0 -0
  315. /cognite/neat/{core → v0/core}/_instances/queries/__init__.py +0 -0
  316. /cognite/neat/{core → v0/core}/_instances/queries/_base.py +0 -0
  317. /cognite/neat/{core → v0/core}/_instances/queries/_queries.py +0 -0
  318. /cognite/neat/{core → v0/core}/_instances/transformers/__init__.py +0 -0
  319. /cognite/neat/{core → v0/core}/_issues/__init__.py +0 -0
  320. /cognite/neat/{core → v0/core}/_issues/formatters.py +0 -0
  321. /cognite/neat/{core → v0/core}/_shared.py +0 -0
  322. /cognite/neat/{core → v0/core}/_store/__init__.py +0 -0
  323. /cognite/neat/{core → v0/core}/_utils/io_.py +0 -0
  324. /cognite/neat/{core → v0/core}/_utils/reader/__init__.py +0 -0
  325. /cognite/neat/{core → v0/core}/_utils/time_.py +0 -0
  326. /cognite/neat/{core → v0/core}/_utils/xml_.py +0 -0
  327. /cognite/neat/{session → v0/session}/__init__.py +0 -0
  328. /cognite/neat/{session → v0/session}/_experimental.py +0 -0
  329. /cognite/neat/{session → v0/session}/_state/README.md +0 -0
  330. /cognite/neat/{session → v0/session}/engine/__init__.py +0 -0
  331. /cognite/neat/{session → v0/session}/engine/_import.py +0 -0
  332. /cognite/neat/{session → v0/session}/engine/_interface.py +0 -0
  333. {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1063 @@
1
+ import json
2
+ from collections import defaultdict
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Literal, TypeVar, cast, overload
5
+
6
+ from pydantic import BaseModel, TypeAdapter, ValidationError
7
+
8
+ from cognite.neat._data_model.models.dms import (
9
+ Constraint,
10
+ ConstraintAdapter,
11
+ ContainerPropertyDefinition,
12
+ ContainerReference,
13
+ ContainerRequest,
14
+ DataModelRequest,
15
+ Index,
16
+ IndexAdapter,
17
+ NodeReference,
18
+ RequestSchema,
19
+ SpaceRequest,
20
+ UniquenessConstraintDefinition,
21
+ ViewReference,
22
+ ViewRequest,
23
+ ViewRequestProperty,
24
+ ViewRequestPropertyAdapter,
25
+ )
26
+ from cognite.neat._data_model.models.dms._constants import DATA_MODEL_DESCRIPTION_MAX_LENGTH
27
+ from cognite.neat._data_model.models.entities import ParsedEntity, parse_entity
28
+ from cognite.neat._exceptions import DataModelImportException
29
+ from cognite.neat._issues import ModelSyntaxError
30
+ from cognite.neat._utils.text import humanize_collection
31
+ from cognite.neat._utils.validation import ValidationContext, humanize_validation_error
32
+
33
+ from .data_classes import CREATOR_KEY, CREATOR_MARKER, DMSContainer, DMSEnum, DMSNode, DMSProperty, DMSView, TableDMS
34
+ from .source import TableSource
35
+
36
+ T_BaseModel = TypeVar("T_BaseModel", bound=BaseModel)
37
+
38
+
39
+ @dataclass
40
+ class ReadViewProperty:
41
+ prop_id: str
42
+ row_no: int
43
+ view_property: ViewRequestProperty
44
+
45
+
46
+ @dataclass
47
+ class ReadContainerProperty:
48
+ prop_id: str
49
+ row_no: int
50
+ container_property: ContainerPropertyDefinition
51
+
52
+
53
+ @dataclass
54
+ class ReadIndex:
55
+ prop_id: str
56
+ order: int | None
57
+ row_no: int
58
+ index_id: str
59
+ index: Index
60
+
61
+
62
+ @dataclass
63
+ class ReadConstraint:
64
+ prop_id: str
65
+ order: int | None
66
+ row_no: int
67
+ constraint_id: str
68
+ constraint: Constraint
69
+
70
+
71
+ @dataclass
72
+ class ReadProperties:
73
+ """Read properties from the properties table.
74
+
75
+ Attributes:
76
+ container: A mapping from container entity to a mapping of property identifier to container property definition.
77
+ view: A mapping from view entity to a mapping of property identifier to view property definition.
78
+ indices: A mapping from (container entity, index identifier) to a list of read indices
79
+ constraints: A mapping from (container entity, constraint identifier) to a list of read constraints
80
+ """
81
+
82
+ container: dict[tuple[ParsedEntity, str], list[ReadContainerProperty]] = field(
83
+ default_factory=lambda: defaultdict(list)
84
+ )
85
+ view: dict[tuple[ParsedEntity, str], list[ReadViewProperty]] = field(default_factory=lambda: defaultdict(list))
86
+ indices: dict[tuple[ParsedEntity, str], list[ReadIndex]] = field(default_factory=lambda: defaultdict(list))
87
+ constraints: dict[tuple[ParsedEntity, str], list[ReadConstraint]] = field(default_factory=lambda: defaultdict(list))
88
+
89
+
90
+ @dataclass
91
+ class ProcessedProperties:
92
+ container: dict[ParsedEntity, dict[str, ContainerPropertyDefinition]] = field(
93
+ default_factory=lambda: defaultdict(dict)
94
+ )
95
+ view: dict[ParsedEntity, dict[str, ViewRequestProperty]] = field(default_factory=lambda: defaultdict(dict))
96
+ indices: dict[ParsedEntity, dict[str, Index]] = field(default_factory=lambda: defaultdict(dict))
97
+ constraints: dict[ParsedEntity, dict[str, Constraint]] = field(default_factory=lambda: defaultdict(dict))
98
+
99
+
100
+ class DMSTableReader:
101
+ """Reads a TableDMS object and converts it to a RequestSchema.
102
+
103
+
104
+ Args:
105
+ default_space (str): The default space to use when no space is given in an entity.
106
+ default_version (str): The default version to use when no version is given in an entity.
107
+ source (TableSource): The source of the table data, used for error reporting.
108
+
109
+ Raises:
110
+ DataModelImportError: If there are any errors in the data model.
111
+
112
+ Attributes:
113
+ errors (list[ModelSyntaxError]): A list of errors encountered during parsing.
114
+
115
+ Class Attributes:
116
+ Sheets: This is used to create error messages. It ensures that the column names matches
117
+ the names in the table, even if they are renamed in the code.
118
+ PropertyColumns: This is used to create error messages for the properties table.
119
+ It ensures that the column names matches the names in the table, even if they are renamed in the code.
120
+ ContainerColumns: This is used to create error messages for the containers table.
121
+ It ensures that the column names matches the names in the table, even if they are renamed in the code.
122
+ ViewColumns: This is used to create error messages for the views table.
123
+ It ensures that the column names matches the names in the table, even if they are renamed in the code.
124
+
125
+ """
126
+
127
+ CELL_MISSING = "#N/A"
128
+
129
+ # The following classes are used when creating error messages. They ensure that the column names
130
+ # matches the names in the table, even if they are renamed in the code.
131
+ # Note that this is not a complete list of all columns, only those that are used in error messages.
132
+ class Sheets:
133
+ metadata = cast(str, TableDMS.model_fields["metadata"].validation_alias)
134
+ properties = cast(str, TableDMS.model_fields["properties"].validation_alias)
135
+ containers = cast(str, TableDMS.model_fields["containers"].validation_alias)
136
+ views = cast(str, TableDMS.model_fields["views"].validation_alias)
137
+ nodes = cast(str, TableDMS.model_fields["nodes"].validation_alias)
138
+
139
+ class PropertyColumns:
140
+ view = cast(str, DMSProperty.model_fields["view"].validation_alias)
141
+ view_property = cast(str, DMSProperty.model_fields["view_property"].validation_alias)
142
+ connection = cast(str, DMSProperty.model_fields["connection"].validation_alias)
143
+ value_type = cast(str, DMSProperty.model_fields["value_type"].validation_alias)
144
+ min_count = cast(str, DMSProperty.model_fields["min_count"].validation_alias)
145
+ max_count = cast(str, DMSProperty.model_fields["max_count"].validation_alias)
146
+ default = cast(str, DMSProperty.model_fields["default"].validation_alias)
147
+ auto_increment = cast(str, DMSProperty.model_fields["auto_increment"].validation_alias)
148
+ container = cast(str, DMSProperty.model_fields["container"].validation_alias)
149
+ container_property = cast(str, DMSProperty.model_fields["container_property"].validation_alias)
150
+ container_property_name = cast(str, DMSProperty.model_fields["container_property_name"].validation_alias)
151
+ container_property_description = cast(
152
+ str, DMSProperty.model_fields["container_property_description"].validation_alias
153
+ )
154
+ index = cast(str, DMSProperty.model_fields["index"].validation_alias)
155
+ constraint = cast(str, DMSProperty.model_fields["constraint"].validation_alias)
156
+
157
+ class ContainerColumns:
158
+ container = cast(str, DMSContainer.model_fields["container"].validation_alias)
159
+ constraint = cast(str, DMSContainer.model_fields["constraint"].validation_alias)
160
+
161
+ class ViewColumns:
162
+ view = cast(str, DMSView.model_fields["view"].validation_alias)
163
+ filter = cast(str, DMSView.model_fields["filter"].validation_alias)
164
+
165
+ def __init__(self, default_space: str, default_version: str, source: TableSource) -> None:
166
+ self.default_space = default_space
167
+ self.default_version = default_version
168
+ self.source = source
169
+ self.errors: list[ModelSyntaxError] = []
170
+
171
+ def read_tables(self, tables: TableDMS) -> RequestSchema:
172
+ space_request = self.read_space(self.default_space)
173
+ node_types = self.read_nodes(tables.nodes)
174
+ enum_collections = self.read_enum_collections(tables.enum)
175
+ container_ref_by_entity = self.read_entity_by_container_ref(tables.containers)
176
+ view_ref_by_entity = self.read_entity_by_view_ref(tables.views)
177
+ read = self.read_properties(tables.properties, enum_collections, container_ref_by_entity, view_ref_by_entity)
178
+ processed = self.process_properties(read)
179
+ containers = self.read_containers(tables.containers, processed)
180
+ views, valid_view_entities = self.read_views(tables.views, processed.view)
181
+ data_model = self.read_data_model(tables, valid_view_entities)
182
+
183
+ if self.errors:
184
+ raise DataModelImportException(self.errors) from None
185
+ return RequestSchema(
186
+ dataModel=data_model, views=views, containers=containers, spaces=[space_request], nodeTypes=node_types
187
+ )
188
+
189
+ def read_space(self, space: str) -> SpaceRequest:
190
+ space_request = self._validate_obj(SpaceRequest, {"space": space}, (self.Sheets.metadata,), field_name="value")
191
+ if space_request is None:
192
+ # If space is invalid, we stop parsing to avoid raising an error for every place the space is used.
193
+ raise DataModelImportException(self.errors) from None
194
+ return space_request
195
+
196
+ def read_nodes(self, nodes: list[DMSNode]) -> list[NodeReference]:
197
+ node_refs: list[NodeReference] = []
198
+ for row_no, row in enumerate(nodes):
199
+ data = self._create_node_ref(row.node)
200
+ instantiated = self._validate_obj(NodeReference, data, (self.Sheets.nodes, row_no))
201
+ if instantiated is not None:
202
+ node_refs.append(instantiated)
203
+ return node_refs
204
+
205
+ @staticmethod
206
+ def read_enum_collections(enum_rows: list[DMSEnum]) -> dict[str, dict[str, Any]]:
207
+ enum_collections: dict[str, dict[str, Any]] = defaultdict(dict)
208
+ for row in enum_rows:
209
+ enum_collections[row.collection][row.value] = {
210
+ "name": row.name,
211
+ "description": row.description,
212
+ }
213
+ return enum_collections
214
+
215
+ def read_entity_by_container_ref(self, containers: list[DMSContainer]) -> dict[ContainerReference, ParsedEntity]:
216
+ entity_by_container_ref: dict[ContainerReference, ParsedEntity] = {}
217
+ for container in containers:
218
+ data = self._create_container_ref(container.container)
219
+ try:
220
+ container_ref = ContainerReference.model_validate(data)
221
+ except ValidationError:
222
+ # Error will be reported when reading the containers
223
+ continue
224
+ entity_by_container_ref[container_ref] = container.container
225
+ return entity_by_container_ref
226
+
227
+ def read_entity_by_view_ref(self, views: list[DMSView]) -> dict[ViewReference, ParsedEntity]:
228
+ entity_by_view_ref: dict[ViewReference, ParsedEntity] = {}
229
+ for view in views:
230
+ data = self._create_view_ref(view.view)
231
+ try:
232
+ view_ref = ViewReference.model_validate(data)
233
+ except ValidationError:
234
+ # Error will be reported when reading the views
235
+ continue
236
+ entity_by_view_ref[view_ref] = view.view
237
+ return entity_by_view_ref
238
+
239
+ def read_properties(
240
+ self,
241
+ properties: list[DMSProperty],
242
+ enum_collections: dict[str, dict[str, Any]],
243
+ container_ref_by_entity: dict[ContainerReference, ParsedEntity],
244
+ view_ref_by_entity: dict[ViewReference, ParsedEntity],
245
+ ) -> ReadProperties:
246
+ read = ReadProperties()
247
+ view_entities = set(view_ref_by_entity.values())
248
+ container_entities = set(container_ref_by_entity.values())
249
+ for row_no, prop in enumerate(properties):
250
+ self._process_view_property(prop, read, row_no, view_ref_by_entity, view_entities)
251
+ if prop.container is None or prop.container_property is None:
252
+ # This is when the property is an edge or reverse direct relation property.
253
+ continue
254
+ self._process_container_property(
255
+ prop, read, enum_collections, row_no, container_ref_by_entity, container_entities
256
+ )
257
+ self._process_index(prop, read, row_no, container_ref_by_entity, container_entities)
258
+ self._process_constraint(prop, read, row_no, container_ref_by_entity, container_entities)
259
+ return read
260
+
261
+ def process_properties(self, read: ReadProperties) -> ProcessedProperties:
262
+ return ProcessedProperties(
263
+ container=self.create_container_properties(read),
264
+ view=self.create_view_properties(read),
265
+ indices=self.create_indices(read),
266
+ constraints=self.create_constraints(read),
267
+ )
268
+
269
+ def create_container_properties(
270
+ self, read: ReadProperties
271
+ ) -> dict[ParsedEntity, dict[str, ContainerPropertyDefinition]]:
272
+ container_props: dict[ParsedEntity, dict[str, ContainerPropertyDefinition]] = defaultdict(dict)
273
+ for (container_entity, prop_id), prop_list in read.container.items():
274
+ if len(prop_list) == 0:
275
+ # Should not happen
276
+ continue
277
+ container_props[container_entity][prop_id] = prop_list[0].container_property
278
+ if len(prop_list) > 1 and self._are_definitions_different(prop_list):
279
+ # If multiple view properties are mapping to the same container property,
280
+ # the container property definitions must be the same.
281
+ rows_str = humanize_collection(
282
+ [self.source.adjust_row_number(self.Sheets.properties, p.row_no) for p in prop_list]
283
+ )
284
+ container_columns_str = humanize_collection(
285
+ [
286
+ self.PropertyColumns.connection,
287
+ self.PropertyColumns.value_type,
288
+ self.PropertyColumns.min_count,
289
+ self.PropertyColumns.max_count,
290
+ self.PropertyColumns.default,
291
+ self.PropertyColumns.auto_increment,
292
+ self.PropertyColumns.container_property_name,
293
+ self.PropertyColumns.container_property_description,
294
+ self.PropertyColumns.index,
295
+ self.PropertyColumns.constraint,
296
+ ]
297
+ )
298
+ self.errors.append(
299
+ ModelSyntaxError(
300
+ message=(
301
+ f"In {self.source.location((self.Sheets.properties,))} "
302
+ f"when the column {self.PropertyColumns.container!r} and "
303
+ f"{self.PropertyColumns.container_property!r} are the same, "
304
+ f"all the container columns ({container_columns_str}) must be the same. "
305
+ f"Inconsistent definitions for container '{container_entity!s} "
306
+ f"and {prop_id!r}' found in rows {rows_str}."
307
+ )
308
+ )
309
+ )
310
+ return container_props
311
+
312
+ def _are_definitions_different(self, prop_list: list[ReadContainerProperty]) -> bool:
313
+ if len(prop_list) < 2:
314
+ return False
315
+ first_def = prop_list[0].container_property
316
+ for prop in prop_list[1:]:
317
+ if first_def != prop.container_property:
318
+ return True
319
+ return False
320
+
321
+ def create_view_properties(self, read: ReadProperties) -> dict[ParsedEntity, dict[str, ViewRequestProperty]]:
322
+ view_props: dict[ParsedEntity, dict[str, ViewRequestProperty]] = defaultdict(dict)
323
+ for (view_entity, prop_id), prop_list in read.view.items():
324
+ if len(prop_list) == 0:
325
+ # Should not happen
326
+ continue
327
+ view_props[view_entity][prop_id] = prop_list[0].view_property
328
+ if len(prop_list) > 1:
329
+ # Safeguard against duplicated rows for view properties.
330
+ rows_str = humanize_collection(
331
+ [self.source.adjust_row_number(self.Sheets.properties, p.row_no) for p in prop_list]
332
+ )
333
+ self.errors.append(
334
+ ModelSyntaxError(
335
+ message=(
336
+ f"In {self.source.location((self.Sheets.properties,))} the combination of columns "
337
+ f"{self.PropertyColumns.view!r} and {self.PropertyColumns.view_property!r} must be unique. "
338
+ f"Duplicated entries for view '{view_entity!s}' and "
339
+ f"property '{prop_id!s}' found in rows {rows_str}."
340
+ )
341
+ )
342
+ )
343
+
344
+ return view_props
345
+
346
+ def create_indices(self, read: ReadProperties) -> dict[ParsedEntity, dict[str, Index]]:
347
+ indices: dict[ParsedEntity, dict[str, Index]] = defaultdict(dict)
348
+ for (container_entity, index_id), index_list in read.indices.items():
349
+ if len(index_list) == 0:
350
+ continue
351
+ # Remove duplicates based on prop_id, keeping the first occurrence
352
+ # Note that we have already validated that the index definitions are the same
353
+ index_list = list({read_index.prop_id: read_index for read_index in index_list}.values())
354
+ index = index_list[0].index
355
+ if len(index_list) == 1:
356
+ indices[container_entity][index_id] = index
357
+ continue
358
+ if missing_order := [idx for idx in index_list if idx.order is None]:
359
+ row_str = humanize_collection(
360
+ [self.source.adjust_row_number(self.Sheets.properties, idx.row_no) for idx in missing_order]
361
+ )
362
+ self.errors.append(
363
+ ModelSyntaxError(
364
+ message=(
365
+ f"In table {self.Sheets.properties!r} column {self.PropertyColumns.index!r}: "
366
+ f"the index {index_id!r} on container {container_entity!s} is defined on multiple "
367
+ f"properties. This requires the 'order' attribute to be set. It is missing in rows "
368
+ f"{row_str}."
369
+ )
370
+ )
371
+ )
372
+ continue
373
+ index.properties = [idx.prop_id for idx in sorted(index_list, key=lambda x: x.order or 999)]
374
+ indices[container_entity][index_id] = index
375
+ return indices
376
+
377
+ def create_constraints(self, read: ReadProperties) -> dict[ParsedEntity, dict[str, Constraint]]:
378
+ constraints: dict[ParsedEntity, dict[str, Constraint]] = defaultdict(dict)
379
+ for (container_entity, constraint_id), constraint_list in read.constraints.items():
380
+ if len(constraint_list) == 0:
381
+ continue
382
+ # Remove duplicates based on prop_id, keeping the first occurrence
383
+ # Note that we have already validated that the constraint definitions are the same
384
+ constraint_list = list(
385
+ {read_constraint.prop_id: read_constraint for read_constraint in constraint_list}.values()
386
+ )
387
+ constraint = constraint_list[0].constraint
388
+ if len(constraint_list) == 1 or not isinstance(constraint, UniquenessConstraintDefinition):
389
+ constraints[container_entity][constraint_id] = constraint
390
+ continue
391
+ if missing_order := [c for c in constraint_list if c.order is None]:
392
+ row_str = humanize_collection(
393
+ [self.source.adjust_row_number(self.Sheets.properties, c.row_no) for c in missing_order]
394
+ )
395
+ self.errors.append(
396
+ ModelSyntaxError(
397
+ message=(
398
+ f"In table {self.Sheets.properties!r} column {self.PropertyColumns.constraint!r}: "
399
+ f"the uniqueness constraint {constraint_id!r} on container {container_entity!s} is defined "
400
+ f"on multiple properties. This requires the 'order' attribute to be set. It is missing in "
401
+ f"rows {row_str}."
402
+ )
403
+ )
404
+ )
405
+ continue
406
+ constraint.properties = [c.prop_id for c in sorted(constraint_list, key=lambda x: x.order or 999)]
407
+ constraints[container_entity][constraint_id] = constraint
408
+ return constraints
409
+
410
+ def _process_view_property(
411
+ self,
412
+ prop: DMSProperty,
413
+ read: ReadProperties,
414
+ row_no: int,
415
+ view_ref_by_entity: dict[ViewReference, ParsedEntity],
416
+ view_entities: set[ParsedEntity],
417
+ ) -> None:
418
+ loc = (self.Sheets.properties, row_no)
419
+ data = self.read_view_property(prop, loc)
420
+ view_prop = self._validate_adapter(ViewRequestPropertyAdapter, data, loc)
421
+ if view_prop is None:
422
+ return None
423
+ if prop.view in view_entities:
424
+ read.view[(prop.view, prop.view_property)].append(ReadViewProperty(prop.view_property, row_no, view_prop))
425
+ return None
426
+ # The view entity was not found in the views table. This could either be because the view is missing,
427
+ # or because either the view entity in the Properties table and the View table are specified with/without
428
+ # default space/version inconsistently.
429
+ try:
430
+ view_ref = ViewReference.model_validate(self._create_view_ref(prop.view))
431
+ except ValidationError:
432
+ # Error will be reported when reading the views
433
+ return None
434
+ if view_ref in view_ref_by_entity:
435
+ view_ref_entity = view_ref_by_entity[view_ref]
436
+ read.view[(view_ref_entity, prop.view_property)].append(
437
+ ReadViewProperty(prop.view_property, row_no, view_prop)
438
+ )
439
+ else:
440
+ self.errors.append(
441
+ ModelSyntaxError(
442
+ message=(
443
+ f"In {self.source.location(loc)} the View '{prop.view!s}' "
444
+ f"was not found in the {self.Sheets.views!r} table."
445
+ )
446
+ )
447
+ )
448
+ return None
449
+
450
+ def _process_container_property(
451
+ self,
452
+ prop: DMSProperty,
453
+ read: ReadProperties,
454
+ enum_collections: dict[str, dict[str, Any]],
455
+ row_no: int,
456
+ container_ref_by_entity: dict[ContainerReference, ParsedEntity],
457
+ container_entities: set[ParsedEntity],
458
+ ) -> None:
459
+ loc = (self.Sheets.properties, row_no)
460
+ data = self.read_container_property(prop, enum_collections, loc=loc)
461
+ container_prop = self._validate_obj(ContainerPropertyDefinition, data, loc)
462
+ if container_prop is None:
463
+ return None
464
+ if not (prop.container and prop.container_property):
465
+ return None
466
+ if prop.container in container_entities:
467
+ read.container[(prop.container, prop.container_property)].append(
468
+ ReadContainerProperty(prop.container_property, row_no, container_prop)
469
+ )
470
+ return None
471
+ # The container entity was not found in the containers table. This could either be because the container
472
+ # is missing, or because either the container entity in the Properties table and the Container table are
473
+ # specified with/without default space/version inconsistently.
474
+ try:
475
+ container_ref = ContainerReference.model_validate(self._create_container_ref(prop.container))
476
+ except ValidationError:
477
+ # Error will be reported when reading the containers
478
+ return None
479
+ if container_ref in container_ref_by_entity:
480
+ container_ref_entity = container_ref_by_entity[container_ref]
481
+ read.container[(container_ref_entity, prop.container_property)].append(
482
+ ReadContainerProperty(prop.container_property, row_no, container_prop)
483
+ )
484
+ # Container can be in CDF, this will be reported by a validator later.
485
+ return None
486
+
487
+ def _process_index(
488
+ self,
489
+ prop: DMSProperty,
490
+ read: ReadProperties,
491
+ row_no: int,
492
+ container_ref_by_entity: dict[ContainerReference, ParsedEntity],
493
+ container_entities: set[ParsedEntity],
494
+ ) -> None:
495
+ if prop.index is None or prop.container_property is None or prop.container is None:
496
+ return
497
+
498
+ loc = (self.Sheets.properties, row_no, self.PropertyColumns.index)
499
+ for index in prop.index:
500
+ data = self.read_index(index, prop.container_property)
501
+ created = self._validate_adapter(IndexAdapter, data, loc)
502
+ if created is None:
503
+ continue
504
+ order = self._read_order(index.properties, loc)
505
+
506
+ if prop.container in container_entities:
507
+ read.indices[(prop.container, index.suffix)].append(
508
+ ReadIndex(
509
+ prop_id=prop.container_property,
510
+ order=order,
511
+ row_no=row_no,
512
+ index_id=index.suffix,
513
+ index=created,
514
+ )
515
+ )
516
+ continue
517
+ # The container entity was not found in the containers table. This could either be because the
518
+ # container is missing, or because either the container entity in the Properties table and the
519
+ # Container table are specified with/without default space/version inconsistently.
520
+
521
+ try:
522
+ container_ref = ContainerReference.model_validate(self._create_container_ref(prop.container))
523
+ except ValidationError:
524
+ # Error will be reported when reading the containers
525
+ continue
526
+ if container_ref in container_ref_by_entity:
527
+ container_ref_entity = container_ref_by_entity[container_ref]
528
+ read.indices[(container_ref_entity, index.suffix)].append(
529
+ ReadIndex(
530
+ prop_id=prop.container_property,
531
+ order=order,
532
+ row_no=row_no,
533
+ index_id=index.suffix,
534
+ index=created,
535
+ )
536
+ )
537
+ else:
538
+ # Error is reported when reading the property.
539
+ ...
540
+
541
+ def _read_order(self, properties: dict[str, Any], loc: tuple[str | int, ...]) -> int | None:
542
+ if "order" not in properties:
543
+ return None
544
+ try:
545
+ return int(properties["order"])
546
+ except ValueError:
547
+ self.errors.append(
548
+ ModelSyntaxError(
549
+ message=f"In {self.source.location(loc)} invalid order value '{properties['order']}'. "
550
+ "Must be an integer."
551
+ )
552
+ )
553
+ return None
554
+
555
+ @staticmethod
556
+ def read_index(index: ParsedEntity, prop_id: str) -> dict[str, Any]:
557
+ return {
558
+ "indexType": index.prefix,
559
+ "properties": [prop_id],
560
+ **index.properties,
561
+ }
562
+
563
+ def _process_constraint(
564
+ self,
565
+ prop: DMSProperty,
566
+ read: ReadProperties,
567
+ row_no: int,
568
+ container_ref_by_entity: dict[ContainerReference, ParsedEntity],
569
+ container_entities: set[ParsedEntity],
570
+ ) -> None:
571
+ if prop.constraint is None or prop.container_property is None or prop.container is None:
572
+ return
573
+ loc = (self.Sheets.properties, row_no, self.PropertyColumns.constraint)
574
+ for constraint in prop.constraint:
575
+ data = self.read_property_constraint(constraint, prop.container_property)
576
+ created = self._validate_adapter(ConstraintAdapter, data, loc)
577
+ if created is None:
578
+ continue
579
+ order = self._read_order(constraint.properties, loc)
580
+
581
+ if prop.container in container_entities:
582
+ read.constraints[(prop.container, constraint.suffix)].append(
583
+ ReadConstraint(
584
+ prop_id=prop.container_property,
585
+ order=order,
586
+ constraint_id=constraint.suffix,
587
+ row_no=row_no,
588
+ constraint=created,
589
+ )
590
+ )
591
+ continue
592
+ # The container entity was not found in the containers table. This could either be because the
593
+ # container is missing, or because either the container entity in the Properties table and the
594
+ # Container table are specified with/without default space/version inconsistently.
595
+ try:
596
+ container_ref = ContainerReference.model_validate(self._create_container_ref(prop.container))
597
+ except ValidationError:
598
+ # Error will be reported when reading the containers
599
+ continue
600
+ if container_ref in container_ref_by_entity:
601
+ container_ref_entity = container_ref_by_entity[container_ref]
602
+ read.constraints[(container_ref_entity, constraint.suffix)].append(
603
+ ReadConstraint(
604
+ prop_id=prop.container_property,
605
+ order=order,
606
+ constraint_id=constraint.suffix,
607
+ row_no=row_no,
608
+ constraint=created,
609
+ )
610
+ )
611
+ else:
612
+ # Error is reported when reading the property.
613
+ ...
614
+
615
+ @staticmethod
616
+ def read_property_constraint(constraint: ParsedEntity, prop_id: str) -> dict[str, Any]:
617
+ return {"constraintType": constraint.prefix, "properties": [prop_id], **constraint.properties}
618
+
619
+ def read_view_property(self, prop: DMSProperty, loc: tuple[str | int, ...]) -> dict[str, Any]:
620
+ """Reads a single view property from a given row in the properties table.
621
+
622
+ The type of property (core, edge, reverse direct relation) is determined based on the connection column
623
+ as follows:
624
+ 1. If the connection is empty or 'direct' it is a core property.
625
+ 2. If the connection is 'edge' it is an edge property.
626
+ 3. If the connection is 'reverse' it is a reverse direct relation property
627
+ 4. Otherwise, it is an error.
628
+
629
+ Args:
630
+ prop (DMSProperty): The property row to read.
631
+ loc (tuple[str | int, ...]): The location of the property in the source for error reporting.
632
+
633
+ Returns:
634
+ ViewRequestProperty: The parsed view property.
635
+ """
636
+
637
+ if prop.connection is None or prop.connection.suffix == "direct":
638
+ return self.read_core_view_property(prop)
639
+ elif prop.connection.suffix == "edge":
640
+ return self.read_edge_view_property(prop, loc)
641
+ elif prop.connection.suffix == "reverse":
642
+ return self.read_reverse_direct_relation_view_property(prop)
643
+ else:
644
+ self.errors.append(
645
+ ModelSyntaxError(
646
+ message=f"In {self.source.location(loc)} invalid connection type '{prop.connection.suffix}'. "
647
+ )
648
+ )
649
+ return {}
650
+
651
+ def read_core_view_property(self, prop: DMSProperty) -> dict[str, Any]:
652
+ source: dict[str, str | None] | None = None
653
+ if prop.connection is not None and prop.value_type.suffix != self.CELL_MISSING:
654
+ source = self._create_view_ref(prop.value_type)
655
+
656
+ return dict(
657
+ connectionType="primary_property",
658
+ name=prop.name,
659
+ description=prop.description,
660
+ container=self._create_container_ref(prop.container),
661
+ containerPropertyIdentifier=prop.container_property,
662
+ source=source,
663
+ )
664
+
665
+ def read_edge_view_property(self, prop: DMSProperty, loc: tuple[str | int, ...]) -> dict[str, Any]:
666
+ if prop.connection is None:
667
+ return {}
668
+ edge_source: dict[str, str | None] | None = None
669
+ if "edgeSource" in prop.connection.properties:
670
+ edge_source = self._create_view_ref_unparsed(
671
+ prop.connection.properties["edgeSource"], (*loc, self.PropertyColumns.connection, "edgeSource")
672
+ )
673
+ return dict(
674
+ connectionType="single_edge_connection" if prop.max_count == 1 else "multi_edge_connection",
675
+ name=prop.name,
676
+ description=prop.description,
677
+ source=self._create_view_ref(prop.value_type),
678
+ type=self._create_node_ref_unparsed(
679
+ prop.connection.properties.get("type"),
680
+ prop.view,
681
+ prop.view_property,
682
+ (*loc, self.PropertyColumns.connection, "type"),
683
+ ),
684
+ edgeSource=edge_source,
685
+ direction=prop.connection.properties.get("direction", "outwards"),
686
+ )
687
+
688
+ def read_reverse_direct_relation_view_property(
689
+ self,
690
+ prop: DMSProperty,
691
+ ) -> dict[str, Any]:
692
+ if prop.connection is None:
693
+ return {}
694
+ view_ref = self._create_view_ref(prop.value_type)
695
+ return dict(
696
+ connectionType="single_reverse_direct_relation" if prop.max_count == 1 else "multi_reverse_direct_relation",
697
+ name=prop.name,
698
+ description=prop.description,
699
+ source=view_ref,
700
+ through={
701
+ "source": view_ref,
702
+ "identifier": prop.connection.properties.get("property"),
703
+ },
704
+ )
705
+
706
+ def read_container_property(
707
+ self, prop: DMSProperty, enum_collections: dict[str, dict[str, Any]], loc: tuple[str | int, ...]
708
+ ) -> dict[str, Any]:
709
+ data_type = self._read_data_type(prop, enum_collections, loc)
710
+ return dict(
711
+ immutable=prop.immutable,
712
+ nullable=prop.min_count == 0 or prop.min_count is None,
713
+ autoIncrement=prop.auto_increment,
714
+ defaultValue=prop.default,
715
+ description=prop.container_property_description,
716
+ name=prop.container_property_name,
717
+ type=data_type,
718
+ )
719
+
720
+ def _read_data_type(
721
+ self, prop: DMSProperty, enum_collections: dict[str, dict[str, Any]], loc: tuple[str | int, ...]
722
+ ) -> dict[str, Any]:
723
+ # Implementation to read the container property type from DMSProperty
724
+ is_list = None if prop.max_count is None else prop.max_count > 1
725
+ max_list_size: int | None = None
726
+ if is_list and prop.max_count is not None:
727
+ max_list_size = prop.max_count
728
+
729
+ args: dict[str, Any] = {
730
+ "maxListSize": max_list_size,
731
+ "list": is_list,
732
+ "type": "direct" if prop.connection is not None else prop.value_type.suffix,
733
+ }
734
+ args.update(prop.value_type.properties)
735
+ if "container" in args and prop.connection is not None:
736
+ # Direct relation constraint.
737
+ args["container"] = self._create_container_ref_unparsed(
738
+ prop.connection.properties["container"], (*loc, self.PropertyColumns.connection, "container")
739
+ )
740
+ if args["type"] == "enum" and "collection" in prop.value_type.properties:
741
+ args["values"] = enum_collections.get(prop.value_type.properties["collection"], {})
742
+ return args
743
+
744
+ def read_containers(
745
+ self, containers: list[DMSContainer], properties: ProcessedProperties
746
+ ) -> list[ContainerRequest]:
747
+ # Implementation to read containers from DMSContainer list
748
+ containers_requests: list[ContainerRequest] = []
749
+ rows_by_seen: dict[ParsedEntity, list[int]] = defaultdict(list)
750
+ for row_no, container in enumerate(containers):
751
+ property_constraints = properties.constraints.get(container.container, {})
752
+ require_constraints = self.read_container_constraints(container, row_no)
753
+ if conflict := set(property_constraints.keys()).intersection(set(require_constraints.keys())):
754
+ conflict_str = humanize_collection(conflict)
755
+ location_str = self.source.location((self.Sheets.containers, row_no, self.ContainerColumns.constraint))
756
+ self.errors.append(
757
+ ModelSyntaxError(
758
+ message=(
759
+ f"In {location_str} the container '{container.container!s}' has constraints defined "
760
+ f"with the same identifier(s) as the uniqueness constraint defined in the "
761
+ f"{self.Sheets.properties} sheet. Ensure that the identifiers are unique. "
762
+ f"Conflicting identifiers: {conflict_str}. "
763
+ )
764
+ )
765
+ )
766
+ constraints = {**property_constraints, **require_constraints}
767
+ container_request = self._validate_obj(
768
+ ContainerRequest,
769
+ dict(
770
+ **self._create_container_ref(container.container),
771
+ usedFor=container.used_for,
772
+ name=container.name,
773
+ description=container.description,
774
+ properties=properties.container[container.container],
775
+ indexes=properties.indices.get(container.container),
776
+ constraints=constraints or None,
777
+ ),
778
+ (self.Sheets.containers, row_no),
779
+ )
780
+ if container_request is None:
781
+ continue
782
+ if container.container in rows_by_seen:
783
+ rows_by_seen[container.container].append(row_no)
784
+ else:
785
+ containers_requests.append(container_request)
786
+ rows_by_seen[container.container] = [row_no]
787
+ for entity, rows in rows_by_seen.items():
788
+ if len(rows) > 1:
789
+ rows_str = humanize_collection([self.source.adjust_row_number(self.Sheets.containers, r) for r in rows])
790
+ self.errors.append(
791
+ ModelSyntaxError(
792
+ message=(
793
+ f"In {self.source.location((self.Sheets.containers,))} the values in "
794
+ f"column {self.ContainerColumns.container!r} must be unique. "
795
+ f"Duplicated entries for container '{entity!s}' found in rows {rows_str}."
796
+ )
797
+ )
798
+ )
799
+ return containers_requests
800
+
801
+ def read_container_constraints(self, container: DMSContainer, row_no: int) -> dict[str, Constraint]:
802
+ constraints: dict[str, Constraint] = {}
803
+ if not container.constraint:
804
+ return constraints
805
+ for entity in container.constraint:
806
+ loc = self.Sheets.containers, row_no, self.ContainerColumns.constraint
807
+ if entity.prefix != "requires":
808
+ self.errors.append(
809
+ ModelSyntaxError(
810
+ message=(
811
+ f"In {self.source.location(loc)} the constraint '{entity.suffix}' on container "
812
+ f"'{container.container!s}' has an invalid type '{entity.prefix}'. Only 'requires' "
813
+ f"constraints are supported at the container level."
814
+ )
815
+ )
816
+ )
817
+ continue
818
+
819
+ if "require" not in entity.properties:
820
+ self.errors.append(
821
+ ModelSyntaxError(
822
+ message=(
823
+ f"In {self.source.location(loc)} the constraint '{entity.suffix}' on container "
824
+ f"'{container.container!s}' is missing the "
825
+ f"'require' property which is required for container level constraints."
826
+ )
827
+ )
828
+ )
829
+ continue
830
+ data = {
831
+ "constraintType": entity.prefix,
832
+ "require": self._create_container_ref_unparsed(entity.properties["require"], loc),
833
+ }
834
+ created = self._validate_adapter(ConstraintAdapter, data, loc)
835
+ if created is None:
836
+ continue
837
+ constraints[entity.suffix] = created
838
+ return constraints
839
+
840
+ def read_views(
841
+ self,
842
+ views: list[DMSView],
843
+ properties: dict[ParsedEntity, dict[str, ViewRequestProperty]],
844
+ ) -> tuple[list[ViewRequest], set[ParsedEntity]]:
845
+ views_requests: list[ViewRequest] = []
846
+ rows_by_seen: dict[ParsedEntity, list[int]] = defaultdict(list)
847
+ for row_no, view in enumerate(views):
848
+ filter_dict: dict[str, Any] | None = None
849
+ if view.filter is not None:
850
+ try:
851
+ filter_dict = json.loads(view.filter)
852
+ except ValueError as e:
853
+ self.errors.append(
854
+ ModelSyntaxError(
855
+ message=(
856
+ f"In {self.source.location((self.Sheets.views, row_no, self.ViewColumns.filter))} "
857
+ f"must be valid json. Got error {e!s}"
858
+ )
859
+ )
860
+ )
861
+ view_request = self._validate_obj(
862
+ ViewRequest,
863
+ dict(
864
+ **self._create_view_ref(view.view),
865
+ name=view.name,
866
+ description=view.description,
867
+ implements=[self._create_view_ref(impl) for impl in view.implements] if view.implements else None,
868
+ filter=filter_dict,
869
+ properties=properties.get(view.view, {}),
870
+ ),
871
+ (self.Sheets.views, row_no),
872
+ )
873
+ if view_request is None:
874
+ continue
875
+ if view.view in rows_by_seen:
876
+ rows_by_seen[view.view].append(row_no)
877
+ else:
878
+ views_requests.append(view_request)
879
+ rows_by_seen[view.view] = [row_no]
880
+ for entity, rows in rows_by_seen.items():
881
+ if len(rows) > 1:
882
+ rows_str = humanize_collection([self.source.adjust_row_number(self.Sheets.views, r) for r in rows])
883
+ self.errors.append(
884
+ ModelSyntaxError(
885
+ message=(
886
+ f"In {self.source.location((self.Sheets.views,))} the values in "
887
+ f"column {self.ViewColumns.view!r} must be unique. "
888
+ f"Duplicated entries for view '{entity!s}' found in rows {rows_str}."
889
+ )
890
+ )
891
+ )
892
+ return views_requests, set(rows_by_seen.keys())
893
+
894
+ def read_data_model(self, tables: TableDMS, valid_view_entities: set[ParsedEntity]) -> DataModelRequest:
895
+ data: dict[str, Any] = {
896
+ **{meta.key: meta.value for meta in tables.metadata},
897
+ "views": [self._create_view_ref(view.view) for view in tables.views if view.view in valid_view_entities],
898
+ }
899
+ if description := self._create_description_field(data):
900
+ data["description"] = description
901
+ model = self._validate_obj(DataModelRequest, data, (self.Sheets.metadata,), field_name="value")
902
+ if model is None:
903
+ # This is the last step, so we can raise the error here.
904
+ raise DataModelImportException(self.errors) from None
905
+ return model
906
+
907
+ def _create_description_field(self, data: dict[str, Any]) -> str | None:
908
+ """DataModelRequest does not have a 'creator' field, this is a special addition that the Neat tables
909
+ format supports (and recommends using). To keep it, Neat adds it to the suffix of the description field.
910
+ """
911
+ if CREATOR_KEY not in data and CREATOR_KEY.title() not in data:
912
+ return None
913
+ creator_val = data.pop(CREATOR_KEY, data.pop(CREATOR_KEY.title(), None))
914
+
915
+ if not creator_val:
916
+ return None
917
+
918
+ creator = str(creator_val)
919
+ # We do a split/join to clean up any spaces around commas. Ensuring that we have a consistent
920
+ # canonical format.
921
+ cleaned_creator = ", ".join(item.strip() for item in creator.split(","))
922
+ if not cleaned_creator:
923
+ return None
924
+ suffix = f"{CREATOR_MARKER}{cleaned_creator}"
925
+ description = data.get("description", "")
926
+ if len(description) + len(suffix) > DATA_MODEL_DESCRIPTION_MAX_LENGTH:
927
+ description = description[: DATA_MODEL_DESCRIPTION_MAX_LENGTH - len(suffix) - 4] + "..."
928
+ if description:
929
+ description = f"{description} {suffix}"
930
+ else:
931
+ description = suffix
932
+ return description
933
+
934
+ def _parse_entity(self, entity: str, loc: tuple[str | int, ...]) -> ParsedEntity | None:
935
+ try:
936
+ parsed = parse_entity(entity)
937
+ except ValueError as e:
938
+ self.errors.append(
939
+ ModelSyntaxError(message=f"In {self.source.location(loc)} failed to parse entity '{entity}': {e!s}")
940
+ )
941
+ return None
942
+ return parsed
943
+
944
+ def _create_view_ref_unparsed(self, entity: str, loc: tuple[str | int, ...]) -> dict[str, str | None]:
945
+ parsed = self._parse_entity(entity, loc)
946
+ if parsed is None:
947
+ return dict()
948
+ return self._create_view_ref(parsed)
949
+
950
+ def _create_view_ref(self, entity: ParsedEntity | None) -> dict[str, str | None]:
951
+ if entity is None or entity.suffix == "":
952
+ # If no suffix is given, we cannot create a valid reference.
953
+ return dict()
954
+ space, version = entity.prefix, entity.properties.get("version")
955
+ if space == "":
956
+ space = self.default_space
957
+ # Only if default space is used, we can use default version.
958
+ if version is None:
959
+ version = self.default_version
960
+ return {
961
+ "space": space,
962
+ "externalId": entity.suffix,
963
+ "version": version,
964
+ }
965
+
966
+ def _create_container_ref_unparsed(self, entity: str, loc: tuple[str | int, ...]) -> dict[str, str]:
967
+ parsed = self._parse_entity(entity, loc)
968
+ if parsed is None:
969
+ return dict()
970
+ return self._create_container_ref(parsed)
971
+
972
+ def _create_container_ref(self, entity: ParsedEntity | None) -> dict[str, str]:
973
+ if entity is None or entity.suffix == "":
974
+ # If no suffix is given, we cannot create a valid reference.
975
+ return dict()
976
+ return {
977
+ "space": entity.prefix or self.default_space,
978
+ "externalId": entity.suffix,
979
+ }
980
+
981
+ def _create_node_ref_unparsed(
982
+ self, entity: str | None, view: ParsedEntity, view_prop: str, loc: tuple[str | int, ...]
983
+ ) -> dict[str, str | None]:
984
+ if entity is None:
985
+ # Use default
986
+ return self._create_node_ref(None, view, view_prop)
987
+ parsed = self._parse_entity(entity, loc)
988
+ if parsed is None:
989
+ return dict()
990
+ return self._create_node_ref(parsed, view, view_prop)
991
+
992
+ @overload
993
+ def _create_node_ref(
994
+ self, entity: ParsedEntity, *, view: None = None, view_prop: None = None
995
+ ) -> dict[str, str | None]: ...
996
+
997
+ @overload
998
+ def _create_node_ref(
999
+ self, entity: ParsedEntity | None, view: ParsedEntity, view_prop: str
1000
+ ) -> dict[str, str | None]: ...
1001
+
1002
+ def _create_node_ref(
1003
+ self, entity: ParsedEntity | None, view: ParsedEntity | None = None, view_prop: str | None = None
1004
+ ) -> dict[str, str | None]:
1005
+ if entity is None or entity.suffix == "":
1006
+ if view is None or view_prop is None:
1007
+ return dict()
1008
+ # If no suffix is given, we fallback to the view's property
1009
+ return {
1010
+ "space": view.prefix or self.default_space,
1011
+ "externalId": f"{view.suffix}.{view_prop}",
1012
+ }
1013
+ return {
1014
+ "space": entity.prefix or self.default_space,
1015
+ "externalId": entity.suffix,
1016
+ }
1017
+
1018
+ def _validate_obj(
1019
+ self,
1020
+ obj: type[T_BaseModel],
1021
+ data: dict,
1022
+ parent_loc: tuple[str | int, ...],
1023
+ field_name: Literal["field", "column", "value"] = "column",
1024
+ ) -> T_BaseModel | None:
1025
+ try:
1026
+ return obj.model_validate(data)
1027
+ except ValidationError as e:
1028
+ self._add_error_messages(e, parent_loc, field_name=field_name)
1029
+ return None
1030
+
1031
+ def _validate_adapter(
1032
+ self, adapter: TypeAdapter[T_BaseModel], data: dict[str, Any], parent_loc: tuple[str | int, ...]
1033
+ ) -> T_BaseModel | None:
1034
+ try:
1035
+ return adapter.validate_python(data, strict=True)
1036
+ except ValidationError as e:
1037
+ self._add_error_messages(e, parent_loc, field_name="column")
1038
+ return None
1039
+
1040
+ def _add_error_messages(
1041
+ self,
1042
+ error: ValidationError,
1043
+ parent_loc: tuple[str | int, ...],
1044
+ field_name: Literal["field", "column", "value"] = "column",
1045
+ ) -> None:
1046
+ context = ValidationContext(
1047
+ parent_loc=parent_loc,
1048
+ humanize_location=self.source.location,
1049
+ field_name=field_name,
1050
+ missing_required_descriptor="empty" if field_name == "column" else "missing",
1051
+ )
1052
+
1053
+ if field_renaming := self.source.field_mapping(parent_loc[0]):
1054
+ context.field_renaming = field_renaming
1055
+
1056
+ seen: set[str] = set()
1057
+ for error_details in error.errors(include_input=True, include_url=False):
1058
+ message = humanize_validation_error(error_details, context)
1059
+ if message in seen:
1060
+ continue
1061
+
1062
+ seen.add(message)
1063
+ self.errors.append(ModelSyntaxError(message=message))