cognite-neat 0.78.1__py3-none-any.whl → 0.78.2__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.78.1"
1
+ __version__ = "0.78.2"
@@ -8,19 +8,17 @@ from cognite.neat.rules.models._base import MatchType
8
8
  from cognite.neat.utils.utils import remove_namespace
9
9
 
10
10
 
11
- def parse_owl_classes(graph: Graph, make_compliant: bool = False, language: str = "en") -> list[dict]:
11
+ def parse_owl_classes(graph: Graph, language: str = "en") -> list[dict]:
12
12
  """Parse owl classes from graph to pandas dataframe.
13
13
 
14
14
  Args:
15
15
  graph: Graph containing owl classes
16
- make_compliant: Flag for generating compliant classes, by default False
17
16
  language: Language to use for parsing, by default "en"
18
17
 
19
18
  Returns:
20
19
  Dataframe containing owl classes
21
20
 
22
- !!! note "make_compliant"
23
- If `make_compliant` is set to True, in presence of errors, default values will be used instead.
21
+ !!! note "Compliant OWL classes"
24
22
  This makes the method very opinionated, but results in a compliant classes.
25
23
  """
26
24
 
@@ -48,8 +46,7 @@ def parse_owl_classes(graph: Graph, make_compliant: bool = False, language: str
48
46
  processed_df = _clean_up_classes(raw_df)
49
47
 
50
48
  # make compliant
51
- if make_compliant:
52
- processed_df = make_classes_compliant(processed_df)
49
+ processed_df = make_classes_compliant(processed_df)
53
50
 
54
51
  # Make Parent Class list elements into string joined with comma
55
52
  processed_df["Parent Class"] = processed_df["Parent Class"].apply(
@@ -12,18 +12,16 @@ from cognite.neat.rules.models._types._base import (
12
12
  from cognite.neat.utils.utils import convert_rdflib_content, remove_none_elements_from_set
13
13
 
14
14
 
15
- def parse_owl_metadata(graph: Graph, make_compliant: bool = False) -> dict:
15
+ def parse_owl_metadata(graph: Graph) -> dict:
16
16
  """Parse owl metadata from graph to dict.
17
17
 
18
18
  Args:
19
19
  graph: Graph containing owl metadata
20
- make_compliant: Flag for generating compliant metadata, by default False
21
20
 
22
21
  Returns:
23
22
  Dictionary containing owl metadata
24
23
 
25
- !!! note "make_compliant"
26
- If `make_compliant` is set to True, in presence of errors, default values will be used instead.
24
+ !!! note "Compliant OWL metadata"
27
25
  This makes the method very opinionated, but results in a compliant metadata.
28
26
 
29
27
 
@@ -72,10 +70,7 @@ def parse_owl_metadata(graph: Graph, make_compliant: bool = False) -> dict:
72
70
  }
73
71
  )
74
72
 
75
- if make_compliant:
76
- return make_metadata_compliant(raw_metadata)
77
-
78
- return raw_metadata
73
+ return make_metadata_compliant(raw_metadata)
79
74
 
80
75
 
81
76
  def make_metadata_compliant(metadata: dict) -> dict:
@@ -10,12 +10,11 @@ from cognite.neat.utils.utils import remove_namespace
10
10
  from ._owl2classes import _data_type_property_class, _object_property_class, _thing_class
11
11
 
12
12
 
13
- def parse_owl_properties(graph: Graph, make_compliant: bool = False, language: str = "en") -> list[dict]:
13
+ def parse_owl_properties(graph: Graph, language: str = "en") -> list[dict]:
14
14
  """Parse owl properties from graph to pandas dataframe.
15
15
 
16
16
  Args:
17
17
  graph: Graph containing owl properties
18
- make_compliant: Flag for generating compliant properties, by default False
19
18
  language: Language to use for parsing, by default "en"
20
19
 
21
20
  Returns:
@@ -53,8 +52,7 @@ def parse_owl_properties(graph: Graph, make_compliant: bool = False, language: s
53
52
  processed_df = _clean_up_properties(raw_df)
54
53
 
55
54
  # make compliant
56
- if make_compliant:
57
- processed_df = make_properties_compliant(processed_df)
55
+ processed_df = make_properties_compliant(processed_df)
58
56
 
59
57
  # drop column _property_type, which was a helper column:
60
58
  processed_df.drop(columns=["_property_type"], inplace=True)
@@ -21,25 +21,21 @@ class OWLImporter(BaseImporter):
21
21
 
22
22
  Args:
23
23
  filepath: Path to OWL ontology
24
- make_compliant: If True, NEAT will attempt to make the imported rules compliant with CDF
25
24
 
26
25
  !!! Note
27
- OWL Ontologies typically lacks some information that is required for making a complete
28
- data model. This means that the methods .to_rules() will typically fail. Instead, it is recommended
29
- that you use the .to_spreadsheet() method to generate an Excel file, and then manually add the missing
30
- information to the Excel file. The Excel file can then be converted to a `Rules` object.
26
+ OWL Ontologies are information models which completeness varies. As such, constructing functional
27
+ data model directly will often be impossible, therefore the produced Rules object will be ill formed.
28
+ To avoid this, neat will automatically attempt to make the imported rules compliant by adding default
29
+ values for missing information, attaching dangling properties to default containers based on the
30
+ property type, etc.
31
31
 
32
- Alternatively, one can set the `make_compliant` parameter to True to allow neat to attempt to make
33
- the imported rules compliant by adding default values for missing information, attaching dangling
34
- properties to default containers based on the property type, etc. One has to be aware
35
- that NEAT will be opinionated about how to make the ontology compliant, and that the resulting
36
- rules may not be what you expect.
32
+ One has to be aware that NEAT will be opinionated about how to make the ontology
33
+ compliant, and that the resulting rules may not be what you expect.
37
34
 
38
35
  """
39
36
 
40
- def __init__(self, filepath: Path, make_compliant: bool = False):
37
+ def __init__(self, filepath: Path):
41
38
  self.owl_filepath = filepath
42
- self.make_compliant = make_compliant
43
39
 
44
40
  @overload
45
41
  def to_rules(self, errors: Literal["raise"], role: RoleTypes | None = None) -> Rules: ...
@@ -67,13 +63,12 @@ class OWLImporter(BaseImporter):
67
63
  graph.bind("skos", SKOS)
68
64
 
69
65
  components = {
70
- "Metadata": parse_owl_metadata(graph, make_compliant=self.make_compliant),
71
- "Classes": parse_owl_classes(graph, make_compliant=self.make_compliant),
72
- "Properties": parse_owl_properties(graph, make_compliant=self.make_compliant),
66
+ "Metadata": parse_owl_metadata(graph),
67
+ "Classes": parse_owl_classes(graph),
68
+ "Properties": parse_owl_properties(graph),
73
69
  }
74
70
 
75
- if self.make_compliant:
76
- components = make_components_compliant(components)
71
+ components = make_components_compliant(components)
77
72
 
78
73
  rules = InformationRules.model_validate(components)
79
74
  return self._to_output(rules, IssueList(), errors, role)
@@ -119,15 +119,6 @@ class OntologyToRules(Step):
119
119
  label="For what role Rules are intended?",
120
120
  options=["infer", *RoleTypes.__members__.keys()],
121
121
  ),
122
- Configurable(
123
- name="Make compliant",
124
- value="True",
125
- label=(
126
- "Attempt to make the imported Rules compliant, by converting "
127
- "the information model provided in the ontology to data model."
128
- ),
129
- options=["True", "False"],
130
- ),
131
122
  ]
132
123
 
133
124
  def run(self, flow_message: FlowMessage) -> (FlowMessage, MultiRuleData): # type: ignore[syntax, override]
@@ -136,7 +127,6 @@ class OntologyToRules(Step):
136
127
 
137
128
  file_name = self.configs.get("File name", None)
138
129
  full_path = flow_message.payload.get("full_path", None) if flow_message.payload else None
139
- make_compliant = self.configs.get("Make compliant", "True") == "True"
140
130
 
141
131
  if file_name:
142
132
  rules_file_path = self.config.rules_store_path / file_name
@@ -152,7 +142,7 @@ class OntologyToRules(Step):
152
142
  if role != "infer" and role is not None:
153
143
  role_enum = RoleTypes[role]
154
144
 
155
- ontology_importer = importers.OWLImporter(filepath=rules_file_path, make_compliant=make_compliant)
145
+ ontology_importer = importers.OWLImporter(filepath=rules_file_path)
156
146
  rules, issues = ontology_importer.to_rules(errors="continue", role=role_enum)
157
147
 
158
148
  if rules is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.78.1
3
+ Version: 0.78.2
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=HinYe1V3FgUaLri1gy6R6_VuKh3sB-UYTNM51cV6k4I,23
2
+ cognite/neat/_version.py,sha256=kWBpkJnZGsOhuJ5bhE96-VWCpvSaENAUiBvGF98dgWI,23
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
@@ -180,10 +180,10 @@ cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py,sha256=QDyGt5YBaxzF4v_
180
180
  cognite/neat/rules/importers/_dtdl2rules/spec.py,sha256=tim_MfN1J0F3Oeqk3BMgIA82d_MZvhRuRMsLK3B4PYc,11897
181
181
  cognite/neat/rules/importers/_inference2rules.py,sha256=CFSwf8ZTg_luMooBaP3_0762fjDlJxCoxjLRm4J2_m4,11187
182
182
  cognite/neat/rules/importers/_owl2rules/__init__.py,sha256=tdGcrgtozdQyST-pTlxIa4cLBNTLvtk1nNYR4vOdFSw,63
183
- cognite/neat/rules/importers/_owl2rules/_owl2classes.py,sha256=LInFeBq-NbBIuMEAwgWch2a4DbBUt4_OMqPkwehW-sw,7591
184
- cognite/neat/rules/importers/_owl2rules/_owl2metadata.py,sha256=NdPN0dBB0NYkAcfC0yrYdIrGfdPbl5gfeGnSV3EtUPM,7786
185
- cognite/neat/rules/importers/_owl2rules/_owl2properties.py,sha256=BLptGmH-Aa5gZu0hDIxSZTrn9GmB2FicWgRYoETLSnQ,7437
186
- cognite/neat/rules/importers/_owl2rules/_owl2rules.py,sha256=vyXtAhHCg-zCv_sfq28bx5BK96GXoCB4KA5LeO_ZuvU,6917
183
+ cognite/neat/rules/importers/_owl2rules/_owl2classes.py,sha256=QpTxvrTGczIa48X8lgXGnMN1AWPhHK0DR6uNq175xak,7357
184
+ cognite/neat/rules/importers/_owl2rules/_owl2metadata.py,sha256=nwnUaBNAAYMoBre2UmsnkJXUuaqGEpR3U3txDrH2w6g,7527
185
+ cognite/neat/rules/importers/_owl2rules/_owl2properties.py,sha256=eKr-e-ZTTV54PJ9UXNVPTT_c9XxszNPraS4Y43AF7qQ,7297
186
+ cognite/neat/rules/importers/_owl2rules/_owl2rules.py,sha256=41_wZFvt0A6TI55zlT04oQkvU7V73li4aGLgc4T4Lxo,6358
187
187
  cognite/neat/rules/importers/_spreadsheet2rules.py,sha256=nKSJyZGoTho0bqQ_5_1XB9Z1C-MwovRgkVrC-AhOuzs,12438
188
188
  cognite/neat/rules/importers/_yaml2rules.py,sha256=F0uksSz1A3po5OlRM2152_w5j8D9oYTLB9NFTkSMlWI,4275
189
189
  cognite/neat/rules/issues/__init__.py,sha256=Ms6jgCxCezc5IgTOwCFtXQPtoVFfOvdcXj84_rs917I,563
@@ -259,7 +259,7 @@ cognite/neat/workflows/steps/lib/current/graph_extractor.py,sha256=vW9UpJScx5dFV
259
259
  cognite/neat/workflows/steps/lib/current/graph_loader.py,sha256=HfGg1HRZhbV58TFu89FTjKeUxGsbCYLeFJIQFDN_pQM,2341
260
260
  cognite/neat/workflows/steps/lib/current/graph_store.py,sha256=r7VTxdaz8jJQU7FJbnRDMxvEYbSAZFNMABhPyfNwiFk,6295
261
261
  cognite/neat/workflows/steps/lib/current/rules_exporter.py,sha256=iFwzDWgUDBSPajaNAcXvu9pVw-jX66upvwyMXyTq7SE,23822
262
- cognite/neat/workflows/steps/lib/current/rules_importer.py,sha256=u79hnIulQ14TsScfwvcXp2UcvNhBX0E4ESxIJloerRY,15626
262
+ cognite/neat/workflows/steps/lib/current/rules_importer.py,sha256=sZJv367gxLrF_ZrQrE8nibIEYh3N6JYiOjZ2MeBO1Cs,15190
263
263
  cognite/neat/workflows/steps/lib/current/rules_validator.py,sha256=LwF9lXlnuPOxDSsOMMTHBi2BHc5rk08IF5zahS9yQuw,4844
264
264
  cognite/neat/workflows/steps/lib/io/__init__.py,sha256=k7IPbIq3ey19oRc5sA_15F99-O6dxzqbm1LihGRRo5A,32
265
265
  cognite/neat/workflows/steps/lib/io/io_steps.py,sha256=QAGypoi1vP32BRiIgBZ0B4qsbFMcwhzpRiVUUnWysLA,16874
@@ -276,8 +276,8 @@ cognite/neat/workflows/steps_registry.py,sha256=fkTX14ZA7_gkUYfWIlx7A1XbCidvqR23
276
276
  cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
277
277
  cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
278
278
  cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
279
- cognite_neat-0.78.1.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
280
- cognite_neat-0.78.1.dist-info/METADATA,sha256=yDfESAmMuhuO2LxGTEozKPAOKN9z7RM1NmxeXRJCkEU,9306
281
- cognite_neat-0.78.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
282
- cognite_neat-0.78.1.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
283
- cognite_neat-0.78.1.dist-info/RECORD,,
279
+ cognite_neat-0.78.2.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
280
+ cognite_neat-0.78.2.dist-info/METADATA,sha256=iUWwZcRnmk4ccIsio_g3ktMvOuv2Bi6vdvoke6ERqys,9306
281
+ cognite_neat-0.78.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
282
+ cognite_neat-0.78.2.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
283
+ cognite_neat-0.78.2.dist-info/RECORD,,