cognite-neat 0.107.0__py3-none-any.whl → 0.109.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.
- cognite/neat/_constants.py +35 -1
- cognite/neat/_graph/_shared.py +4 -0
- cognite/neat/_graph/extractors/_classic_cdf/_base.py +115 -14
- cognite/neat/_graph/extractors/_classic_cdf/_classic.py +87 -6
- cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +48 -12
- cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +19 -1
- cognite/neat/_graph/extractors/_dms.py +162 -47
- cognite/neat/_graph/extractors/_dms_graph.py +54 -4
- cognite/neat/_graph/extractors/_mock_graph_generator.py +1 -1
- cognite/neat/_graph/extractors/_rdf_file.py +3 -2
- cognite/neat/_graph/loaders/__init__.py +1 -3
- cognite/neat/_graph/loaders/_rdf2dms.py +20 -10
- cognite/neat/_graph/queries/_base.py +144 -84
- cognite/neat/_graph/queries/_construct.py +1 -1
- cognite/neat/_graph/transformers/__init__.py +3 -1
- cognite/neat/_graph/transformers/_base.py +4 -4
- cognite/neat/_graph/transformers/_classic_cdf.py +13 -13
- cognite/neat/_graph/transformers/_prune_graph.py +3 -3
- cognite/neat/_graph/transformers/_rdfpath.py +3 -4
- cognite/neat/_graph/transformers/_value_type.py +71 -13
- cognite/neat/_issues/errors/__init__.py +2 -0
- cognite/neat/_issues/errors/_external.py +8 -0
- cognite/neat/_issues/errors/_resources.py +1 -1
- cognite/neat/_issues/warnings/__init__.py +0 -2
- cognite/neat/_issues/warnings/_models.py +1 -1
- cognite/neat/_issues/warnings/_properties.py +0 -8
- cognite/neat/_issues/warnings/_resources.py +1 -1
- cognite/neat/_rules/catalog/classic_model.xlsx +0 -0
- cognite/neat/_rules/exporters/_rules2instance_template.py +3 -3
- cognite/neat/_rules/exporters/_rules2yaml.py +1 -1
- cognite/neat/_rules/importers/__init__.py +3 -1
- cognite/neat/_rules/importers/_dtdl2rules/spec.py +1 -2
- cognite/neat/_rules/importers/_rdf/__init__.py +2 -2
- cognite/neat/_rules/importers/_rdf/_base.py +2 -2
- cognite/neat/_rules/importers/_rdf/_inference2rules.py +310 -26
- cognite/neat/_rules/models/_base_rules.py +22 -11
- cognite/neat/_rules/models/dms/_exporter.py +5 -4
- cognite/neat/_rules/models/dms/_rules.py +1 -8
- cognite/neat/_rules/models/dms/_rules_input.py +4 -0
- cognite/neat/_rules/models/information/_rules_input.py +5 -0
- cognite/neat/_rules/transformers/__init__.py +10 -3
- cognite/neat/_rules/transformers/_base.py +6 -1
- cognite/neat/_rules/transformers/_converters.py +530 -364
- cognite/neat/_rules/transformers/_mapping.py +4 -4
- cognite/neat/_session/_base.py +100 -47
- cognite/neat/_session/_create.py +133 -0
- cognite/neat/_session/_drop.py +60 -2
- cognite/neat/_session/_fix.py +28 -0
- cognite/neat/_session/_inspect.py +22 -7
- cognite/neat/_session/_mapping.py +8 -8
- cognite/neat/_session/_prepare.py +3 -247
- cognite/neat/_session/_read.py +138 -17
- cognite/neat/_session/_set.py +50 -1
- cognite/neat/_session/_show.py +16 -43
- cognite/neat/_session/_state.py +53 -52
- cognite/neat/_session/_to.py +11 -4
- cognite/neat/_session/_wizard.py +1 -1
- cognite/neat/_session/exceptions.py +8 -1
- cognite/neat/_store/_graph_store.py +301 -146
- cognite/neat/_store/_provenance.py +36 -20
- cognite/neat/_store/_rules_store.py +253 -267
- cognite/neat/_store/exceptions.py +40 -4
- cognite/neat/_utils/auth.py +5 -3
- cognite/neat/_version.py +1 -1
- {cognite_neat-0.107.0.dist-info → cognite_neat-0.109.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.107.0.dist-info → cognite_neat-0.109.0.dist-info}/RECORD +69 -67
- {cognite_neat-0.107.0.dist-info → cognite_neat-0.109.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.107.0.dist-info → cognite_neat-0.109.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.107.0.dist-info → cognite_neat-0.109.0.dist-info}/entry_points.txt +0 -0
|
@@ -20,7 +20,7 @@ import uuid
|
|
|
20
20
|
from collections.abc import Iterable, Sequence
|
|
21
21
|
from dataclasses import dataclass, field
|
|
22
22
|
from datetime import datetime
|
|
23
|
-
from typing import
|
|
23
|
+
from typing import Generic, TypeVar
|
|
24
24
|
|
|
25
25
|
from rdflib import PROV, RDF, Literal, URIRef
|
|
26
26
|
|
|
@@ -49,9 +49,31 @@ UNKNOWN_AGENT = Agent(acted_on_behalf_of="UNKNOWN", id_=DEFAULT_NAMESPACE["unkno
|
|
|
49
49
|
@dataclass(frozen=True)
|
|
50
50
|
class Entity:
|
|
51
51
|
was_attributed_to: Agent
|
|
52
|
-
issues: IssueList
|
|
53
|
-
was_generated_by:
|
|
54
|
-
id_: URIRef
|
|
52
|
+
issues: IssueList
|
|
53
|
+
was_generated_by: "Activity | None" = field(repr=False)
|
|
54
|
+
id_: URIRef
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def create_with_defaults(
|
|
58
|
+
cls,
|
|
59
|
+
was_attributed_to: Agent,
|
|
60
|
+
issues: IssueList | None = None,
|
|
61
|
+
was_generated_by: "Activity | None" = None,
|
|
62
|
+
id_: URIRef = DEFAULT_NAMESPACE["graph-store"],
|
|
63
|
+
) -> "Entity":
|
|
64
|
+
return cls(
|
|
65
|
+
was_attributed_to=was_attributed_to,
|
|
66
|
+
issues=issues or IssueList(),
|
|
67
|
+
was_generated_by=was_generated_by,
|
|
68
|
+
id_=id_,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def create_new_unknown_entity(cls) -> "Entity":
|
|
73
|
+
return cls.create_with_defaults(
|
|
74
|
+
was_attributed_to=UNKNOWN_AGENT,
|
|
75
|
+
id_=DEFAULT_NAMESPACE[f"unknown-entity/{uuid.uuid4()}"],
|
|
76
|
+
)
|
|
55
77
|
|
|
56
78
|
def as_triples(self) -> list[Triple]:
|
|
57
79
|
output: list[tuple[URIRef, URIRef, Literal | URIRef]] = [
|
|
@@ -70,16 +92,10 @@ class Entity:
|
|
|
70
92
|
|
|
71
93
|
return output
|
|
72
94
|
|
|
73
|
-
@classmethod
|
|
74
|
-
def new_unknown_entity(cls) -> "Entity":
|
|
75
|
-
return cls(
|
|
76
|
-
was_attributed_to=UNKNOWN_AGENT,
|
|
77
|
-
id_=DEFAULT_NAMESPACE[f"unknown-entity/{uuid.uuid4()}"],
|
|
78
|
-
)
|
|
79
|
-
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
T_Entity = TypeVar("T_Entity", bound=Entity)
|
|
97
|
+
INSTANCES_ENTITY = Entity.create_with_defaults(was_attributed_to=NEAT_AGENT, id_=CDF_NAMESPACE["instances"])
|
|
98
|
+
EMPTY_ENTITY = Entity.create_with_defaults(was_attributed_to=NEAT_AGENT, id_=DEFAULT_NAMESPACE["empty-entity"])
|
|
83
99
|
|
|
84
100
|
|
|
85
101
|
@dataclass(frozen=True)
|
|
@@ -111,12 +127,12 @@ class Activity:
|
|
|
111
127
|
|
|
112
128
|
|
|
113
129
|
@dataclass(frozen=True)
|
|
114
|
-
class Change(FrozenNeatObject):
|
|
130
|
+
class Change(FrozenNeatObject, Generic[T_Entity]):
|
|
115
131
|
agent: Agent
|
|
116
132
|
activity: Activity
|
|
117
|
-
target_entity:
|
|
133
|
+
target_entity: T_Entity
|
|
118
134
|
description: str
|
|
119
|
-
source_entity: Entity = field(default_factory=Entity.
|
|
135
|
+
source_entity: Entity = field(default_factory=Entity.create_new_unknown_entity)
|
|
120
136
|
|
|
121
137
|
def as_triples(self) -> list[Triple]:
|
|
122
138
|
return (
|
|
@@ -127,7 +143,7 @@ class Change(FrozenNeatObject):
|
|
|
127
143
|
)
|
|
128
144
|
|
|
129
145
|
@classmethod
|
|
130
|
-
def record(cls, activity: str, start: datetime, end: datetime, description: str) -> "Change":
|
|
146
|
+
def record(cls, activity: str, start: datetime, end: datetime, description: str) -> "Change[Entity]":
|
|
131
147
|
"""User friendly method to record a change that occurred in the graph store."""
|
|
132
148
|
agent = Agent()
|
|
133
149
|
activity = Activity(
|
|
@@ -136,8 +152,8 @@ class Change(FrozenNeatObject):
|
|
|
136
152
|
started_at_time=start,
|
|
137
153
|
ended_at_time=end,
|
|
138
154
|
)
|
|
139
|
-
target_entity = Entity(was_generated_by=activity, was_attributed_to=agent)
|
|
140
|
-
return
|
|
155
|
+
target_entity = Entity.create_with_defaults(was_generated_by=activity, was_attributed_to=agent)
|
|
156
|
+
return Change(
|
|
141
157
|
agent=agent,
|
|
142
158
|
activity=activity,
|
|
143
159
|
target_entity=target_entity,
|
|
@@ -154,7 +170,7 @@ class Change(FrozenNeatObject):
|
|
|
154
170
|
}
|
|
155
171
|
|
|
156
172
|
|
|
157
|
-
class Provenance(NeatList[Change]):
|
|
173
|
+
class Provenance(NeatList[Change[T_Entity]]):
|
|
158
174
|
def __init__(self, changes: Sequence[Change] | None = None):
|
|
159
175
|
super().__init__(changes or [])
|
|
160
176
|
|