cognite-neat 0.109.4__py3-none-any.whl → 0.110.0__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.

Potentially problematic release.


This version of cognite-neat might be problematic. Click here for more details.

Files changed (67) hide show
  1. cognite/neat/_alpha.py +2 -0
  2. cognite/neat/_client/_api/schema.py +17 -1
  3. cognite/neat/_client/data_classes/schema.py +3 -3
  4. cognite/neat/_constants.py +11 -0
  5. cognite/neat/_graph/extractors/_classic_cdf/_classic.py +9 -10
  6. cognite/neat/_graph/extractors/_iodd.py +3 -3
  7. cognite/neat/_graph/extractors/_mock_graph_generator.py +9 -7
  8. cognite/neat/_graph/loaders/_rdf2dms.py +285 -346
  9. cognite/neat/_graph/queries/_base.py +28 -92
  10. cognite/neat/_graph/transformers/__init__.py +1 -3
  11. cognite/neat/_graph/transformers/_rdfpath.py +2 -49
  12. cognite/neat/_issues/__init__.py +1 -6
  13. cognite/neat/_issues/_base.py +21 -252
  14. cognite/neat/_issues/_contextmanagers.py +46 -0
  15. cognite/neat/_issues/_factory.py +61 -0
  16. cognite/neat/_issues/errors/__init__.py +18 -4
  17. cognite/neat/_issues/errors/_wrapper.py +81 -3
  18. cognite/neat/_issues/formatters.py +4 -4
  19. cognite/neat/_issues/warnings/__init__.py +3 -2
  20. cognite/neat/_issues/warnings/_properties.py +8 -0
  21. cognite/neat/_rules/_constants.py +9 -0
  22. cognite/neat/_rules/_shared.py +3 -2
  23. cognite/neat/_rules/analysis/__init__.py +2 -3
  24. cognite/neat/_rules/analysis/_base.py +450 -258
  25. cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
  26. cognite/neat/_rules/exporters/_rules2excel.py +2 -8
  27. cognite/neat/_rules/exporters/_rules2instance_template.py +2 -2
  28. cognite/neat/_rules/exporters/_rules2ontology.py +5 -4
  29. cognite/neat/_rules/importers/_base.py +2 -47
  30. cognite/neat/_rules/importers/_dms2rules.py +7 -10
  31. cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +2 -2
  32. cognite/neat/_rules/importers/_rdf/_inference2rules.py +59 -25
  33. cognite/neat/_rules/importers/_rdf/_shared.py +1 -1
  34. cognite/neat/_rules/importers/_spreadsheet2rules.py +12 -9
  35. cognite/neat/_rules/models/dms/_rules.py +3 -1
  36. cognite/neat/_rules/models/dms/_rules_input.py +4 -0
  37. cognite/neat/_rules/models/dms/_validation.py +14 -4
  38. cognite/neat/_rules/models/entities/_loaders.py +1 -1
  39. cognite/neat/_rules/models/entities/_multi_value.py +2 -2
  40. cognite/neat/_rules/models/information/_rules.py +18 -17
  41. cognite/neat/_rules/models/information/_rules_input.py +2 -1
  42. cognite/neat/_rules/models/information/_validation.py +3 -1
  43. cognite/neat/_rules/transformers/__init__.py +8 -2
  44. cognite/neat/_rules/transformers/_converters.py +228 -43
  45. cognite/neat/_rules/transformers/_verification.py +5 -10
  46. cognite/neat/_session/_base.py +4 -4
  47. cognite/neat/_session/_prepare.py +12 -0
  48. cognite/neat/_session/_read.py +21 -17
  49. cognite/neat/_session/_show.py +11 -123
  50. cognite/neat/_session/_state.py +0 -2
  51. cognite/neat/_session/_subset.py +64 -0
  52. cognite/neat/_session/_to.py +63 -12
  53. cognite/neat/_store/_graph_store.py +5 -246
  54. cognite/neat/_utils/rdf_.py +2 -2
  55. cognite/neat/_utils/spreadsheet.py +44 -1
  56. cognite/neat/_utils/text.py +51 -32
  57. cognite/neat/_version.py +1 -1
  58. {cognite_neat-0.109.4.dist-info → cognite_neat-0.110.0.dist-info}/METADATA +1 -1
  59. {cognite_neat-0.109.4.dist-info → cognite_neat-0.110.0.dist-info}/RECORD +62 -64
  60. {cognite_neat-0.109.4.dist-info → cognite_neat-0.110.0.dist-info}/WHEEL +1 -1
  61. cognite/neat/_graph/queries/_construct.py +0 -187
  62. cognite/neat/_graph/queries/_shared.py +0 -173
  63. cognite/neat/_rules/analysis/_dms.py +0 -57
  64. cognite/neat/_rules/analysis/_information.py +0 -249
  65. cognite/neat/_rules/models/_rdfpath.py +0 -372
  66. {cognite_neat-0.109.4.dist-info → cognite_neat-0.110.0.dist-info}/LICENSE +0 -0
  67. {cognite_neat-0.109.4.dist-info → cognite_neat-0.110.0.dist-info}/entry_points.txt +0 -0
@@ -1,17 +1,17 @@
1
1
  cognite/neat/__init__.py,sha256=AXLMIF5t8RmjOpSaIlfqT8ltbPc__Tb8nAVbc1pkE0Q,176
2
- cognite/neat/_alpha.py,sha256=MXVWltw8esJPFNbLIt74_Xib7z-PXWJOBrTCxK-Z2Qs,483
2
+ cognite/neat/_alpha.py,sha256=j_XtXvczefxVxRvA4fLkzz3w4lA_svH0jO3Rmf1bEQ4,631
3
3
  cognite/neat/_client/__init__.py,sha256=RQ7MwL8mwGqGHokRzsPqO3XStDzmI4-c12_gz1UPJ74,177
4
4
  cognite/neat/_client/_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cognite/neat/_client/_api/data_modeling_loaders.py,sha256=0BZ5_NeszBvs4DHuHr0cGXytmvkTxrQ8k7v6iaX_mn4,35932
6
- cognite/neat/_client/_api/schema.py,sha256=mKN38Et45smCt0eg4Rzrl3Rc0b5fs06YSK8yYTzklTA,4845
6
+ cognite/neat/_client/_api/schema.py,sha256=Cp1Rrn4X2XozY1xGqNy7sk11TnyIAltRLgGxrk_Jyrg,5668
7
7
  cognite/neat/_client/_api_client.py,sha256=6cNMizDuqMJZiOqiNRLX46BEtlCB-BpgGLyypksRVYU,616
8
8
  cognite/neat/_client/data_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  cognite/neat/_client/data_classes/data_modeling.py,sha256=RvpUp9ygd-yffQFJ7O2mQqMLDPIa-dmip5zPb8QVIiw,6672
10
10
  cognite/neat/_client/data_classes/neat_sequence.py,sha256=QZWSfWnwk6KlYJvsInco4Wdwc1U8DnOQKWmHebArbQY,10830
11
- cognite/neat/_client/data_classes/schema.py,sha256=uD8ExxEiIP3zhK4b--Q5fND-vmcC05a9WU5ItLsqG88,23179
11
+ cognite/neat/_client/data_classes/schema.py,sha256=b1YMA2GIPaZQ3UydWkkneGQZjA_Rb04H1sSQ8Z1UuUc,23194
12
12
  cognite/neat/_client/testing.py,sha256=M5WUzi3YbtZAN22TXas0SjvMSxmjPFT5m3lNwR0MVkI,1077
13
13
  cognite/neat/_config.py,sha256=WT1BS8uADcFvGoUYOOfwFOVq_VBl472TisdoA3wLick,280
14
- cognite/neat/_constants.py,sha256=OStolbvP16sM9LltZG6irG27W1tioNGwVr84-Hv6Ovk,5752
14
+ cognite/neat/_constants.py,sha256=7H2UlCVP5WV4B6glTIKmnZ108g16JViFIdBxLf5spzQ,6151
15
15
  cognite/neat/_graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  cognite/neat/_graph/_shared.py,sha256=6avH6mtjxjHI7JDLkXwICxGvZwooGBr6APs1_w1To-A,940
17
17
  cognite/neat/_graph/_tracking/__init__.py,sha256=WOwsYieZtCW-iW15YkxUFrfKVVdLWdXHOGGStTwvE8A,91
@@ -26,7 +26,7 @@ cognite/neat/_graph/extractors/_base.py,sha256=qQE-fl3f1hfqZg5KLF3zLHybP0u8ofRKf
26
26
  cognite/neat/_graph/extractors/_classic_cdf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  cognite/neat/_graph/extractors/_classic_cdf/_assets.py,sha256=9WVFrAtUFAp_AAlb26Rtt2Axz9xsPQYetg7SKVrNCr4,1474
28
28
  cognite/neat/_graph/extractors/_classic_cdf/_base.py,sha256=PaJg-E2LepmEf4OehSR0Z2dwuSRBIsidtE4nITMNsig,16311
29
- cognite/neat/_graph/extractors/_classic_cdf/_classic.py,sha256=BmBnCvhyujGnWlnFMvw6tV3mbUAU2XuonctQSji5Vok,18729
29
+ cognite/neat/_graph/extractors/_classic_cdf/_classic.py,sha256=XuxafusIneUHqXMnoX-HfkStEIAA0MXHji89arkULec,18577
30
30
  cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py,sha256=xRFv9pVFgIMTZ45E8teMC0Ynku_CuZdcZkVCbhPuPBk,1294
31
31
  cognite/neat/_graph/extractors/_classic_cdf/_events.py,sha256=B8hRoMAg8GQvApjxals5PfPyjmdPO93U3nj_G7g0kDQ,1394
32
32
  cognite/neat/_graph/extractors/_classic_cdf/_files.py,sha256=Q816cVQ9qS7Art66HJfErL2OV7MxH_eSIG7bJ8_HJ7Q,1406
@@ -37,118 +37,116 @@ cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py,sha256=6CmmxWWG2IErfN
37
37
  cognite/neat/_graph/extractors/_dexpi.py,sha256=SFWnKXYpQToWag9aoX8fxISNa9b8KlqjZnkwI18BzNY,9431
38
38
  cognite/neat/_graph/extractors/_dms.py,sha256=2IBQzQ-UAbdmqykPAhRJAnf5oYh0A_Ha5dLLecj8-NM,14045
39
39
  cognite/neat/_graph/extractors/_dms_graph.py,sha256=Da34mY1gl457iIIFbCDejOXsIlwZSG3GpJt4M5dCMbw,8047
40
- cognite/neat/_graph/extractors/_iodd.py,sha256=nMSLmtgvxLrQJMA5NECF1OCp4Bcv0Vq0WsNv8X9Oj1k,18458
41
- cognite/neat/_graph/extractors/_mock_graph_generator.py,sha256=RPYrNsg30oqAkaEwX_rKuSuzPirKMdezLWBsKyyz55U,15421
40
+ cognite/neat/_graph/extractors/_iodd.py,sha256=sV5xKZi2ZT7MQsUQTVji9vxH34pD5yAvUjtT-gb8mts,18473
41
+ cognite/neat/_graph/extractors/_mock_graph_generator.py,sha256=k6qVslbxwE2WpU1L5NLgHJExk8Sho96Ag6-_bcCiLwA,15436
42
42
  cognite/neat/_graph/extractors/_rdf_file.py,sha256=vz145N1_ZDAlAzCuMiv2z5-7Z4nG2fciLMnl9OpEc3M,2857
43
43
  cognite/neat/_graph/loaders/__init__.py,sha256=XS6vwmxgBzntg7UuG_ct_1hfhShVnFH5u0gGrdA8WfA,699
44
44
  cognite/neat/_graph/loaders/_base.py,sha256=Fp6uUkNfAM-SVgsLz7tyNJxJ1eeEw3h2d4Q0YyppR-Y,3991
45
- cognite/neat/_graph/loaders/_rdf2dms.py,sha256=WGC4qBDgZ_gVreO-20XluEtF0klqZC0gdx-jjXY3qxg,29904
45
+ cognite/neat/_graph/loaders/_rdf2dms.py,sha256=oOYLBbqHpX9ZucrhP-zaU4LM-uzp3p0Pp3K7ViwRgiE,27317
46
46
  cognite/neat/_graph/queries/__init__.py,sha256=BgDd-037kvtWwAoGAy8eORVNMiZ5-E9sIV0txIpeaN4,50
47
- cognite/neat/_graph/queries/_base.py,sha256=gC29GAIaswrc4aTy0dp7vMIXLUgSJgRSGp3cMoSOwcE,17307
48
- cognite/neat/_graph/queries/_construct.py,sha256=OVoCLq6Xeow2eGsdZVG4Cca7s1NtgbPdebxDf2RbFvw,7214
49
- cognite/neat/_graph/queries/_shared.py,sha256=uhw-nY4jJvivgtj1msdCRrfTWgauU7ybSHUqqUaFOUU,5390
50
- cognite/neat/_graph/transformers/__init__.py,sha256=YQoJ2vuZ2bo1cSnzWM_exw3pkzQFiBRb-0uUMpXb178,1850
47
+ cognite/neat/_graph/queries/_base.py,sha256=7JuO3vsibWenrAESNAjuEt8o-YmcIAOj03TC7KGLBi8,14866
48
+ cognite/neat/_graph/transformers/__init__.py,sha256=YzC1Z8BuT77NwagWX4Z-F9R9BARLSS7zM4bCdxBbqKg,1761
51
49
  cognite/neat/_graph/transformers/_base.py,sha256=8W_PSlsp-jQuKNb9z-lN0Khdq1tKsnWxXAMj2XnXcTc,4561
52
50
  cognite/neat/_graph/transformers/_classic_cdf.py,sha256=NExmfGaCjTE_7WeG2M1VnF7L71JAup3S-7t-sEiqIH4,26295
53
51
  cognite/neat/_graph/transformers/_iodd.py,sha256=KNz1fPdKK40UaHgPMECzNZgSeU5PdPRyLdaRYdq1iug,866
54
52
  cognite/neat/_graph/transformers/_prune_graph.py,sha256=X9wVOBl3mhcPB-SSqWvJHV1hNIq7ra4_HX4_2lpT74Y,12438
55
- cognite/neat/_graph/transformers/_rdfpath.py,sha256=KLNnuLmeMCobJ6Q81l5kUqUt_fkKAovzuiy9zO97sTI,5003
53
+ cognite/neat/_graph/transformers/_rdfpath.py,sha256=9KCiq8UCeNWcV9VAmyV5gbqwmozUaHRJuMyzVmL3ji4,3156
56
54
  cognite/neat/_graph/transformers/_value_type.py,sha256=wsuiIKHG6O8F7PaedicMfynTxiVpLZ55zwVU3mCDEYw,15679
57
- cognite/neat/_issues/__init__.py,sha256=OVgWivp_Br31p8zPeHjOEXs-Wj7lJU1pU1L3pfhfuqE,518
58
- cognite/neat/_issues/_base.py,sha256=fZODjRPyiZjVj1ujqKVQOrTh8SaliR9ayG0zRRmyptc,21044
59
- cognite/neat/_issues/errors/__init__.py,sha256=05PgHRvAwMX9FPRLyAhzOvSXL-JCOs1SqtJGUB975fk,2046
55
+ cognite/neat/_issues/__init__.py,sha256=NQ-PN3fqp-hBPlpG2AZEND4cDn3_3UXAPfhLNtF5mtc,457
56
+ cognite/neat/_issues/_base.py,sha256=UDcx0s9_PqLD4z1NnOxI4wgsk2z6IiVCuJoG-V8aPyQ,11671
57
+ cognite/neat/_issues/_contextmanagers.py,sha256=Qve1778doz41N6NYxs_lVhJfvUEtD1r-WwBv386UUnc,1502
58
+ cognite/neat/_issues/_factory.py,sha256=-5KZLCbukmlCuEVzDYlHq0a6vpGQWDSwao_Eybow1oI,2671
59
+ cognite/neat/_issues/errors/__init__.py,sha256=BKnt5qUAyyeKs5odWToCiD5Gr5X8GQ4OX1fTDbSZw4c,2297
60
60
  cognite/neat/_issues/errors/_external.py,sha256=KrF0_ubXlyd903ARUFZlBI45Y-I3q2FS8vSWb9t4WBI,2043
61
61
  cognite/neat/_issues/errors/_general.py,sha256=MnBm9V1S-Agr9kUfTMvviBB4_NkuOXamlgJCu2UojEM,849
62
62
  cognite/neat/_issues/errors/_properties.py,sha256=T_nquQeEQS3DQY--DQ13acxhGX_-gpUMjWGTBKCh6r8,2536
63
63
  cognite/neat/_issues/errors/_resources.py,sha256=qndhGGPdulWpU7G4PkFHsF4Bjflf3lehGV4A0l-BeNI,3966
64
- cognite/neat/_issues/errors/_wrapper.py,sha256=e7Zrj7YkzjwS_T880Bh4r0gwstCjU8256_-2A5MA-iA,239
65
- cognite/neat/_issues/formatters.py,sha256=ziNWT_YXwovTfU8Av5iYuSLgszzJYKTawM_z67VBdlU,3331
66
- cognite/neat/_issues/warnings/__init__.py,sha256=1iYRzwaMftwcueiA8KMA_bGdxdWxmSfMRqUPeTmHV_w,2909
64
+ cognite/neat/_issues/errors/_wrapper.py,sha256=QkAjvryW5RFZV8sSRXu-EFtnZaxH2GO5g67rxXwPFUo,2307
65
+ cognite/neat/_issues/formatters.py,sha256=XgtfnnDkXY_LE8xPpFfm2N9yXN6aY4d9NZhsix_WgHo,3315
66
+ cognite/neat/_issues/warnings/__init__.py,sha256=dkrlKW0ykp0mw5uwN12oBeYFtb-KDefdt1uP-ak-1Ug,2941
67
67
  cognite/neat/_issues/warnings/_external.py,sha256=O5GSRmIsAC6HyToQ7itpFFNILWCAg0OehPTVUy8pTuc,1319
68
68
  cognite/neat/_issues/warnings/_general.py,sha256=idZZZDbeSrDJJ1PomdmIO40QsZQNn_lWztWvMA-9q50,782
69
69
  cognite/neat/_issues/warnings/_models.py,sha256=cowgEjD7OMgTY7OpJT5WGxMFrCjdM3YUWYsw7lzroeI,4373
70
- cognite/neat/_issues/warnings/_properties.py,sha256=793TAs0KUIFKx92AWEFNTfJ4rZBA9q7J08DKsEZJGwM,2915
70
+ cognite/neat/_issues/warnings/_properties.py,sha256=PWACBtbMEeWuSp1tcgoGmTHS2Nd-rJ4I-t5mEewzexc,3206
71
71
  cognite/neat/_issues/warnings/_resources.py,sha256=oyKVzwpMKFMaG4A-ei-5md4ap7rvvSA5RW7ZTJVwC68,3552
72
72
  cognite/neat/_issues/warnings/user_modeling.py,sha256=_cN1wbaQUStZ13aG0VbN5UwKM9YdtyPfuSNJ1AAS6o8,3668
73
73
  cognite/neat/_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- cognite/neat/_rules/_constants.py,sha256=lOyf7nybSYOuAE_wKmTMncHYz0Io0_J_YVnYBzjrvZA,5637
75
- cognite/neat/_rules/_shared.py,sha256=2WrvsSKP4XQisDXUVu5z4GOfjQMIQZwed_UNfb4NCoY,1282
76
- cognite/neat/_rules/analysis/__init__.py,sha256=sTW-gDkHn2VPAHnuOBYJF40Ap3AfxvhLkDGoIRKyOJE,126
77
- cognite/neat/_rules/analysis/_base.py,sha256=7pgCl3Zsg4uxzvzPRbByTs6wBGuVUeYf2ec-PiG7nLY,16745
78
- cognite/neat/_rules/analysis/_dms.py,sha256=k9OrN6kRCcdPr8GCJDRXyF0nNXmBYJQDtoGqw7R87po,2204
79
- cognite/neat/_rules/analysis/_information.py,sha256=F3fAsQS8gLTfyy4z4t4cNaoMqU9TyDRzEOMzid6FJDc,10727
74
+ cognite/neat/_rules/_constants.py,sha256=sEmSDLAjoEq5_3aBk0SruT0ch8W8HzyMZtIVRRi87ig,5781
75
+ cognite/neat/_rules/_shared.py,sha256=XPC1NhkzYoSew0_F7JC_J6chNFLaC_rjfPpfcMcYzfc,1349
76
+ cognite/neat/_rules/analysis/__init__.py,sha256=0Y7KiXpzrwOIU7GVlC3zlizj1TXe6sodAJzMh1rTZLE,62
77
+ cognite/neat/_rules/analysis/_base.py,sha256=-6EAhpm1EHMr7pLA1HQPaQiMNyH-st5TjzFUjpeOWQs,24580
80
78
  cognite/neat/_rules/catalog/__init__.py,sha256=dwDB8b-5GKZuwVyPuiwsH0EaK2FY9-wJrkTjKoL8KE4,250
81
79
  cognite/neat/_rules/catalog/classic_model.xlsx,sha256=YkocpkKypizjsWYwOdn5yzIz_BSl8T8SQLxgm4GIjLQ,15014
82
80
  cognite/neat/_rules/catalog/hello_world_pump.xlsx,sha256=4Fv9qyv7ARHBXSIh-PiOUHcYrtgznKyR2PZCdEBlA0o,17071
83
- cognite/neat/_rules/catalog/info-rules-imf.xlsx,sha256=hj3ej7F1RYYyhGjX0rjVSOe_ZYD8m3AOA87-YtRqM84,56342
81
+ cognite/neat/_rules/catalog/info-rules-imf.xlsx,sha256=vrE5g8vBtsGpwJqygxG3t9I3x4SUAyQsi1vtWfZ8QW4,53682
84
82
  cognite/neat/_rules/exporters/__init__.py,sha256=IYBa0DIYlx8cFItgYRw9W4FY_LmVEjuaqMz3JORZZX0,1204
85
83
  cognite/neat/_rules/exporters/_base.py,sha256=VkNMy8wsH-x4tAjS44cXgzzNH0CM2k_4RhkMwK50J7g,2284
86
84
  cognite/neat/_rules/exporters/_rules2dms.py,sha256=7I3a8ZPwkIBQAClQbMjJ2D2aIITY-OBVUD-8hirCmzM,19183
87
- cognite/neat/_rules/exporters/_rules2excel.py,sha256=z2KOL-sNqnv0xi4Kjuo_2YAPMDeGTdMxaBswcs41lPU,13756
88
- cognite/neat/_rules/exporters/_rules2instance_template.py,sha256=xICzDU8Ij3Q7FhYDbEjttLc8vwqbMajfN88lrTDpn9U,5944
89
- cognite/neat/_rules/exporters/_rules2ontology.py,sha256=l0QJKh0qJ5CDtReWDeQ2jt7wa__v0FEgVMX9jCKHT2U,22120
85
+ cognite/neat/_rules/exporters/_rules2excel.py,sha256=lfsOa4uws1BYGNRUlV-EdbWkIjDCWelwHBPsoOFbMjk,13692
86
+ cognite/neat/_rules/exporters/_rules2instance_template.py,sha256=gI0tWFKzAhuFtnxVA7A9_AGYyL9lH_Yst-OYPNtTguA,5937
87
+ cognite/neat/_rules/exporters/_rules2ontology.py,sha256=8GIawhTeNIS59zWYX2j3F63Ix9-xNGxgTzU1HiGkN98,22105
90
88
  cognite/neat/_rules/exporters/_rules2yaml.py,sha256=ggaPR8FO8PwZk1_nhwb5wVHk_C4s6qh1RrlbPkNcbBo,3160
91
89
  cognite/neat/_rules/exporters/_validation.py,sha256=DVJGdNNU2WtAFgUg0h4SWVhveRErEPOcYdT65y5toV0,682
92
90
  cognite/neat/_rules/importers/__init__.py,sha256=KiTNglSK6OVCdvPiGmO2dTKEGQJWT5Yxa6XWqm7YClQ,1408
93
- cognite/neat/_rules/importers/_base.py,sha256=HOmfESfF9KLGWGa5AmhPGc-AimwKHgoShbxPz90h2JE,3589
94
- cognite/neat/_rules/importers/_dms2rules.py,sha256=gpfckYFV1SH_kmUiwK4wtvBLL8zHABsX4ccbBpa9UHw,22902
91
+ cognite/neat/_rules/importers/_base.py,sha256=yLrrOgjtkSPfLACmtRXGlHmaeGkk0kGnowregWbIPUo,1940
92
+ cognite/neat/_rules/importers/_dms2rules.py,sha256=34ts_ohJVtbHa6tKWu_G_m7YeqSoRo5M9FFZ85yfbHA,22774
95
93
  cognite/neat/_rules/importers/_dtdl2rules/__init__.py,sha256=CNR-sUihs2mnR1bPMKs3j3L4ds3vFTsrl6YycExZTfU,68
96
94
  cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py,sha256=wW4saKva61Q_i17guY0dc4OseJDQfqHy_QZBtm0OD6g,12134
97
95
  cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py,sha256=j38U0um1ZWI-yRvEUR3z33vOvMCYXJxSO9L_B7m9xDE,11707
98
- cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py,sha256=amK-Q1n4Zl_LdZko23ZW6cJD7G6U3vm8EIDr3qiRo64,6097
96
+ cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py,sha256=nJRl47WsoDOrNUX9r_lf8KOXC2cmcz9bRSoeXk3eNDI,6107
99
97
  cognite/neat/_rules/importers/_dtdl2rules/spec.py,sha256=SjvgEoxrUgWOAx1-2gru8UvW0HuFgUA9LRcrRu31TaU,12155
100
98
  cognite/neat/_rules/importers/_rdf/__init__.py,sha256=2alnwoYVj1-F_M0R2NFFp7A9pZUbViJngygOydlC45Y,239
101
99
  cognite/neat/_rules/importers/_rdf/_base.py,sha256=c8BvHdNRdirLJ7KcGH71osbn2dF8xoVkrCpVYbac4b0,5686
102
100
  cognite/neat/_rules/importers/_rdf/_imf2rules.py,sha256=M5hfWZUhoCgXFlr8QNfogNCI2pxzqqAvTJII4yA8xJw,3723
103
- cognite/neat/_rules/importers/_rdf/_inference2rules.py,sha256=8b_Ze-834oRJPCfX1yCdJMTtTNhRFCoMdwlquqjNjZI,25804
101
+ cognite/neat/_rules/importers/_rdf/_inference2rules.py,sha256=yxqHMJsF354zECsI63TNdo1coZEnsqbH7GLpdFhZDHU,28050
104
102
  cognite/neat/_rules/importers/_rdf/_owl2rules.py,sha256=gTMe94DC9xe8NR9KNVHTMTshg_NzVuN1v8Lz95BUshI,3392
105
- cognite/neat/_rules/importers/_rdf/_shared.py,sha256=mxBoqFQfvHeLa4kbDYAd7FEcHe1fv97tcqHd9gmFeKk,5867
106
- cognite/neat/_rules/importers/_spreadsheet2rules.py,sha256=2KhOSzNPmQgBb64L3aIARwmqY944LNP_9QciMnn7ecY,10911
103
+ cognite/neat/_rules/importers/_rdf/_shared.py,sha256=kufv_VxwBzU6MLJF1jZhTTJ6nvPd7mrRVj21wjb0kLw,5868
104
+ cognite/neat/_rules/importers/_spreadsheet2rules.py,sha256=wjB7RVevjvXL3gaL1SGEW411ie76ZrFbe9fngzO-ncQ,10977
107
105
  cognite/neat/_rules/importers/_yaml2rules.py,sha256=k2oDgz--mxFVeyqQG3uvyYcb0BkFHwKHdBYHVaxtAEc,3721
108
106
  cognite/neat/_rules/models/__init__.py,sha256=tf6tyWiYO0eC2PHCcpy208dwOHjEi9hg0sEaQLcB3uA,1024
109
107
  cognite/neat/_rules/models/_base_input.py,sha256=kAVI6QYAzsgQ79eLPc_hANJjl-o1e9IKeD7lF61ru9Y,6656
110
108
  cognite/neat/_rules/models/_base_rules.py,sha256=TpDhGaodzfzfyrSGChx76Tw_zN2YvtxqFz2lvOMHFPE,15134
111
- cognite/neat/_rules/models/_rdfpath.py,sha256=clZGAzulIFKV2rzwoVZpLRlQUEyrAaiM7SjOoj1KUnY,11948
112
109
  cognite/neat/_rules/models/_types.py,sha256=6fHLiVPRlk5QsFjmvDFFqw1htPcPp-RfnUzYoMWNfeg,5418
113
110
  cognite/neat/_rules/models/data_types.py,sha256=LJuWUbStlZM4hUJGExOJIJXmAA4uiA0tvO9zKqLUrQg,9805
114
111
  cognite/neat/_rules/models/dms/__init__.py,sha256=fRaUH0IwG0YwWd_DNKM6j-jHHFyiIVz4_8DPiS1KR0Y,695
115
112
  cognite/neat/_rules/models/dms/_exporter.py,sha256=WFDhkFeY2kJCguru-btcvjDcbMG5ISIAQzIUtDjIlxQ,28097
116
- cognite/neat/_rules/models/dms/_rules.py,sha256=VK8QKLf6NxeoaMci5g7EG08XKzSKJZYJwP4wZxa5eUQ,20507
117
- cognite/neat/_rules/models/dms/_rules_input.py,sha256=noSpYjHKW_GMaeuADOG-Z21ClxiD_tIGxl-dxOKxk-g,13390
118
- cognite/neat/_rules/models/dms/_validation.py,sha256=PNFHsDNHJZfbHY1qt6D4t3eFOGjqe6Koa702Gzcz0I8,27734
113
+ cognite/neat/_rules/models/dms/_rules.py,sha256=AUqF5Zyv0uT9S4lsug9KMrT1ee7hUhWqeQyhsfSwvzY,20524
114
+ cognite/neat/_rules/models/dms/_rules_input.py,sha256=a0G2UVePrknkRcQN7eKPp5r8Rn587VJ50qt7aJFBEPQ,13487
115
+ cognite/neat/_rules/models/dms/_validation.py,sha256=1Z-KoolNAiDVrQTa4deLUaKQSexkGKheKQXe-agpfb8,28166
119
116
  cognite/neat/_rules/models/entities/__init__.py,sha256=Hlucp3LyV6ncLl79aqRTbSy2qgiGzoyN8x54D_zaJCY,1469
120
117
  cognite/neat/_rules/models/entities/_constants.py,sha256=g52-pFP_Qghp86NYk76pLDM52b3T4MXMztxhpeDW3Oc,344
121
- cognite/neat/_rules/models/entities/_loaders.py,sha256=jFllRty5XpS6uLklr9wJkx7Bzm-qwg65um6hnVistvw,2728
122
- cognite/neat/_rules/models/entities/_multi_value.py,sha256=6j-nlUA392yQP_uB_CFB6_qFReNhi54ZlbFTcOKpbKY,2755
118
+ cognite/neat/_rules/models/entities/_loaders.py,sha256=OQDbz5ANMQ_7ZcdMIBdTR94BoCpWrBA2KBH3fCW0JQo,2728
119
+ cognite/neat/_rules/models/entities/_multi_value.py,sha256=xJyh0-aAbKYlgvmnk2lkKTHMBKMY2bZ97L4rd0tBRBg,2754
123
120
  cognite/neat/_rules/models/entities/_single_value.py,sha256=XZA4rqXzL-97bsCEAz1imUtn4lir_ikiBfs5LVtziSI,19604
124
121
  cognite/neat/_rules/models/entities/_types.py,sha256=df9rnXJJKciv2Bp-Ve2q4xdEJt6WWniq12Z0hW2d6sk,1917
125
122
  cognite/neat/_rules/models/entities/_wrapped.py,sha256=SpXIpglXBgaZt6geRparCWdY2F6SH0Fy99fcnA8x8Uk,7648
126
123
  cognite/neat/_rules/models/information/__init__.py,sha256=lV7l8RTfWBvN_DFkzea8OzADjq0rZGgWe_0Fiwtfje0,556
127
- cognite/neat/_rules/models/information/_rules.py,sha256=RQDcXEVZz9GG6KghpK-Vp4W_4ThoC12kfsPQdMkW75o,13766
128
- cognite/neat/_rules/models/information/_rules_input.py,sha256=njpi37IxTBLH4k51tRJeASU6yQXt324NSuxcZ_CjyU8,5940
129
- cognite/neat/_rules/models/information/_validation.py,sha256=HbaLShj6uumu-t9I3FUI_iKQfUDiwEkuFENHgWIPfrk,10202
124
+ cognite/neat/_rules/models/information/_rules.py,sha256=BOFRHpxB7IAXv21a7Hae2QU4pS1YdhPoQbt3-wYv9FU,13805
125
+ cognite/neat/_rules/models/information/_rules_input.py,sha256=PCJfFqA1Vry_5wpryJSaIYC46MU4OK-6B9waOjBbUqY,5991
126
+ cognite/neat/_rules/models/information/_validation.py,sha256=Y05RQCW4cUmbKpdJ69OePDRDx4xHpt2Ae-OOzCg_QY8,10395
130
127
  cognite/neat/_rules/models/mapping/__init__.py,sha256=T68Hf7rhiXa7b03h4RMwarAmkGnB-Bbhc1H07b2PyC4,100
131
128
  cognite/neat/_rules/models/mapping/_classic2core.py,sha256=AhLWoXk4PlBVA6SgBtY9dcLcpqEMaYcsiEatI19miPk,1211
132
129
  cognite/neat/_rules/models/mapping/_classic2core.yaml,sha256=jodkmcTborWJmG3At16OChtnol696X6D4lgAa7aaQ78,20491
133
- cognite/neat/_rules/transformers/__init__.py,sha256=S6iUB7wpAh-7uF5k_EgXT4cGfi8ok5lczGemVxgKckQ,1413
130
+ cognite/neat/_rules/transformers/__init__.py,sha256=vp6OQnRUGdIrPVDOsY_tM2KBzis-IldaoVkAQEFgvVM,1563
134
131
  cognite/neat/_rules/transformers/_base.py,sha256=9LnjKbYIf9238PQXedkTZsMXAyEND6glUD187iEaHfc,2783
135
- cognite/neat/_rules/transformers/_converters.py,sha256=8rQ_cPghbvuBGIHfXtQE_COpFwPy-60dgyLnSTUUINs,78242
132
+ cognite/neat/_rules/transformers/_converters.py,sha256=d8fA3hJJ1bF82WTq8i3wj41ERMRoxhu-DWnR93-eVCk,85735
136
133
  cognite/neat/_rules/transformers/_mapping.py,sha256=lf-RKN__5Bg3-tZjEOCa1Sf_JtM_ScQ_TYcnciEnaYQ,18189
137
- cognite/neat/_rules/transformers/_verification.py,sha256=jKTppklUCVwVlRfYyMfnUtV8r2ACTY-AtsoMF6L-KXo,4593
134
+ cognite/neat/_rules/transformers/_verification.py,sha256=coZjoLqdfS8yrPP62T_xEKrDZc9ETbPWrLuwEVBSLZQ,4370
138
135
  cognite/neat/_session/__init__.py,sha256=fxQ5URVlUnmEGYyB8Baw7IDq-uYacqkigbc4b-Pr9Fw,58
139
- cognite/neat/_session/_base.py,sha256=lNCjSiQIn1hI3zSru1hXGTQ0nVzy3CcXTO7vL4XRzno,11935
136
+ cognite/neat/_session/_base.py,sha256=7-jbpuZbayvUQWy2Ac6E_jLv3fO-2B3uQaKv8u6RpzM,11969
140
137
  cognite/neat/_session/_collector.py,sha256=RcOGY0DjTCCKJt9j_p0gnQXn4omhsIX2G8Aq3ZFHIt4,4218
141
138
  cognite/neat/_session/_create.py,sha256=doDCbDIWMbHCYe3cyk1obQaFdYJjvARg3X4lRUVicCk,7214
142
139
  cognite/neat/_session/_drop.py,sha256=gOkDAnddASpFxYxkPjlTyhkpNfnmDEj94GRI8tnHFR0,4167
143
140
  cognite/neat/_session/_fix.py,sha256=gpmbJ4TbB_v2nw4fEA2Qtf0ifO3UDEMHGdztha28S_U,898
144
141
  cognite/neat/_session/_inspect.py,sha256=VkmDfIjh49NPS8wNa1OdWqhW-oJy1EvMDhKiooMvcjI,9040
145
142
  cognite/neat/_session/_mapping.py,sha256=AkQwmqYH-0EgqoXHqCFwJY92hNSGzfojOelhVFlqH4c,2655
146
- cognite/neat/_session/_prepare.py,sha256=fozBTqF8hUTfOf4wzDDulc0Fi5bDfO1C1EeBU0Bii3Q,12088
147
- cognite/neat/_session/_read.py,sha256=V2F7InkvIODdML7jy4aGXH4PE91tWFzIGcNzOWnsTvM,22514
143
+ cognite/neat/_session/_prepare.py,sha256=BZ1NurenrsZDU4tg629wnt1Iuw_zVLRA58FNTQMYS9I,12636
144
+ cognite/neat/_session/_read.py,sha256=DAzNaNWOW3WrHrRibAmJeIlwKu0_1HWW0zfUyLIPxwg,22618
148
145
  cognite/neat/_session/_set.py,sha256=ZYR5G97fi-y68edbG-ftLqM_FRtn9G8V5zDtpslR9go,4070
149
- cognite/neat/_session/_show.py,sha256=3hUMWBlHCyMiVTbX1GmpVFfthpv3yBIZ293aU0mDxZ8,15156
150
- cognite/neat/_session/_state.py,sha256=udCCS5tWA2z7P1YK65iyC-weDwgQg07P_MS3TLjJC90,4075
151
- cognite/neat/_session/_to.py,sha256=Wls8Obfx4Aodgyf_8jq7HxPt8JSHoFQ-DhJIfVoe3JU,11682
146
+ cognite/neat/_session/_show.py,sha256=2lnkud996ouwf6-aKGvU0cU0ttfMeQ3vcb__g_7Yko4,10539
147
+ cognite/neat/_session/_state.py,sha256=yUkUUEBUvA_DFq9Aosgv9BWzJU68U550OVOMVEPobj4,3923
148
+ cognite/neat/_session/_subset.py,sha256=-uwSBM2-PsKgky4VtQCSUuSRNJHLE54MVnRdVxvzKAE,2113
149
+ cognite/neat/_session/_to.py,sha256=xmLv2G-3WNdPBijbzuefuzeT2BBjTZfWShTJV0K-OIM,14168
152
150
  cognite/neat/_session/_wizard.py,sha256=9idlzhZy54h2Iwupe9iXKX3RDb5jJQuBZFEouni50L0,1476
153
151
  cognite/neat/_session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvca6n48bu_bI,120
154
152
  cognite/neat/_session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
@@ -157,7 +155,7 @@ cognite/neat/_session/engine/_load.py,sha256=LcoYVthQyCzLWKzRE_75_nElS-n_eMWSPAg
157
155
  cognite/neat/_session/exceptions.py,sha256=XCLVaEe7SMIyNW7mwt0WF7_e5K8KfV9yHkEtsjL60Tg,3182
158
156
  cognite/neat/_shared.py,sha256=Ov59SWYboRRsncB_5V1ZC_BAoACfNLjo80vqE5Ru6wo,2325
159
157
  cognite/neat/_store/__init__.py,sha256=RrvuZrMdezqun5dOrwHWSk26kampZcvqiHBqSFumkEE,130
160
- cognite/neat/_store/_graph_store.py,sha256=ru0wuJtBAZoN2HJOJhBmldAsbRpp9zMcIcwfTzEcsN0,26882
158
+ cognite/neat/_store/_graph_store.py,sha256=M-_eDMtdxqsbW-M1ZPt9xQ1k7kDWiDCsmTGEFFQer2c,17007
161
159
  cognite/neat/_store/_provenance.py,sha256=0HeWyzvfCTxQiG2PygLLqWpdCAooVsFRckpGsnJbwzk,7260
162
160
  cognite/neat/_store/_rules_store.py,sha256=R-bkiNiwqGQ9udrEmamvuEidQsemFpGBif1zmf4H-QA,17713
163
161
  cognite/neat/_store/exceptions.py,sha256=fbed_CGDdYU4oELgCL0_c5d85HGrUiYvXmL2D0WIDww,1593
@@ -167,18 +165,18 @@ cognite/neat/_utils/auxiliary.py,sha256=WFOycFgoYipvDmtGvn6ZNH3H8iNZmHamrfe2kXRb
167
165
  cognite/neat/_utils/collection_.py,sha256=JvYLSR6Cf8PIKGhr8HKRvep0U-z0980jbnIM_g-5I5I,2366
168
166
  cognite/neat/_utils/graph_transformations_report.py,sha256=rjEy4XMvOygFL4UgnYOmFW6AHxaU9IXep-dmYc5654c,1230
169
167
  cognite/neat/_utils/io_.py,sha256=D2Mg8sOxfBoDg3fC0jBzaxO3vkXmr0QvZSgYIv6xRkM,386
170
- cognite/neat/_utils/rdf_.py,sha256=b3sE3aTW9lu4gJWQJEaq_NCLbI54cc1o12utz-xbLh8,9023
168
+ cognite/neat/_utils/rdf_.py,sha256=sQqpV5SJbc2nglpnovLtrU-iOsKICBw2I5_6TC5JXv0,9038
171
169
  cognite/neat/_utils/reader/__init__.py,sha256=fPkrNB_9hLB7CyHTCFV_xEbIfOMqUQzNly5JN33-QfM,146
172
170
  cognite/neat/_utils/reader/_base.py,sha256=Q35hz8tqAiQiELjE4DsDDKQHLtRmSTrty4Gep9rg_CU,5444
173
- cognite/neat/_utils/spreadsheet.py,sha256=20L_44m0hg3UdBFwCxnmAravxvCOolNZwVOGHfjYGR4,3089
174
- cognite/neat/_utils/text.py,sha256=9sBlE05S_9irzRxRvafBlWWy-kPgvUPV2Xo-_IgcwHM,4944
171
+ cognite/neat/_utils/spreadsheet.py,sha256=Z2R2qcN0oYE3BLMCE9cbmCwi2rPMGKJ3u21jzzIoZg0,4279
172
+ cognite/neat/_utils/text.py,sha256=h8DOlPNfpsVbz-ooAv4vT-c03Q87auSNOgnv4GA1wZs,5854
175
173
  cognite/neat/_utils/time_.py,sha256=O30LUiDH9TdOYz8_a9pFqTtJdg8vEjC3qHCk8xZblG8,345
176
174
  cognite/neat/_utils/upload.py,sha256=iWKmsQgw4EHLv-11NjYu7zAj5LtqTAfNa87a1kWeuaU,5727
177
175
  cognite/neat/_utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP2DQ,1710
178
- cognite/neat/_version.py,sha256=QVwn7nO52-wrWZD6BCidVN8e8DGr4r7lQqTaIGS5Sds,46
176
+ cognite/neat/_version.py,sha256=952Ev-GVvU0D8wLaKYXCt6w8qdXbDuacCC1VgK-YLy8,46
179
177
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
180
- cognite_neat-0.109.4.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
181
- cognite_neat-0.109.4.dist-info/METADATA,sha256=d9-11fBzN6fR8usoDMQUtGkUpEKjFxdjS3mTbN7TVsU,5361
182
- cognite_neat-0.109.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
183
- cognite_neat-0.109.4.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
184
- cognite_neat-0.109.4.dist-info/RECORD,,
178
+ cognite_neat-0.110.0.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
179
+ cognite_neat-0.110.0.dist-info/METADATA,sha256=WlvZQxFQEaOzGlmUQ-u_tVg0hAqct0kheC1M2qHgGAw,5361
180
+ cognite_neat-0.110.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
181
+ cognite_neat-0.110.0.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
182
+ cognite_neat-0.110.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,187 +0,0 @@
1
- import re
2
- from typing import cast
3
-
4
- from rdflib import Graph, URIRef
5
-
6
- from cognite.neat._rules.analysis import InformationAnalysis
7
- from cognite.neat._rules.models._rdfpath import (
8
- Hop,
9
- RDFPath,
10
- SelfReferenceProperty,
11
- SingleProperty,
12
- Traversal,
13
- )
14
- from cognite.neat._rules.models.entities import ClassEntity
15
- from cognite.neat._rules.models.information import InformationProperty, InformationRules
16
- from cognite.neat._utils.collection_ import most_occurring_element
17
-
18
- from ._shared import Triple, hop2property_path
19
-
20
- _QUERY_TEMPLATE = """CONSTRUCT {{ {graph_template} }}
21
- WHERE {{ {bind_instance_id}
22
- {graph_pattern}
23
- }}"""
24
-
25
-
26
- def build_construct_query(
27
- class_: ClassEntity,
28
- graph: Graph,
29
- rules: InformationRules,
30
- properties_optional: bool = True,
31
- instance_id: URIRef | None = None,
32
- ) -> str | None:
33
- """Builds a CONSTRUCT query for a given class and rules and optionally filters by class instances.
34
-
35
- Args:
36
- class_ : The class entity for which the query is generated.
37
- graph : The graph containing instances of classes.
38
- rules : The information rules to use for query generation.
39
- properties_optional : Whether to make all properties optional. Defaults to True.
40
- class_instances : List of class instances to filter by. Defaults to None (no filter, return all instances).
41
-
42
- Returns:
43
- str: CONSTRUCT query.
44
-
45
- !!! note "On CONSTRUCT Query"
46
- CONSTRUCT query is composed of two parts: graph template and graph pattern.
47
- Graph template is used the shape of instance acquired using graph pattern.
48
- This allows us to create a new graph with the new shape without actually modifying
49
- the original graph, or creating new instances.
50
-
51
- The CONSTRUCT query is far less forgiving than the SELECT query. It will not return
52
- anything if one of the properties that define the "shape" of the class instance is missing.
53
- This is the reason why there is an option to make all properties optional, so that
54
- the query will return all instances that have at least one property defined.
55
- """
56
-
57
- if (
58
- transformations := InformationAnalysis(rules)
59
- .class_property_pairs(only_rdfpath=True, consider_inheritance=True)
60
- .get(class_, None)
61
- ):
62
- templates, patterns = to_construct_triples(
63
- graph, list(transformations.values()), rules.prefixes, properties_optional
64
- )
65
-
66
- return _QUERY_TEMPLATE.format(
67
- bind_instance_id=(f"BIND(<{instance_id}> AS ?instance)" if instance_id else ""),
68
- graph_template="\n".join(triples2sparql_statement(templates)),
69
- graph_pattern="\n".join(triples2sparql_statement(patterns)),
70
- )
71
-
72
- else:
73
- return None
74
-
75
-
76
- def to_construct_triples(
77
- graph: Graph,
78
- transformations: list[InformationProperty],
79
- prefixes: dict,
80
- properties_optional: bool = True,
81
- ) -> tuple[list[Triple], list[Triple]]:
82
- """Converts transformations of a class to CONSTRUCT triples which are used to generate CONSTRUCT query
83
-
84
- Args:
85
- graph: Graph containing instances of classes (used for property inference for hops)
86
- transformations : List of transformations to use to form triples
87
- prefixes : Dictionary of prefixes for namespaces
88
- properties_optional : Flag indicating if properties should be optional. Defaults to True.
89
-
90
- Returns:
91
- tuple: Tuple of triples that define graph template and graph pattern parts of CONSTRUCT query
92
-
93
-
94
- !!! note "Purely inherited transformations"
95
- Assumption that neat makes is that in case of purely inherited transformations
96
- we will type instance with class to which transformation belongs to.
97
-
98
- Otherwise we will type instance with class that is most occurring in non-inherited
99
- transformations.
100
-
101
- """
102
- # TODO: Add handling of UNIONs in rules
103
-
104
- templates = []
105
- patterns = []
106
- non_inherited_starting_rdf_types = []
107
-
108
- for transformation in transformations:
109
- traversal = cast(RDFPath, transformation.instance_source).traversal
110
-
111
- # keeping track of starting rdf types of non-inherited transformations/properties
112
- if isinstance(traversal, Traversal) and not transformation.inherited:
113
- non_inherited_starting_rdf_types.append(traversal.class_.id)
114
-
115
- graph_template_triple = Triple(
116
- subject="?instance",
117
- predicate=f"{transformation.class_.prefix}:{transformation.property_}",
118
- object=f"?{re.sub(r'[^_a-zA-Z0-9/_]', '_', str(transformation.property_).lower())}",
119
- optional=False,
120
- )
121
- templates.append(graph_template_triple)
122
-
123
- # use case AllReferences: binding instance to certain rdf property
124
- if isinstance(traversal, SelfReferenceProperty):
125
- graph_pattern_triple = Triple(
126
- subject="BIND(?instance",
127
- predicate="AS",
128
- object=f"{graph_template_triple.object})",
129
- optional=False,
130
- )
131
-
132
- # use case SingleProperty: simple property traversal
133
- elif isinstance(traversal, SingleProperty):
134
- graph_pattern_triple = Triple(
135
- subject=graph_template_triple.subject,
136
- predicate=traversal.property.id,
137
- object=graph_template_triple.object,
138
- optional=(True if properties_optional else not transformation.is_mandatory),
139
- )
140
-
141
- # use case Hop: property traversal with multiple hops turned into property path
142
- # see: https://www.oxfordsemantic.tech/faqs/what-is-a-property-path
143
- elif isinstance(traversal, Hop):
144
- graph_pattern_triple = Triple(
145
- subject="?instance",
146
- predicate=hop2property_path(graph, traversal, prefixes),
147
- object=graph_template_triple.object,
148
- optional=(True if properties_optional else not transformation.is_mandatory),
149
- )
150
-
151
- # other type of rdfpaths are skipped
152
- else:
153
- continue
154
-
155
- patterns.append(graph_pattern_triple)
156
-
157
- # Add first triple for graph pattern stating type of object
158
- # we use most occurring here to pull out most occurring rdf type of the starting
159
- # node of the transformation, or the class itself to which the transformation is
160
- # defined for.
161
- # This is safeguard in case there are multiple classes in the graph pattern
162
- patterns.insert(
163
- 0,
164
- Triple(
165
- subject="?instance",
166
- predicate="a",
167
- object=(
168
- most_occurring_element(non_inherited_starting_rdf_types)
169
- if non_inherited_starting_rdf_types
170
- else str(transformation.class_)
171
- ),
172
- optional=False,
173
- ),
174
- )
175
-
176
- return templates, patterns
177
-
178
-
179
- def triples2sparql_statement(triples: list[Triple]):
180
- return [
181
- (
182
- f"OPTIONAL {{ {triple.subject} {triple.predicate} {triple.object} . }}"
183
- if triple.optional
184
- else f"{triple.subject} {triple.predicate} {triple.object} ."
185
- )
186
- for triple in triples
187
- ]
@@ -1,173 +0,0 @@
1
- import sys
2
- from collections.abc import Iterable
3
- from typing import ClassVar, cast
4
-
5
- from pydantic import BaseModel, ConfigDict, Field
6
- from rdflib import Graph, Literal, Namespace
7
- from rdflib.term import URIRef
8
-
9
- from cognite.neat._constants import get_default_prefixes_and_namespaces
10
- from cognite.neat._rules.models._rdfpath import (
11
- Hop,
12
- Step,
13
- )
14
- from cognite.neat._utils.rdf_ import remove_namespace_from_uri, uri_to_short_form
15
-
16
- if sys.version_info >= (3, 11):
17
- from typing import Self
18
- else:
19
- from typing_extensions import Self
20
-
21
-
22
- class Triple(BaseModel):
23
- model_config: ClassVar[ConfigDict] = ConfigDict(
24
- populate_by_name=True, arbitrary_types_allowed=True, strict=False, extra="allow"
25
- )
26
-
27
- subject: str | URIRef
28
- predicate: str | URIRef
29
- object: str | URIRef | Literal | None = None
30
- optional: bool = Field(
31
- description="Indicates whether a triple is optional, used when building SPARQL query",
32
- default=False,
33
- )
34
-
35
- @classmethod
36
- def from_rdflib_triple(cls, triple: tuple[URIRef, URIRef, URIRef | Literal]) -> Self:
37
- return cls(subject=triple[0], predicate=triple[1], object=triple[2])
38
-
39
-
40
- def generate_prefix_header(prefixes: dict[str, Namespace] | None = None) -> str:
41
- """Generate prefix header which is added to SPARQL query and allows for shorten query statements
42
-
43
- Parameters
44
- ----------
45
- prefixes : dict
46
- Dict containing prefix - namespace pairs, defaults to internal set of prefixes
47
-
48
- Returns
49
- -------
50
- str
51
- Prefix header
52
- """
53
-
54
- prefixes = prefixes or get_default_prefixes_and_namespaces()
55
-
56
- return "".join(f"PREFIX {key}:<{value}>\n" for key, value in prefixes.items())
57
-
58
-
59
- def get_predicate_id(
60
- graph: Graph,
61
- subject_type_id: str,
62
- object_type_id: str,
63
- prefixes: dict[str, Namespace] | None = None,
64
- ) -> URIRef:
65
- """Returns predicate (aka property) URI (i.e., ID) that connects subject and object
66
-
67
- Parameters
68
- ----------
69
- graph : Graph
70
- Data model graph or data model instance (aka knowledge graph)
71
- subject_type_id : str
72
- ID of subject type (aka subject class)
73
- object_type_id : str
74
- ID of object type (aka object class)
75
- prefixes : dict, optional
76
- Dict containing prefix - namespace pairs, defaults to internal set of prefixes
77
-
78
- Returns
79
- -------
80
- URIRef
81
- ID of predicate (aka property) connecting subject and object
82
- """
83
-
84
- prefixes = prefixes or get_default_prefixes_and_namespaces()
85
-
86
- query = """
87
-
88
- SELECT ?predicateTypeID
89
- WHERE {
90
- ?subjectInstanceID a subjectTypeID .
91
- ?objectInstanceID a objectTypeID .
92
- ?subjectInstanceID ?predicateTypeID ?objectInstanceID .
93
- } LIMIT 1"""
94
-
95
- query = query.replace("insertPrefixes", generate_prefix_header(prefixes))
96
- final_query = query.replace("subjectTypeID", subject_type_id).replace("objectTypeID", object_type_id)
97
- res = list(cast(tuple, graph.query(final_query)))
98
-
99
- if len(res) != 1:
100
- raise ValueError("Subject and Object must have exactly 1 relation!")
101
-
102
- return res[0][0]
103
-
104
-
105
- def hop2property_path(
106
- graph: Graph,
107
- hop: Hop,
108
- prefixes: dict[str, Namespace] | None = None,
109
- ) -> str:
110
- """Converts hop to property path string
111
-
112
- Parameters
113
- ----------
114
- graph : Graph
115
- Graph containing instances of classes
116
- hop : Hop
117
- Hop to convert
118
- prefixes : dict[str, Namespace]
119
- Dictionary of prefixes to use for compression and predicate querying
120
-
121
- Returns
122
- -------
123
- str
124
- Property path string for hop traversal (e.g. ^rdf:type/rdfs:subClassOf)
125
- """
126
- prefixes = prefixes if prefixes else get_default_prefixes_and_namespaces()
127
-
128
- # setting previous step to origin, as we are starting from there
129
- previous_step = Step(class_=hop.class_, direction="origin")
130
-
131
- # add triples for all steps until destination
132
- property_path = ""
133
- for current_step in hop.traversal:
134
- sub_entity, obj_entity = (
135
- (current_step, previous_step) if current_step.direction == "source" else (previous_step, current_step)
136
- )
137
-
138
- predicate_raw = get_predicate_id(graph, sub_entity.class_.id, obj_entity.class_.id, prefixes)
139
-
140
- predicate = uri_to_short_form(predicate_raw, prefixes)
141
-
142
- predicate = f"^{predicate}" if current_step.direction == "source" else predicate
143
- property_path += f"{predicate}/"
144
-
145
- previous_step = current_step
146
-
147
- if previous_step.property:
148
- return property_path + previous_step.property.id
149
- else:
150
- # removing "/" at the end of property path if there is no property at the end
151
- return property_path[:-1]
152
-
153
-
154
- def triples2dictionary(triples: Iterable[tuple[URIRef, URIRef, str | URIRef]]) -> dict[URIRef, dict[str, list[str]]]:
155
- """Converts list of triples to dictionary"""
156
- dictionary: dict[URIRef, dict[str, list[str]]] = {}
157
- for triple in triples:
158
- id_: str
159
- property_: str
160
- value: str
161
- uri: URIRef
162
-
163
- id_, property_, value = remove_namespace_from_uri(triple) # type: ignore[misc]
164
- uri = triple[0]
165
-
166
- if uri not in dictionary:
167
- dictionary[uri] = {"external_id": [id_]}
168
-
169
- if property_ not in dictionary[uri]:
170
- dictionary[uri][property_] = [value]
171
- else:
172
- dictionary[uri][property_].append(value)
173
- return dictionary