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,230 @@
1
+ import re
2
+ import sys
3
+ from abc import ABC
4
+ from typing import Any, ClassVar, Final, Literal, TypeVar, cast, get_args
5
+
6
+ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
7
+ from rdflib import Literal as RDFLiteral
8
+ from rdflib import URIRef
9
+
10
+ from cognite.neat.v0.core._data_model._constants import EntityTypes
11
+ from cognite.neat.v0.core._data_model.models.data_types import _XSD_TYPES, DataType
12
+ from cognite.neat.v0.core._data_model.models.entities._constants import _PARSE
13
+ from cognite.neat.v0.core._data_model.models.entities._single_value import ConceptEntity, ConceptualEntity
14
+ from cognite.neat.v0.core._issues.errors._general import NeatValueError
15
+ from cognite.neat.v0.core._utils.rdf_ import remove_namespace_from_uri
16
+
17
+ if sys.version_info <= (3, 11):
18
+ from typing_extensions import Self
19
+ else:
20
+ from typing import Self
21
+
22
+
23
+ ValueConstraints = Literal["allValuesFrom", "someValuesFrom", "hasValue"]
24
+ CardinalityConstraints = Literal["minCardinality", "maxCardinality", "cardinality", "qualifiedCardinality"]
25
+
26
+
27
+ # Constants for regex patterns - more maintainable
28
+ PROPERTY_PATTERN: Final[str] = r"[a-zA-Z0-9._~?@!$&'*+,;=%-]+"
29
+ VALUE_PATTERN: Final[str] = r".+"
30
+ CARDINALITY_VALUE_PATTERN: Final[str] = r"\d+"
31
+ ON_PATTERN: Final[str] = r"[^(]*"
32
+
33
+ VALUE_CONSTRAINT_REGEX = re.compile(
34
+ rf"^{EntityTypes.value_constraint}:(?P<property>{PROPERTY_PATTERN})\((?P<constraint>{'|'.join(get_args(ValueConstraints))}),(?P<value>{VALUE_PATTERN})\)$"
35
+ )
36
+
37
+ CARDINALITY_CONSTRAINT_REGEX = re.compile(
38
+ rf"^{EntityTypes.cardinality_constraint}:(?P<property>{PROPERTY_PATTERN})\((?P<constraint>{'|'.join(get_args(CardinalityConstraints))}),(?P<value>{CARDINALITY_VALUE_PATTERN})(?:,(?P<on>{ON_PATTERN}))?\)$"
39
+ )
40
+
41
+
42
+ class NamedIndividualEntity(ConceptualEntity):
43
+ type_: ClassVar[EntityTypes] = EntityTypes.named_individual
44
+
45
+ @model_validator(mode="after")
46
+ def reset_prefix(self) -> Self:
47
+ self.prefix = "ni"
48
+ return self
49
+
50
+
51
+ class ConceptPropertyRestriction(ABC, BaseModel):
52
+ model_config: ClassVar[ConfigDict] = ConfigDict(
53
+ str_strip_whitespace=True,
54
+ arbitrary_types_allowed=True,
55
+ strict=False,
56
+ extra="ignore",
57
+ )
58
+ type_: ClassVar[EntityTypes] = EntityTypes.concept_restriction
59
+ property_: str
60
+
61
+ @classmethod
62
+ def load(cls: "type[T_ConceptPropertyRestriction]", data: Any, **defaults: Any) -> "T_ConceptPropertyRestriction":
63
+ if isinstance(data, cls):
64
+ return data
65
+ elif not isinstance(data, str):
66
+ raise ValueError(f"Cannot load {cls.__name__} from {data}")
67
+
68
+ return cls.model_validate({_PARSE: data, "defaults": defaults})
69
+
70
+ @model_validator(mode="before")
71
+ def _load(cls, data: Any) -> dict:
72
+ defaults = {}
73
+ if isinstance(data, dict) and _PARSE in data:
74
+ defaults = data.get("defaults", {})
75
+ data = data[_PARSE]
76
+ if isinstance(data, dict):
77
+ data.update(defaults)
78
+ return data
79
+
80
+ if not isinstance(data, str):
81
+ raise ValueError(f"Cannot load {cls.__name__} from {data}")
82
+
83
+ return cls._parse(data, defaults)
84
+
85
+ @classmethod
86
+ def _parse(cls, data: str, defaults: dict) -> dict:
87
+ raise NotImplementedError(f"{cls.__name__} must implement _parse method")
88
+
89
+ def dump(self) -> str:
90
+ return self.__str__()
91
+
92
+ def as_tuple(self) -> tuple[str, ...]:
93
+ # We haver overwritten the serialization to str, so we need to do it manually
94
+ extra: tuple[str, ...] = tuple(
95
+ [
96
+ str(v or "")
97
+ for field_name in self.model_fields.keys()
98
+ if (v := getattr(self, field_name)) and field_name not in {"property_"}
99
+ ]
100
+ )
101
+
102
+ return self.property_, *extra
103
+
104
+ def __lt__(self, other: object) -> bool:
105
+ if not isinstance(other, ConceptPropertyRestriction):
106
+ return NotImplemented
107
+ return self.as_tuple() < other.as_tuple()
108
+
109
+ def __eq__(self, other: object) -> bool:
110
+ if not isinstance(other, ConceptPropertyRestriction):
111
+ return NotImplemented
112
+ return self.as_tuple() == other.as_tuple()
113
+
114
+ def __hash__(self) -> int:
115
+ return hash(str(self))
116
+
117
+
118
+ T_ConceptPropertyRestriction = TypeVar("T_ConceptPropertyRestriction", bound="ConceptPropertyRestriction")
119
+
120
+
121
+ class ConceptPropertyValueConstraint(ConceptPropertyRestriction):
122
+ type_: ClassVar[EntityTypes] = EntityTypes.value_constraint
123
+ constraint: ValueConstraints
124
+ value: RDFLiteral | ConceptEntity | NamedIndividualEntity
125
+
126
+ @field_validator("value")
127
+ def validate_value(cls, value: Any) -> Any:
128
+ if isinstance(value, RDFLiteral) and value.datatype is None:
129
+ raise NeatValueError("RDFLiteral must have a datatype set, which must be one of the XSD types.")
130
+ return value
131
+
132
+ def __str__(self) -> str:
133
+ value_str = (
134
+ f"{self.value.value}^^{remove_namespace_from_uri(cast(URIRef, self.value.datatype))}"
135
+ if isinstance(self.value, RDFLiteral)
136
+ else str(self.value)
137
+ )
138
+ return f"{self.type_}:{self.property_}({self.constraint},{value_str})"
139
+
140
+ @classmethod
141
+ def _parse(cls, data: str, defaults: dict) -> dict:
142
+ if not (result := VALUE_CONSTRAINT_REGEX.match(data)):
143
+ raise NeatValueError(f"Invalid value constraint format: {data}")
144
+
145
+ property_ = result.group("property")
146
+ constraint = result.group("constraint")
147
+ raw_value = result.group("value")
148
+
149
+ value: NamedIndividualEntity | RDFLiteral | ConceptEntity
150
+ # scenario 1: NamedIndividual as value restriction
151
+ if raw_value.startswith("ni:"):
152
+ value = NamedIndividualEntity.load(raw_value)
153
+ # scenario 2: Datatype as value restriction
154
+ elif "^^" in raw_value:
155
+ if len(value_components := raw_value.split("^^")) == 2 and value_components[1] in _XSD_TYPES:
156
+ value = RDFLiteral(value_components[0], datatype=DataType.load(value_components[1]).as_xml_uri_ref())
157
+ else:
158
+ raise NeatValueError(f"Invalid value format for datatype: {raw_value}")
159
+
160
+ # scenario 3: ConceptEntity as value restriction
161
+ else:
162
+ value = ConceptEntity.load(raw_value, **defaults)
163
+
164
+ return dict(property_=property_, constraint=constraint, value=value)
165
+
166
+
167
+ class ConceptPropertyCardinalityConstraint(ConceptPropertyRestriction):
168
+ type_: ClassVar[EntityTypes] = EntityTypes.cardinality_constraint
169
+ constraint: CardinalityConstraints
170
+ value: int = Field(ge=0)
171
+ on: DataType | ConceptEntity | None = None
172
+
173
+ def __str__(self) -> str:
174
+ on_str = f",{self.on}" if self.on else ""
175
+ return f"{self.type_}:{self.property_}({self.constraint},{self.value}{on_str})"
176
+
177
+ @classmethod
178
+ def _parse(cls, data: str, defaults: dict) -> dict:
179
+ if not (result := CARDINALITY_CONSTRAINT_REGEX.match(data)):
180
+ raise NeatValueError(f"Invalid cardinality constraint format: {data}")
181
+
182
+ property_ = result.group("property")
183
+ constraint = result.group("constraint")
184
+ value = result.group("value")
185
+ on = result.group("on")
186
+ if on:
187
+ if on in _XSD_TYPES:
188
+ on = DataType.load(on)
189
+ else:
190
+ on = cast(ConceptEntity, ConceptEntity.load(on, **defaults))
191
+
192
+ return dict(property_=property_, constraint=constraint, value=value, on=on)
193
+
194
+
195
+ def parse_restriction(data: str, **defaults: Any) -> ConceptPropertyRestriction:
196
+ """Parse a string to create either a value or cardinality restriction.
197
+
198
+ Args:
199
+ data: String representation of the restriction
200
+ **defaults: Default values to use when parsing
201
+
202
+ Returns:
203
+ Either a ConceptPropertyValueConstraint or ConceptPropertyCardinalityConstraint
204
+
205
+ Raises:
206
+ NeatValueError: If the string cannot be parsed as either restriction type
207
+ """
208
+ # Check for value constraint pattern first (more specific)
209
+ if VALUE_CONSTRAINT_REGEX.match(data):
210
+ try:
211
+ return ConceptPropertyValueConstraint.load(data, **defaults)
212
+ except Exception as e:
213
+ raise NeatValueError(f"Failed to parse value constraint: {data}") from e
214
+
215
+ # Check for cardinality constraint pattern
216
+ if CARDINALITY_CONSTRAINT_REGEX.match(data):
217
+ try:
218
+ return ConceptPropertyCardinalityConstraint.load(data, **defaults)
219
+ except Exception as e:
220
+ raise NeatValueError(f"Failed to parse cardinality constraint: {data}") from e
221
+
222
+ # If neither pattern matches, provide a clear error
223
+ raise NeatValueError(
224
+ f"Invalid restriction format: {data}. "
225
+ f"Expected format: '{EntityTypes.value_constraint}:property(constraint,value)' "
226
+ f"or '{EntityTypes.cardinality_constraint}:property(constraint,value[,on])'"
227
+ )
228
+
229
+
230
+ T_ConceptRestriction = TypeVar("T_ConceptRestriction", bound=ConceptPropertyRestriction)
@@ -22,8 +22,8 @@ from pydantic import (
22
22
  model_validator,
23
23
  )
24
24
 
25
- from cognite.neat.core._issues.errors import NeatValueError
26
- from cognite.neat.core._utils.text import replace_non_alphanumeric_with_underscore
25
+ from cognite.neat.v0.core._issues.errors import NeatValueError
26
+ from cognite.neat.v0.core._utils.text import replace_non_alphanumeric_with_underscore
27
27
 
28
28
  if sys.version_info >= (3, 11):
29
29
  from enum import StrEnum
@@ -32,7 +32,7 @@ else:
32
32
  from backports.strenum import StrEnum
33
33
  from typing_extensions import Self
34
34
 
35
- from cognite.neat.core._data_model._constants import (
35
+ from cognite.neat.v0.core._data_model._constants import (
36
36
  ENTITY_PATTERN,
37
37
  SPLIT_ON_COMMA_PATTERN,
38
38
  SPLIT_ON_EDGE_ENTITY_ARGS_PATTERN,
@@ -59,7 +59,13 @@ class ConceptualEntity(BaseModel, extra="ignore"):
59
59
 
60
60
  @classmethod
61
61
  @overload
62
- def load(cls: "type[T_Entity]", data: Any, strict: Literal[True], **defaults: Any) -> "T_Entity": ...
62
+ def load(
63
+ cls: "type[T_Entity]",
64
+ data: Any,
65
+ strict: Literal[True],
66
+ return_on_failure: Literal[False] = False,
67
+ **defaults: Any,
68
+ ) -> "T_Entity": ...
63
69
 
64
70
  @classmethod
65
71
  @overload
@@ -67,25 +73,59 @@ class ConceptualEntity(BaseModel, extra="ignore"):
67
73
  cls: "type[T_Entity]",
68
74
  data: Any,
69
75
  strict: Literal[False] = False,
76
+ return_on_failure: Literal[False] = False,
70
77
  **defaults: Any,
71
78
  ) -> "T_Entity | UnknownEntity": ...
72
79
 
73
80
  @classmethod
74
- def load(cls: "type[T_Entity]", data: Any, strict: bool = False, **defaults: Any) -> "T_Entity | UnknownEntity":
81
+ @overload
82
+ def load(
83
+ cls: "type[T_Entity]",
84
+ data: Any,
85
+ strict: Literal[False] = False,
86
+ return_on_failure: Literal[True] = True,
87
+ **defaults: Any,
88
+ ) -> "T_Entity | Any": ...
89
+
90
+ @classmethod
91
+ @overload
92
+ def load(
93
+ cls: "type[T_Entity]",
94
+ data: Any,
95
+ strict: Literal[True] = True,
96
+ return_on_failure: Literal[True] = True,
97
+ **defaults: Any,
98
+ ) -> "T_Entity | Any": ...
99
+
100
+ @classmethod
101
+ def load(
102
+ cls: "type[T_Entity]", data: Any, strict: bool = False, return_on_failure: bool = False, **defaults: Any
103
+ ) -> "T_Entity | UnknownEntity | Any":
104
+ """Loads an entity from a string or dict representation.
105
+
106
+ Args:
107
+ data: The data to load the entity from. Can be a string or a dict.
108
+ strict: If True, will raise an error if the data is "unknown".
109
+ return_on_failure: If True, will return the input data if loading fails.
110
+ This is used when you want to defer error handling to a later stage.
111
+ defaults: Default values to use when loading the entity. These will be used if the corresponding
112
+ """
75
113
  if isinstance(data, cls):
76
114
  return data
77
115
  elif isinstance(data, str) and data == str(Unknown):
78
116
  if strict:
79
117
  raise NeatValueError(f"Failed to load entity {data!s}")
80
118
  return UnknownEntity(prefix=Undefined, suffix=Unknown)
81
- if defaults and isinstance(defaults, dict):
82
- # This is a trick to pass in default values
83
- try:
119
+ try:
120
+ if defaults and isinstance(defaults, dict):
121
+ # This is a trick to pass in default values
84
122
  return cls.model_validate({_PARSE: data, "defaults": defaults})
85
- except ValueError:
86
- raise
87
- else:
88
- return cls.model_validate(data)
123
+ else:
124
+ return cls.model_validate(data)
125
+ except ValueError:
126
+ if return_on_failure:
127
+ return data
128
+ raise
89
129
 
90
130
  @model_validator(mode="before")
91
131
  def _load(cls, data: Any) -> "dict | ConceptualEntity":
@@ -342,7 +382,13 @@ class PhysicalEntity(ConceptualEntity, Generic[T_ID], ABC):
342
382
 
343
383
  @classmethod # type: ignore[override]
344
384
  @overload
345
- def load(cls: "type[T_DMSEntity]", data: Any, strict: Literal[True], **defaults: Any) -> "T_DMSEntity": ...
385
+ def load(
386
+ cls: "type[T_DMSEntity]",
387
+ data: Any,
388
+ strict: Literal[True],
389
+ return_on_failure: Literal[False] = False,
390
+ **defaults: Any,
391
+ ) -> "T_DMSEntity": ...
346
392
 
347
393
  @classmethod
348
394
  @overload
@@ -350,18 +396,56 @@ class PhysicalEntity(ConceptualEntity, Generic[T_ID], ABC):
350
396
  cls: "type[T_DMSEntity]",
351
397
  data: Any,
352
398
  strict: Literal[False] = False,
399
+ return_on_failure: Literal[False] = False,
353
400
  **defaults: Any,
354
401
  ) -> "T_DMSEntity | PhysicalUnknownEntity": ...
355
402
 
356
403
  @classmethod
404
+ @overload
357
405
  def load(
358
- cls: "type[T_DMSEntity]", data: Any, strict: bool = False, **defaults: Any
359
- ) -> "T_DMSEntity | PhysicalUnknownEntity": # type: ignore
406
+ cls: "type[T_DMSEntity]",
407
+ data: Any,
408
+ strict: Literal[False] = False,
409
+ return_on_failure: Literal[True] = True,
410
+ **defaults: Any,
411
+ ) -> "T_DMSEntity | Any": ...
412
+
413
+ @classmethod
414
+ @overload
415
+ def load(
416
+ cls: "type[T_DMSEntity]",
417
+ data: Any,
418
+ strict: Literal[True] = True,
419
+ return_on_failure: Literal[True] = True,
420
+ **defaults: Any,
421
+ ) -> "T_DMSEntity | Any": ...
422
+
423
+ @classmethod
424
+ def load(
425
+ cls: "type[T_DMSEntity]",
426
+ data: Any,
427
+ strict: Literal[True, False] = False,
428
+ return_on_failure: Literal[True, False] = False,
429
+ **defaults: Any,
430
+ ) -> "T_DMSEntity | PhysicalUnknownEntity | Any":
431
+ """Loads a DMS entity from a string or dict representation.
432
+
433
+ Args:
434
+ data: The data to load the entity from. Can be a string or a dict.
435
+ strict: If True, will raise an error if the data is "unknown".
436
+ return_on_failure: If True, will return the input data if loading fails.
437
+ This is used when you want to defer error handling to a later stage.
438
+ defaults: Default values to use when loading the entity. These will be used if the corresponding
439
+ fields are missing in the input data.
440
+
441
+ """
360
442
  if isinstance(data, str) and data == str(Unknown):
361
443
  if strict:
362
444
  raise NeatValueError(f"Failed to load entity {data!s}")
363
445
  return PhysicalUnknownEntity.from_id(None)
364
- return cast(T_DMSEntity, super().load(data, **defaults))
446
+ if isinstance(data, UnknownEntity):
447
+ return PhysicalUnknownEntity.from_id(None)
448
+ return cast(T_DMSEntity, super().load(data, strict=False, return_on_failure=return_on_failure, **defaults))
365
449
 
366
450
  @property
367
451
  def space(self) -> str:
@@ -495,6 +579,13 @@ class EdgeEntity(PhysicalEntity[None]):
495
579
  properties: ViewEntity | None = None
496
580
  direction: Literal["outwards", "inwards"] = "outwards"
497
581
 
582
+ @field_validator("direction", mode="before")
583
+ @classmethod
584
+ def _normalize_direction(cls, value: Any) -> str:
585
+ if isinstance(value, str):
586
+ return value.lower()
587
+ return value
588
+
498
589
  def dump(self, **defaults: Any) -> str:
499
590
  # Add default direction
500
591
  return super().dump(**defaults, direction="outwards")
@@ -569,3 +660,17 @@ class ContainerIndexEntity(PhysicalEntity[None]):
569
660
  @classmethod
570
661
  def from_id(cls, id: None) -> Self:
571
662
  return cls(suffix="dummy")
663
+
664
+
665
+ class ContainerConstraintEntity(PhysicalEntity[None]):
666
+ type_: ClassVar[EntityTypes] = EntityTypes.container_constraint
667
+ prefix: _UndefinedType | Literal["uniqueness", "requires"] = Undefined # type: ignore[assignment]
668
+ suffix: str
669
+ require: ContainerEntity | None = None
670
+
671
+ def as_id(self) -> None:
672
+ return None
673
+
674
+ @classmethod
675
+ def from_id(cls, id: None) -> Self:
676
+ return cls(suffix="dummy")
@@ -9,6 +9,7 @@ from pydantic import (
9
9
  from ._single_value import (
10
10
  AssetEntity,
11
11
  ConceptEntity,
12
+ ContainerConstraintEntity,
12
13
  ContainerEntity,
13
14
  ContainerIndexEntity,
14
15
  RelationshipEntity,
@@ -76,6 +77,15 @@ ContainerIndexListType = Annotated[
76
77
  when_used="unless-none",
77
78
  ),
78
79
  ]
80
+ ContainerConstraintListType = Annotated[
81
+ list[ContainerConstraintEntity],
82
+ BeforeValidator(_split_str),
83
+ PlainSerializer(
84
+ _join_str,
85
+ return_type=str,
86
+ when_used="unless-none",
87
+ ),
88
+ ]
79
89
 
80
90
  ViewEntityList = Annotated[
81
91
  list[ViewEntity],
@@ -3,12 +3,12 @@ from pathlib import Path
3
3
 
4
4
  import yaml
5
5
 
6
- from cognite.neat.core._data_model._shared import ImportedDataModel
7
- from cognite.neat.core._data_model.models.physical import (
6
+ from cognite.neat.v0.core._data_model._shared import ImportedDataModel
7
+ from cognite.neat.v0.core._data_model.models.physical import (
8
8
  PhysicalDataModel,
9
9
  UnverifiedPhysicalDataModel,
10
10
  )
11
- from cognite.neat.core._issues.errors import NeatValueError
11
+ from cognite.neat.v0.core._issues.errors import NeatValueError
12
12
 
13
13
  _CLASSIC_TO_CORE_MAPPING = Path(__file__).resolve().parent / "_classic2core.yaml"
14
14
 
@@ -19,8 +19,8 @@ def _read_source_file() -> str:
19
19
 
20
20
 
21
21
  def load_classic_to_core_mapping(org_name: str | None, source_space: str, source_version: str) -> PhysicalDataModel:
22
- from cognite.neat.core._data_model.importers import DictImporter
23
- from cognite.neat.core._data_model.transformers import VerifyPhysicalDataModel
22
+ from cognite.neat.v0.core._data_model.importers import DictImporter
23
+ from cognite.neat.v0.core._data_model.transformers import VerifyPhysicalDataModel
24
24
 
25
25
  raw_str = _read_source_file()
26
26
  if org_name is not None:
@@ -1,4 +1,4 @@
1
- from cognite.neat.core._client.data_classes.schema import DMSSchema
1
+ from cognite.neat.v0.core._client.data_classes.schema import DMSSchema
2
2
 
3
3
  from ._unverified import (
4
4
  UnverifiedPhysicalContainer,
@@ -13,20 +13,20 @@ from cognite.client.data_classes.data_modeling.views import (
13
13
  ViewPropertyApply,
14
14
  )
15
15
 
16
- from cognite.neat.core._client.data_classes.data_modeling import (
16
+ from cognite.neat.v0.core._client.data_classes.data_modeling import (
17
17
  ContainerApplyDict,
18
18
  NodeApplyDict,
19
19
  SpaceApplyDict,
20
20
  ViewApplyDict,
21
21
  )
22
- from cognite.neat.core._client.data_classes.schema import DMSSchema
23
- from cognite.neat.core._constants import (
22
+ from cognite.neat.v0.core._client.data_classes.schema import DMSSchema
23
+ from cognite.neat.v0.core._constants import (
24
24
  COGNITE_SPACES,
25
25
  DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
26
26
  DMS_PRIMITIVE_LIST_DEFAULT_LIMIT,
27
27
  )
28
- from cognite.neat.core._data_model.models.data_types import DataType, Double, Enum, Float
29
- from cognite.neat.core._data_model.models.entities import (
28
+ from cognite.neat.v0.core._data_model.models.data_types import DataType, Double, Enum, Float, LangString, String
29
+ from cognite.neat.v0.core._data_model.models.entities import (
30
30
  ConceptEntity,
31
31
  ContainerEntity,
32
32
  ContainerIndexEntity,
@@ -41,16 +41,16 @@ from cognite.neat.core._data_model.models.entities import (
41
41
  UnitEntity,
42
42
  ViewEntity,
43
43
  )
44
- from cognite.neat.core._issues.errors import (
44
+ from cognite.neat.v0.core._issues.errors import (
45
45
  NeatTypeError,
46
46
  NeatValueError,
47
47
  ResourceNotFoundError,
48
48
  )
49
- from cognite.neat.core._issues.warnings import (
49
+ from cognite.neat.v0.core._issues.warnings import (
50
50
  NotSupportedWarning,
51
51
  PropertyNotFoundWarning,
52
52
  )
53
- from cognite.neat.core._issues.warnings.user_modeling import (
53
+ from cognite.neat.v0.core._issues.warnings.user_modeling import (
54
54
  EmptyContainerWarning,
55
55
  HasDataFilterOnNoPropertiesViewWarning,
56
56
  )
@@ -243,17 +243,21 @@ class _DMSExporter:
243
243
  connection = cast(EdgeEntity, prop.connection)
244
244
 
245
245
  if connection.direction == "inwards" and isinstance(prop.value_type, ViewEntity):
246
- edge_type_candidates = outwards_type_by_view_value_type.get((prop.view, prop.value_type), [])
247
- if len(edge_type_candidates) == 0:
248
- # Warning in validation, should not have an inwards connection without an outwards connection
249
- edge_type = cls._default_edge_type_from_view_id(prop.view.as_id(), prop_id)
250
- elif len(edge_type_candidates) == 1:
251
- edge_type = edge_type_candidates[0]
246
+ if connection.edge_type is not None:
247
+ edge_type = connection.edge_type.as_reference()
252
248
  else:
253
- raise NeatValueError(
254
- f"Cannot infer edge type for {view_id}.{prop_id}, multiple candidates: {edge_type_candidates}."
255
- "Please specify edge type explicitly, i.e., edge(type=<YOUR_TYPE>)."
256
- )
249
+ edge_type_candidates = outwards_type_by_view_value_type.get((prop.view, prop.value_type), [])
250
+ if len(edge_type_candidates) == 0:
251
+ # Warning in validation, should not have an inwards connection without an outwards connection
252
+ edge_type = cls._default_edge_type_from_view_id(prop.view.as_id(), prop_id)
253
+ elif len(edge_type_candidates) == 1:
254
+ edge_type = edge_type_candidates[0]
255
+ else:
256
+ raise NeatValueError(
257
+ f"Cannot infer edge type for {view_id}.{prop_id}, multiple candidates: "
258
+ f"{edge_type_candidates}. "
259
+ "Please specify edge type explicitly, i.e., edge(type=<YOUR_TYPE>)."
260
+ )
257
261
  view_property_id = (prop.view, prop.view_property)
258
262
  edge_types_by_view_property_id[view_property_id] = edge_type
259
263
 
@@ -347,6 +351,8 @@ class _DMSExporter:
347
351
  args["max_list_size"] = prop.max_count
348
352
  if isinstance(prop.value_type, Double | Float) and isinstance(prop.value_type.unit, UnitEntity):
349
353
  args["unit"] = prop.value_type.unit.as_reference()
354
+ if isinstance(prop.value_type, String | LangString) and prop.value_type.max_text_size is not None:
355
+ args["max_text_size"] = prop.value_type.max_text_size
350
356
  if isinstance(prop.value_type, Enum):
351
357
  if prop.value_type.collection not in enum_values_by_collection:
352
358
  raise ResourceNotFoundError(
@@ -377,7 +383,8 @@ class _DMSExporter:
377
383
  for prop in container_properties:
378
384
  if prop.container_property is not None:
379
385
  for constraint in prop.constraint or []:
380
- uniqueness_properties[constraint].add(prop.container_property)
386
+ uniqueness_properties[cast(str, constraint.suffix)].add(prop.container_property)
387
+
381
388
  for constraint_name, properties in uniqueness_properties.items():
382
389
  container.constraints = container.constraints or {}
383
390
  container.constraints[constraint_name] = dm.UniquenessConstraint(properties=list(properties))
@@ -391,9 +398,9 @@ class _DMSExporter:
391
398
  container.indexes = container.indexes or {}
392
399
  index_property_list = [prop_id for prop_id, _ in sorted(properties, key=lambda x: x[1].order or 0)]
393
400
  index_entity = properties[0][1]
394
- if index_entity.prefix == "inverted" or (index_entity.prefix is Undefined and is_list):
401
+ if index_entity.prefix == "inverted" or (index_entity.prefix == Undefined and is_list):
395
402
  container.indexes[index_name] = InvertedIndex(properties=index_property_list)
396
- elif index_entity.prefix == "btree" or (index_entity.prefix is Undefined and not is_list):
403
+ elif index_entity.prefix == "btree" or (index_entity.prefix == Undefined and not is_list):
397
404
  container.indexes[index_name] = BTreeIndex(
398
405
  properties=index_property_list, cursorable=index_entity.cursorable or False
399
406
  )