Skip to content

Commit 3f9424c

Browse files
gsaluja9luisremisJoshStoddardgithub-actions[bot]
authored
Release 0.2.4 (#117)
* Fixes on server (#112) * Add QueryGenerator class (#113) * Docs and tests for resposne handler. (#103) It addresses a bug in response handler that called a batch with partial objects with empty values, as it was based on batch size value. Added tests for the same.This relies on fixtures from pytest. * Add PolygonDataCSV (#105) * PolygonLoader * +PolygonDataCSV, +batch_context for getitem() * remove unused * pep8 * draw polygons * fix connection ref bounding * draw specific polygons, polygon overlays * add more image overlay types * color silliness * better handling of polygon constraints * fix slow queries, revert batch context * pep8 * revert BBoxLoader * Increasing the size of the database. Co-authored-by: Gautam <[email protected]> * Version bump: 0.2.3 to 0.2.4 * Update config for tests on new ApertureDB version Co-authored-by: luisremis <[email protected]> Co-authored-by: JoshStoddard <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ba15a70 commit 3f9424c

19 files changed

+807
-188
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ dmypy.json
128128
# Pyre type checker
129129
.pyre/
130130

131+
# VSCode
132+
.vscode/
133+
131134
#Data files
132135
*.adb.csv
133136
*.jpg

aperturedb/BBoxDataCSV.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,30 @@ def __init__(self, filename):
7171

7272
def getitem(self, idx):
7373

74-
val = self.df.loc[idx, self.img_key]
75-
box_data_headers = [HEADER_X_POS,
76-
HEADER_Y_POS, HEADER_WIDTH, HEADER_HEIGHT]
77-
box_data = [int(self.df.loc[idx, h]) for h in box_data_headers]
78-
7974
q = []
8075

81-
ref_counter = idx + 1
82-
# TODO we could reuse image references within the batch
83-
# instead of creating a new find for every image.
84-
img_ref = ref_counter
76+
img_id = self.df.loc[idx, self.img_key]
77+
78+
img_ref = (idx % 10000) + 1
79+
8580
fi = {
8681
"FindImage": {
8782
"_ref": img_ref,
88-
}
83+
"constraints": {
84+
self.img_key: ["==", img_id],
85+
},
86+
"blobs": False,
87+
},
8988
}
90-
91-
key = self.img_key
92-
val = val
93-
constraints = {}
94-
constraints[key] = ["==", val]
95-
fi["FindImage"]["constraints"] = constraints
9689
q.append(fi)
9790

91+
box_data_headers = [HEADER_X_POS,
92+
HEADER_Y_POS, HEADER_WIDTH, HEADER_HEIGHT]
93+
box_data = [int(self.df.loc[idx, h]) for h in box_data_headers]
94+
9895
rect_attrs = ["x", "y", "width", "height"]
9996
custom_fields = {
100-
"image": img_ref,
97+
"image_ref": img_ref,
10198
"rectangle": {
10299
attr: val for attr, val in zip(rect_attrs, box_data)
103100
},

aperturedb/BBoxLoader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def generate_batch(self, bbox_data):
140140
fi = {
141141
"FindImage": {
142142
"_ref": img_ref,
143+
"blobs": False,
143144
}
144145
}
145146

@@ -154,7 +155,7 @@ def generate_batch(self, bbox_data):
154155

155156
ai = {
156157
"AddBoundingBox": {
157-
"image": img_ref,
158+
"image_ref": img_ref,
158159
"rectangle": {
159160
"x": data["x"],
160161
"y": data["y"],

aperturedb/ConnectionDataCSV.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def getitem(self, idx):
7777

7878
try:
7979

80-
ref_src = 2 * idx + 1
80+
ref_src = (2 * idx) % 10000 + 1
8181
fe_a = {
8282
"FindEntity": {
8383
"_ref": ref_src,
@@ -90,7 +90,7 @@ def getitem(self, idx):
9090
"==", src_value]
9191
q.append(fe_a)
9292

93-
ref_dst = 2 * idx + 2
93+
ref_dst = ref_src + 1
9494
fe_b = {
9595
"FindEntity": {
9696
"_ref": ref_dst,

aperturedb/Connector.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -198,40 +198,47 @@ def _connect(self):
198198
if sys.platform.startswith('linux'):
199199
self.conn.setsockopt(socket.SOL_TCP, socket.TCP_QUICKACK, 1)
200200

201-
self.conn.connect((self.host, self.port))
201+
try:
202+
self.conn.connect((self.host, self.port))
202203

203-
# Handshake with server to negotiate protocol
204+
# Handshake with server to negotiate protocol
204205

205-
protocol = 2 if self.use_ssl else 1
206+
protocol = 2 if self.use_ssl else 1
206207

207-
hello_msg = struct.pack('@II', PROTOCOL_VERSION, protocol)
208+
hello_msg = struct.pack('@II', PROTOCOL_VERSION, protocol)
208209

209-
# Send desire protocol
210-
self._send_msg(hello_msg)
210+
# Send desire protocol
211+
self._send_msg(hello_msg)
211212

212-
# Receive response from server
213-
response = self._recv_msg()
213+
# Receive response from server
214+
response = self._recv_msg()
214215

215-
version, server_protocol = struct.unpack('@II', response)
216+
version, server_protocol = struct.unpack('@II', response)
216217

217-
if version != PROTOCOL_VERSION:
218-
logger.warning("Protocol version differ from server")
218+
if version != PROTOCOL_VERSION:
219+
logger.warning("Protocol version differ from server")
219220

220-
if server_protocol != protocol:
221-
self.conn.close()
222-
self.connected = False
223-
raise Exception(
224-
"Server did not accept protocol. Aborting Connection.")
221+
if server_protocol != protocol:
222+
self.conn.close()
223+
self.connected = False
224+
raise Exception(
225+
"Server did not accept protocol. Aborting Connection.")
225226

226-
if self.use_ssl:
227+
if self.use_ssl:
227228

228-
# Server is ok with SSL, we switch over SSL.
229-
self.context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
230-
self.context.check_hostname = False
231-
# TODO, we need to add support for local certificates
232-
# For now, we let the server send us the certificate
233-
self.context.verify_mode = ssl.VerifyMode.CERT_NONE
234-
self.conn = self.context.wrap_socket(self.conn)
229+
# Server is ok with SSL, we switch over SSL.
230+
self.context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
231+
self.context.check_hostname = False
232+
# TODO, we need to add support for local certificates
233+
# For now, we let the server send us the certificate
234+
self.context.verify_mode = ssl.VerifyMode.CERT_NONE
235+
self.conn = self.context.wrap_socket(self.conn)
236+
237+
except BaseException as e:
238+
logger.error(f"Error connecting to server: {str(e)}")
239+
self.conn.close()
240+
self.connected = False
241+
raise ConnectionError("Failed to connect to ApertureDB")
235242

236243
self.connected = True
237244

0 commit comments

Comments
 (0)