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

cognite/neat/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.81.11"
1
+ __version__ = "0.81.12"
@@ -14,6 +14,7 @@ from cognite.neat.graph._shared import MIMETypes
14
14
  from cognite.neat.graph.extractors import RdfFileExtractor, TripleExtractors
15
15
  from cognite.neat.graph.models import Triple
16
16
  from cognite.neat.graph.transformers import Transformers
17
+ from cognite.neat.rules.models.entities import ClassEntity
17
18
  from cognite.neat.rules.models.information import InformationRules
18
19
  from cognite.neat.utils import remove_namespace
19
20
  from cognite.neat.utils.auxiliary import local_import
@@ -42,6 +43,8 @@ class NeatGraphStore:
42
43
  graph: Graph,
43
44
  rules: InformationRules | None = None,
44
45
  ):
46
+ self.rules: InformationRules | None = None
47
+
45
48
  _start = datetime.now(timezone.utc)
46
49
  self.graph = graph
47
50
  self.provenance = Provenance(
@@ -54,11 +57,30 @@ class NeatGraphStore:
54
57
  )
55
58
  ]
56
59
  )
57
- self.rules = rules
58
60
 
59
- if self.rules and self.rules.prefixes:
60
- self._upsert_prefixes(self.rules.prefixes)
61
+ if rules:
62
+ self.rules = rules
61
63
  self.base_namespace = self.rules.metadata.namespace
64
+ self.provenance.append(
65
+ Change.record(
66
+ activity=f"{type(self)}.rules",
67
+ start=_start,
68
+ end=datetime.now(timezone.utc),
69
+ description=f"Added rules to graph store as {type(self.rules).__name__}",
70
+ )
71
+ )
72
+
73
+ if self.rules.prefixes:
74
+ self._upsert_prefixes(self.rules.prefixes)
75
+ self.provenance.append(
76
+ Change.record(
77
+ activity=f"{type(self).__name__}._upsert_prefixes",
78
+ start=_start,
79
+ end=datetime.now(timezone.utc),
80
+ description="Upsert prefixes to graph store",
81
+ )
82
+ )
83
+
62
84
  else:
63
85
  self.base_namespace = DEFAULT_NAMESPACE
64
86
 
@@ -144,6 +166,23 @@ class NeatGraphStore:
144
166
  )
145
167
  )
146
168
 
169
+ def read(self, class_: str) -> list[tuple[str, str, str]]:
170
+ """Read instances for given view from the graph store."""
171
+ # PLACEHOLDER: Implement reading instances for a given view
172
+ # not yet developed
173
+
174
+ if not self.rules:
175
+ warnings.warn("No rules found for the graph store, returning empty list.", stacklevel=2)
176
+ return []
177
+
178
+ class_entity = ClassEntity(prefix=self.rules.metadata.prefix, suffix=class_)
179
+
180
+ if class_entity not in [definition.class_ for definition in self.rules.classes.data]:
181
+ warnings.warn("Desired type not found in graph!", stacklevel=2)
182
+ return []
183
+
184
+ return []
185
+
147
186
  def _parse_file(
148
187
  self,
149
188
  filepath: Path,
@@ -8,7 +8,7 @@ import pandas as pd
8
8
  from pydantic import ValidationError
9
9
 
10
10
  from cognite.neat.rules.models import SchemaCompleteness
11
- from cognite.neat.rules.models._rdfpath import TransformationRuleType
11
+ from cognite.neat.rules.models._rdfpath import RDFPath
12
12
  from cognite.neat.rules.models.entities import ClassEntity, EntityTypes, ParentClassEntity, ReferenceEntity
13
13
  from cognite.neat.rules.models.information import InformationClass, InformationProperty, InformationRules
14
14
  from cognite.neat.utils.utils import get_inheritance_path
@@ -191,7 +191,7 @@ class InformationArchitectRulesAnalysis(BaseAnalysis):
191
191
  )
192
192
  continue
193
193
 
194
- if (only_rdfpath and property_.rule_type == TransformationRuleType.rdfpath) or not only_rdfpath:
194
+ if (only_rdfpath and isinstance(property_.transformation, RDFPath)) or not only_rdfpath:
195
195
  processed_properties[property_.property_] = property_
196
196
  class_property_pairs[class_] = processed_properties
197
197
 
@@ -23,13 +23,8 @@ from cognite.neat.rules.models._base import (
23
23
  SheetList,
24
24
  )
25
25
  from cognite.neat.rules.models._rdfpath import (
26
- AllReferences,
27
- Hop,
28
- RawLookup,
29
- SingleProperty,
30
- SPARQLQuery,
26
+ RDFPath,
31
27
  TransformationRuleType,
32
- Traversal,
33
28
  parse_rule,
34
29
  )
35
30
  from cognite.neat.rules.models._types import (
@@ -156,9 +151,7 @@ class InformationProperty(SheetEntity):
156
151
  default: Default value of the property
157
152
  reference: Reference to the source of the information, HTTP URI
158
153
  match_type: The match type of the resource being described and the source entity.
159
- rule_type: Rule type for the transformation from source to target representation
160
- of knowledge graph. Defaults to None (no transformation)
161
- rule: Actual rule for the transformation from source to target representation of
154
+ transformation: Actual rule for the transformation from source to target representation of
162
155
  knowledge graph. Defaults to None (no transformation)
163
156
  """
164
157
 
@@ -174,10 +167,7 @@ class InformationProperty(SheetEntity):
174
167
  default: Any | None = Field(alias="Default", default=None)
175
168
  reference: URLEntity | ReferenceEntity | None = Field(alias="Reference", default=None, union_mode="left_to_right")
176
169
  match_type: MatchType | None = Field(alias="Match Type", default=None)
177
- rule_type: str | TransformationRuleType | None = Field(alias="Rule Type", default=None)
178
- rule: str | AllReferences | SingleProperty | Hop | RawLookup | SPARQLQuery | Traversal | None = Field(
179
- alias="Rule", default=None
180
- )
170
+ transformation: str | RDFPath | None = Field(alias="Transformation", default=None)
181
171
  comment: str | None = Field(alias="Comment", default=None)
182
172
 
183
173
  @field_serializer("max_count", when_used="json-unless-none")
@@ -193,15 +183,10 @@ class InformationProperty(SheetEntity):
193
183
  return value
194
184
 
195
185
  @model_validator(mode="after")
196
- def is_valid_rule(self):
197
- # TODO: Can we skip rule_type and simply try to parse the rule and if it fails, raise an error?
198
- if self.rule_type:
199
- self.rule_type = self.rule_type.lower()
200
- if not self.rule:
201
- raise exceptions.RuleTypeProvidedButRuleMissing(
202
- self.property_, self.class_, self.rule_type
203
- ).to_pydantic_custom_error()
204
- self.rule = parse_rule(self.rule, self.rule_type)
186
+ def generate_valid_transformation(self):
187
+ # TODO: Currently only supporting RDFpath
188
+ if self.transformation:
189
+ self.transformation = parse_rule(self.transformation, TransformationRuleType.rdfpath)
205
190
  return self
206
191
 
207
192
  @model_validator(mode="after")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.81.11
3
+ Version: 0.81.12
4
4
  Summary: Knowledge graph transformation
5
5
  Home-page: https://cognite-neat.readthedocs-hosted.com/
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  cognite/neat/__init__.py,sha256=v-rRiDOgZ3sQSMQKq0vgUQZvpeOkoHFXissAx6Ktg84,61
2
- cognite/neat/_version.py,sha256=j--riKojvVEPIAPPLvKSvPrl9iDUa3FZVs9awN4iAfo,24
2
+ cognite/neat/_version.py,sha256=OtnGmIWRjJFr0mzcY_B-OHhCTRN8YcyzoBXF9kupUVY,24
3
3
  cognite/neat/app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cognite/neat/app/api/asgi/metrics.py,sha256=nxFy7L5cChTI0a-zkCiJ59Aq8yLuIJp5c9Dg0wRXtV0,152
5
5
  cognite/neat/app/api/configuration.py,sha256=2U5M6M252swvQPQyooA1EBzFUZNtcTmuSaywfJDgckM,4232
@@ -73,7 +73,7 @@ cognite/neat/graph/loaders/_base.py,sha256=bdYC6CwsHVqnQa1QzOhL68qQhF1OtrsearqH6
73
73
  cognite/neat/graph/loaders/_rdf2dms.py,sha256=w0y2ECKw7RrQndGyTVIWeFF2WDxs9yvl_eWNqg-tKO8,13018
74
74
  cognite/neat/graph/models.py,sha256=AtLgZh2qyRP6NRetjQCy9qLMuTQB0CH52Zsev-qa2sk,149
75
75
  cognite/neat/graph/stores/__init__.py,sha256=G-VG_YwfRt1kuPao07PDJyZ3w_0-eguzLUM13n-Z_RA,64
76
- cognite/neat/graph/stores/_base.py,sha256=-MwqfVCBd4j4xWaI7zOvypsGqtbET-2eKQKf36DO0A0,11001
76
+ cognite/neat/graph/stores/_base.py,sha256=JpjG0RPV-KW71BomonXBRs5Gqh9BwNu3FQeykyT-h5s,12490
77
77
  cognite/neat/graph/stores/_oxrdflib.py,sha256=A5zeRm5_e8ui_ihGpgstRDg_N7qcLZ3QZBRGrOXSGI0,9569
78
78
  cognite/neat/graph/stores/_provenance.py,sha256=Hr9WBhFj-eoet4czL8XSBGYnu9Yn66YsTgH_G0n3QpY,3293
79
79
  cognite/neat/graph/transformers/__init__.py,sha256=wXrNSyJNGnis3haaCKVPZ5y5kKSUsOUHnh-860ekatk,555
@@ -178,7 +178,7 @@ cognite/neat/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
178
178
  cognite/neat/rules/_shared.py,sha256=5dc2dfwqjNB_Us27x7oRNkEoEETT0gQChoiIU8mcvyQ,170
179
179
  cognite/neat/rules/analysis/__init__.py,sha256=J2yL0QWSvXOWLbaYPyA0HXHh3aqOWmkwobScdgVQpw8,115
180
180
  cognite/neat/rules/analysis/_base.py,sha256=PmN5NLgGsovsHtsnvUzc_zuarWl-Xwk1azWcYKKuWdA,669
181
- cognite/neat/rules/analysis/_information_rules.py,sha256=F-LBLYyEz6B3J3v1KQ_2G79LzgMXPmcSIw6S8SMGaxs,19179
181
+ cognite/neat/rules/analysis/_information_rules.py,sha256=BFfeR5RVCQpCPEM7llL35LSUUr3ph4qF8lhZgWtc4HY,19156
182
182
  cognite/neat/rules/examples/__init__.py,sha256=nxIwueAcHgZhkYriGxnDLQmIyiT8PByPHbScjYKDKe0,374
183
183
  cognite/neat/rules/examples/wind-energy.owl,sha256=NuomCA9FuuLF0JlSuG3OKqD4VBcHgSjDKFLV17G1zV8,65934
184
184
  cognite/neat/rules/exceptions.py,sha256=YLnsbXXJdDSr_szQoioEtOdqDV8PR7RdQjpMP2SWeCs,123868
@@ -233,7 +233,7 @@ cognite/neat/rules/models/domain.py,sha256=wZ-DeIPFnacbNlxSrRuLzUpnhHdTpzNc22z0s
233
233
  cognite/neat/rules/models/entities.py,sha256=lkLsKg8U3Xto30PCB85ScDpv2SPRVq1ukVEQHzH53_g,18868
234
234
  cognite/neat/rules/models/information/__init__.py,sha256=HR6g8xgyU53U7Ck8pPdbT70817Q4NC1r1pCRq5SA8iw,291
235
235
  cognite/neat/rules/models/information/_converter.py,sha256=r0a2uyzv8m82xzAkYt_-ZXdMN5u46SA_mn95Oo7ng-s,11424
236
- cognite/neat/rules/models/information/_rules.py,sha256=ZVTOn5fEB-AbrXL8A6SN9DwOmF9FhgyS7FzibrkT6ZM,13546
236
+ cognite/neat/rules/models/information/_rules.py,sha256=b-vXZhclEIQsiP-_yFPc5i1-7-dFGVSYXCZz377JdRg,12903
237
237
  cognite/neat/rules/models/information/_rules_input.py,sha256=xmcQQl2vBYSG_IbxOwb6x4CdN3nIg_TY2-3RAeGDYic,10418
238
238
  cognite/neat/rules/models/information/_serializer.py,sha256=yti9I_xJruxrib66YIBInhze___Io-oPTQH6uWDumPE,3503
239
239
  cognite/neat/rules/models/information/_validation.py,sha256=Is2GzL2lZU3A5zPu3NjvlXfmIU2_Y10C5Nxi5Denz4g,7528
@@ -297,8 +297,8 @@ cognite/neat/workflows/steps_registry.py,sha256=fkTX14ZA7_gkUYfWIlx7A1XbCidvqR23
297
297
  cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
298
298
  cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
299
299
  cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
300
- cognite_neat-0.81.11.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
301
- cognite_neat-0.81.11.dist-info/METADATA,sha256=MmBADLlk7wOEvD_MHykgRKYfjDJIoVYbf8WeGTeF9ac,9291
302
- cognite_neat-0.81.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
303
- cognite_neat-0.81.11.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
304
- cognite_neat-0.81.11.dist-info/RECORD,,
300
+ cognite_neat-0.81.12.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
301
+ cognite_neat-0.81.12.dist-info/METADATA,sha256=a1qQBv7iw7Rvhn2oT2zPnfXg-EvzxQZR4fwqjl5V2Bs,9291
302
+ cognite_neat-0.81.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
303
+ cognite_neat-0.81.12.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
304
+ cognite_neat-0.81.12.dist-info/RECORD,,