cognite-neat 0.123.26__py3-none-any.whl → 1.0.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. cognite/neat/__init__.py +4 -3
  2. cognite/neat/_client/__init__.py +5 -0
  3. cognite/neat/_client/api.py +8 -0
  4. cognite/neat/_client/client.py +21 -0
  5. cognite/neat/_client/config.py +40 -0
  6. cognite/neat/_client/containers_api.py +138 -0
  7. cognite/neat/_client/data_classes.py +44 -0
  8. cognite/neat/_client/data_model_api.py +115 -0
  9. cognite/neat/_client/init/credentials.py +70 -0
  10. cognite/neat/_client/init/env_vars.py +131 -0
  11. cognite/neat/_client/init/main.py +51 -0
  12. cognite/neat/_client/spaces_api.py +115 -0
  13. cognite/neat/_client/statistics_api.py +24 -0
  14. cognite/neat/_client/views_api.py +144 -0
  15. cognite/neat/_config.py +266 -0
  16. cognite/neat/_data_model/_analysis.py +571 -0
  17. cognite/neat/_data_model/_constants.py +74 -0
  18. cognite/neat/_data_model/_identifiers.py +61 -0
  19. cognite/neat/_data_model/_shared.py +41 -0
  20. cognite/neat/_data_model/_snapshot.py +134 -0
  21. cognite/neat/_data_model/deployer/_differ.py +140 -0
  22. cognite/neat/_data_model/deployer/_differ_container.py +360 -0
  23. cognite/neat/_data_model/deployer/_differ_data_model.py +54 -0
  24. cognite/neat/_data_model/deployer/_differ_space.py +9 -0
  25. cognite/neat/_data_model/deployer/_differ_view.py +299 -0
  26. cognite/neat/_data_model/deployer/data_classes.py +644 -0
  27. cognite/neat/_data_model/deployer/deployer.py +431 -0
  28. cognite/neat/_data_model/exporters/__init__.py +15 -0
  29. cognite/neat/_data_model/exporters/_api_exporter.py +37 -0
  30. cognite/neat/_data_model/exporters/_base.py +24 -0
  31. cognite/neat/_data_model/exporters/_table_exporter/exporter.py +128 -0
  32. cognite/neat/_data_model/exporters/_table_exporter/workbook.py +409 -0
  33. cognite/neat/_data_model/exporters/_table_exporter/writer.py +480 -0
  34. cognite/neat/_data_model/importers/__init__.py +5 -0
  35. cognite/neat/_data_model/importers/_api_importer.py +166 -0
  36. cognite/neat/_data_model/importers/_base.py +16 -0
  37. cognite/neat/_data_model/importers/_table_importer/data_classes.py +344 -0
  38. cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
  39. cognite/neat/_data_model/importers/_table_importer/reader.py +1102 -0
  40. cognite/neat/_data_model/importers/_table_importer/source.py +94 -0
  41. cognite/neat/_data_model/models/conceptual/_base.py +18 -0
  42. cognite/neat/_data_model/models/conceptual/_concept.py +67 -0
  43. cognite/neat/_data_model/models/conceptual/_data_model.py +51 -0
  44. cognite/neat/_data_model/models/conceptual/_properties.py +104 -0
  45. cognite/neat/_data_model/models/conceptual/_property.py +105 -0
  46. cognite/neat/_data_model/models/dms/__init__.py +206 -0
  47. cognite/neat/_data_model/models/dms/_base.py +31 -0
  48. cognite/neat/_data_model/models/dms/_constants.py +48 -0
  49. cognite/neat/_data_model/models/dms/_constraints.py +42 -0
  50. cognite/neat/_data_model/models/dms/_container.py +159 -0
  51. cognite/neat/_data_model/models/dms/_data_model.py +95 -0
  52. cognite/neat/_data_model/models/dms/_data_types.py +195 -0
  53. cognite/neat/_data_model/models/dms/_http.py +28 -0
  54. cognite/neat/_data_model/models/dms/_indexes.py +30 -0
  55. cognite/neat/_data_model/models/dms/_limits.py +96 -0
  56. cognite/neat/_data_model/models/dms/_references.py +141 -0
  57. cognite/neat/_data_model/models/dms/_schema.py +18 -0
  58. cognite/neat/_data_model/models/dms/_space.py +48 -0
  59. cognite/neat/_data_model/models/dms/_types.py +17 -0
  60. cognite/neat/_data_model/models/dms/_view_filter.py +310 -0
  61. cognite/neat/_data_model/models/dms/_view_property.py +235 -0
  62. cognite/neat/_data_model/models/dms/_views.py +216 -0
  63. cognite/neat/_data_model/models/entities/__init__.py +50 -0
  64. cognite/neat/_data_model/models/entities/_base.py +101 -0
  65. cognite/neat/_data_model/models/entities/_constants.py +22 -0
  66. cognite/neat/_data_model/models/entities/_data_types.py +144 -0
  67. cognite/neat/_data_model/models/entities/_identifiers.py +61 -0
  68. cognite/neat/_data_model/models/entities/_parser.py +226 -0
  69. cognite/neat/_data_model/validation/dms/__init__.py +75 -0
  70. cognite/neat/_data_model/validation/dms/_ai_readiness.py +381 -0
  71. cognite/neat/_data_model/validation/dms/_base.py +25 -0
  72. cognite/neat/_data_model/validation/dms/_connections.py +681 -0
  73. cognite/neat/_data_model/validation/dms/_consistency.py +58 -0
  74. cognite/neat/_data_model/validation/dms/_containers.py +199 -0
  75. cognite/neat/_data_model/validation/dms/_limits.py +368 -0
  76. cognite/neat/_data_model/validation/dms/_orchestrator.py +70 -0
  77. cognite/neat/_data_model/validation/dms/_views.py +164 -0
  78. cognite/neat/_exceptions.py +68 -0
  79. cognite/neat/_issues.py +68 -0
  80. cognite/neat/_session/__init__.py +3 -0
  81. cognite/neat/_session/_html/_render.py +30 -0
  82. cognite/neat/_session/_html/static/__init__.py +8 -0
  83. cognite/neat/_session/_html/static/deployment.css +476 -0
  84. cognite/neat/_session/_html/static/deployment.js +181 -0
  85. cognite/neat/_session/_html/static/issues.css +211 -0
  86. cognite/neat/_session/_html/static/issues.js +168 -0
  87. cognite/neat/_session/_html/static/shared.css +186 -0
  88. cognite/neat/_session/_html/templates/__init__.py +4 -0
  89. cognite/neat/_session/_html/templates/deployment.html +80 -0
  90. cognite/neat/_session/_html/templates/issues.html +45 -0
  91. cognite/neat/_session/_issues.py +81 -0
  92. cognite/neat/_session/_physical.py +294 -0
  93. cognite/neat/_session/_result/__init__.py +3 -0
  94. cognite/neat/_session/_result/_deployment/__init__.py +0 -0
  95. cognite/neat/_session/_result/_deployment/_physical/__init__.py +0 -0
  96. cognite/neat/_session/_result/_deployment/_physical/_changes.py +196 -0
  97. cognite/neat/_session/_result/_deployment/_physical/_statistics.py +180 -0
  98. cognite/neat/_session/_result/_deployment/_physical/serializer.py +35 -0
  99. cognite/neat/_session/_result/_result.py +31 -0
  100. cognite/neat/_session/_session.py +81 -0
  101. cognite/neat/_session/_usage_analytics/__init__.py +0 -0
  102. cognite/neat/_session/_usage_analytics/_collector.py +131 -0
  103. cognite/neat/_session/_usage_analytics/_constants.py +23 -0
  104. cognite/neat/_session/_usage_analytics/_storage.py +240 -0
  105. cognite/neat/_session/_wrappers.py +101 -0
  106. cognite/neat/_state_machine/__init__.py +10 -0
  107. cognite/neat/_state_machine/_base.py +37 -0
  108. cognite/neat/_state_machine/_states.py +52 -0
  109. cognite/neat/_store/__init__.py +3 -0
  110. cognite/neat/_store/_provenance.py +88 -0
  111. cognite/neat/_store/_store.py +220 -0
  112. cognite/neat/_utils/__init__.py +0 -0
  113. cognite/neat/_utils/_reader.py +194 -0
  114. cognite/neat/_utils/auxiliary.py +49 -0
  115. cognite/neat/_utils/collection.py +11 -0
  116. cognite/neat/_utils/http_client/__init__.py +39 -0
  117. cognite/neat/_utils/http_client/_client.py +245 -0
  118. cognite/neat/_utils/http_client/_config.py +19 -0
  119. cognite/neat/_utils/http_client/_data_classes.py +294 -0
  120. cognite/neat/_utils/http_client/_tracker.py +31 -0
  121. cognite/neat/_utils/repo.py +19 -0
  122. cognite/neat/_utils/text.py +71 -0
  123. cognite/neat/_utils/useful_types.py +37 -0
  124. cognite/neat/_utils/validation.py +154 -0
  125. cognite/neat/_v0/__init__.py +0 -0
  126. cognite/neat/_v0/core/__init__.py +0 -0
  127. cognite/neat/_v0/core/_client/_api/__init__.py +0 -0
  128. cognite/neat/{core → _v0/core}/_client/_api/data_modeling_loaders.py +8 -7
  129. cognite/neat/{core → _v0/core}/_client/_api/neat_instances.py +5 -5
  130. cognite/neat/{core → _v0/core}/_client/_api/schema.py +5 -5
  131. cognite/neat/{core → _v0/core}/_client/_api/statistics.py +3 -3
  132. cognite/neat/{core → _v0/core}/_client/_api_client.py +1 -1
  133. cognite/neat/_v0/core/_client/data_classes/__init__.py +0 -0
  134. cognite/neat/{core → _v0/core}/_client/data_classes/schema.py +4 -4
  135. cognite/neat/{core → _v0/core}/_client/testing.py +1 -1
  136. cognite/neat/{core → _v0/core}/_constants.py +5 -3
  137. cognite/neat/_v0/core/_data_model/__init__.py +0 -0
  138. cognite/neat/{core → _v0/core}/_data_model/_constants.py +7 -0
  139. cognite/neat/{core → _v0/core}/_data_model/_shared.py +4 -4
  140. cognite/neat/{core → _v0/core}/_data_model/analysis/_base.py +8 -8
  141. cognite/neat/{core → _v0/core}/_data_model/exporters/__init__.py +1 -2
  142. cognite/neat/{core → _v0/core}/_data_model/exporters/_base.py +7 -7
  143. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2dms.py +9 -9
  144. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2excel.py +12 -12
  145. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2instance_template.py +4 -4
  146. cognite/neat/{core/_data_model/exporters/_data_model2ontology.py → _v0/core/_data_model/exporters/_data_model2semantic_model.py} +126 -116
  147. cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
  148. cognite/neat/{core → _v0/core}/_data_model/importers/_base.py +5 -5
  149. cognite/neat/{core → _v0/core}/_data_model/importers/_base_file_reader.py +2 -2
  150. cognite/neat/{core → _v0/core}/_data_model/importers/_dict2data_model.py +5 -5
  151. cognite/neat/{core → _v0/core}/_data_model/importers/_dms2data_model.py +18 -15
  152. cognite/neat/{core → _v0/core}/_data_model/importers/_graph2data_model.py +12 -12
  153. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_base.py +12 -12
  154. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
  155. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_owl2data_model.py +41 -21
  156. cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_shared.py +9 -9
  157. cognite/neat/{core → _v0/core}/_data_model/importers/_spreadsheet2data_model.py +92 -12
  158. cognite/neat/{core → _v0/core}/_data_model/models/__init__.py +3 -3
  159. cognite/neat/{core → _v0/core}/_data_model/models/_base_verified.py +5 -5
  160. cognite/neat/{core → _v0/core}/_data_model/models/_import_contexts.py +1 -1
  161. cognite/neat/{core → _v0/core}/_data_model/models/_types.py +5 -5
  162. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_unverified.py +16 -10
  163. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_validation.py +12 -12
  164. cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_verified.py +9 -9
  165. cognite/neat/{core → _v0/core}/_data_model/models/data_types.py +14 -4
  166. cognite/neat/{core → _v0/core}/_data_model/models/entities/__init__.py +6 -0
  167. cognite/neat/_v0/core/_data_model/models/entities/_loaders.py +155 -0
  168. cognite/neat/{core → _v0/core}/_data_model/models/entities/_multi_value.py +2 -2
  169. cognite/neat/_v0/core/_data_model/models/entities/_restrictions.py +230 -0
  170. cognite/neat/{core → _v0/core}/_data_model/models/entities/_single_value.py +121 -16
  171. cognite/neat/{core → _v0/core}/_data_model/models/entities/_types.py +10 -0
  172. cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.py +5 -5
  173. cognite/neat/{core → _v0/core}/_data_model/models/physical/__init__.py +1 -1
  174. cognite/neat/{core → _v0/core}/_data_model/models/physical/_exporter.py +26 -19
  175. cognite/neat/{core → _v0/core}/_data_model/models/physical/_unverified.py +133 -37
  176. cognite/neat/{core → _v0/core}/_data_model/models/physical/_validation.py +24 -20
  177. cognite/neat/{core → _v0/core}/_data_model/models/physical/_verified.py +95 -24
  178. cognite/neat/{core → _v0/core}/_data_model/transformers/_base.py +4 -4
  179. cognite/neat/{core → _v0/core}/_data_model/transformers/_converters.py +35 -28
  180. cognite/neat/{core → _v0/core}/_data_model/transformers/_mapping.py +7 -7
  181. cognite/neat/{core → _v0/core}/_data_model/transformers/_union_conceptual.py +5 -5
  182. cognite/neat/{core → _v0/core}/_data_model/transformers/_verification.py +7 -7
  183. cognite/neat/_v0/core/_instances/__init__.py +0 -0
  184. cognite/neat/{core → _v0/core}/_instances/_tracking/base.py +1 -1
  185. cognite/neat/{core → _v0/core}/_instances/_tracking/log.py +1 -1
  186. cognite/neat/{core → _v0/core}/_instances/extractors/__init__.py +3 -2
  187. cognite/neat/{core → _v0/core}/_instances/extractors/_base.py +6 -6
  188. cognite/neat/_v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
  189. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_base.py +7 -7
  190. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_classic.py +12 -12
  191. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_relationships.py +3 -3
  192. cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_sequences.py +2 -2
  193. cognite/neat/{core → _v0/core}/_instances/extractors/_dict.py +6 -3
  194. cognite/neat/{core → _v0/core}/_instances/extractors/_dms.py +6 -6
  195. cognite/neat/{core → _v0/core}/_instances/extractors/_dms_graph.py +11 -11
  196. cognite/neat/{core → _v0/core}/_instances/extractors/_mock_graph_generator.py +10 -10
  197. cognite/neat/{core → _v0/core}/_instances/extractors/_raw.py +3 -3
  198. cognite/neat/{core → _v0/core}/_instances/extractors/_rdf_file.py +7 -7
  199. cognite/neat/{core → _v0/core}/_instances/loaders/_base.py +5 -5
  200. cognite/neat/{core → _v0/core}/_instances/loaders/_rdf2dms.py +17 -17
  201. cognite/neat/{core → _v0/core}/_instances/loaders/_rdf_to_instance_space.py +11 -11
  202. cognite/neat/{core → _v0/core}/_instances/queries/_select.py +29 -3
  203. cognite/neat/{core → _v0/core}/_instances/queries/_update.py +1 -1
  204. cognite/neat/{core → _v0/core}/_instances/transformers/_base.py +4 -4
  205. cognite/neat/{core → _v0/core}/_instances/transformers/_classic_cdf.py +6 -6
  206. cognite/neat/{core → _v0/core}/_instances/transformers/_prune_graph.py +4 -4
  207. cognite/neat/{core → _v0/core}/_instances/transformers/_rdfpath.py +1 -1
  208. cognite/neat/{core → _v0/core}/_instances/transformers/_value_type.py +4 -4
  209. cognite/neat/{core → _v0/core}/_issues/_base.py +5 -5
  210. cognite/neat/{core → _v0/core}/_issues/_contextmanagers.py +1 -1
  211. cognite/neat/{core → _v0/core}/_issues/_factory.py +3 -3
  212. cognite/neat/{core → _v0/core}/_issues/errors/__init__.py +1 -1
  213. cognite/neat/{core → _v0/core}/_issues/errors/_external.py +1 -1
  214. cognite/neat/{core → _v0/core}/_issues/errors/_general.py +1 -1
  215. cognite/neat/{core → _v0/core}/_issues/errors/_properties.py +1 -1
  216. cognite/neat/{core → _v0/core}/_issues/errors/_resources.py +2 -2
  217. cognite/neat/{core → _v0/core}/_issues/errors/_wrapper.py +7 -3
  218. cognite/neat/{core → _v0/core}/_issues/warnings/__init__.py +1 -1
  219. cognite/neat/{core → _v0/core}/_issues/warnings/_external.py +1 -1
  220. cognite/neat/{core → _v0/core}/_issues/warnings/_general.py +1 -1
  221. cognite/neat/{core → _v0/core}/_issues/warnings/_models.py +2 -2
  222. cognite/neat/{core → _v0/core}/_issues/warnings/_properties.py +2 -2
  223. cognite/neat/{core → _v0/core}/_issues/warnings/_resources.py +1 -1
  224. cognite/neat/{core → _v0/core}/_issues/warnings/user_modeling.py +1 -1
  225. cognite/neat/{core → _v0/core}/_store/_data_model.py +12 -12
  226. cognite/neat/{core → _v0/core}/_store/_instance.py +43 -10
  227. cognite/neat/{core → _v0/core}/_store/_provenance.py +3 -3
  228. cognite/neat/{core → _v0/core}/_store/exceptions.py +4 -4
  229. cognite/neat/_v0/core/_utils/__init__.py +0 -0
  230. cognite/neat/{core → _v0/core}/_utils/auth.py +22 -12
  231. cognite/neat/{core → _v0/core}/_utils/auxiliary.py +1 -1
  232. cognite/neat/{core → _v0/core}/_utils/collection_.py +2 -2
  233. cognite/neat/{core → _v0/core}/_utils/graph_transformations_report.py +1 -1
  234. cognite/neat/{core → _v0/core}/_utils/rdf_.py +1 -1
  235. cognite/neat/{core → _v0/core}/_utils/reader/_base.py +1 -1
  236. cognite/neat/{core → _v0/core}/_utils/spreadsheet.py +18 -4
  237. cognite/neat/{core → _v0/core}/_utils/text.py +1 -1
  238. cognite/neat/{core → _v0/core}/_utils/upload.py +3 -3
  239. cognite/neat/{session → _v0}/engine/_load.py +1 -1
  240. cognite/neat/_v0/plugins/__init__.py +4 -0
  241. cognite/neat/_v0/plugins/_base.py +9 -0
  242. cognite/neat/_v0/plugins/_data_model.py +48 -0
  243. cognite/neat/{plugins → _v0/plugins}/_issues.py +1 -1
  244. cognite/neat/{plugins → _v0/plugins}/_manager.py +7 -16
  245. cognite/neat/{session → _v0/session}/_base.py +13 -15
  246. cognite/neat/{session → _v0/session}/_collector.py +1 -1
  247. cognite/neat/_v0/session/_diff.py +51 -0
  248. cognite/neat/{session → _v0/session}/_drop.py +3 -3
  249. cognite/neat/{session → _v0/session}/_explore.py +2 -2
  250. cognite/neat/{session → _v0/session}/_fix.py +2 -2
  251. cognite/neat/{session → _v0/session}/_inspect.py +3 -3
  252. cognite/neat/{session → _v0/session}/_mapping.py +3 -3
  253. cognite/neat/{session → _v0/session}/_plugin.py +4 -5
  254. cognite/neat/{session → _v0/session}/_prepare.py +8 -8
  255. cognite/neat/{session → _v0/session}/_read.py +34 -21
  256. cognite/neat/{session → _v0/session}/_set.py +8 -8
  257. cognite/neat/{session → _v0/session}/_show.py +5 -5
  258. cognite/neat/{session → _v0/session}/_state.py +10 -10
  259. cognite/neat/{session → _v0/session}/_subset.py +4 -4
  260. cognite/neat/{session → _v0/session}/_template.py +11 -11
  261. cognite/neat/{session → _v0/session}/_to.py +12 -12
  262. cognite/neat/{session → _v0/session}/_wizard.py +1 -1
  263. cognite/neat/{session → _v0/session}/exceptions.py +5 -5
  264. cognite/neat/_version.py +1 -1
  265. cognite/neat/legacy.py +6 -0
  266. cognite_neat-1.0.22.dist-info/METADATA +123 -0
  267. cognite_neat-1.0.22.dist-info/RECORD +329 -0
  268. cognite_neat-1.0.22.dist-info/WHEEL +4 -0
  269. cognite/neat/core/_data_model/models/entities/_loaders.py +0 -75
  270. cognite/neat/plugins/__init__.py +0 -3
  271. cognite/neat/plugins/data_model/importers/__init__.py +0 -5
  272. cognite/neat/plugins/data_model/importers/_base.py +0 -28
  273. cognite/neat/session/_session/_data_model/__init__.py +0 -3
  274. cognite/neat/session/_session/_data_model/_read.py +0 -193
  275. cognite/neat/session/_session/_data_model/_routes.py +0 -45
  276. cognite/neat/session/_session/_data_model/_show.py +0 -147
  277. cognite/neat/session/_session/_data_model/_write.py +0 -335
  278. cognite_neat-0.123.26.dist-info/METADATA +0 -144
  279. cognite_neat-0.123.26.dist-info/RECORD +0 -201
  280. cognite_neat-0.123.26.dist-info/WHEEL +0 -4
  281. cognite_neat-0.123.26.dist-info/licenses/LICENSE +0 -201
  282. /cognite/neat/{core → _client/init}/__init__.py +0 -0
  283. /cognite/neat/{core/_client/_api → _data_model}/__init__.py +0 -0
  284. /cognite/neat/{core/_client/data_classes → _data_model/deployer}/__init__.py +0 -0
  285. /cognite/neat/{core/_data_model → _data_model/exporters/_table_exporter}/__init__.py +0 -0
  286. /cognite/neat/{core/_instances → _data_model/importers/_table_importer}/__init__.py +0 -0
  287. /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models}/__init__.py +0 -0
  288. /cognite/neat/{core/_utils → _data_model/models/conceptual}/__init__.py +0 -0
  289. /cognite/neat/{plugins/data_model → _data_model/validation}/__init__.py +0 -0
  290. /cognite/neat/{session/_session → _session/_html}/__init__.py +0 -0
  291. /cognite/neat/{core → _v0/core}/_client/__init__.py +0 -0
  292. /cognite/neat/{core → _v0/core}/_client/data_classes/data_modeling.py +0 -0
  293. /cognite/neat/{core → _v0/core}/_client/data_classes/neat_sequence.py +0 -0
  294. /cognite/neat/{core → _v0/core}/_client/data_classes/statistics.py +0 -0
  295. /cognite/neat/{core → _v0/core}/_config.py +0 -0
  296. /cognite/neat/{core → _v0/core}/_data_model/analysis/__init__.py +0 -0
  297. /cognite/neat/{core → _v0/core}/_data_model/catalog/__init__.py +0 -0
  298. /cognite/neat/{core → _v0/core}/_data_model/catalog/classic_model.xlsx +0 -0
  299. /cognite/neat/{core → _v0/core}/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
  300. /cognite/neat/{core → _v0/core}/_data_model/catalog/hello_world_pump.xlsx +0 -0
  301. /cognite/neat/{core → _v0/core}/_data_model/importers/__init__.py +0 -0
  302. /cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/__init__.py +0 -0
  303. /cognite/neat/{core → _v0/core}/_data_model/models/_base_unverified.py +0 -0
  304. /cognite/neat/{core → _v0/core}/_data_model/models/conceptual/__init__.py +0 -0
  305. /cognite/neat/{core → _v0/core}/_data_model/models/entities/_constants.py +0 -0
  306. /cognite/neat/{core → _v0/core}/_data_model/models/entities/_wrapped.py +0 -0
  307. /cognite/neat/{core → _v0/core}/_data_model/models/mapping/__init__.py +0 -0
  308. /cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.yaml +0 -0
  309. /cognite/neat/{core → _v0/core}/_data_model/transformers/__init__.py +0 -0
  310. /cognite/neat/{core → _v0/core}/_instances/_shared.py +0 -0
  311. /cognite/neat/{core → _v0/core}/_instances/_tracking/__init__.py +0 -0
  312. /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
  313. /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44.xml +0 -0
  314. /cognite/neat/{core → _v0/core}/_instances/examples/__init__.py +0 -0
  315. /cognite/neat/{core → _v0/core}/_instances/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
  316. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_assets.py +0 -0
  317. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_data_sets.py +0 -0
  318. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_events.py +0 -0
  319. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_files.py +0 -0
  320. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_labels.py +0 -0
  321. /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_timeseries.py +0 -0
  322. /cognite/neat/{core → _v0/core}/_instances/loaders/__init__.py +0 -0
  323. /cognite/neat/{core → _v0/core}/_instances/queries/__init__.py +0 -0
  324. /cognite/neat/{core → _v0/core}/_instances/queries/_base.py +0 -0
  325. /cognite/neat/{core → _v0/core}/_instances/queries/_queries.py +0 -0
  326. /cognite/neat/{core → _v0/core}/_instances/transformers/__init__.py +0 -0
  327. /cognite/neat/{core → _v0/core}/_issues/__init__.py +0 -0
  328. /cognite/neat/{core → _v0/core}/_issues/formatters.py +0 -0
  329. /cognite/neat/{core → _v0/core}/_shared.py +0 -0
  330. /cognite/neat/{core → _v0/core}/_store/__init__.py +0 -0
  331. /cognite/neat/{core → _v0/core}/_utils/io_.py +0 -0
  332. /cognite/neat/{core → _v0/core}/_utils/reader/__init__.py +0 -0
  333. /cognite/neat/{core → _v0/core}/_utils/tarjan.py +0 -0
  334. /cognite/neat/{core → _v0/core}/_utils/time_.py +0 -0
  335. /cognite/neat/{core → _v0/core}/_utils/xml_.py +0 -0
  336. /cognite/neat/{session → _v0}/engine/__init__.py +0 -0
  337. /cognite/neat/{session → _v0}/engine/_import.py +0 -0
  338. /cognite/neat/{session → _v0}/engine/_interface.py +0 -0
  339. /cognite/neat/{session → _v0/session}/__init__.py +0 -0
  340. /cognite/neat/{session → _v0/session}/_experimental.py +0 -0
  341. /cognite/neat/{session → _v0/session}/_state/README.md +0 -0
@@ -0,0 +1,48 @@
1
+ SPACE_FORMAT_PATTERN = r"^[a-zA-Z][a-zA-Z0-9_-]{0,41}[a-zA-Z0-9]?$"
2
+ DM_EXTERNAL_ID_PATTERN = r"^[a-zA-Z]([a-zA-Z0-9_]{0,253}[a-zA-Z0-9])?$"
3
+ CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN = r"^[a-zA-Z0-9][a-zA-Z0-9_-]{0,253}[a-zA-Z0-9]?$"
4
+ INSTANCE_ID_PATTERN = r"^[^\x00]{1,256}$"
5
+ ENUM_VALUE_IDENTIFIER_PATTERN = r"^[_A-Za-z][_0-9A-Za-z]{0,127}$"
6
+ DM_VERSION_PATTERN = r"^[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?$"
7
+ DATA_MODEL_DESCRIPTION_MAX_LENGTH = 1024
8
+ FORBIDDEN_ENUM_VALUES = frozenset({"true", "false", "null"})
9
+ FORBIDDEN_SPACES = frozenset(["space", "cdf", "dms", "pg3", "shared", "system", "node", "edge"])
10
+ FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS = frozenset(
11
+ [
12
+ "Query",
13
+ "Mutation",
14
+ "Subscription",
15
+ "String",
16
+ "Int32",
17
+ "Int64",
18
+ "Int",
19
+ "Float32",
20
+ "Float64",
21
+ "Float",
22
+ "Timestamp",
23
+ "JSONObject",
24
+ "Date",
25
+ "Numeric",
26
+ "Boolean",
27
+ "PageInfo",
28
+ "File",
29
+ "Sequence",
30
+ "TimeSeries",
31
+ ]
32
+ )
33
+ FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER = frozenset(
34
+ [
35
+ "space",
36
+ "externalId",
37
+ "createdTime",
38
+ "lastUpdatedTime",
39
+ "deletedTime",
40
+ "edge_id",
41
+ "node_id",
42
+ "project_id",
43
+ "property_group",
44
+ "seq",
45
+ "tg_table_name",
46
+ "extensions",
47
+ ]
48
+ )
@@ -0,0 +1,42 @@
1
+ from abc import ABC
2
+ from typing import Annotated, Any, Literal
3
+
4
+ from pydantic import Field, TypeAdapter, field_serializer
5
+ from pydantic_core.core_schema import FieldSerializationInfo
6
+
7
+ from cognite.neat._utils.useful_types import BaseModelObject
8
+
9
+ from ._references import ContainerReference
10
+ from ._types import Bool
11
+
12
+
13
+ class ConstraintDefinition(BaseModelObject, ABC):
14
+ constraint_type: str
15
+
16
+
17
+ class UniquenessConstraintDefinition(ConstraintDefinition):
18
+ constraint_type: Literal["uniqueness"] = "uniqueness"
19
+ properties: list[str] = Field(
20
+ description="List of properties included in the constraint.", min_length=1, max_length=10
21
+ )
22
+ by_space: Bool | None = Field(default=None, description="Whether to make the constraint space-specific.")
23
+
24
+
25
+ class RequiresConstraintDefinition(ConstraintDefinition):
26
+ constraint_type: Literal["requires"] = "requires"
27
+ require: ContainerReference = Field(description="Reference to an existing container.")
28
+
29
+ @field_serializer("require", mode="plain")
30
+ @classmethod
31
+ def serialize_require(cls, require: ContainerReference, info: FieldSerializationInfo) -> dict[str, Any]:
32
+ output = require.model_dump(**vars(info))
33
+ output["type"] = "container"
34
+ return output
35
+
36
+
37
+ Constraint = Annotated[
38
+ UniquenessConstraintDefinition | RequiresConstraintDefinition,
39
+ Field(discriminator="constraint_type"),
40
+ ]
41
+
42
+ ConstraintAdapter: TypeAdapter[Constraint] = TypeAdapter(Constraint)
@@ -0,0 +1,159 @@
1
+ import re
2
+ from abc import ABC
3
+ from typing import Any, Literal
4
+
5
+ from pydantic import Field, field_validator
6
+ from pydantic_core.core_schema import ValidationInfo
7
+
8
+ from cognite.neat._utils.text import humanize_collection
9
+ from cognite.neat._utils.useful_types import BaseModelObject
10
+
11
+ from ._base import APIResource, Resource, WriteableResource
12
+ from ._constants import (
13
+ CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN,
14
+ DM_EXTERNAL_ID_PATTERN,
15
+ FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS,
16
+ FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER,
17
+ SPACE_FORMAT_PATTERN,
18
+ )
19
+ from ._constraints import Constraint
20
+ from ._data_types import DataType
21
+ from ._indexes import Index
22
+ from ._references import ContainerReference
23
+
24
+ KEY_PATTERN = re.compile(CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN)
25
+
26
+
27
+ class ContainerPropertyDefinition(BaseModelObject):
28
+ immutable: bool | None = Field(
29
+ default=None,
30
+ description="Should updates to this property be rejected after the initial population?",
31
+ )
32
+ nullable: bool | None = Field(
33
+ default=None,
34
+ description="Does this property need to be set to a value, or not?",
35
+ )
36
+ auto_increment: bool | None = Field(
37
+ default=None,
38
+ description="Increment the property based on its highest current value (max value).",
39
+ )
40
+ default_value: str | int | float | bool | dict[str, Any] | None = Field(
41
+ default=None,
42
+ description="Default value to use when you do not specify a value for the property.",
43
+ )
44
+ description: str | None = Field(
45
+ default=None,
46
+ description="Description of the content and suggested use for this property.",
47
+ max_length=1024,
48
+ )
49
+ name: str | None = Field(
50
+ default=None,
51
+ description="Readable property name.",
52
+ max_length=255,
53
+ )
54
+ type: DataType = Field(description="The type of data you can store in this property.")
55
+
56
+
57
+ class Container(Resource, APIResource[ContainerReference], ABC):
58
+ space: str = Field(
59
+ description="The workspace for the container, a unique identifier for the space.",
60
+ min_length=1,
61
+ max_length=43,
62
+ pattern=SPACE_FORMAT_PATTERN,
63
+ )
64
+ external_id: str = Field(
65
+ description="External-id of the container.",
66
+ min_length=1,
67
+ max_length=255,
68
+ pattern=DM_EXTERNAL_ID_PATTERN,
69
+ )
70
+ name: str | None = Field(
71
+ default=None,
72
+ description="name for the container.",
73
+ max_length=255,
74
+ )
75
+ description: str | None = Field(
76
+ default=None,
77
+ description="Description of the container.",
78
+ max_length=1024,
79
+ )
80
+ used_for: Literal["node", "edge", "all"] | None = Field(
81
+ default=None,
82
+ description="Should this operation apply to nodes, edges or both.",
83
+ )
84
+ properties: dict[str, ContainerPropertyDefinition] = Field(
85
+ description="Set of properties to apply to the container.",
86
+ )
87
+ constraints: dict[str, Constraint] | None = Field(
88
+ default=None,
89
+ description="Set of constraints to apply to the container.",
90
+ max_length=10,
91
+ )
92
+ indexes: dict[str, Index] | None = Field(
93
+ default=None,
94
+ description="Set of indexes to apply to the container.",
95
+ max_length=10,
96
+ )
97
+
98
+ @field_validator("indexes", "constraints", mode="after")
99
+ def validate_key_length(cls, val: dict[str, Any] | None, info: ValidationInfo) -> dict[str, Any] | None:
100
+ """Validate keys"""
101
+ if not isinstance(val, dict):
102
+ return val
103
+ invalid_keys = {key for key in val.keys() if not (1 <= len(key) <= 43)}
104
+ if invalid_keys:
105
+ raise ValueError(
106
+ f"{info.field_name} keys must be between 1 and 43 characters long. Invalid keys: "
107
+ f"{humanize_collection(invalid_keys)}"
108
+ )
109
+ return val
110
+
111
+ @field_validator("properties", mode="after")
112
+ def validate_property_keys(cls, val: dict[str, Any]) -> dict[str, Any]:
113
+ """Validate property keys"""
114
+ if invalid_keys := {key for key in val if not KEY_PATTERN.match(key)}:
115
+ raise ValueError(
116
+ f"Property keys must match pattern '{CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN}'. "
117
+ f"Invalid keys: {humanize_collection(invalid_keys)}"
118
+ )
119
+
120
+ if forbidden_keys := set(val.keys()).intersection(FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER):
121
+ raise ValueError(
122
+ f"Property keys cannot be any of the following reserved values: {humanize_collection(forbidden_keys)}"
123
+ )
124
+ return val
125
+
126
+ @field_validator("external_id")
127
+ def check_forbidden_external_id_value(cls, val: str) -> str:
128
+ """Check the external_id not present in forbidden set"""
129
+ if val in FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS:
130
+ raise ValueError(
131
+ f"{val!r} is a reserved container External ID. Reserved External IDs are: "
132
+ f"{humanize_collection(FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS)}"
133
+ )
134
+ return val
135
+
136
+ def as_reference(self) -> ContainerReference:
137
+ return ContainerReference(
138
+ space=self.space,
139
+ external_id=self.external_id,
140
+ )
141
+
142
+
143
+ class ContainerRequest(Container): ...
144
+
145
+
146
+ class ContainerResponse(Container, WriteableResource[ContainerRequest]):
147
+ created_time: int = Field(
148
+ description="When the container was created. The number of milliseconds since 00:00:00 "
149
+ "Thursday, 1 January 1970, "
150
+ "Coordinated Universal Time (UTC), minus leap seconds."
151
+ )
152
+ last_updated_time: int = Field(
153
+ description="When the container was last updated. The number of milliseconds since 00:00:00 Thursday, "
154
+ "1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
155
+ )
156
+ is_global: bool = Field(description="Whether the container is a global container.")
157
+
158
+ def as_request(self) -> "ContainerRequest":
159
+ return ContainerRequest.model_validate(self.model_dump(by_alias=True))
@@ -0,0 +1,95 @@
1
+ from abc import ABC
2
+ from typing import Any
3
+
4
+ from pydantic import Field, field_serializer
5
+ from pydantic_core.core_schema import FieldSerializationInfo
6
+
7
+ from ._base import APIResource, Resource, WriteableResource
8
+ from ._constants import (
9
+ DATA_MODEL_DESCRIPTION_MAX_LENGTH,
10
+ DM_EXTERNAL_ID_PATTERN,
11
+ DM_VERSION_PATTERN,
12
+ SPACE_FORMAT_PATTERN,
13
+ )
14
+ from ._references import DataModelReference, ViewReference
15
+
16
+
17
+ class DataModel(Resource, APIResource[DataModelReference], ABC):
18
+ """Cognite Data Model resource.
19
+
20
+ Data models group and structure views into reusable collections.
21
+ A data model contains a set of views where the node types can
22
+ refer to each other with direct relations and edges.
23
+ """
24
+
25
+ space: str = Field(
26
+ description="The workspace for the data model, a unique identifier for the space.",
27
+ min_length=1,
28
+ max_length=43,
29
+ pattern=SPACE_FORMAT_PATTERN,
30
+ )
31
+ external_id: str = Field(
32
+ description="External-id of the data model.",
33
+ min_length=1,
34
+ max_length=255,
35
+ pattern=DM_EXTERNAL_ID_PATTERN,
36
+ )
37
+ version: str = Field(
38
+ description="Version of the data model.",
39
+ max_length=43,
40
+ pattern=DM_VERSION_PATTERN,
41
+ )
42
+ name: str | None = Field(
43
+ default=None,
44
+ description="Human readable name for the data model.",
45
+ max_length=255,
46
+ )
47
+ description: str | None = Field(
48
+ default=None,
49
+ description="Description of the data model.",
50
+ max_length=DATA_MODEL_DESCRIPTION_MAX_LENGTH,
51
+ )
52
+ # The API supports View here, but in Neat we will only use ViewReference
53
+ views: list[ViewReference] | None = Field(
54
+ description="List of views included in this data model.",
55
+ default=None,
56
+ )
57
+
58
+ def as_reference(self) -> DataModelReference:
59
+ return DataModelReference(
60
+ space=self.space,
61
+ external_id=self.external_id,
62
+ version=self.version,
63
+ )
64
+
65
+ @field_serializer("views", mode="plain")
66
+ @classmethod
67
+ def serialize_views(
68
+ cls, views: list[ViewReference] | None, info: FieldSerializationInfo
69
+ ) -> list[dict[str, Any]] | None:
70
+ if views is None:
71
+ return None
72
+ output: list[dict[str, Any]] = []
73
+ for view in views:
74
+ dumped = view.model_dump(**vars(info))
75
+ dumped["type"] = "view"
76
+ output.append(dumped)
77
+ return output
78
+
79
+
80
+ class DataModelRequest(DataModel): ...
81
+
82
+
83
+ class DataModelResponse(DataModel, WriteableResource[DataModelRequest]):
84
+ created_time: int = Field(
85
+ description="When the data model was created. The number of milliseconds since 00:00:00 Thursday, "
86
+ "1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
87
+ )
88
+ last_updated_time: int = Field(
89
+ description="When the data model was last updated. The number of milliseconds since 00:00:00 Thursday, "
90
+ "1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
91
+ )
92
+ is_global: bool = Field(description="Is this a global data model.")
93
+
94
+ def as_request(self) -> DataModelRequest:
95
+ return DataModelRequest.model_validate(self.model_dump(by_alias=True))
@@ -0,0 +1,195 @@
1
+ import re
2
+ from abc import ABC
3
+ from collections.abc import Mapping
4
+ from typing import Annotated, Literal
5
+
6
+ from pydantic import Field, TypeAdapter, field_validator
7
+
8
+ from cognite.neat._utils.auxiliary import get_concrete_subclasses
9
+ from cognite.neat._utils.useful_types import BaseModelObject
10
+
11
+ from ._constants import ENUM_VALUE_IDENTIFIER_PATTERN, FORBIDDEN_ENUM_VALUES, INSTANCE_ID_PATTERN
12
+ from ._references import ContainerReference, ViewReference
13
+
14
+
15
+ class PropertyTypeDefinition(BaseModelObject, ABC):
16
+ type: str
17
+
18
+
19
+ class ListablePropertyTypeDefinition(PropertyTypeDefinition, ABC):
20
+ list: bool | None = Field(
21
+ default=None,
22
+ description="Specifies that the data type is a list of values.",
23
+ )
24
+ max_list_size: int | None = Field(
25
+ default=None,
26
+ description="Specifies the maximum number of values in the list",
27
+ )
28
+
29
+
30
+ class TextProperty(ListablePropertyTypeDefinition):
31
+ type: Literal["text"] = "text"
32
+ max_text_size: int | None = Field(
33
+ default=None,
34
+ description="Specifies the maximum size in bytes of the text property, when encoded with utf-8.",
35
+ )
36
+ collation: str | None = Field(
37
+ default=None,
38
+ description="he set of language specific rules - used when sorting text fields.",
39
+ )
40
+
41
+
42
+ class Unit(BaseModelObject):
43
+ external_id: str = Field(
44
+ description="The external ID of the unit. Must match the unit in the Cognite Unit catalog.",
45
+ min_length=1,
46
+ max_length=256,
47
+ pattern=INSTANCE_ID_PATTERN,
48
+ )
49
+ source_unit: str | None = Field(
50
+ default=None,
51
+ description="The unit in the source system.",
52
+ )
53
+
54
+
55
+ class FloatProperty(ListablePropertyTypeDefinition, ABC):
56
+ unit: Unit | None = Field(default=None, description="The unit of the data stored in this property", exclude=False)
57
+
58
+
59
+ class Float32Property(FloatProperty):
60
+ type: Literal["float32"] = "float32"
61
+
62
+
63
+ class Float64Property(FloatProperty):
64
+ type: Literal["float64"] = "float64"
65
+
66
+
67
+ class BooleanProperty(ListablePropertyTypeDefinition):
68
+ type: Literal["boolean"] = "boolean"
69
+
70
+
71
+ class Int32Property(ListablePropertyTypeDefinition):
72
+ type: Literal["int32"] = "int32"
73
+
74
+
75
+ class Int64Property(ListablePropertyTypeDefinition):
76
+ type: Literal["int64"] = "int64"
77
+
78
+
79
+ class TimestampProperty(ListablePropertyTypeDefinition):
80
+ type: Literal["timestamp"] = "timestamp"
81
+
82
+
83
+ class DateProperty(ListablePropertyTypeDefinition):
84
+ type: Literal["date"] = "date"
85
+
86
+
87
+ class JSONProperty(ListablePropertyTypeDefinition):
88
+ type: Literal["json"] = "json"
89
+
90
+
91
+ class TimeseriesCDFExternalIdReference(ListablePropertyTypeDefinition):
92
+ type: Literal["timeseries"] = "timeseries"
93
+
94
+
95
+ class FileCDFExternalIdReference(ListablePropertyTypeDefinition):
96
+ type: Literal["file"] = "file"
97
+
98
+
99
+ class SequenceCDFExternalIdReference(ListablePropertyTypeDefinition):
100
+ type: Literal["sequence"] = "sequence"
101
+
102
+
103
+ class DirectNodeRelation(ListablePropertyTypeDefinition):
104
+ type: Literal["direct"] = "direct"
105
+ container: ContainerReference | None = Field(
106
+ default=None,
107
+ description="The (optional) required type for the node the direct relation points to. If specified, "
108
+ "the node must exist before the direct relation is referenced and of the specified type. "
109
+ "If no container specification is used, the node will be auto created with the built-in node "
110
+ "container type, and it does not explicitly have to be created before the node that references it.",
111
+ )
112
+ # This property is only available in the response object. It will be ignored in the request object.
113
+ # In the request object, use ViewCoreProperty.source instead.
114
+ source: ViewReference | None = Field(
115
+ None, description="The hint showing the view what the direct relation points to.", exclude=True
116
+ )
117
+
118
+
119
+ class EnumValue(BaseModelObject):
120
+ name: str | None = Field(
121
+ None,
122
+ max_length=255,
123
+ description="The name of the enum value.",
124
+ )
125
+ description: str | None = Field(
126
+ default=None,
127
+ max_length=1024,
128
+ description="Description of the enum value.",
129
+ )
130
+
131
+
132
+ _ENUM_KEY = re.compile(ENUM_VALUE_IDENTIFIER_PATTERN)
133
+
134
+
135
+ class EnumProperty(PropertyTypeDefinition):
136
+ type: Literal["enum"] = "enum"
137
+ unknown_value: str | None = Field(
138
+ default=None,
139
+ description="TThe value to use when the enum value is unknown. This can optionally be used to "
140
+ "provide forward-compatibility, Specifying what value to use if the client does not "
141
+ "recognize the returned value. It is not possible to ingest the unknown value, "
142
+ "but it must be part of the allowed values.",
143
+ min_length=1,
144
+ max_length=128,
145
+ pattern=ENUM_VALUE_IDENTIFIER_PATTERN,
146
+ )
147
+ values: dict[str, EnumValue] = Field(
148
+ description="A set of all possible values for the enum property.",
149
+ min_length=1,
150
+ max_length=32,
151
+ )
152
+
153
+ @field_validator("values", mode="after")
154
+ def _valid_enum_value(cls, val: dict[str, EnumValue]) -> dict[str, EnumValue]:
155
+ errors: list[str] = []
156
+ for key in val.keys():
157
+ if not _ENUM_KEY.match(key):
158
+ errors.append(
159
+ f"Enum value {key!r} is not valid. Enum values must match "
160
+ f"the pattern: {ENUM_VALUE_IDENTIFIER_PATTERN}"
161
+ )
162
+ if len(key) > 128 or len(key) < 1:
163
+ errors.append(f"Enum value {key!r} must be between 1 and 128 characters long.")
164
+ if key.lower() in FORBIDDEN_ENUM_VALUES:
165
+ errors.append(
166
+ f"Enum value {key!r} cannot be any of the following reserved values: {FORBIDDEN_ENUM_VALUES}"
167
+ )
168
+ if errors:
169
+ raise ValueError(";".join(errors))
170
+ return val
171
+
172
+
173
+ DataType = Annotated[
174
+ TextProperty
175
+ | Float32Property
176
+ | Float64Property
177
+ | BooleanProperty
178
+ | Int32Property
179
+ | Int64Property
180
+ | TimestampProperty
181
+ | DateProperty
182
+ | JSONProperty
183
+ | TimeseriesCDFExternalIdReference
184
+ | FileCDFExternalIdReference
185
+ | SequenceCDFExternalIdReference
186
+ | EnumProperty
187
+ | DirectNodeRelation,
188
+ Field(discriminator="type"),
189
+ ]
190
+
191
+ DataTypeAdapter: TypeAdapter[DataType] = TypeAdapter(DataType)
192
+
193
+ DMS_DATA_TYPES: Mapping[str, type[PropertyTypeDefinition]] = {
194
+ cls_.model_fields["type"].default: cls_ for cls_ in get_concrete_subclasses(PropertyTypeDefinition)
195
+ }
@@ -0,0 +1,28 @@
1
+ from typing import TypeAlias, TypeVar
2
+
3
+ from cognite.neat._utils.http_client import ItemBody
4
+ from cognite.neat._utils.useful_types import ReferenceObject
5
+
6
+ from ._container import ContainerRequest
7
+ from ._data_model import DataModelRequest
8
+ from ._references import (
9
+ ContainerReference,
10
+ DataModelReference,
11
+ SpaceReference,
12
+ ViewReference,
13
+ )
14
+ from ._space import SpaceRequest
15
+ from ._views import ViewRequest
16
+
17
+ DataModelResource: TypeAlias = SpaceRequest | DataModelRequest | ViewRequest | ContainerRequest
18
+
19
+ T_DataModelResource = TypeVar("T_DataModelResource", bound=DataModelResource)
20
+
21
+ ResourceId: TypeAlias = SpaceReference | DataModelReference | ViewReference | ContainerReference
22
+
23
+ T_ResourceId = TypeVar("T_ResourceId", bound=ResourceId)
24
+
25
+
26
+ class DataModelBody(ItemBody[ReferenceObject, DataModelResource]):
27
+ def as_ids(self) -> list[ReferenceObject]:
28
+ return [item.as_reference() for item in self.items]
@@ -0,0 +1,30 @@
1
+ from abc import ABC
2
+ from typing import Annotated, Literal
3
+
4
+ from pydantic import Field, TypeAdapter
5
+
6
+ from cognite.neat._utils.useful_types import BaseModelObject
7
+
8
+ from ._types import Bool
9
+
10
+
11
+ class IndexDefinition(BaseModelObject, ABC):
12
+ index_type: str
13
+ properties: list[str] = Field(description="List of properties to define the index across.")
14
+
15
+
16
+ class BtreeIndex(IndexDefinition):
17
+ index_type: Literal["btree"] = "btree"
18
+ by_space: Bool | None = Field(default=None, description="Whether to make the index space-specific.")
19
+ cursorable: Bool | None = Field(
20
+ default=None, description="Whether the index can be used for cursor-based pagination."
21
+ )
22
+
23
+
24
+ class InvertedIndex(IndexDefinition):
25
+ index_type: Literal["inverted"] = "inverted"
26
+
27
+
28
+ Index = Annotated[BtreeIndex | InvertedIndex, Field(discriminator="index_type")]
29
+
30
+ IndexAdapter: TypeAdapter[Index] = TypeAdapter(Index)
@@ -0,0 +1,96 @@
1
+ from pydantic import BaseModel, Field
2
+
3
+ from cognite.neat._client.statistics_api import StatisticsResponse
4
+
5
+ from ._data_types import DataType, DirectNodeRelation, Int32Property, Int64Property
6
+
7
+
8
+ class SpaceLimit(BaseModel):
9
+ """Limits for spaces."""
10
+
11
+ limit: int = 100
12
+
13
+
14
+ class ListablePropertyLimits(BaseModel):
15
+ """Limits for list properties."""
16
+
17
+ limit: int = Field(2_000, description="Max limit for types other than int32/64 with b-tree index.")
18
+ int32_with_btree_limit: int = Field(600, description="Max limit for Int32 properties with B-tree index.")
19
+ int64_with_btree_limit: int = Field(300, description="Max limit for Int64 properties with B-tree index.")
20
+ # defaults
21
+ direct_default: int = Field(100, description="Default limit for direct relations.")
22
+ other_default: int = Field(1_000, description="Default limit for types other than direct.")
23
+
24
+ def __call__(self, data_type: DataType, has_btree_index: bool = False) -> int:
25
+ """Get the limit for a specific data type."""
26
+ if isinstance(data_type, Int32Property) and has_btree_index:
27
+ return self.int32_with_btree_limit
28
+ if isinstance(data_type, Int64Property) and has_btree_index:
29
+ return self.int64_with_btree_limit
30
+ return self.limit
31
+
32
+ def default(self, data_type: DataType) -> int:
33
+ """Get the default limit for a specific data type."""
34
+ if isinstance(data_type, DirectNodeRelation):
35
+ return self.direct_default
36
+ return self.other_default
37
+
38
+
39
+ class ContainerPropertyLimits(BaseModel):
40
+ limit: int = Field(100, description="Limit of properties per container.")
41
+ enums: int = Field(32, description="Limit of enums per property.")
42
+ total: int = Field(25_000, description="Total limit of properties.")
43
+
44
+ listable: ListablePropertyLimits = Field(default_factory=ListablePropertyLimits)
45
+
46
+ def __call__(self) -> int:
47
+ return self.limit
48
+
49
+
50
+ class ContainerLimits(BaseModel):
51
+ """Limits for containers."""
52
+
53
+ limit: int = 1_000
54
+ properties: ContainerPropertyLimits = Field(default_factory=ContainerPropertyLimits)
55
+
56
+
57
+ class ViewLimits(BaseModel):
58
+ """Limits for views."""
59
+
60
+ limit: int = 2_000
61
+ versions: int = 100
62
+ properties: int = 300
63
+ implements: int = 10
64
+ containers: int = 10
65
+
66
+
67
+ class DataModelLimits(BaseModel):
68
+ """Limits for data models."""
69
+
70
+ limit: int = 500
71
+ versions: int = Field(100, description="Limit of versions per data model.")
72
+ views: int = Field(100, description="Limit of views per data model.")
73
+
74
+
75
+ class SchemaLimits(BaseModel):
76
+ """CDF Data Modeling resource limits."""
77
+
78
+ spaces: SpaceLimit = Field(default_factory=SpaceLimit)
79
+ containers: ContainerLimits = Field(default_factory=ContainerLimits)
80
+ views: ViewLimits = Field(default_factory=ViewLimits)
81
+ data_models: DataModelLimits = Field(default_factory=DataModelLimits)
82
+
83
+ @classmethod
84
+ def from_api_response(cls, response: StatisticsResponse) -> "SchemaLimits":
85
+ """Populate limits from API response."""
86
+ # Implementation to parse and set limits from response can be added here
87
+
88
+ container = ContainerLimits(**response.containers.model_dump())
89
+ container.properties.limit = response.container_properties.limit
90
+
91
+ return cls(
92
+ spaces=SpaceLimit(**response.spaces.model_dump()),
93
+ containers=container,
94
+ views=ViewLimits(**response.views.model_dump()),
95
+ data_models=DataModelLimits(**response.data_models.model_dump()),
96
+ )