cognite-neat 0.70.1__py3-none-any.whl → 0.70.3__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.70.1"
1
+ __version__ = "0.70.3"
@@ -175,12 +175,13 @@ class DMSExporter(CDFExporter[DMSSchema]):
175
175
  # are changed. This is a workaround to force the conversion.
176
176
  redeploy_data_model = False
177
177
 
178
- for items, loader in to_export:
179
- all_item_ids = loader.get_ids(items)
178
+ for all_items, loader in to_export:
179
+ all_item_ids = loader.get_ids(all_items)
180
180
  skipped = sum(1 for item_id in all_item_ids if item_id in schema.frozen_ids)
181
181
  item_ids = [item_id for item_id in all_item_ids if item_id not in schema.frozen_ids]
182
182
  cdf_items = loader.retrieve(item_ids)
183
183
  cdf_item_by_id = {loader.get_id(item): item for item in cdf_items}
184
+ items = [item for item in all_items if loader.get_id(item) in item_ids]
184
185
  to_create, to_update, unchanged, to_delete = [], [], [], []
185
186
  is_redeploying = loader.resource_name == "data_models" and redeploy_data_model
186
187
  for item in items:
@@ -25,7 +25,7 @@ def parse_owl_classes(graph: Graph, make_compliant: bool = False, language: str
25
25
  """
26
26
 
27
27
  query = """
28
- SELECT ?class ?name ?description ?parentClass ?source ?match ?comment
28
+ SELECT ?class ?name ?description ?parentClass ?reference ?match ?comment
29
29
  WHERE {
30
30
  ?class a owl:Class .
31
31
  OPTIONAL {?class rdfs:subClassOf ?parentClass }.
@@ -62,7 +62,7 @@ def parse_owl_classes(graph: Graph, make_compliant: bool = False, language: str
62
62
  def _parse_raw_dataframe(query_results: list[tuple]) -> pd.DataFrame:
63
63
  df = pd.DataFrame(
64
64
  query_results,
65
- columns=["Class", "Name", "Description", "Parent Class", "Source", "Match", "Comment"],
65
+ columns=["Class", "Name", "Description", "Parent Class", "Reference", "Match", "Comment"],
66
66
  )
67
67
  if df.empty:
68
68
  return df
@@ -70,9 +70,8 @@ def _parse_raw_dataframe(query_results: list[tuple]) -> pd.DataFrame:
70
70
  # # remove NaNs
71
71
  df.replace(np.nan, "", regex=True, inplace=True)
72
72
 
73
- df.Source = df.Class
73
+ df.Reference = df.Class
74
74
  df.Class = df.Class.apply(lambda x: remove_namespace(x))
75
- df["Source Entity Name"] = df.Class
76
75
  df["Match Type"] = len(df) * [MatchType.exact]
77
76
  df["Comment"] = len(df) * [None]
78
77
  df["Parent Class"] = df["Parent Class"].apply(lambda x: remove_namespace(x))
@@ -87,7 +86,7 @@ def _clean_up_classes(df: pd.DataFrame) -> pd.DataFrame:
87
86
  "Name": group_df["Name"].unique()[0],
88
87
  "Description": "\n".join(list(group_df.Description.unique())),
89
88
  "Parent Class": ", ".join(list(group_df["Parent Class"].unique())),
90
- "Source": group_df["Source"].unique()[0],
89
+ "Reference": group_df["Reference"].unique()[0],
91
90
  "Match Type": group_df["Match Type"].unique()[0],
92
91
  "Comment": group_df["Comment"].unique()[0],
93
92
  }
@@ -154,7 +153,7 @@ def _object_property_class() -> dict:
154
153
  "Name": None,
155
154
  "Description": "The class of object properties.",
156
155
  "Parent Class": None,
157
- "Source": OWL.ObjectProperty,
156
+ "Reference": OWL.ObjectProperty,
158
157
  "Match Type": MatchType.exact,
159
158
  "Comment": "Added by NEAT based on owl:ObjectProperty but adapted to NEAT and use in CDF.",
160
159
  }
@@ -166,7 +165,7 @@ def _data_type_property_class() -> dict:
166
165
  "Name": None,
167
166
  "Description": "The class of data properties.",
168
167
  "Parent Class": None,
169
- "Source": OWL.DatatypeProperty,
168
+ "Reference": OWL.DatatypeProperty,
170
169
  "Match Type": MatchType.exact,
171
170
  "Comment": "Added by NEAT based on owl:DatatypeProperty but adapted to NEAT and use in CDF.",
172
171
  }
@@ -178,7 +177,7 @@ def _thing_class() -> dict:
178
177
  "Name": None,
179
178
  "Description": "The class of holding class individuals.",
180
179
  "Parent Class": None,
181
- "Source": OWL.Thing,
180
+ "Reference": OWL.Thing,
182
181
  "Match Type": MatchType.exact,
183
182
  "Comment": (
184
183
  "Added by NEAT. "
@@ -206,7 +205,7 @@ def _add_parent_class(df: pd.DataFrame) -> list[dict]:
206
205
  "Name": None,
207
206
  "Description": None,
208
207
  "Parent Class": None,
209
- "Source": None,
208
+ "Reference": None,
210
209
  "Match Type": None,
211
210
  "Comment": (
212
211
  "Added by NEAT. "
@@ -24,7 +24,7 @@ def parse_owl_properties(graph: Graph, make_compliant: bool = False, language: s
24
24
 
25
25
  query = """
26
26
 
27
- SELECT ?class ?property ?name ?description ?type ?minCount ?maxCount ?source
27
+ SELECT ?class ?property ?name ?description ?type ?minCount ?maxCount ?reference
28
28
  ?match ?propertyType
29
29
  WHERE {
30
30
  ?property a ?propertyType.
@@ -71,7 +71,7 @@ def _parse_raw_dataframe(query_results: list[tuple]) -> pd.DataFrame:
71
71
  "Value Type",
72
72
  "Min Count",
73
73
  "Max Count",
74
- "Source",
74
+ "Reference",
75
75
  "Match Type",
76
76
  "_property_type",
77
77
  ],
@@ -81,7 +81,7 @@ def _parse_raw_dataframe(query_results: list[tuple]) -> pd.DataFrame:
81
81
 
82
82
  df.replace(np.nan, "", regex=True, inplace=True)
83
83
 
84
- df.Source = df.Property
84
+ df.Reference = df.Property
85
85
  df.Class = df.Class.apply(lambda x: remove_namespace(x))
86
86
  df.Property = df.Property.apply(lambda x: remove_namespace(x))
87
87
  df["Value Type"] = df["Value Type"].apply(lambda x: remove_namespace(x))
@@ -109,7 +109,7 @@ def _clean_up_properties(df: pd.DataFrame) -> pd.DataFrame:
109
109
  "Value Type": property_grouped_df["Value Type"].unique()[0],
110
110
  "Min Count": property_grouped_df["Min Count"].unique()[0],
111
111
  "Max Count": property_grouped_df["Max Count"].unique()[0],
112
- "Source": property_grouped_df["Source"].unique()[0],
112
+ "Reference": property_grouped_df["Reference"].unique()[0],
113
113
  "Match Type": property_grouped_df["Match Type"].unique()[0],
114
114
  "Comment": property_grouped_df["Comment"].unique()[0],
115
115
  "_property_type": property_grouped_df["_property_type"].unique()[0],
@@ -88,6 +88,7 @@ class OWLImporter(BaseImporter):
88
88
  def make_components_compliant(components: dict) -> dict:
89
89
  components = _add_missing_classes(components)
90
90
  components = _add_missing_value_types(components)
91
+ components = _add_default_property_to_dangling_classes(components)
91
92
 
92
93
  return components
93
94
 
@@ -129,11 +130,24 @@ def _add_missing_value_types(components: dict) -> dict:
129
130
  """
130
131
 
131
132
  xsd_types = set(XSD_VALUE_TYPE_MAPPINGS.keys())
132
- value_types = {definition["Value Type"] for definition in components["Properties"]}
133
+ candidate_value_types = {definition["Value Type"] for definition in components["Properties"]} - {
134
+ definition["Class"] for definition in components["Classes"]
135
+ }
136
+
137
+ # to avoid issue of case sensitivity for xsd types
138
+ value_types_lower = {v.lower() for v in candidate_value_types}
139
+ xsd_types_lower = {x.lower() for x in xsd_types}
140
+
141
+ # Create a mapping from lowercase strings to original strings
142
+ value_types_mapping = {v.lower(): v for v in candidate_value_types}
133
143
 
134
- classes = {definition["Class"] for definition in components["Classes"]}
144
+ # Find the difference
145
+ difference = value_types_lower - xsd_types_lower
135
146
 
136
- for class_ in value_types.difference(classes).difference(xsd_types):
147
+ # Convert the difference back to the original case
148
+ difference_original_case = {value_types_mapping[d] for d in difference}
149
+
150
+ for class_ in difference_original_case:
137
151
  components["Classes"].append(
138
152
  {
139
153
  "Class": class_,
@@ -146,3 +160,39 @@ def _add_missing_value_types(components: dict) -> dict:
146
160
  )
147
161
 
148
162
  return components
163
+
164
+
165
+ def _add_default_property_to_dangling_classes(components: dict[str, list[dict]]) -> dict:
166
+ """Add missing classes to Classes.
167
+
168
+ Args:
169
+ tables: imported tables from owl ontology
170
+
171
+ Returns:
172
+ Updated tables with missing classes added to containers
173
+ """
174
+
175
+ dangling_classes = {
176
+ definition["Class"] for definition in components["Classes"] if not definition.get("Parent Class", None)
177
+ } - {definition["Class"] for definition in components["Properties"]}
178
+
179
+ comment = (
180
+ "Added by NEAT. "
181
+ "This is property has been added to this class since otherwise it will create "
182
+ "dangling classes in the ontology."
183
+ )
184
+
185
+ for class_ in dangling_classes:
186
+ components["Properties"].append(
187
+ {
188
+ "Class": class_,
189
+ "Property": "label",
190
+ "Value Type": "string",
191
+ "Comment": comment,
192
+ "Min Count": 0,
193
+ "Max Count": 1,
194
+ "Reference": "http://www.w3.org/2000/01/rdf-schema#label",
195
+ }
196
+ )
197
+
198
+ return components
@@ -632,7 +632,9 @@ class _DMSExporter:
632
632
  if not view.in_model
633
633
  }
634
634
  data_model = rules.metadata.as_data_model()
635
- data_model.views = [view_id for view_id in views.as_ids() if view_id not in views_not_in_model]
635
+ data_model.views = sorted(
636
+ [view_id for view_id in views.as_ids() if view_id not in views_not_in_model], key=lambda v: v.as_tuple() # type: ignore[union-attr]
637
+ )
636
638
 
637
639
  spaces = self._create_spaces(rules.metadata, containers, views, data_model)
638
640
 
@@ -83,6 +83,7 @@ _DATA_TYPES: list[dict] = [
83
83
  {"name": "anyURI", "python": str, "GraphQL": "String", "dms": Text},
84
84
  {"name": "normalizedString", "python": str, "GraphQL": "String", "dms": Text},
85
85
  {"name": "token", "python": str, "GraphQL": "String", "dms": Text},
86
+ {"name": "PlainLiteral", "python": str, "GraphQL": "String", "dms": Text},
86
87
  # Graphql does not have a datetime/date type this is CDF specific
87
88
  {"name": "dateTime", "python": datetime, "GraphQL": "Timestamp", "dms": Timestamp},
88
89
  {"name": "dateTimeStamp", "python": datetime, "GraphQL": "Timestamp", "dms": Timestamp},
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.70.1
3
+ Version: 0.70.3
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=WVjSRSd2zgGQFanscfNpVjo_q_ShT12r7ukn4JBk-AU,23
2
+ cognite/neat/_version.py,sha256=F-q5hXyPtZzXmX2Dnq2XZj8mpyj_44adbjIxdt654tM,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=xnKdBE_dtq1nRvKa79YGA_wimI5UhoSRuBQz4LkLzQw,4606
@@ -113,7 +113,7 @@ cognite/neat/rules/exporter/_validation.py,sha256=CnEer181-EdnWl3yOuZJKOJ80W7H7q
113
113
  cognite/neat/rules/exporters/__init__.py,sha256=Gn3CjkVKHJF9Po1ZPH4wAJ-sRW9up7b2CpXm-eReV3Q,413
114
114
  cognite/neat/rules/exporters/_base.py,sha256=aRCzRjGDoXILkGvASev2UjVvLXrVCRTFiKgYwzJZqAo,1518
115
115
  cognite/neat/rules/exporters/_models.py,sha256=f_RbFhoyD27z6Dsk4upYMHp7JHZRCfIvZsEzH5JSvtc,1645
116
- cognite/neat/rules/exporters/_rules2dms.py,sha256=5KUVBYyGr4Q4YVqBs6taTeh8nDVM1L-ABGFTpcaph4c,12129
116
+ cognite/neat/rules/exporters/_rules2dms.py,sha256=hvmMxwL9RCAA1b2i5RndjgWnKJv3TKkxdWFovLpJacA,12221
117
117
  cognite/neat/rules/exporters/_rules2excel.py,sha256=uK-aS9sBwXUCFQLIO1jciBQrB4w7ySF6MafDqG23hrQ,9080
118
118
  cognite/neat/rules/exporters/_rules2ontology.py,sha256=70T28d1tcT179kt5yOZQlLgAQ67uydz3XbhbA10IRuI,19768
119
119
  cognite/neat/rules/exporters/_rules2yaml.py,sha256=HKgFlpgD7U2vWLQC_VdSvkDk19QgeVAd_J8wQ9ZgrN8,3038
@@ -141,10 +141,10 @@ cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py,sha256=o-n9KBWvA5Y7Fj
141
141
  cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py,sha256=QThkjUuEVWI19ynl8zca6nE-zHMk_Pv-9dFwGwovEUE,6925
142
142
  cognite/neat/rules/importers/_dtdl2rules/spec.py,sha256=7Kd4WJEVoRoM8ssvl5zv2ALHDh3Mc0EUJ7v_6i8xJOk,11926
143
143
  cognite/neat/rules/importers/_owl2rules/__init__.py,sha256=tdGcrgtozdQyST-pTlxIa4cLBNTLvtk1nNYR4vOdFSw,63
144
- cognite/neat/rules/importers/_owl2rules/_owl2classes.py,sha256=9iv_5FWVNcR8UZcXPTvzvQgMA-_-y52I39wHzpM0Q6U,7610
144
+ cognite/neat/rules/importers/_owl2rules/_owl2classes.py,sha256=tCEwwJPCdFLodM0q0gXfbyEe0rZvIG4emDTcUzDYRWI,7597
145
145
  cognite/neat/rules/importers/_owl2rules/_owl2metadata.py,sha256=kCTCAbUaUGgSwnH-jgFg01SfxD2VikyPy5L-vgxUjHA,7674
146
- cognite/neat/rules/importers/_owl2rules/_owl2properties.py,sha256=AJzdmsTrfDUbmJ4n6fTr_Sp8uUSPVGAWvCxpKS9Na7I,7304
147
- cognite/neat/rules/importers/_owl2rules/_owl2rules.py,sha256=Ojjatyb6JFxC4kkGn9akkuK2NE1S2eh4RKZbVcwlPAo,5442
146
+ cognite/neat/rules/importers/_owl2rules/_owl2properties.py,sha256=KNOrOySUXM9Krg6HEPNtiThlHfSEhd0EoQBtu_lczu8,7319
147
+ cognite/neat/rules/importers/_owl2rules/_owl2rules.py,sha256=0QplDQnDslqwZ7B8-TuJWJkC30C7MAGyG81YhHdvasQ,7116
148
148
  cognite/neat/rules/importers/_spreadsheet2rules.py,sha256=GVkTtWnQkM8nXkPAOs2UpxKnsPHA6898Tb7aTgcDDPM,10573
149
149
  cognite/neat/rules/importers/_yaml2rules.py,sha256=sIaYY3Zo--v1cXSu65n4ZPv47cS-5InvSbpkw3Ahov4,4198
150
150
  cognite/neat/rules/issues/__init__.py,sha256=Ms6jgCxCezc5IgTOwCFtXQPtoVFfOvdcXj84_rs917I,563
@@ -163,7 +163,7 @@ cognite/neat/rules/models/_rules/_types/_base.py,sha256=EsTqjXUP0zpuQ-Z_BMP-00rJ
163
163
  cognite/neat/rules/models/_rules/_types/_field.py,sha256=dOVAU1jWCupFVnrYYwLfI-nNUC4rv4vXHMzpiObtWiw,10295
164
164
  cognite/neat/rules/models/_rules/_types/_value.py,sha256=I7Ke388M2NOi0U5F9kAzOjE0O4ZXbIxefupgDAjnISM,6079
165
165
  cognite/neat/rules/models/_rules/base.py,sha256=9DgtdCmpz84sMFxZB_stWkalVbjA4HQKsTMpSjjOVLU,10635
166
- cognite/neat/rules/models/_rules/dms_architect_rules.py,sha256=aevTRWHscgYBih4DqdMzKPAHpj5NVOrCpld0sTp-5Qk,49379
166
+ cognite/neat/rules/models/_rules/dms_architect_rules.py,sha256=d4WKTyuSWWw6ioOYCnayTQcTWNGv-dys2LU3PBI8Fuc,49465
167
167
  cognite/neat/rules/models/_rules/dms_schema.py,sha256=-ru40beGY2WJvf9_sd5eO2Wh8x2qLQ2UmgzExloBWac,30229
168
168
  cognite/neat/rules/models/_rules/domain_rules.py,sha256=mOE4M6wOurmnAehxbnxvP9vIVXsFuKSiyMmD1shXKpA,2051
169
169
  cognite/neat/rules/models/_rules/information_rules.py,sha256=e_SesgvMbzgC9WMFx0b_6qrpOIQvoQ_kXUiXrSYC9RI,20984
@@ -171,7 +171,7 @@ cognite/neat/rules/models/raw_rules.py,sha256=Y7ZVKyvLhX0s6WdwztbFiYFj4EijGEfjtB
171
171
  cognite/neat/rules/models/rdfpath.py,sha256=kk1dqxl3n2W_vSQtpSJri2O4nCXnCDZB2lhLsLV1PN0,7344
172
172
  cognite/neat/rules/models/rules.py,sha256=ECKrQEtoiQqtR8W-rKMAWmODpHeHhI8Qzf3TwCa3dy8,51063
173
173
  cognite/neat/rules/models/tables.py,sha256=hj7qjjIpwDXBnkVQrL47V2kjFxDz7aE4mkYOZTwepj8,171
174
- cognite/neat/rules/models/value_types.py,sha256=CcAaj7-SfLE9HkQBOmqJFGlWaq19YiB9mIZhR7Ly9oY,4316
174
+ cognite/neat/rules/models/value_types.py,sha256=3OPP5i4CtXfRsgtoBB53Cptr3ZSOm3AqhX4uSgCMiuw,4395
175
175
  cognite/neat/utils/__init__.py,sha256=l5Nyqhqo25bcQXCOb_lk01cr-UXsG8cczz_y_I0u6bg,68
176
176
  cognite/neat/utils/auxiliary.py,sha256=E2-YtddzScvN7l7j0kNYIMlfqIUT9NWMqLpcJYPK4rY,309
177
177
  cognite/neat/utils/cdf.py,sha256=dTg8wnm2916yhWT_2Jg9_PlauHCbmnuNgmpqrGU8eO0,711
@@ -227,8 +227,8 @@ cognite/neat/workflows/steps_registry.py,sha256=PZVoHX4d6Vmjz6XzUFnFFWMCnrVnqkUC
227
227
  cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
228
228
  cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
229
229
  cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
230
- cognite_neat-0.70.1.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
231
- cognite_neat-0.70.1.dist-info/METADATA,sha256=olXq5x4vGn839BRr4LQBKuE8gsBpqDuiUW57iH9he1k,9321
232
- cognite_neat-0.70.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
233
- cognite_neat-0.70.1.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
234
- cognite_neat-0.70.1.dist-info/RECORD,,
230
+ cognite_neat-0.70.3.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
231
+ cognite_neat-0.70.3.dist-info/METADATA,sha256=qocFaYXnky1ctPppojAvHonQARRka6NpByF7SmanOU0,9321
232
+ cognite_neat-0.70.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
233
+ cognite_neat-0.70.3.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
234
+ cognite_neat-0.70.3.dist-info/RECORD,,