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,308 @@
1
+ import itertools
2
+ from collections import Counter, defaultdict
3
+
4
+ from cognite.neat.v0.core._constants import get_base_concepts
5
+ from cognite.neat.v0.core._data_model._constants import PATTERNS, EntityTypes
6
+ from cognite.neat.v0.core._data_model.models._import_contexts import ImportContext, SpreadsheetContext
7
+ from cognite.neat.v0.core._data_model.models.entities import ConceptEntity, UnknownEntity
8
+ from cognite.neat.v0.core._data_model.models.entities._multi_value import MultiValueTypeInfo
9
+ from cognite.neat.v0.core._issues import IssueList
10
+ from cognite.neat.v0.core._issues.errors import NeatValueError
11
+ from cognite.neat.v0.core._issues.errors._resources import (
12
+ ResourceDuplicatedError,
13
+ ResourceNotDefinedError,
14
+ )
15
+ from cognite.neat.v0.core._issues.warnings._models import (
16
+ ConceptOnlyDataModelWarning,
17
+ ConversionToPhysicalModelImpossibleWarning,
18
+ DanglingPropertyWarning,
19
+ UndefinedConceptWarning,
20
+ )
21
+ from cognite.neat.v0.core._issues.warnings._resources import (
22
+ ResourceNotDefinedWarning,
23
+ ResourceRegexViolationWarning,
24
+ )
25
+ from cognite.neat.v0.core._utils.text import humanize_collection
26
+
27
+ from ._verified import ConceptualDataModel
28
+
29
+
30
+ class ConceptualValidation:
31
+ """This class does all the validation of the conceptual data model that have dependencies
32
+ between components."""
33
+
34
+ def __init__(
35
+ self,
36
+ data_model: ConceptualDataModel,
37
+ context: ImportContext | None = None,
38
+ ):
39
+ # import here to avoid circular import issues
40
+ from cognite.neat.v0.core._data_model.analysis._base import DataModelAnalysis
41
+
42
+ self.data_model = data_model
43
+ self.analysis = DataModelAnalysis(self.data_model)
44
+ self._read_info_by_spreadsheet = context if isinstance(context, SpreadsheetContext) else SpreadsheetContext({})
45
+ self._metadata = data_model.metadata
46
+ self._properties = data_model.properties
47
+ self._concepts = data_model.concepts
48
+ self._cdf_concepts = {
49
+ ConceptEntity.load(concept_as_string) for concept_as_string in get_base_concepts(base_model="CogniteCore")
50
+ }
51
+ self.issue_list = IssueList()
52
+
53
+ def validate(self) -> IssueList:
54
+ self._duplicated_resources()
55
+ self._namespaces_reassigned()
56
+ self._concepts_without_properties_exist()
57
+ self._concepts_with_properties_defined()
58
+ self._ancestors_defined()
59
+
60
+ self._object_properties_use_defined_concepts()
61
+ self._dangling_properties()
62
+
63
+ self._concept_only_data_model()
64
+ self._regex_compliance_with_physical_data_model()
65
+ self._physical_data_model_conversion()
66
+
67
+ return self.issue_list
68
+
69
+ def _physical_data_model_conversion(self) -> None:
70
+ """Check if the conceptual data model has issues that will likely lead
71
+ to problems when converting to a physical data model."""
72
+ warning_types_preventing_conversion = [
73
+ ConceptOnlyDataModelWarning,
74
+ ResourceRegexViolationWarning,
75
+ ResourceNotDefinedWarning,
76
+ UndefinedConceptWarning,
77
+ DanglingPropertyWarning,
78
+ ]
79
+
80
+ if seen_warnings := frozenset(
81
+ [
82
+ warning_type.__name__
83
+ for warning_type in warning_types_preventing_conversion
84
+ if self.issue_list.has_warning_type(warning_type)
85
+ ]
86
+ ):
87
+ self.issue_list.append_if_not_exist(ConversionToPhysicalModelImpossibleWarning(issue_types=seen_warnings))
88
+
89
+ def _concept_only_data_model(self) -> None:
90
+ """Check if the data model only consists of concepts without any properties."""
91
+ if not self._properties:
92
+ self.issue_list.append_if_not_exist(ConceptOnlyDataModelWarning())
93
+
94
+ def _dangling_properties(self) -> None:
95
+ """Check if there are properties that do not reference any concept."""
96
+ dangling_properties = [prop for prop in self._properties if prop.concept == UnknownEntity()]
97
+ if dangling_properties:
98
+ for prop in dangling_properties:
99
+ self.issue_list.append_if_not_exist(DanglingPropertyWarning(property_id=prop.property_))
100
+
101
+ def _duplicated_resources(self) -> None:
102
+ properties_sheet_info = self._read_info_by_spreadsheet.get("Properties")
103
+ concepts_sheet_info = self._read_info_by_spreadsheet.get("Concepts")
104
+
105
+ visited = defaultdict(list)
106
+ for row_no, property_ in enumerate(self._properties):
107
+ visited[property_._identifier()].append(
108
+ properties_sheet_info.adjusted_row_number(row_no) if properties_sheet_info else row_no + 1
109
+ )
110
+
111
+ for identifier, rows in visited.items():
112
+ if len(rows) == 1:
113
+ continue
114
+ self.issue_list.append(
115
+ ResourceDuplicatedError(
116
+ identifier[1],
117
+ "property",
118
+ (
119
+ "the Properties sheet at row "
120
+ f"{humanize_collection(rows)}"
121
+ " if data model is read from a spreadsheet."
122
+ ),
123
+ )
124
+ )
125
+
126
+ visited = defaultdict(list)
127
+ for row_no, concept in enumerate(self._concepts):
128
+ visited[concept._identifier()].append(
129
+ concepts_sheet_info.adjusted_row_number(row_no) if concepts_sheet_info else row_no + 1
130
+ )
131
+
132
+ for identifier, rows in visited.items():
133
+ if len(rows) == 1:
134
+ continue
135
+ self.issue_list.append_if_not_exist(
136
+ ResourceDuplicatedError(
137
+ identifier[0],
138
+ "concept",
139
+ (
140
+ f"the Concepts sheet at row {humanize_collection(rows)}"
141
+ " if data model is read from a spreadsheet."
142
+ ),
143
+ )
144
+ )
145
+
146
+ def _concepts_without_properties_exist(self) -> None:
147
+ """This validation checks if concepts have properties defined or inherit properties from other concepts."""
148
+ concepts = {concept.concept for concept in self._concepts}
149
+ ancestors_by_concept = self.analysis.parents_by_concept(include_ancestors=True, include_different_space=True)
150
+ concepts_with_properties = self.analysis.defined_concepts().union(self._cdf_concepts)
151
+
152
+ if candidate_concepts := concepts.difference(concepts_with_properties):
153
+ for concept in candidate_concepts:
154
+ # Here we check if at least one of the ancestors of the concept has properties
155
+ if (ancestors := ancestors_by_concept.get(concept)) and ancestors.intersection(
156
+ concepts_with_properties
157
+ ):
158
+ continue
159
+
160
+ self.issue_list.append_if_not_exist(UndefinedConceptWarning(concept_id=str(concept)))
161
+
162
+ def _concepts_with_properties_defined(self) -> None:
163
+ """This validation checks if concepts to which properties are attached are defined."""
164
+ concepts = {concept.concept for concept in self._concepts}
165
+ concepts_with_properties = {property_.concept for property_ in self._properties} - {UnknownEntity()}
166
+
167
+ if undefined_concepts_with_properties := concepts_with_properties.difference(concepts):
168
+ for concept in undefined_concepts_with_properties:
169
+ self.issue_list.append_if_not_exist(
170
+ ResourceNotDefinedError(
171
+ identifier=concept,
172
+ resource_type="concept",
173
+ location="Concepts sheet",
174
+ )
175
+ )
176
+
177
+ def _ancestors_defined(self) -> None:
178
+ """This is a validation to check if the ancestor concepts (e.g. parents) are defined."""
179
+ concepts = {concept.concept for concept in self._concepts}.union(self._cdf_concepts)
180
+ ancestors = set(
181
+ itertools.chain.from_iterable(
182
+ self.analysis.parents_by_concept(include_ancestors=True, include_different_space=True).values()
183
+ )
184
+ ).difference(self._cdf_concepts)
185
+
186
+ if undefined_ancestor := ancestors.difference(concepts):
187
+ for ancestor in undefined_ancestor:
188
+ self.issue_list.append_if_not_exist(
189
+ ResourceNotDefinedWarning(
190
+ resource_type="concept",
191
+ identifier=ancestor,
192
+ location="Concepts sheet",
193
+ )
194
+ )
195
+
196
+ def _object_properties_use_defined_concepts(self) -> None:
197
+ """Check if the value types of object properties are defined as concepts."""
198
+
199
+ concepts = {concept.concept for concept in self._concepts}
200
+ # We remove UnknownEntity from the concepts to avoid false positives
201
+ # as `UnknownEntity` is used as a placeholder when the value type is not defined.
202
+ value_types = {
203
+ property_.value_type
204
+ for property_ in self.data_model.properties
205
+ if property_.type_ == EntityTypes.object_property
206
+ }.difference({UnknownEntity()})
207
+
208
+ if undefined_value_types := value_types.difference(concepts):
209
+ for value_type in undefined_value_types:
210
+ self.issue_list.append_if_not_exist(
211
+ ResourceNotDefinedWarning(
212
+ resource_type="concept",
213
+ identifier=value_type,
214
+ location="Concepts sheet",
215
+ )
216
+ )
217
+
218
+ def _regex_compliance_with_physical_data_model(self) -> None:
219
+ """Check regex compliance with DMS of properties, classes and value types."""
220
+
221
+ for prop_ in self._properties:
222
+ if not PATTERNS.physical_property_id_compliance.match(prop_.property_):
223
+ self.issue_list.append_if_not_exist(
224
+ ResourceRegexViolationWarning(
225
+ prop_.property_,
226
+ "Property",
227
+ "Properties sheet, Property column",
228
+ PATTERNS.physical_property_id_compliance.pattern,
229
+ )
230
+ )
231
+ if prop_.concept != UnknownEntity() and not PATTERNS.view_id_compliance.match(prop_.concept.suffix):
232
+ self.issue_list.append_if_not_exist(
233
+ ResourceRegexViolationWarning(
234
+ prop_.concept,
235
+ "Concept",
236
+ "Properties sheet, Concept column",
237
+ PATTERNS.view_id_compliance.pattern,
238
+ )
239
+ )
240
+
241
+ # Handling Value Type
242
+ if (
243
+ isinstance(prop_.value_type, ConceptEntity)
244
+ and prop_.value_type != UnknownEntity()
245
+ and not PATTERNS.view_id_compliance.match(prop_.value_type.suffix)
246
+ ):
247
+ self.issue_list.append_if_not_exist(
248
+ ResourceRegexViolationWarning(
249
+ prop_.value_type,
250
+ "Value Type",
251
+ "Properties sheet, Value Type column",
252
+ PATTERNS.view_id_compliance.pattern,
253
+ )
254
+ )
255
+ if isinstance(prop_.value_type, MultiValueTypeInfo):
256
+ for value_type in prop_.value_type.types:
257
+ if (
258
+ isinstance(prop_.value_type, ConceptEntity)
259
+ and prop_.value_type != UnknownEntity()
260
+ and not PATTERNS.view_id_compliance.match(value_type.suffix)
261
+ ):
262
+ self.issue_list.append_if_not_exist(
263
+ ResourceRegexViolationWarning(
264
+ value_type,
265
+ "Value Type",
266
+ "Properties sheet, Value Type column",
267
+ PATTERNS.view_id_compliance.pattern,
268
+ )
269
+ )
270
+
271
+ for concepts in self._concepts:
272
+ if not PATTERNS.view_id_compliance.match(concepts.concept.suffix):
273
+ self.issue_list.append_if_not_exist(
274
+ ResourceRegexViolationWarning(
275
+ concepts.concept,
276
+ "Concept",
277
+ "Concepts sheet, Concept column",
278
+ PATTERNS.view_id_compliance.pattern,
279
+ )
280
+ )
281
+
282
+ if concepts.implements:
283
+ for parent in concepts.implements:
284
+ if not PATTERNS.view_id_compliance.match(parent.suffix):
285
+ self.issue_list.append_if_not_exist(
286
+ ResourceRegexViolationWarning(
287
+ parent,
288
+ "Concept",
289
+ "Concepts sheet, Implements column",
290
+ PATTERNS.view_id_compliance.pattern,
291
+ )
292
+ )
293
+
294
+ def _namespaces_reassigned(self) -> None:
295
+ prefixes = self.data_model.prefixes.copy()
296
+ prefixes[self.data_model.metadata.namespace.prefix] = self.data_model.metadata.namespace
297
+
298
+ if len(set(prefixes.values())) != len(prefixes):
299
+ reused_namespaces = [value for value, count in Counter(prefixes.values()).items() if count > 1]
300
+ impacted_prefixes = [key for key, value in prefixes.items() if value in reused_namespaces]
301
+ self.issue_list.append_if_not_exist(
302
+ NeatValueError(
303
+ "Namespace collision detected. The following prefixes "
304
+ f"are assigned to the same namespace: {impacted_prefixes}"
305
+ f"\nImpacted namespaces: {reused_namespaces}"
306
+ "\nMake sure that each unique namespace is assigned to a unique prefix"
307
+ )
308
+ )
@@ -7,9 +7,9 @@ from pydantic import Field, field_serializer, field_validator, model_validator
7
7
  from pydantic_core.core_schema import SerializationInfo
8
8
  from rdflib import Namespace, URIRef
9
9
 
10
- from cognite.neat.core._constants import get_default_prefixes_and_namespaces
11
- from cognite.neat.core._data_model._constants import EntityTypes
12
- from cognite.neat.core._data_model.models._base_verified import (
10
+ from cognite.neat.v0.core._constants import get_default_prefixes_and_namespaces
11
+ from cognite.neat.v0.core._data_model._constants import EntityTypes
12
+ from cognite.neat.v0.core._data_model.models._base_verified import (
13
13
  BaseVerifiedDataModel,
14
14
  BaseVerifiedMetadata,
15
15
  DataModelLevel,
@@ -17,7 +17,7 @@ from cognite.neat.core._data_model.models._base_verified import (
17
17
  SheetList,
18
18
  SheetRow,
19
19
  )
20
- from cognite.neat.core._data_model.models._types import (
20
+ from cognite.neat.v0.core._data_model.models._types import (
21
21
  ConceptEntityType,
22
22
  ConceptualPropertyType,
23
23
  MultiValueTypeType,
@@ -25,17 +25,17 @@ from cognite.neat.core._data_model.models._types import (
25
25
  )
26
26
 
27
27
  # NeatIdType,
28
- from cognite.neat.core._data_model.models.data_types import DataType
29
- from cognite.neat.core._data_model.models.entities import (
28
+ from cognite.neat.v0.core._data_model.models.data_types import DataType
29
+ from cognite.neat.v0.core._data_model.models.entities import (
30
30
  ClassEntityList,
31
31
  ConceptEntity,
32
32
  ConceptualEntity,
33
33
  UnknownEntity,
34
34
  )
35
- from cognite.neat.core._issues.errors import PropertyDefinitionError
35
+ from cognite.neat.v0.core._issues.errors import PropertyDefinitionError
36
36
 
37
37
  if TYPE_CHECKING:
38
- from cognite.neat.core._data_model.models import PhysicalDataModel
38
+ from cognite.neat.v0.core._data_model.models import PhysicalDataModel
39
39
 
40
40
 
41
41
  class ConceptualMetadata(BaseVerifiedMetadata):
@@ -123,7 +123,7 @@ class ConceptualProperty(SheetRow):
123
123
  knowledge graph. Defaults to None (no transformation)
124
124
  """
125
125
 
126
- concept: ConceptEntityType = Field(
126
+ concept: ConceptEntityType | UnknownEntity = Field(
127
127
  alias="Concept",
128
128
  description="Concept id that the property is defined for, strongly advise `PascalCase` usage.",
129
129
  )
@@ -241,8 +241,10 @@ class ConceptualProperty(SheetRow):
241
241
 
242
242
  class ConceptualDataModel(BaseVerifiedDataModel):
243
243
  metadata: ConceptualMetadata = Field(alias="Metadata", description="Metadata for the conceptual data model")
244
- properties: SheetList[ConceptualProperty] = Field(alias="Properties", description="List of properties")
245
244
  concepts: SheetList[Concept] = Field(alias="Concepts", description="List of concepts")
245
+ properties: SheetList[ConceptualProperty] = Field(
246
+ alias="Properties", default_factory=SheetList, description="List of properties"
247
+ )
246
248
  prefixes: dict[str, Namespace] = Field(
247
249
  alias="Prefixes",
248
250
  default_factory=get_default_prefixes_and_namespaces,
@@ -301,7 +303,7 @@ class ConceptualDataModel(BaseVerifiedDataModel):
301
303
  classes_by_neat_id[view.conceptual].physical = neat_id
302
304
 
303
305
  def as_physical_data_model(self) -> "PhysicalDataModel":
304
- from cognite.neat.core._data_model.transformers._converters import (
306
+ from cognite.neat.v0.core._data_model.transformers._converters import (
305
307
  _ConceptualDataModelConverter,
306
308
  )
307
309
 
@@ -10,12 +10,12 @@ from pydantic import BaseModel, Field, model_serializer, model_validator
10
10
  from pydantic.functional_validators import ModelWrapValidatorHandler
11
11
  from rdflib import URIRef
12
12
 
13
- from cognite.neat.core._constants import XML_SCHEMA_NAMESPACE
14
- from cognite.neat.core._data_model._constants import (
13
+ from cognite.neat.v0.core._constants import XML_SCHEMA_NAMESPACE
14
+ from cognite.neat.v0.core._data_model._constants import (
15
15
  SPLIT_ON_COMMA_PATTERN,
16
16
  SPLIT_ON_EQUAL_PATTERN,
17
17
  )
18
- from cognite.neat.core._data_model.models.entities._single_value import (
18
+ from cognite.neat.v0.core._data_model.models.entities._single_value import (
19
19
  ConceptEntity,
20
20
  UnitEntity,
21
21
  )
@@ -246,6 +246,11 @@ class String(DataType):
246
246
  sql = "STRING"
247
247
 
248
248
  name: typing.Literal["string"] = "string"
249
+ max_text_size: int | None = Field(
250
+ None,
251
+ alias="maxTextSize",
252
+ description="Specifies the maximum size in bytes of the text property, when encoded with utf-8.",
253
+ )
249
254
 
250
255
 
251
256
  class LangString(DataType):
@@ -256,6 +261,11 @@ class LangString(DataType):
256
261
  sql = "STRING"
257
262
 
258
263
  name: typing.Literal["langString"] = "langString"
264
+ max_text_size: int | None = Field(
265
+ None,
266
+ alias="maxTextSize",
267
+ description="Specifies the maximum size in bytes of the text property, when encoded with utf-8.",
268
+ )
259
269
 
260
270
 
261
271
  class AnyURI(DataType):
@@ -292,7 +302,7 @@ class DateTime(DataType):
292
302
  python = datetime
293
303
  dms = dms.Timestamp
294
304
  graphql = "Timestamp"
295
- xsd = "dateTimeStamp"
305
+ xsd = "dateTime"
296
306
  sql = "TIMESTAMP"
297
307
 
298
308
  name: typing.Literal["dateTime"] = "dateTime"
@@ -1,11 +1,13 @@
1
1
  from ._constants import Undefined, Unknown
2
2
  from ._loaders import load_connection, load_dms_value_type, load_value_type
3
3
  from ._multi_value import MultiValueTypeInfo
4
+ from ._restrictions import ConceptPropertyCardinalityConstraint, ConceptPropertyValueConstraint, parse_restriction
4
5
  from ._single_value import (
5
6
  AssetEntity,
6
7
  AssetFields,
7
8
  ConceptEntity,
8
9
  ConceptualEntity,
10
+ ContainerConstraintEntity,
9
11
  ContainerEntity,
10
12
  ContainerIndexEntity,
11
13
  DataModelEntity,
@@ -31,7 +33,10 @@ __all__ = [
31
33
  "CdfResourceEntityList",
32
34
  "ClassEntityList",
33
35
  "ConceptEntity",
36
+ "ConceptPropertyCardinalityConstraint",
37
+ "ConceptPropertyValueConstraint",
34
38
  "ConceptualEntity",
39
+ "ContainerConstraintEntity",
35
40
  "ContainerEntity",
36
41
  "ContainerEntityList",
37
42
  "ContainerIndexEntity",
@@ -61,4 +66,5 @@ __all__ = [
61
66
  "load_connection",
62
67
  "load_dms_value_type",
63
68
  "load_value_type",
69
+ "parse_restriction",
64
70
  ]
@@ -0,0 +1,155 @@
1
+ from typing import Literal, overload
2
+
3
+ from cognite.neat.v0.core._data_model.models.data_types import DataType
4
+ from cognite.neat.v0.core._issues.errors import NeatTypeError
5
+
6
+ from ._multi_value import MultiValueTypeInfo
7
+ from ._single_value import (
8
+ ConceptEntity,
9
+ EdgeEntity,
10
+ PhysicalUnknownEntity,
11
+ ReverseConnectionEntity,
12
+ Unknown,
13
+ UnknownEntity,
14
+ ViewEntity,
15
+ )
16
+
17
+
18
+ @overload
19
+ def load_value_type(
20
+ raw: str | MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity,
21
+ default_prefix: str,
22
+ return_on_failure: Literal[False] = False,
23
+ ) -> MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity: ...
24
+
25
+
26
+ @overload
27
+ def load_value_type(
28
+ raw: str | MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity,
29
+ default_prefix: str,
30
+ return_on_failure: Literal[True],
31
+ ) -> MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity | None | str: ...
32
+
33
+
34
+ def load_value_type(
35
+ raw: str | MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity,
36
+ default_prefix: str,
37
+ return_on_failure: Literal[True, False] = False,
38
+ ) -> MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity | None | str:
39
+ """
40
+ Loads a value type from a raw string or entity.
41
+
42
+ Args:
43
+ raw: The raw value to load.
44
+ default_prefix: The default prefix to use if not specified in the raw value.
45
+ return_on_failure: If True, returns the raw value on parsing failure instead of raising an error.
46
+
47
+ Returns:
48
+ The loaded value type entity, or the raw value if loading fails and `return_on_failure` is True.
49
+ """
50
+ if isinstance(raw, MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity):
51
+ return raw
52
+ elif isinstance(raw, str):
53
+ # property holding xsd data type
54
+ # check if it is multi value type
55
+ if "," in raw:
56
+ value_type = MultiValueTypeInfo.load(raw)
57
+ value_type.set_default_prefix(default_prefix)
58
+ return value_type
59
+ elif DataType.is_data_type(raw):
60
+ return DataType.load(raw)
61
+
62
+ # unknown value type
63
+ elif raw == str(Unknown):
64
+ return UnknownEntity()
65
+
66
+ # property holding link to class
67
+ else:
68
+ return ConceptEntity.load(raw, prefix=default_prefix, return_on_failure=return_on_failure)
69
+ else:
70
+ raise NeatTypeError(f"Invalid value type: {type(raw)}")
71
+
72
+
73
+ @overload
74
+ def load_dms_value_type(
75
+ raw: str | DataType | ViewEntity | PhysicalUnknownEntity,
76
+ default_space: str,
77
+ default_version: str,
78
+ return_on_failure: Literal[False],
79
+ ) -> DataType | ViewEntity | PhysicalUnknownEntity: ...
80
+
81
+
82
+ @overload
83
+ def load_dms_value_type(
84
+ raw: str | DataType | ViewEntity | PhysicalUnknownEntity,
85
+ default_space: str,
86
+ default_version: str,
87
+ return_on_failure: Literal[True],
88
+ ) -> DataType | ViewEntity | PhysicalUnknownEntity | str: ...
89
+
90
+
91
+ def load_dms_value_type(
92
+ raw: str | DataType | ViewEntity | PhysicalUnknownEntity,
93
+ default_space: str,
94
+ default_version: str,
95
+ return_on_failure: Literal[True, False] = False,
96
+ ) -> DataType | ViewEntity | PhysicalUnknownEntity | str:
97
+ """
98
+ Loads a value type from a raw string or entity in the context of a data modeling service
99
+
100
+ Args:
101
+ raw: The raw value to load.
102
+ default_space: The default space to use if not specified in the raw value.
103
+ default_version: The default version to use if not specified in the raw value.
104
+ return_on_failure: If True, returns the raw value on parsing failure instead of raising an error.
105
+
106
+ Returns:
107
+ The loaded value type entity, or the raw value if loading fails and `return_on_failure` is True.
108
+ """
109
+ if isinstance(raw, DataType | ViewEntity | PhysicalUnknownEntity):
110
+ return raw
111
+ elif isinstance(raw, str):
112
+ if DataType.is_data_type(raw):
113
+ return DataType.load(raw)
114
+ elif raw == str(Unknown):
115
+ return PhysicalUnknownEntity()
116
+ else:
117
+ return ViewEntity.load(
118
+ raw, space=default_space, version=default_version, return_on_failure=return_on_failure
119
+ )
120
+ raise NeatTypeError(f"Invalid value type: {type(raw)}")
121
+
122
+
123
+ @overload
124
+ def load_connection(
125
+ raw: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | str | None,
126
+ default_space: str,
127
+ default_version: str,
128
+ return_on_failure: Literal[False] = False,
129
+ ) -> Literal["direct"] | ReverseConnectionEntity | EdgeEntity | None: ...
130
+
131
+
132
+ @overload
133
+ def load_connection(
134
+ raw: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | str | None,
135
+ default_space: str,
136
+ default_version: str,
137
+ return_on_failure: Literal[True],
138
+ ) -> Literal["direct"] | ReverseConnectionEntity | EdgeEntity | None | str: ...
139
+
140
+
141
+ def load_connection(
142
+ raw: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | str | None,
143
+ default_space: str,
144
+ default_version: str,
145
+ return_on_failure: Literal[True, False] = False,
146
+ ) -> Literal["direct"] | ReverseConnectionEntity | EdgeEntity | None | str:
147
+ if isinstance(raw, str) and raw.lower() == "direct":
148
+ return "direct" # type: ignore[return-value]
149
+ elif isinstance(raw, EdgeEntity | ReverseConnectionEntity) or raw is None:
150
+ return raw # type: ignore[return-value]
151
+ elif isinstance(raw, str) and raw.startswith("edge"):
152
+ return EdgeEntity.load(raw, space=default_space, version=default_version, return_on_failure=return_on_failure) # type: ignore[return-value]
153
+ elif isinstance(raw, str) and raw.startswith("reverse"):
154
+ return ReverseConnectionEntity.load(raw, return_on_failure=return_on_failure) # type: ignore[return-value]
155
+ raise NeatTypeError(f"Invalid connection: {type(raw)}")
@@ -6,8 +6,8 @@ from pydantic import (
6
6
  model_validator,
7
7
  )
8
8
 
9
- from cognite.neat.core._data_model._constants import EntityTypes
10
- from cognite.neat.core._data_model.models.data_types import DataType
9
+ from cognite.neat.v0.core._data_model._constants import EntityTypes
10
+ from cognite.neat.v0.core._data_model.models.data_types import DataType
11
11
 
12
12
  from ._constants import _PARSE, Undefined
13
13
  from ._single_value import ConceptEntity, UnknownEntity