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,255 @@
1
+ from typing import Any, Literal, cast
2
+ from urllib.parse import quote
3
+
4
+ from rdflib import BNode, Graph, Namespace, URIRef
5
+ from rdflib import Literal as RdfLiteral
6
+ from rdflib.plugins.sparql import prepareQuery
7
+ from rdflib.query import ResultRow
8
+
9
+ from cognite.neat.v0.core._constants import cognite_prefixes
10
+ from cognite.neat.v0.core._data_model.models.entities._constants import Unknown
11
+ from cognite.neat.v0.core._data_model.models.entities._single_value import ConceptEntity
12
+ from cognite.neat.v0.core._issues._base import IssueList
13
+ from cognite.neat.v0.core._issues.errors._general import NeatValueError
14
+ from cognite.neat.v0.core._issues.warnings._resources import (
15
+ ResourceRedefinedWarning,
16
+ ResourceRetrievalWarning,
17
+ )
18
+ from cognite.neat.v0.core._utils.rdf_ import remove_namespace_from_uri, uri_to_entity_components
19
+
20
+
21
+ def parse_concepts(
22
+ graph: Graph, query: str, parameters: set, language: str, issue_list: IssueList
23
+ ) -> tuple[dict, IssueList]:
24
+ """Parse concepts from graph
25
+
26
+ Args:
27
+ graph: Graph containing concept definitions
28
+ query: SPARQL query to use for parsing concepts
29
+ parameters: Set of parameters to extract from the query results
30
+ language: Language to use for parsing, by default "en"
31
+ issue_list: List to collect issues during parsing
32
+
33
+ Returns:
34
+ Dataframe containing owl classes
35
+ """
36
+
37
+ concepts: dict[str, dict] = {}
38
+
39
+ query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
40
+ prefixes = cognite_prefixes()
41
+
42
+ for raw in graph.query(query):
43
+ res: dict = convert_rdflib_content(
44
+ cast(ResultRow, raw).asdict(), uri_handling="as-concept-entity", prefixes=prefixes
45
+ )
46
+ res = {key: res.get(key, None) for key in parameters}
47
+
48
+ # Safeguarding against incomplete semantic definitions
49
+ if res["implements"] and isinstance(res["implements"], BNode):
50
+ issue_list.append(
51
+ ResourceRetrievalWarning(
52
+ res["concept"],
53
+ "implements",
54
+ error=("Unable to determine concept that is being implemented"),
55
+ )
56
+ )
57
+ continue
58
+
59
+ # sanitize the concept and implements
60
+ res["concept"] = sanitize_entity(res["concept"])
61
+ res["implements"] = sanitize_entity(res["implements"]) if res["implements"] else None
62
+
63
+ concept_id = res["concept"]
64
+
65
+ if concept_id not in concepts:
66
+ concepts[concept_id] = res
67
+ else:
68
+ # Handling implements
69
+ if concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], list):
70
+ if res["implements"] and res["implements"] not in concepts[concept_id]["implements"]:
71
+ concepts[concept_id]["implements"].append(res["implements"])
72
+
73
+ elif concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], str):
74
+ concepts[concept_id]["implements"] = [concepts[concept_id]["implements"]]
75
+
76
+ if res["implements"] and res["implements"] not in concepts[concept_id]["implements"]:
77
+ concepts[concept_id]["implements"].append(res["implements"])
78
+ elif res["implements"]:
79
+ concepts[concept_id]["implements"] = [res["implements"]]
80
+
81
+ handle_meta("concept", concepts, concept_id, res, "name", issue_list)
82
+ handle_meta("concept", concepts, concept_id, res, "description", issue_list)
83
+ if not concepts:
84
+ issue_list.append(NeatValueError("Unable to parse concepts"))
85
+
86
+ return concepts, issue_list
87
+
88
+
89
+ def parse_properties(
90
+ graph: Graph, query: str, parameters: set, language: str, issue_list: IssueList
91
+ ) -> tuple[dict, IssueList]:
92
+ """Parse properties from graph
93
+
94
+ Args:
95
+ graph: Graph containing property definitions
96
+ query: SPARQL query to use for parsing properties
97
+ parameters: Set of parameters to extract from the query results
98
+ language: Language to use for parsing, by default "en"
99
+ issue_list: List to collect issues during parsing
100
+
101
+ Returns:
102
+ Dataframe containing owl classes
103
+ """
104
+
105
+ properties: dict[str, dict] = {}
106
+
107
+ query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
108
+ prefixes = cognite_prefixes()
109
+
110
+ for raw in graph.query(query):
111
+ res: dict = convert_rdflib_content(
112
+ cast(ResultRow, raw).asdict(), uri_handling="as-concept-entity", prefixes=prefixes
113
+ )
114
+ res = {key: res.get(key, None) for key in parameters}
115
+
116
+ # Quote the concept id to ensure it is web-safe
117
+ res["property_"] = quote(res["property_"], safe="")
118
+ property_id = res["property_"]
119
+
120
+ # Skip Bnode
121
+ if isinstance(res["concept"], BNode):
122
+ issue_list.append(
123
+ ResourceRetrievalWarning(
124
+ property_id,
125
+ "property",
126
+ error="Cannot determine concept of property as it is a blank node",
127
+ )
128
+ )
129
+ continue
130
+
131
+ # Skip Bnode
132
+ if isinstance(res["value_type"], BNode):
133
+ issue_list.append(
134
+ ResourceRetrievalWarning(
135
+ property_id,
136
+ "property",
137
+ error="Unable to determine value type of property as it is a blank node",
138
+ )
139
+ )
140
+ continue
141
+
142
+ # Quote the concept and value_type if they exist if not signal neat that they are not available
143
+ res["concept"] = sanitize_entity(res["concept"]) if res["concept"] else str(Unknown)
144
+ res["value_type"] = sanitize_entity(res["value_type"]) if res["value_type"] else str(Unknown)
145
+
146
+ id_ = f"{res['concept']}.{res['property_']}"
147
+
148
+ if id_ not in properties:
149
+ properties[id_] = res
150
+ properties[id_]["value_type"] = [properties[id_]["value_type"]]
151
+ else:
152
+ handle_meta("property", properties, id_, res, "name", issue_list)
153
+ handle_meta(
154
+ "property",
155
+ properties,
156
+ id_,
157
+ res,
158
+ "description",
159
+ issue_list,
160
+ )
161
+
162
+ # Handling multi-value types
163
+ if res["value_type"] not in properties[id_]["value_type"]:
164
+ properties[id_]["value_type"].append(res["value_type"])
165
+
166
+ for prop in properties.values():
167
+ prop["value_type"] = ", ".join(prop["value_type"])
168
+
169
+ if not properties:
170
+ issue_list.append(NeatValueError("Unable to parse properties"))
171
+
172
+ return properties, issue_list
173
+
174
+
175
+ def handle_meta(
176
+ resource_type: str,
177
+ resources: dict[str, dict],
178
+ resource_id: str,
179
+ res: dict,
180
+ feature: str,
181
+ issue_list: IssueList,
182
+ ) -> None:
183
+ if not resources[resource_id][feature] and res[feature]:
184
+ resources[resource_id][feature] = res[feature]
185
+
186
+ current_value = resources[resource_id][feature]
187
+ new_value = res[feature]
188
+
189
+ if not current_value and new_value:
190
+ resources[resource_id][feature] = new_value
191
+ elif current_value and new_value and current_value != new_value:
192
+ issue_list.append(
193
+ ResourceRedefinedWarning(
194
+ identifier=resource_id,
195
+ resource_type=resource_type,
196
+ feature=feature,
197
+ current_value=current_value,
198
+ new_value=new_value,
199
+ )
200
+ )
201
+
202
+
203
+ def convert_rdflib_content(
204
+ content: RdfLiteral | URIRef | dict | list,
205
+ uri_handling: Literal["skip", "remove-namespace", "as-concept-entity"] = "skip",
206
+ prefixes: dict[str, Namespace] | None = None,
207
+ ) -> Any:
208
+ """Converts rdflib content to a more Python-friendly format.
209
+
210
+ Args:
211
+ content: The content to convert, can be a RdfLiteral, URIRef, dict, or list.
212
+ uri_handling: How to handle URIs. Options are:
213
+ - "skip": Leave URIs as is.
214
+ - "remove-namespace": Remove the namespace from URIs.
215
+ - "short-form": Convert URIs to a short form using prefixes.
216
+
217
+ """
218
+ if isinstance(content, RdfLiteral):
219
+ return content.toPython()
220
+ elif isinstance(content, URIRef):
221
+ if uri_handling == "remove-namespace":
222
+ return remove_namespace_from_uri(content)
223
+ elif uri_handling == "as-concept-entity":
224
+ if components := uri_to_entity_components(content, prefixes or {}):
225
+ return ConceptEntity(prefix=components[0], suffix=components[3], version=components[2])
226
+ # fallback to "remove-namespace"
227
+ else:
228
+ return convert_rdflib_content(content, uri_handling="remove-namespace", prefixes=prefixes)
229
+ else:
230
+ return content.toPython()
231
+ elif isinstance(content, dict):
232
+ return {key: convert_rdflib_content(value, uri_handling, prefixes) for key, value in content.items()}
233
+ elif isinstance(content, list):
234
+ return [convert_rdflib_content(item, uri_handling, prefixes) for item in content]
235
+ else:
236
+ return content
237
+
238
+
239
+ def sanitize_entity(entity: str | ConceptEntity, safe: str = "") -> str:
240
+ """Sanitize an entity to ensure it yields entity form that will pass downstream validation.
241
+
242
+ Args:
243
+ entity: The entity to sanitize. Can be a string or a ConceptEntity.
244
+ safe: Characters that should not be quoted during sanitization.
245
+
246
+ Returns:
247
+ A web-safe string representation of the entity
248
+ """
249
+ if isinstance(entity, str):
250
+ return quote(entity, safe=safe)
251
+ # if it already we dont need to quote it so we return its string representation
252
+ elif isinstance(entity, ConceptEntity):
253
+ return str(entity)
254
+ else:
255
+ raise ValueError(f"Invalid entity type: {type(entity)}. Expected str, ConceptEntity.")
@@ -10,27 +10,35 @@ import pandas as pd
10
10
  from openpyxl import load_workbook
11
11
  from openpyxl.worksheet.worksheet import Worksheet
12
12
  from pandas import ExcelFile
13
+ from pydantic import ValidationError
13
14
  from rdflib import Namespace, URIRef
14
15
 
15
- from cognite.neat.core._data_model._shared import (
16
+ from cognite.neat.v0.core._data_model._constants import SPLIT_ON_COMMA_PATTERN
17
+ from cognite.neat.v0.core._data_model._shared import (
16
18
  ImportedDataModel,
17
19
  T_UnverifiedDataModel,
18
20
  )
19
- from cognite.neat.core._data_model.models import (
21
+ from cognite.neat.v0.core._data_model.models import (
20
22
  UNVERIFIED_DATA_MODEL_BY_ROLE,
21
23
  VERIFIED_DATA_MODEL_BY_ROLE,
22
24
  RoleTypes,
23
25
  SchemaCompleteness,
24
26
  )
25
- from cognite.neat.core._issues import IssueList, MultiValueError
26
- from cognite.neat.core._issues.errors import (
27
+ from cognite.neat.v0.core._data_model.models._import_contexts import SpreadsheetContext
28
+ from cognite.neat.v0.core._data_model.models.entities._single_value import ContainerConstraintEntity, ContainerEntity
29
+ from cognite.neat.v0.core._issues import IssueList, MultiValueError
30
+ from cognite.neat.v0.core._issues.errors import (
27
31
  FileMissingRequiredFieldError,
28
32
  FileNotFoundNeatError,
29
33
  FileReadError,
30
34
  )
31
- from cognite.neat.core._issues.warnings import FileMissingRequiredFieldWarning
32
- from cognite.neat.core._utils.spreadsheet import SpreadsheetRead, read_individual_sheet
33
- from cognite.neat.core._utils.text import humanize_collection
35
+ from cognite.neat.v0.core._issues.warnings import FileMissingRequiredFieldWarning
36
+ from cognite.neat.v0.core._utils.spreadsheet import (
37
+ SpreadsheetRead,
38
+ find_column_and_row_with_value,
39
+ read_individual_sheet,
40
+ )
41
+ from cognite.neat.v0.core._utils.text import humanize_collection
34
42
 
35
43
  from ._base import BaseImporter
36
44
 
@@ -271,7 +279,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
271
279
  raise MultiValueError(issue_list.errors)
272
280
 
273
281
  if user_read is None:
274
- return ImportedDataModel(None, {})
282
+ return ImportedDataModel(None, None)
275
283
 
276
284
  sheets = user_read.sheets
277
285
  original_role = user_read.role
@@ -287,7 +295,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
287
295
  except Exception as e:
288
296
  issue_list.append(FileReadError(self.filepath, f"Failed to delete temporary file: {e}"))
289
297
 
290
- return ImportedDataModel(data_model, read_info_by_sheet)
298
+ return ImportedDataModel(data_model, SpreadsheetContext(read_info_by_sheet))
291
299
 
292
300
  @property
293
301
  def description(self) -> str:
@@ -305,7 +313,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
305
313
 
306
314
  """
307
315
 
308
- workbook = load_workbook(filepath)
316
+ workbook = load_workbook(filepath, data_only=True)
309
317
 
310
318
  if "Classes" in workbook.sheetnames:
311
319
  print(
@@ -322,13 +330,17 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
322
330
  if "Properties" in workbook.sheetnames:
323
331
  _replace_class_with_concept_cell(workbook["Properties"])
324
332
 
325
- with tempfile.NamedTemporaryFile(prefix="temp_neat_file", suffix=".xlsx", delete=False) as temp_file:
326
- workbook.save(temp_file.name)
327
- return Path(temp_file.name)
333
+ elif "Containers" in workbook.sheetnames:
334
+ _replace_legacy_constraint_form(workbook["Containers"])
335
+ _replace_legacy_constraint_form(workbook["Properties"])
328
336
 
329
337
  else:
330
338
  return filepath
331
339
 
340
+ with tempfile.NamedTemporaryFile(prefix="temp_neat_file", suffix=".xlsx", delete=False) as temp_file:
341
+ workbook.save(temp_file.name)
342
+ return Path(temp_file.name)
343
+
332
344
 
333
345
  def _replace_class_with_concept_cell(sheet: Worksheet) -> None:
334
346
  """
@@ -341,3 +353,72 @@ def _replace_class_with_concept_cell(sheet: Worksheet) -> None:
341
353
  for cell in row:
342
354
  if cell.value == "Class":
343
355
  cell.value = "Concept"
356
+
357
+
358
+ def _replace_legacy_constraint_form(sheet: Worksheet) -> None:
359
+ """
360
+ Replaces the legacy form of container constraints with the new form in the given sheet.
361
+
362
+ Args:
363
+ sheet (Worksheet): The sheet in which to replace the old form of container constraints.
364
+ """
365
+ column, row = find_column_and_row_with_value(sheet, "Constraint", False)
366
+
367
+ if not column or not row:
368
+ return None
369
+
370
+ # Iterate over values in the constraint column and replace old form with new form
371
+ replaced: bool = False
372
+ for cell_row in sheet.iter_rows(min_row=row + 1, min_col=column, max_col=column):
373
+ cell = cell_row[0]
374
+ if cell.value is not None: # Skip empty cells
375
+ # Container sheet update
376
+ if sheet.title.lower() == "containers":
377
+ constraints = []
378
+ for constraint in SPLIT_ON_COMMA_PATTERN.split(str(cell.value)):
379
+ # latest format, do nothing
380
+ if "require" in constraint.lower():
381
+ constraints.append(constraint)
382
+ continue
383
+
384
+ try:
385
+ container = ContainerEntity.load(constraint, space="default")
386
+ container_str = container.external_id if container.space == "default" else str(container)
387
+ constraints.append(
388
+ f"requires:{container.space}_{container.external_id}(require={container_str})"
389
+ )
390
+ replaced = True
391
+ except ValidationError:
392
+ constraints.append(constraint)
393
+
394
+ cell.value = ",".join(constraints)
395
+
396
+ # Properties sheet update
397
+ elif sheet.title.lower() == "properties":
398
+ constraints = []
399
+ for constraint in SPLIT_ON_COMMA_PATTERN.split(str(cell.value)):
400
+ try:
401
+ constraint_entity = ContainerConstraintEntity.load(constraint)
402
+
403
+ if constraint_entity.prefix in ["uniqueness", "requires"]:
404
+ constraints.append(constraint)
405
+
406
+ # Replace old format with new format
407
+ else:
408
+ constraints.append(f"uniqueness:{constraint}")
409
+ replaced = True
410
+
411
+ # If the constraint is not valid, we keep it as is
412
+ # to be caught by validation later
413
+ except ValidationError:
414
+ constraints.append(constraint)
415
+
416
+ cell.value = ",".join(constraints)
417
+
418
+ if replaced:
419
+ print(
420
+ (
421
+ "You are using a legacy container constraints format "
422
+ f"in the {sheet.title} sheet. Please update to the latest format."
423
+ ),
424
+ )
@@ -1,8 +1,8 @@
1
- from cognite.neat.core._client.data_classes.schema import DMSSchema
2
- from cognite.neat.core._data_model.models.conceptual._unverified import (
1
+ from cognite.neat.v0.core._client.data_classes.schema import DMSSchema
2
+ from cognite.neat.v0.core._data_model.models.conceptual._unverified import (
3
3
  UnverifiedConceptualDataModel,
4
4
  )
5
- from cognite.neat.core._data_model.models.conceptual._verified import (
5
+ from cognite.neat.v0.core._data_model.models.conceptual._verified import (
6
6
  ConceptualDataModel,
7
7
  )
8
8
 
@@ -26,8 +26,8 @@ from pydantic.main import IncEx
26
26
  from pydantic_core import core_schema
27
27
  from rdflib import Namespace, URIRef
28
28
 
29
- from cognite.neat.core._constants import DEFAULT_NAMESPACE
30
- from cognite.neat.core._data_model.models._types import (
29
+ from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE
30
+ from cognite.neat.v0.core._data_model.models._types import (
31
31
  ContainerEntityType,
32
32
  DataModelExternalIdType,
33
33
  PhysicalPropertyType,
@@ -37,13 +37,13 @@ from cognite.neat.core._data_model.models._types import (
37
37
  VersionType,
38
38
  ViewEntityType,
39
39
  )
40
- from cognite.neat.core._data_model.models.data_types import DataType
41
- from cognite.neat.core._data_model.models.entities import (
40
+ from cognite.neat.v0.core._data_model.models.data_types import DataType
41
+ from cognite.neat.v0.core._data_model.models.entities import (
42
42
  EdgeEntity,
43
43
  ReverseConnectionEntity,
44
44
  ViewEntity,
45
45
  )
46
- from cognite.neat.core._utils.rdf_ import uri_display_name
46
+ from cognite.neat.v0.core._utils.rdf_ import uri_display_name
47
47
 
48
48
  if sys.version_info >= (3, 11):
49
49
  from enum import StrEnum
@@ -0,0 +1,82 @@
1
+ from collections.abc import Hashable, ItemsView, Iterator, KeysView, Mapping, ValuesView
2
+ from typing import TypeVar
3
+
4
+ from rdflib import URIRef
5
+
6
+ from cognite.neat.v0.core._utils.spreadsheet import SpreadsheetRead
7
+
8
+ T_Key = TypeVar("T_Key", bound=Hashable)
9
+ T_Value = TypeVar("T_Value")
10
+
11
+
12
+ class ImportContext(dict, Mapping[T_Key, T_Value]):
13
+ def __init__(self, data: Mapping[T_Key, T_Value] | None = None) -> None:
14
+ super().__init__(data or {})
15
+
16
+ # The below methods are included to make better type hints in the IDE
17
+ def __getitem__(self, k: T_Key) -> T_Value:
18
+ return super().__getitem__(k)
19
+
20
+ def __setitem__(self, k: T_Key, v: T_Value) -> None:
21
+ super().__setitem__(k, v)
22
+
23
+ def __delitem__(self, k: T_Key) -> None:
24
+ super().__delitem__(k)
25
+
26
+ def __iter__(self) -> Iterator[T_Key]:
27
+ return super().__iter__()
28
+
29
+ def keys(self) -> KeysView[T_Key]: # type: ignore[override]
30
+ return super().keys()
31
+
32
+ def values(self) -> ValuesView[T_Value]: # type: ignore[override]
33
+ return super().values()
34
+
35
+ def items(self) -> ItemsView[T_Key, T_Value]: # type: ignore[override]
36
+ return super().items()
37
+
38
+ def get(self, __key: T_Key, __default: T_Value | None = None) -> T_Value: # type: ignore[override]
39
+ return super().get(__key, __default)
40
+
41
+ def pop(self, __key: T_Key, __default: T_Value | None = None) -> T_Value: # type: ignore[override]
42
+ return super().pop(__key, __default)
43
+
44
+ def popitem(self) -> tuple[T_Key, T_Value]:
45
+ return super().popitem()
46
+
47
+
48
+ class SpreadsheetContext(ImportContext[str, SpreadsheetRead]):
49
+ def __init__(self, data: dict[str, SpreadsheetRead] | None = None) -> None:
50
+ """Initialize the SpreadsheetContext with a dictionary of SpreadsheetRead objects.
51
+
52
+ Args:
53
+ data (dict[str, SpreadsheetRead]): A dictionary where keys are sheet names and values are
54
+ SpreadsheetRead objects containing the read data.
55
+ """
56
+ super().__init__(data or {})
57
+ for k, v in self.items():
58
+ if not isinstance(k, str):
59
+ raise TypeError(f"Expected string key, got {type(k).__name__}")
60
+ if not isinstance(v, SpreadsheetRead):
61
+ raise TypeError(f"Expected SpreadsheetRead for key '{k}', got {type(v).__name__}")
62
+
63
+
64
+ class GraphContext(ImportContext[str, Mapping[URIRef, int]]):
65
+ def __init__(self, data: dict[str, Mapping[URIRef, int]] | None = None) -> None:
66
+ """Initialize the GraphContext with a dictionary of mappings from URIRef to int.
67
+
68
+ Args:
69
+ data (dict[str, Mapping[URIRef, int]]): A dictionary where keys are graph names and values are
70
+ mappings of URIRef to integer identifiers.
71
+ """
72
+ super().__init__(data or {})
73
+ for k, v in self.items():
74
+ if not isinstance(k, str):
75
+ raise TypeError(f"Expected string key, got {type(k).__name__}")
76
+ if not isinstance(v, Mapping):
77
+ raise TypeError(f"Expected Mapping[URIRef, int] for key '{k}', got {type(v).__name__}")
78
+ for uri, value in v.items():
79
+ if not isinstance(uri, URIRef):
80
+ raise TypeError(f"Expected URIRef key in mapping for '{k}', got {type(uri).__name__}")
81
+ if not isinstance(value, int):
82
+ raise TypeError(f"Expected int value in mapping for '{k}', got {type(value).__name__}")
@@ -14,21 +14,21 @@ from pydantic import (
14
14
  )
15
15
  from pydantic.functional_serializers import PlainSerializer
16
16
 
17
- from cognite.neat.core._data_model._constants import (
17
+ from cognite.neat.v0.core._data_model._constants import (
18
18
  DATA_MODEL_COMPLIANCE_REGEX,
19
19
  PATTERNS,
20
20
  PREFIX_COMPLIANCE_REGEX,
21
21
  VERSION_COMPLIANCE_REGEX,
22
22
  EntityTypes,
23
23
  )
24
- from cognite.neat.core._data_model.models.entities._multi_value import MultiValueTypeInfo
25
- from cognite.neat.core._data_model.models.entities._single_value import (
24
+ from cognite.neat.v0.core._data_model.models.entities._multi_value import MultiValueTypeInfo
25
+ from cognite.neat.v0.core._data_model.models.entities._single_value import (
26
26
  ConceptEntity,
27
27
  ContainerEntity,
28
28
  ViewEntity,
29
29
  )
30
- from cognite.neat.core._issues.errors import RegexViolationError
31
- from cognite.neat.core._issues.warnings import RegexViolationWarning
30
+ from cognite.neat.v0.core._issues.errors import RegexViolationError
31
+ from cognite.neat.v0.core._issues.warnings import RegexViolationWarning
32
32
 
33
33
  Entities: TypeAlias = ConceptEntity | ViewEntity | ContainerEntity
34
34
  T_Entities = TypeVar("T_Entities", bound=Entities)
@@ -6,19 +6,19 @@ import pandas as pd
6
6
  from cognite.client import data_modeling as dm
7
7
  from rdflib import Namespace, URIRef
8
8
 
9
- from cognite.neat.core._constants import DEFAULT_NAMESPACE
10
- from cognite.neat.core._data_model.models._base_unverified import (
9
+ from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE
10
+ from cognite.neat.v0.core._data_model.models._base_unverified import (
11
11
  UnverifiedComponent,
12
12
  UnverifiedDataModel,
13
13
  )
14
- from cognite.neat.core._data_model.models.data_types import DataType
15
- from cognite.neat.core._data_model.models.entities import (
14
+ from cognite.neat.v0.core._data_model.models.data_types import DataType
15
+ from cognite.neat.v0.core._data_model.models.entities import (
16
16
  ConceptEntity,
17
17
  MultiValueTypeInfo,
18
18
  UnknownEntity,
19
19
  load_value_type,
20
20
  )
21
- from cognite.neat.core._utils.rdf_ import uri_display_name
21
+ from cognite.neat.v0.core._utils.rdf_ import uri_display_name
22
22
 
23
23
  from ._verified import (
24
24
  Concept,
@@ -78,7 +78,7 @@ class UnverifiedConceptualMetadata(UnverifiedComponent[ConceptualMetadata]):
78
78
 
79
79
  @dataclass
80
80
  class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
81
- concept: ConceptEntity | str
81
+ concept: ConceptEntity | str | UnknownEntity
82
82
  property_: str
83
83
  value_type: DataType | ConceptEntity | MultiValueTypeInfo | UnknownEntity | str
84
84
  name: str | None = None
@@ -100,8 +100,8 @@ class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
100
100
 
101
101
  def dump(self, default_prefix: str, **kwargs) -> dict[str, Any]: # type: ignore
102
102
  output = super().dump()
103
- output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix)
104
- output["Value Type"] = load_value_type(self.value_type, default_prefix)
103
+ output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix, return_on_failure=True)
104
+ output["Value Type"] = load_value_type(self.value_type, default_prefix, return_on_failure=True)
105
105
  return output
106
106
 
107
107
  def copy(self, update: dict[str, Any], default_prefix: str) -> "UnverifiedConceptualProperty":
@@ -135,10 +135,16 @@ class UnverifiedConcept(UnverifiedComponent[Concept]):
135
135
  parent: list[ConceptEntity] | None = None
136
136
  if isinstance(self.implements, str):
137
137
  self.implements = self.implements.strip()
138
- parent = [ConceptEntity.load(parent, prefix=default_prefix) for parent in self.implements.split(",")]
138
+ parent = [
139
+ ConceptEntity.load(parent_str, prefix=default_prefix, return_on_failure=True)
140
+ for parent_str in self.implements.split(",")
141
+ ]
139
142
  elif isinstance(self.implements, list):
140
- parent = [ConceptEntity.load(parent_, prefix=default_prefix) for parent_ in self.implements]
141
- output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix)
143
+ parent = [
144
+ ConceptEntity.load(parent_str, prefix=default_prefix, return_on_failure=True)
145
+ for parent_str in self.implements
146
+ ]
147
+ output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix, return_on_failure=True)
142
148
  output["Implements"] = parent
143
149
  return output
144
150
 
@@ -146,8 +152,8 @@ class UnverifiedConcept(UnverifiedComponent[Concept]):
146
152
  @dataclass
147
153
  class UnverifiedConceptualDataModel(UnverifiedDataModel[ConceptualDataModel]):
148
154
  metadata: UnverifiedConceptualMetadata
149
- properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
150
155
  concepts: list[UnverifiedConcept] = field(default_factory=list)
156
+ properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
151
157
  prefixes: dict[str, Namespace] | None = None
152
158
 
153
159
  @classmethod