sinapsis-aperturedb 0.1.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.
- sinapsis_aperturedb/__init__.py +0 -0
- sinapsis_aperturedb/helpers/__init__.py +0 -0
- sinapsis_aperturedb/helpers/aperturedb_env_var_keys.py +60 -0
- sinapsis_aperturedb/helpers/query_base_models/__init__.py +0 -0
- sinapsis_aperturedb/helpers/query_base_models/add.py +34 -0
- sinapsis_aperturedb/helpers/query_base_models/base.py +165 -0
- sinapsis_aperturedb/helpers/query_base_models/delete.py +38 -0
- sinapsis_aperturedb/helpers/query_base_models/find.py +52 -0
- sinapsis_aperturedb/helpers/query_base_models/update.py +72 -0
- sinapsis_aperturedb/helpers/tags.py +7 -0
- sinapsis_aperturedb/templates/__init__.py +22 -0
- sinapsis_aperturedb/templates/aperturedb_add_to_table.py +72 -0
- sinapsis_aperturedb/templates/aperturedb_client_base.py +234 -0
- sinapsis_aperturedb/templates/aperturedb_database_info.py +43 -0
- sinapsis_aperturedb/templates/aperturedb_delete_from_table.py +27 -0
- sinapsis_aperturedb/templates/aperturedb_find_in_table.py +23 -0
- sinapsis_aperturedb/templates/aperturedb_update_table.py +30 -0
- sinapsis_aperturedb-0.1.0.dist-info/METADATA +238 -0
- sinapsis_aperturedb-0.1.0.dist-info/RECORD +22 -0
- sinapsis_aperturedb-0.1.0.dist-info/WHEEL +5 -0
- sinapsis_aperturedb-0.1.0.dist-info/licenses/LICENSE +661 -0
- sinapsis_aperturedb-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from typing import Any, Tuple
|
|
3
|
+
|
|
4
|
+
from aperturedb import Connector
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
7
|
+
from sinapsis_core.template_base import Template
|
|
8
|
+
from sinapsis_core.template_base.base_models import (
|
|
9
|
+
OutputTypes,
|
|
10
|
+
TemplateAttributes,
|
|
11
|
+
TemplateAttributeType,
|
|
12
|
+
UIPropertiesMetadata,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from sinapsis_aperturedb.helpers.aperturedb_env_var_keys import (
|
|
16
|
+
APERTUREDB_API_KEY,
|
|
17
|
+
APERTUREDB_HOST,
|
|
18
|
+
APERTUREDB_PASSWORD,
|
|
19
|
+
APERTUREDB_PORT,
|
|
20
|
+
APERTUREDB_USER,
|
|
21
|
+
)
|
|
22
|
+
from sinapsis_aperturedb.helpers.query_base_models.base import (
|
|
23
|
+
ConnectionParams,
|
|
24
|
+
Query,
|
|
25
|
+
QueryParameters,
|
|
26
|
+
Response,
|
|
27
|
+
)
|
|
28
|
+
from sinapsis_aperturedb.helpers.tags import Tags
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ApertureDBClientQueryAttributes(TemplateAttributes):
|
|
32
|
+
"""Attributes for ApertureDBCommandBase template.
|
|
33
|
+
|
|
34
|
+
connect_with_key: Controls whether to connect with APERTUREDB_KEY or with host, user and password
|
|
35
|
+
input_keys: Instance names from command templates
|
|
36
|
+
use_ssl: Set to false only to use Community Edition local docker for experiments.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
connect_with_key: bool = False
|
|
40
|
+
connection_params: ConnectionParams = Field(default_factory=dict)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ApertureDBClientQuery(Template):
|
|
44
|
+
"""Base Template to connect to an ApertureDB server and run queries.
|
|
45
|
+
|
|
46
|
+
Generate a client connection to an ApertureDB server and run queries set through
|
|
47
|
+
previous ApertureDB command templates.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
AttributesBaseModel = ApertureDBClientQueryAttributes
|
|
51
|
+
UIProperties = UIPropertiesMetadata(
|
|
52
|
+
category="ApertureDB",
|
|
53
|
+
output_type=OutputTypes.TEXT,
|
|
54
|
+
tags=[Tags.JSON, Tags.DATABASE],
|
|
55
|
+
)
|
|
56
|
+
COMMAND: str
|
|
57
|
+
|
|
58
|
+
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
59
|
+
super().__init__(attributes)
|
|
60
|
+
self.connect_to_host()
|
|
61
|
+
|
|
62
|
+
def connect_to_host(self) -> None:
|
|
63
|
+
"""Connect to an ApertureDB server with a key or with user and password."""
|
|
64
|
+
if isinstance(self.attributes.connection_params, dict) and not self.attributes.connection_params:
|
|
65
|
+
self.attributes.connection_params = ConnectionParams()
|
|
66
|
+
|
|
67
|
+
conn_params = self.attributes.connection_params.get_connection_params()
|
|
68
|
+
if isinstance(conn_params, dict) and not conn_params:
|
|
69
|
+
self.attributes.connection_params = ConnectionParams(
|
|
70
|
+
host=APERTUREDB_HOST,
|
|
71
|
+
user=APERTUREDB_USER,
|
|
72
|
+
port=APERTUREDB_PORT,
|
|
73
|
+
password=APERTUREDB_PASSWORD,
|
|
74
|
+
key=APERTUREDB_API_KEY,
|
|
75
|
+
use_ssl=False,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if self.attributes.connect_with_key:
|
|
79
|
+
self.client = Connector.Connector(key=self.attributes.connection_params.key)
|
|
80
|
+
else:
|
|
81
|
+
self.client = Connector.Connector(
|
|
82
|
+
host=self.attributes.connection_params.host,
|
|
83
|
+
user=self.attributes.connection_params.user,
|
|
84
|
+
port=self.attributes.connection_params.port,
|
|
85
|
+
password=self.attributes.connection_params.password,
|
|
86
|
+
use_ssl=self.attributes.connection_params.use_ssl,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def get_query_response(
|
|
90
|
+
self, query: Tuple[list[dict[str, Any]], list[bytes]] | list[dict[str, Any]]
|
|
91
|
+
) -> dict[str, Any]:
|
|
92
|
+
"""Execute a query against the ApertureDB server.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
query (Tuple[list[dict[str, Any]], list[bytes]] | list[dict[str, Any]]):
|
|
96
|
+
Query to execute, either as a list of query dicts or a tuple of query dicts and blobs.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
dict[str, Any]: Response from the ApertureDB server.
|
|
100
|
+
"""
|
|
101
|
+
response = self.client.query(query)
|
|
102
|
+
return response
|
|
103
|
+
|
|
104
|
+
def add_query_response_to_data_container(
|
|
105
|
+
self, responses: list[Response], blobs: list[bytes], container: DataContainer
|
|
106
|
+
) -> DataContainer:
|
|
107
|
+
"""Format the received response from ApertureDB server as generic data.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
responses (list[Response]): list of response base models
|
|
111
|
+
blobs (list[bytes]): list of output blobs as bytes objects
|
|
112
|
+
container (DataContainer): data container
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
DataContainer: data container with response data
|
|
116
|
+
"""
|
|
117
|
+
_ = blobs
|
|
118
|
+
responses_output = []
|
|
119
|
+
for response in responses:
|
|
120
|
+
response_dict = response.format_response_dict()
|
|
121
|
+
if response.status == -1:
|
|
122
|
+
self.logger.error(response_dict)
|
|
123
|
+
responses_output.append(response_dict)
|
|
124
|
+
self._set_generic_data(container, responses_output)
|
|
125
|
+
return container
|
|
126
|
+
|
|
127
|
+
@staticmethod
|
|
128
|
+
def format_response(response_dict: dict[str, Any]) -> Response:
|
|
129
|
+
"""Format the received response dictionary as base model.
|
|
130
|
+
|
|
131
|
+
Possible response formats are:
|
|
132
|
+
{"status": ...}
|
|
133
|
+
{"<Command (AddEntity, UpdateEntity,...)>": {"status": ....}}
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
response_dict (dict[str, Any]): received response dict
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
Response: response base model
|
|
140
|
+
"""
|
|
141
|
+
if "status" in response_dict:
|
|
142
|
+
return Response(**response_dict)
|
|
143
|
+
command_key, command_dict = response_dict.popitem()
|
|
144
|
+
return Response(command=command_key, **command_dict)
|
|
145
|
+
|
|
146
|
+
def preprocess_response(self, response_output: Any, blob_output: Any) -> Tuple[list[Response], list[bytes]]:
|
|
147
|
+
"""Process the received response and format it as Response base models.
|
|
148
|
+
|
|
149
|
+
Responses can vary, depending on results from queries, so processing is
|
|
150
|
+
required before adding to container.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
response_output (Any): Responses received from server
|
|
154
|
+
blob_output (Any): Blobs received from server
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Tuple[list[Response], list[bytes]]: Formatted responses and blobs
|
|
158
|
+
"""
|
|
159
|
+
responses: list[Response] = []
|
|
160
|
+
blobs: list[bytes] = []
|
|
161
|
+
|
|
162
|
+
if isinstance(response_output, list):
|
|
163
|
+
responses = [self.format_response(r) for r in response_output if isinstance(r, dict)]
|
|
164
|
+
elif isinstance(response_output, dict):
|
|
165
|
+
responses = [self.format_response(response_output)]
|
|
166
|
+
|
|
167
|
+
if isinstance(blob_output, list):
|
|
168
|
+
blobs = [blob for blob in blob_output if isinstance(blob, bytes)]
|
|
169
|
+
elif isinstance(blob_output, bytes):
|
|
170
|
+
blobs = [blob_output]
|
|
171
|
+
|
|
172
|
+
return responses, blobs
|
|
173
|
+
|
|
174
|
+
def get_command_parameters(self) -> QueryParameters:
|
|
175
|
+
"""Get query parameters for the command.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
QueryParameters: Query parameters object.
|
|
179
|
+
"""
|
|
180
|
+
_ = self
|
|
181
|
+
parameters = QueryParameters()
|
|
182
|
+
return parameters
|
|
183
|
+
|
|
184
|
+
def get_query_from_attrs(self) -> list[dict[str, Any]]:
|
|
185
|
+
"""Get query from template attributes.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
list[dict[str, Any]]: List containing the formatted query.
|
|
189
|
+
"""
|
|
190
|
+
parameters = self.get_command_parameters()
|
|
191
|
+
|
|
192
|
+
query_base_model = Query(command=self.COMMAND, parameters=parameters)
|
|
193
|
+
|
|
194
|
+
query, _ = query_base_model.prepare_query()
|
|
195
|
+
return [query]
|
|
196
|
+
|
|
197
|
+
def process_query_list(self, query: list[dict[str, Any]], container: DataContainer) -> None:
|
|
198
|
+
"""Process a list of queries and add responses to data container.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
query (list[dict[str, Any]]): List of query dictionaries.
|
|
202
|
+
container (DataContainer): Data container to store responses.
|
|
203
|
+
"""
|
|
204
|
+
response_output, blob_output = self.get_query_response(query)
|
|
205
|
+
responses, response_blobs = self.preprocess_response(response_output, blob_output)
|
|
206
|
+
|
|
207
|
+
self.add_query_response_to_data_container(responses, response_blobs, container)
|
|
208
|
+
|
|
209
|
+
def execute(self, container: DataContainer) -> DataContainer:
|
|
210
|
+
"""Execute the query and return the updated data container.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
container (DataContainer): Input data container.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
DataContainer: Data container with query results.
|
|
217
|
+
"""
|
|
218
|
+
query = self.get_query_from_attrs()
|
|
219
|
+
self.process_query_list(query, container)
|
|
220
|
+
return container
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class ApertureDBGetStatus(ApertureDBClientQuery):
|
|
224
|
+
"""This template adds a query to obtain the server status.
|
|
225
|
+
|
|
226
|
+
When invoked without parameters, it returns general status information:
|
|
227
|
+
|
|
228
|
+
system: "ApertureDB",
|
|
229
|
+
status: 0(ok), -1(not ready),
|
|
230
|
+
info: general information "OK",
|
|
231
|
+
version: "0.15.1",
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
COMMAND = "GetStatus"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from pydantic import Field
|
|
3
|
+
|
|
4
|
+
from sinapsis_aperturedb.helpers.query_base_models.base import (
|
|
5
|
+
GetSchemaParameters,
|
|
6
|
+
QueryParameters,
|
|
7
|
+
)
|
|
8
|
+
from sinapsis_aperturedb.templates.aperturedb_client_base import (
|
|
9
|
+
ApertureDBClientQuery,
|
|
10
|
+
ApertureDBClientQueryAttributes,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ApertureDBGetSchemaAttributes(ApertureDBClientQueryAttributes):
|
|
15
|
+
"""Attributes for ApertureDBGetSchema template."""
|
|
16
|
+
|
|
17
|
+
parameters: GetSchemaParameters = Field(
|
|
18
|
+
default_factory=dict,
|
|
19
|
+
description="Parameters for GetSchema command",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ApertureDBGetSchema(ApertureDBClientQuery):
|
|
24
|
+
"""This template creates a GetSchema query.
|
|
25
|
+
|
|
26
|
+
Retrieve schema information based on current data.
|
|
27
|
+
Parameters
|
|
28
|
+
|
|
29
|
+
[optional] ref: Reference to other entities or connections within the transaction.
|
|
30
|
+
[optional] type: This can be "entities", "connections", or "both". Default is set to "both" when not specified.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
AttributesBaseModel = ApertureDBGetSchemaAttributes
|
|
35
|
+
COMMAND = "GetSchema"
|
|
36
|
+
|
|
37
|
+
def get_command_parameters(self) -> QueryParameters:
|
|
38
|
+
"""Get the command parameters for the GetSchema query.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
QueryParameters: The parameters for the GetSchema command.
|
|
42
|
+
"""
|
|
43
|
+
return self.attributes.parameters
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from sinapsis_aperturedb.helpers.query_base_models.delete import (
|
|
4
|
+
DeleteEntityParameters,
|
|
5
|
+
)
|
|
6
|
+
from sinapsis_aperturedb.templates.aperturedb_client_base import (
|
|
7
|
+
ApertureDBCommandBase,
|
|
8
|
+
ApertureDBCommandBaseAttributes,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# TO-DO: Rework delete templates to be more dynamic
|
|
13
|
+
class ApertureDBDeleteClassAttributes(ApertureDBCommandBaseAttributes):
|
|
14
|
+
"""Attributes for ApertureDBCommandBase template."""
|
|
15
|
+
|
|
16
|
+
class_name: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ApertureDBDeleteClassEntities(ApertureDBCommandBase):
|
|
20
|
+
AttributesBaseModel = ApertureDBDeleteClassAttributes
|
|
21
|
+
COMMAND = "DeleteEntity"
|
|
22
|
+
|
|
23
|
+
def get_command_parameters(self) -> DeleteEntityParameters:
|
|
24
|
+
parameters = DeleteEntityParameters(with_class=self.attributes.class_name)
|
|
25
|
+
return parameters
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from pydantic import Field
|
|
3
|
+
|
|
4
|
+
from sinapsis_aperturedb.helpers.query_base_models.find import (
|
|
5
|
+
FindEntityParameters,
|
|
6
|
+
)
|
|
7
|
+
from sinapsis_aperturedb.templates.aperturedb_client_base import (
|
|
8
|
+
ApertureDBClientQuery,
|
|
9
|
+
ApertureDBClientQueryAttributes,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ApertureDBFindEntities(ApertureDBClientQuery):
|
|
14
|
+
class ApertureDBFindEntityAttributes(ApertureDBClientQueryAttributes):
|
|
15
|
+
"""Attributes for ApertureDBFindBase template."""
|
|
16
|
+
|
|
17
|
+
find_parameters: FindEntityParameters = Field(default_factory=dict)
|
|
18
|
+
|
|
19
|
+
AttributesBaseModel = ApertureDBFindEntityAttributes
|
|
20
|
+
COMMAND = "FindEntity"
|
|
21
|
+
|
|
22
|
+
def get_command_parameters(self) -> FindEntityParameters:
|
|
23
|
+
return self.attributes.find_parameters
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from pydantic import Field
|
|
3
|
+
|
|
4
|
+
from sinapsis_aperturedb.helpers.query_base_models.update import (
|
|
5
|
+
UpdateEntityParameters,
|
|
6
|
+
)
|
|
7
|
+
from sinapsis_aperturedb.templates.aperturedb_client_base import (
|
|
8
|
+
ApertureDBCommandBase,
|
|
9
|
+
ApertureDBCommandBaseAttributes,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# TO-DO: Rework Update templates to be more dynamic. Make Constraints easier to add
|
|
14
|
+
class ApertureDBUpdateEntityAttributes(ApertureDBCommandBaseAttributes):
|
|
15
|
+
"""Attributes for ApertureDBUpdateEntity template."""
|
|
16
|
+
|
|
17
|
+
parameters: UpdateEntityParameters = Field(
|
|
18
|
+
default_factory=dict,
|
|
19
|
+
description="Parameters for UpdateEntity/UpdateConnection command",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ApertureDBUpdateEntity(ApertureDBCommandBase):
|
|
24
|
+
AttributesBaseModel = ApertureDBUpdateEntityAttributes
|
|
25
|
+
COMMAND = "UpdateEntity"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ApertureDBUpdateConnection(ApertureDBCommandBase):
|
|
29
|
+
AttributesBaseModel = ApertureDBUpdateEntityAttributes
|
|
30
|
+
COMMAND = "UpdateConnection"
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sinapsis-aperturedb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Templates for multimodal database operations using ApertureDB API.
|
|
5
|
+
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
|
+
Project-URL: Homepage, https://sinapsis.tech
|
|
7
|
+
Project-URL: Documentation, https://docs.sinapsis.tech/docs
|
|
8
|
+
Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
|
|
9
|
+
Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-aperturedb.git
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: aperturedb>=0.4.53
|
|
14
|
+
Requires-Dist: sinapsis>=0.2.24
|
|
15
|
+
Provides-Extra: all
|
|
16
|
+
Requires-Dist: sinapsis-data-readers>=0.1.24; extra == "all"
|
|
17
|
+
Requires-Dist: sinapsis-data-writers>=0.1.16; extra == "all"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
<!-- [](https://github.com/Sinapsis-AI/sinapsis-aperturedb/blob/main/README.es.md) -->
|
|
21
|
+
<h1 align="center">
|
|
22
|
+
<br>
|
|
23
|
+
<a href="https://sinapsis.tech/">
|
|
24
|
+
<img
|
|
25
|
+
src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
|
|
26
|
+
alt="" width="300">
|
|
27
|
+
</a><br>
|
|
28
|
+
Sinapsis ApertureDB
|
|
29
|
+
<br>
|
|
30
|
+
</h1>
|
|
31
|
+
|
|
32
|
+
<h4 align="center">Modular templates for database entity management with ApertureDB</h4>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<a href="#installation">🐍 Installation</a> •
|
|
36
|
+
<a href="#features"> 🚀 Features</a> •
|
|
37
|
+
<a href="#example"> 📚 Usage example</a> •
|
|
38
|
+
<a href="#webapp"> 🌐 Webapp</a> •
|
|
39
|
+
<a href="#documentation">📙 Documentation</a> •
|
|
40
|
+
<a href="#license"> 🔍 License </a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
**Sinapsis ApertureDB** provides a robust and flexible integration for the ApertureDB Python SDK. It enables users to execute complex database operations—such as entity management, status monitoring, and schema retrieval—through a modular, template-based system.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<h2 id="installation"> 🐍 Installation </h2>
|
|
47
|
+
|
|
48
|
+
Install using your package manager of choice. We encourage the use of <code>uv</code>
|
|
49
|
+
|
|
50
|
+
Example with <code>uv</code>:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv pip install sinapsis-aperturedb --extra-index-url https://pypi.sinapsis.tech
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
or with raw <code>pip</code>:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install sinapsis-aperturedb --extra-index-url https://pypi.sinapsis.tech
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
<h2 id="features">🚀 Features</h2>
|
|
63
|
+
|
|
64
|
+
<h3>Templates Supported</h3>
|
|
65
|
+
|
|
66
|
+
- **ApertureDBAddEntitiesFromCSV**: Ingests tabular data from a pandas DataFrame stored within a DataContainer, mapping each row to a unique Entity for bulk insertion into the database.
|
|
67
|
+
- **ApertureDBFindEntities**: Executes targeted entity queries within ApertureDB, retrieving records that match a specific set of user-defined constraints and filters.
|
|
68
|
+
- **ApertureDBGetStatus**: Polls the ApertureDB server to retrieve real-time health metrics, connectivity status, and operational readiness.
|
|
69
|
+
- **ApertureDBGetSchema**: Introspects the database to generate a comprehensive overview of the current data model, including entity types, properties, and relationships.
|
|
70
|
+
|
|
71
|
+
> [!TIP]
|
|
72
|
+
> Use CLI command ```sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis ApertureDB.
|
|
73
|
+
|
|
74
|
+
> [!TIP]
|
|
75
|
+
> Use CLI command ```sinapsis info --example-template-config TEMPLATE_NAME``` to produce an example Agent config for the Template specified in ***TEMPLATE_NAME***.
|
|
76
|
+
|
|
77
|
+
For example, for ***ApertureDBGetStatus*** use ```sinapsis info --example-template-config ApertureDBGetStatus``` to produce an example config like:
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
agent:
|
|
81
|
+
name: my_test_agent
|
|
82
|
+
templates:
|
|
83
|
+
- template_name: InputTemplate
|
|
84
|
+
class_name: InputTemplate
|
|
85
|
+
attributes: {}
|
|
86
|
+
- template_name: ApertureDBGetStatus
|
|
87
|
+
class_name: ApertureDBGetStatus
|
|
88
|
+
template_input: InputTemplate
|
|
89
|
+
attributes:
|
|
90
|
+
connect_with_key: false
|
|
91
|
+
connection_params:
|
|
92
|
+
host: localhost
|
|
93
|
+
user: ''
|
|
94
|
+
port: 55555
|
|
95
|
+
password: ''
|
|
96
|
+
key: ''
|
|
97
|
+
use_ssl: false
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<h2 id='example'>📚 Usage example</h2>
|
|
101
|
+
|
|
102
|
+
You can begin testing ```sinapsis-aperturedb``` by executing the ```ApertureDBGetStatus``` configuration. To utilize the ```ApertureDB``` templates, you must first establish a connection to an ApertureDB instance. You have three primary options:
|
|
103
|
+
|
|
104
|
+
- Cloud: Connect to a hosted ApertureDB instance using a generated API key.
|
|
105
|
+
- Local: Deploy a local instance using the aperturedb-community Docker image.
|
|
106
|
+
- Docker Compose: Automatically deploy the aperturedb service and execute the getStatus configuration in one workflow.
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary ><strong><span style="font-size: 1.4em;"> ☁️ ApertureDB Cloud </span></strong></summary>
|
|
110
|
+
|
|
111
|
+
1. **Generate an API key**: Create an ApertureDB Cloud account and generate your API key by following the official [ApertureDB setup guide](https://docs.aperturedata.io/Setup/server/Cloud).
|
|
112
|
+
|
|
113
|
+
2. **Configure Environment Variables**: Set the ```APERTUREDB_API_KEY``` variable in your terminal. This key is used by the connect_with_key attribute in your configuration.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
export APERTUREDB_API_KEY="your-api-key-here"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
3. **Prepare the GetStatus Configuration**: Save the following YAML as ```check_status.yaml```. This configuration tells the agent to authenticate using your stored API key.
|
|
120
|
+
|
|
121
|
+
```yaml
|
|
122
|
+
agent:
|
|
123
|
+
name: aperturedb_get_status
|
|
124
|
+
description: Validates connection and retrieves ApertureDB server health status.
|
|
125
|
+
|
|
126
|
+
templates:
|
|
127
|
+
- template_name: InputTemplate
|
|
128
|
+
class_name: InputTemplate
|
|
129
|
+
attributes: {}
|
|
130
|
+
|
|
131
|
+
- template_name: GetStatus
|
|
132
|
+
class_name: ApertureDBGetStatus
|
|
133
|
+
template_input: InputTemplate
|
|
134
|
+
attributes:
|
|
135
|
+
connect_with_key: true
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
4. **Execute via CLI**: Run the configuration using the Sinapsis CLI:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
sinapsis run check_status.yaml
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary ><strong><span style="font-size: 1.4em;"> 💻 Local ApertureDB instance </span></strong></summary>
|
|
148
|
+
|
|
149
|
+
For local prototyping and testing of <code>sinapsis-aperturedb</code>, you can deploy a containerized instance of **ApertureDB Community Edition**.
|
|
150
|
+
|
|
151
|
+
1. **Deploy the container**. Use the following Docker command to run the ApertureDB Community Edition. This setup maps the default port and configures initial credentials.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
docker run -p 55555:55555 -e ADB_MASTER_KEY=admin -e ADB_FORCE_SSL=false aperturedata/aperturedb-community
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
2. **Configure Environment Variables**: Set your connection parameters so sinapsis-aperturedb can authenticate with the local instance.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export APERTUREDB_HOST="localhost"
|
|
161
|
+
export APERTUREDB_PORT=55555
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
3. **Prepare the GetStatus Configuration**: Use the following YAML configuration to verify the connection. Save this as ```check_status.yaml```:
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
agent:
|
|
168
|
+
name: aperturedb_get_status
|
|
169
|
+
description: Validates connection and retrieves ApertureDB server health status.
|
|
170
|
+
|
|
171
|
+
templates:
|
|
172
|
+
- template_name: InputTemplate
|
|
173
|
+
class_name: InputTemplate
|
|
174
|
+
attributes: {}
|
|
175
|
+
|
|
176
|
+
- template_name: GetStatus
|
|
177
|
+
class_name: ApertureDBGetStatus
|
|
178
|
+
template_input: InputTemplate
|
|
179
|
+
attributes:
|
|
180
|
+
connect_with_key: false
|
|
181
|
+
connection_params:
|
|
182
|
+
host: localhost
|
|
183
|
+
user: admin
|
|
184
|
+
port: 55555
|
|
185
|
+
password: admin
|
|
186
|
+
use_ssl: false
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
4. **Execute via CLI**: Run the configuration using the Sinapsis CLI:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
sinapsis run check_status.yaml
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
</details>
|
|
196
|
+
|
|
197
|
+
<details>
|
|
198
|
+
<summary id="docker"><strong><span style="font-size: 1.4em;">🐳 Docker Compose</span></strong></summary>
|
|
199
|
+
|
|
200
|
+
**IMPORTANT** This docker image depends on the sinapsis:base image. Refer to the official [Sinapsis Docker Instructions](https://github.com/Sinapsis-ai/sinapsis?tab=readme-ov-file#docker) to build the base before proceeding.
|
|
201
|
+
|
|
202
|
+
1. **Build the sinapsis-aperturedb image**: Compile the local environment using the provided compose file.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
docker compose -f docker/compose.yaml build
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
2. **Start the app container**: Launch the service in the background or attached mode.
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
docker compose -f docker/compose_app.yaml up -d
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
3. **Monitor logs and status**: Verify the connection to ApertureDB by tailing the container logs.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
docker logs -f sinapsis-aperturedb-app
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
4. **To stop the app**: Gracefully shut down the services and clean up network resources.
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
docker compose -f docker/compose_app.yaml down
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
</details>
|
|
227
|
+
|
|
228
|
+
<h2 id="documentation">📙 Documentation</h2>
|
|
229
|
+
|
|
230
|
+
Documentation for this and other sinapsis packages is available on the [sinapsis website](https://docs.sinapsis.tech/docs)
|
|
231
|
+
|
|
232
|
+
Tutorials for different projects within sinapsis are available at [sinapsis tutorials page](https://docs.sinapsis.tech/tutorials)
|
|
233
|
+
|
|
234
|
+
<h2 id="license">🔍 License</h2>
|
|
235
|
+
|
|
236
|
+
This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.
|
|
237
|
+
|
|
238
|
+
For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
sinapsis_aperturedb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
sinapsis_aperturedb/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
sinapsis_aperturedb/helpers/aperturedb_env_var_keys.py,sha256=FWFQhtYtk48NcClibYTTBroZWjALftHoBmOpYkRlsOI,1730
|
|
4
|
+
sinapsis_aperturedb/helpers/tags.py,sha256=FCOM6zqD0fchIcLiIzMOU7FY4jSasR4I_eoxuiDoewM,110
|
|
5
|
+
sinapsis_aperturedb/helpers/query_base_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
sinapsis_aperturedb/helpers/query_base_models/add.py,sha256=hhX7zaaM868GPlzJ3kY4RO22uxBrBjY8baAkEBEGhrk,1191
|
|
7
|
+
sinapsis_aperturedb/helpers/query_base_models/base.py,sha256=hKXQjOB3RdNp2Io3aMMxYBjXzIfUAXkBt0k5aONEbUc,5772
|
|
8
|
+
sinapsis_aperturedb/helpers/query_base_models/delete.py,sha256=DfP6-4X3AcVlJo6Q2DCGsPM61NfLTmjvIOp0sBe8lFQ,909
|
|
9
|
+
sinapsis_aperturedb/helpers/query_base_models/find.py,sha256=ZOpx2nWlDYGwTCort1Sc6xIXLqtNOuNG9l8b7pT4gMA,2273
|
|
10
|
+
sinapsis_aperturedb/helpers/query_base_models/update.py,sha256=sCg6byMWfspJ1hzbL1wQjA_o3AHPM4h1En9KnXH0kVE,1951
|
|
11
|
+
sinapsis_aperturedb/templates/__init__.py,sha256=XQF9ImJB_lEYEw6o0g29fJpMrIt7t4fGXGKVqOMoC_Q,768
|
|
12
|
+
sinapsis_aperturedb/templates/aperturedb_add_to_table.py,sha256=ojXCy78lX4WR-OKG1ucCv9DYgxwDzrLaQkERptMj_dY,2575
|
|
13
|
+
sinapsis_aperturedb/templates/aperturedb_client_base.py,sha256=VjvnsD88QwfAxnkkaJQWxDNRitB3fVQwFsibBRAQsDY,8409
|
|
14
|
+
sinapsis_aperturedb/templates/aperturedb_database_info.py,sha256=sgn2IxOsgpSkJyUCcyYxAFLdHihhs6deudyMc-TmeWE,1302
|
|
15
|
+
sinapsis_aperturedb/templates/aperturedb_delete_from_table.py,sha256=ns3KdAUnGaOzIte27bqA1QJ51KTGTmMfwwIgp9823z8,784
|
|
16
|
+
sinapsis_aperturedb/templates/aperturedb_find_in_table.py,sha256=RdV0zpOBhgSQeXMA83C1Xo1wb5mkWTbT2cG94mWdH6Y,738
|
|
17
|
+
sinapsis_aperturedb/templates/aperturedb_update_table.py,sha256=p1yyuRmDbbrJzRSqPTISY2RUpZbVvnCrMGEIsZxgXUs,954
|
|
18
|
+
sinapsis_aperturedb-0.1.0.dist-info/licenses/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
|
|
19
|
+
sinapsis_aperturedb-0.1.0.dist-info/METADATA,sha256=p8SMGU5i-wHw-NiVq1IQATj5c8vzIBSokSdt2qt0O0o,8946
|
|
20
|
+
sinapsis_aperturedb-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
21
|
+
sinapsis_aperturedb-0.1.0.dist-info/top_level.txt,sha256=dlIQe41I4k09mGdsS5qP-Nd1RjacdTmVFmkHOUv7N5A,20
|
|
22
|
+
sinapsis_aperturedb-0.1.0.dist-info/RECORD,,
|