graflo 1.3.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.
- graflo/README.md +18 -0
- graflo/__init__.py +70 -0
- graflo/architecture/__init__.py +38 -0
- graflo/architecture/actor.py +1120 -0
- graflo/architecture/actor_util.py +450 -0
- graflo/architecture/edge.py +297 -0
- graflo/architecture/onto.py +374 -0
- graflo/architecture/resource.py +161 -0
- graflo/architecture/schema.py +136 -0
- graflo/architecture/transform.py +292 -0
- graflo/architecture/util.py +93 -0
- graflo/architecture/vertex.py +586 -0
- graflo/caster.py +655 -0
- graflo/cli/__init__.py +14 -0
- graflo/cli/ingest.py +194 -0
- graflo/cli/manage_dbs.py +197 -0
- graflo/cli/plot_schema.py +132 -0
- graflo/cli/xml2json.py +93 -0
- graflo/data_source/__init__.py +48 -0
- graflo/data_source/api.py +339 -0
- graflo/data_source/base.py +97 -0
- graflo/data_source/factory.py +298 -0
- graflo/data_source/file.py +133 -0
- graflo/data_source/memory.py +72 -0
- graflo/data_source/registry.py +82 -0
- graflo/data_source/sql.py +185 -0
- graflo/db/__init__.py +44 -0
- graflo/db/arango/__init__.py +22 -0
- graflo/db/arango/conn.py +1026 -0
- graflo/db/arango/query.py +180 -0
- graflo/db/arango/util.py +88 -0
- graflo/db/conn.py +377 -0
- graflo/db/connection/__init__.py +6 -0
- graflo/db/connection/config_mapping.py +18 -0
- graflo/db/connection/onto.py +688 -0
- graflo/db/connection/wsgi.py +29 -0
- graflo/db/manager.py +119 -0
- graflo/db/neo4j/__init__.py +16 -0
- graflo/db/neo4j/conn.py +639 -0
- graflo/db/postgres/__init__.py +156 -0
- graflo/db/postgres/conn.py +425 -0
- graflo/db/postgres/resource_mapping.py +139 -0
- graflo/db/postgres/schema_inference.py +245 -0
- graflo/db/postgres/types.py +148 -0
- graflo/db/tigergraph/__init__.py +9 -0
- graflo/db/tigergraph/conn.py +2212 -0
- graflo/db/util.py +49 -0
- graflo/filter/__init__.py +21 -0
- graflo/filter/onto.py +525 -0
- graflo/logging.conf +22 -0
- graflo/onto.py +190 -0
- graflo/plot/__init__.py +17 -0
- graflo/plot/plotter.py +556 -0
- graflo/util/__init__.py +23 -0
- graflo/util/chunker.py +751 -0
- graflo/util/merge.py +150 -0
- graflo/util/misc.py +37 -0
- graflo/util/onto.py +332 -0
- graflo/util/transform.py +448 -0
- graflo-1.3.3.dist-info/METADATA +190 -0
- graflo-1.3.3.dist-info/RECORD +64 -0
- graflo-1.3.3.dist-info/WHEEL +4 -0
- graflo-1.3.3.dist-info/entry_points.txt +5 -0
- graflo-1.3.3.dist-info/licenses/LICENSE +126 -0
graflo/onto.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Core ontology and base classes for graph database operations.
|
|
2
|
+
|
|
3
|
+
This module provides the fundamental data structures and base classes used throughout
|
|
4
|
+
the graph database system. It includes base classes for enums, dataclasses, and
|
|
5
|
+
database-specific configurations.
|
|
6
|
+
|
|
7
|
+
Key Components:
|
|
8
|
+
- BaseEnum: Base class for string-based enumerations with flexible membership testing
|
|
9
|
+
- BaseDataclass: Base class for dataclasses with JSON/YAML serialization support
|
|
10
|
+
- DBFlavor: Enum for supported database types (ArangoDB, Neo4j)
|
|
11
|
+
- ExpressionFlavor: Enum for expression language types
|
|
12
|
+
- AggregationType: Enum for supported aggregation operations
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
>>> class MyEnum(BaseEnum):
|
|
16
|
+
... VALUE1 = "value1"
|
|
17
|
+
... VALUE2 = "value2"
|
|
18
|
+
>>> "value1" in MyEnum # True
|
|
19
|
+
>>> "invalid" in MyEnum # False
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import dataclasses
|
|
23
|
+
from copy import deepcopy
|
|
24
|
+
from enum import EnumMeta
|
|
25
|
+
from strenum import StrEnum
|
|
26
|
+
from dataclass_wizard import JSONWizard, YAMLWizard
|
|
27
|
+
from dataclass_wizard.enums import DateTimeTo
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class MetaEnum(EnumMeta):
|
|
31
|
+
"""Metaclass for flexible enumeration membership testing.
|
|
32
|
+
|
|
33
|
+
This metaclass allows checking if a value is a valid member of an enum
|
|
34
|
+
using the `in` operator, even if the value hasn't been instantiated as
|
|
35
|
+
an enum member.
|
|
36
|
+
|
|
37
|
+
Example:
|
|
38
|
+
>>> class MyEnum(BaseEnum):
|
|
39
|
+
... VALUE = "value"
|
|
40
|
+
>>> "value" in MyEnum # True
|
|
41
|
+
>>> "invalid" in MyEnum # False
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __contains__(cls, item, **kwargs):
|
|
45
|
+
"""Check if an item is a valid member of the enum.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
item: Value to check for membership
|
|
49
|
+
**kwargs: Additional keyword arguments
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
bool: True if the item is a valid enum member, False otherwise
|
|
53
|
+
"""
|
|
54
|
+
try:
|
|
55
|
+
cls(item, **kwargs)
|
|
56
|
+
except ValueError:
|
|
57
|
+
return False
|
|
58
|
+
return True
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class BaseEnum(StrEnum, metaclass=MetaEnum):
|
|
62
|
+
"""Base class for string-based enumerations.
|
|
63
|
+
|
|
64
|
+
This class provides a foundation for string-based enums with flexible
|
|
65
|
+
membership testing through the MetaEnum metaclass.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class DBFlavor(BaseEnum):
|
|
72
|
+
"""Supported database types.
|
|
73
|
+
|
|
74
|
+
This enum defines the supported graph database types in the system.
|
|
75
|
+
|
|
76
|
+
Attributes:
|
|
77
|
+
ARANGO: ArangoDB database
|
|
78
|
+
NEO4J: Neo4j database
|
|
79
|
+
TIGERGRAPH: TigerGraph database
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
ARANGO = "arango"
|
|
83
|
+
NEO4J = "neo4j"
|
|
84
|
+
TIGERGRAPH = "tigergraph"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ExpressionFlavor(BaseEnum):
|
|
88
|
+
"""Supported expression language types.
|
|
89
|
+
|
|
90
|
+
This enum defines the supported expression languages for querying and
|
|
91
|
+
filtering data.
|
|
92
|
+
|
|
93
|
+
Attributes:
|
|
94
|
+
ARANGO: ArangoDB AQL expressions
|
|
95
|
+
NEO4J: Neo4j Cypher expressions
|
|
96
|
+
TIGERGRAPH: TigerGraph GSQL expressions
|
|
97
|
+
PYTHON: Python expressions
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
ARANGO = "arango"
|
|
101
|
+
NEO4J = "neo4j"
|
|
102
|
+
TIGERGRAPH = "tigergraph"
|
|
103
|
+
PYTHON = "python"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class AggregationType(BaseEnum):
|
|
107
|
+
"""Supported aggregation operations.
|
|
108
|
+
|
|
109
|
+
This enum defines the supported aggregation operations for data analysis.
|
|
110
|
+
|
|
111
|
+
Attributes:
|
|
112
|
+
COUNT: Count operation
|
|
113
|
+
MAX: Maximum value
|
|
114
|
+
MIN: Minimum value
|
|
115
|
+
AVERAGE: Average value
|
|
116
|
+
SORTED_UNIQUE: Sorted unique values
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
COUNT = "COUNT"
|
|
120
|
+
MAX = "MAX"
|
|
121
|
+
MIN = "MIN"
|
|
122
|
+
AVERAGE = "AVERAGE"
|
|
123
|
+
SORTED_UNIQUE = "SORTED_UNIQUE"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@dataclasses.dataclass
|
|
127
|
+
class BaseDataclass(JSONWizard, JSONWizard.Meta, YAMLWizard):
|
|
128
|
+
"""Base class for dataclasses with serialization support.
|
|
129
|
+
|
|
130
|
+
This class provides a foundation for dataclasses with JSON and YAML
|
|
131
|
+
serialization capabilities. It includes methods for updating instances
|
|
132
|
+
and accessing field members.
|
|
133
|
+
|
|
134
|
+
Attributes:
|
|
135
|
+
marshal_date_time_as: Format for datetime serialization
|
|
136
|
+
key_transform_with_dump: Key transformation style for serialization
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
marshal_date_time_as = DateTimeTo.ISO_FORMAT
|
|
140
|
+
key_transform_with_dump = "SNAKE"
|
|
141
|
+
# skip_defaults = True
|
|
142
|
+
|
|
143
|
+
def update(self, other):
|
|
144
|
+
"""Update this instance with values from another instance.
|
|
145
|
+
|
|
146
|
+
This method performs a deep update of the instance's attributes using
|
|
147
|
+
values from another instance of the same type. It handles different
|
|
148
|
+
types of attributes (sets, lists, dicts, dataclasses) appropriately.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
other: Another instance of the same type to update from
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
TypeError: If other is not an instance of the same type
|
|
155
|
+
"""
|
|
156
|
+
if not isinstance(other, type(self)):
|
|
157
|
+
raise TypeError(
|
|
158
|
+
f"Expected {type(self).__name__} instance, got {type(other).__name__}"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
for field in dataclasses.fields(self):
|
|
162
|
+
name = field.name
|
|
163
|
+
current_value = getattr(self, name)
|
|
164
|
+
other_value = getattr(other, name)
|
|
165
|
+
|
|
166
|
+
if other_value is None:
|
|
167
|
+
pass
|
|
168
|
+
elif isinstance(other_value, set):
|
|
169
|
+
setattr(self, name, current_value | deepcopy(other_value))
|
|
170
|
+
elif isinstance(other_value, list):
|
|
171
|
+
setattr(self, name, current_value + deepcopy(other_value))
|
|
172
|
+
elif isinstance(other_value, dict):
|
|
173
|
+
setattr(self, name, {**current_value, **deepcopy(other_value)})
|
|
174
|
+
elif dataclasses.is_dataclass(type(other_value)):
|
|
175
|
+
if current_value is not None:
|
|
176
|
+
current_value.update(other_value)
|
|
177
|
+
else:
|
|
178
|
+
setattr(self, name, deepcopy(other_value))
|
|
179
|
+
else:
|
|
180
|
+
if current_value is None:
|
|
181
|
+
setattr(self, name, other_value)
|
|
182
|
+
|
|
183
|
+
@classmethod
|
|
184
|
+
def get_fields_members(cls):
|
|
185
|
+
"""Get list of field members excluding private ones.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
list[str]: List of public field names
|
|
189
|
+
"""
|
|
190
|
+
return [k for k in cls.__annotations__ if not k.startswith("_")]
|
graflo/plot/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Plotting utilities for graph visualization.
|
|
2
|
+
|
|
3
|
+
This module provides tools for visualizing graph schemas and structures.
|
|
4
|
+
It includes functionality for creating visual representations of graph
|
|
5
|
+
databases, their vertices, edges, and relationships.
|
|
6
|
+
|
|
7
|
+
Key Components:
|
|
8
|
+
- SchemaPlotter: Creates visual representations of graph schemas
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
>>> plotter = SchemaPlotter(schema)
|
|
12
|
+
>>> plotter.plot("schema.png")
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .plotter import SchemaPlotter
|
|
16
|
+
|
|
17
|
+
__all__ = ["SchemaPlotter"]
|