Skip to content

Commit 90ced25

Browse files
authored
Merge pull request #303 from aperture-data/release-0.4.10
Release 0.4.10
2 parents 88a1316 + 9b202c5 commit 90ced25

25 files changed

+415
-159
lines changed

aperturedb/Blobs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44

55

66
class Blobs(Entities):
7+
"""
8+
**The object mapper representation of blobs in ApertureDB.**
9+
10+
This class is a layer on top of the native query.
11+
It facilitates interactions with blobs in the database in the pythonic way.
12+
"""
713
db_object = "_Blob"

aperturedb/BoundingBoxes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44

55

66
class BoundingBoxes(Entities):
7+
"""
8+
**The object mapper representation of bounding boxes in ApertureDB.**
9+
10+
This class is a layer on top of the native query.
11+
It facilitates interactions with bounding boxes in the database in the pythonic way.
12+
"""
713
db_object = "_BoundingBox"

aperturedb/Configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33

44
@dataclass(repr=False)
55
class Configuration:
6+
"""
7+
**Configuration object for aperturedb sdk to be able to connect to ApertureDB**
8+
"""
69
host: str
710
port: int
811
username: str
912
password: str
1013
name: str
1114
use_ssl: bool = True
1215
use_rest: bool = False
16+
use_keepalive: bool = True
1317

1418
def __repr__(self) -> str:
1519
mode = "REST" if self.use_rest else "TCP"

aperturedb/Connector.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import ssl
3737
import logging
3838

39+
import keepalive
40+
3941
from threading import Lock
4042
from types import SimpleNamespace
4143
from dataclasses import dataclass
@@ -73,11 +75,9 @@ def valid(self) -> bool:
7375

7476
class Connector(object):
7577
"""
76-
.. _connector-label:
77-
7878
**Class to facilitate connections with an instance of aperturedb**
7979
80-
It lets the client execute any query as per the `Native Query specs <https://docs.aperturedata.io/>`_
80+
It lets the client execute any query as per the `Native Query specs </category/aperturedb-query-language>`_
8181
8282
Args:
8383
str (host): Address of the host to connect to.
@@ -86,12 +86,17 @@ class Connector(object):
8686
str (password): Password to specify while connecting to the db.
8787
str (token): Token to use while connecting to the database.
8888
bool (use_ssl): Use SSL to encrypt communication with the database.
89+
bool (use_keepalive): Set keepalive on the connection with the database.
90+
This has two benefits: It reduces the chance of disconnection for a long-running query,
91+
and it means that diconnections are detected sooner.
92+
Turn this off to reduce traffic on high-cost network connections.
8993
Configuration (config): Configuration object to use for connection.
9094
"""
9195

9296
def __init__(self, host="localhost", port=55555,
9397
user="", password="", token="",
9498
use_ssl=True, shared_data=None, authenticate=True,
99+
use_keepalive=True,
95100
config: Configuration = None):
96101
self.connected = False
97102
self.last_response = ''
@@ -101,19 +106,22 @@ def __init__(self, host="localhost", port=55555,
101106
self.host = host
102107
self.port = port
103108
self.use_ssl = use_ssl
109+
self.use_keepalive = use_keepalive
104110
self.config = Configuration(
105111
host=self.host,
106112
port=self.port,
107113
use_ssl=self.use_ssl,
108114
username=user,
109115
password=password,
110-
name="runtime"
116+
name="runtime",
117+
use_keepalive=use_keepalive
111118
)
112119
else:
113120
self.config = config
114121
self.host = config.host
115122
self.port = config.port
116123
self.use_ssl = config.use_ssl
124+
self.use_keepalive = config.use_keepalive
117125

118126
self._connect()
119127

@@ -228,6 +236,8 @@ def _connect(self):
228236

229237
self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
230238
self.conn.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
239+
if self.use_keepalive:
240+
keepalive.set(self.conn)
231241

232242
# TCP_QUICKACK only supported in Linux 2.4.4+.
233243
# We use startswith for checking the platform following Python's

aperturedb/ConnectorRest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def valid(self) -> bool:
6868

6969
class ConnectorRest(Connector):
7070
"""
71-
.. _connector-label:
72-
7371
**Class to use aperturedb's REST interface**
7472
7573
Args:

aperturedb/Constraints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class Conjunction(Enum):
88

99

1010
class Constraints(object):
11+
"""
12+
**Constraints object for the Object mapper API**
13+
"""
1114

1215
def __init__(self, conjunction: Conjunction = Conjunction.AND):
1316
self._conjunction = conjunction.value

aperturedb/DaskManager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818

1919
class DaskManager:
20+
"""
21+
**Class responsible for setting up a local cluster and assigning parts
22+
of data to each worker**
23+
"""
24+
2025
def __init__(self, num_workers: int = -1):
2126
self.__num_workers = num_workers
2227
# The -1 magic number is to use as many 90% of the cores (1 worker per core).

aperturedb/DescriptorDataCSV.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DescriptorDataCSV(CSVParser.CSVParser):
6060
which is same for line 1 and line 2. The UUID and constraint_UUID ensure that a Descriptor is inserted only once in the DB.
6161
6262
Association of an entity to a Descriptor can be specified by first ingesting other Objects, then Descriptors and finally by
63-
using :class:`~aperturedb.ConnectionDataCSV.ConnectionDataCSV`
63+
using [ConnectionDataCSV](/python_sdk/data_loaders/csv_wrappers/ConnectionDataCSV)
6464
6565
In the above example, the constraint_UUID ensures that a connection with the specified
6666
UUID would be only inserted if it does not already exist in the database.

aperturedb/Entities.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212

1313
class Entities(Subscriptable):
1414
"""
15-
This class is the common class to query any entity from apertureDB.
16-
The specialized subclasses, which provide a more userfriendly interface, are:
17-
:class:`~aperturedb.Entities.Images`
18-
:class:`~aperturedb.Entities.Polygons`
15+
This class is the common class to query any entity from ApertureDB.
16+
The specialized subclasses, which provide a more user friendly interface, are:
17+
* [Blobs](/python_sdk/object_wrappers/Blobs)
18+
* [Bounding Boxes](/python_sdk/object_wrappers/BoundingBoxes)
19+
* [Images](/python_sdk/object_wrappers/Images)
20+
* [Plygons](/python_sdk/object_wrappers/Polygons)
21+
* [Videos](/python_sdk/object_wrappers/Videos)
1922
"""
2023
db_object = "Entity"
2124
find_command = f"Find{db_object}"

aperturedb/ImageDataCSV.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
class ImageDataProcessor():
2727
"""
28-
Processing for Image Data used for Loading
28+
**Processing for Image data, used when loading images**
2929
"""
3030

3131
def __init__(self, check_image, n_download_retries):

0 commit comments

Comments
 (0)