Skip to content

Commit 1646223

Browse files
authored
Merge pull request #24 from aperture-data/release-0.0.12
Release 0.0.12
2 parents 248c634 + 7649022 commit 1646223

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

aperturedb/BlobLoader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def __getitem__(self, idx):
4343
filename = self.df.loc[idx, BLOB_PATH]
4444
blob_ok, blob = self.load_blob(filename)
4545
if not blob_ok:
46-
Exception("Error loading blob: " + filename )
46+
print("Error loading blob: " + filename )
47+
raise Exception("Error loading blob: " + filename )
48+
4749
data["blob"] = blob
4850

4951
properties = self.parse_properties (self.df, idx)

aperturedb/DescriptorLoader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def __getitem__(self, idx):
5151
descriptor, desc_ok = self.load_descriptor(filename, index)
5252

5353
if not desc_ok:
54-
Exception("Error loading descriptor: " + filename + ":" + index)
54+
print("Error loading descriptor: " + filename + ":" + index)
55+
raise Exception("Error loading descriptor: " + filename + ":" + index)
5556

5657
data = {
5758
"descriptor_blob": descriptor,

aperturedb/ImageLoader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ def __init__(self, filename, check_image=True):
4040
self.props_keys = [x for x in self.props_keys if x != IMG_FORMAT]
4141
self.constraints_keys = [x for x in self.header[1:] if x.startswith(CSVParser.CONTRAINTS_PREFIX) ]
4242

43+
# TODO: we can add support for slicing here.
4344
def __getitem__(self, idx):
4445

4546
filename = self.df.loc[idx, HEADER_PATH]
4647
data = {}
4748

4849
img_ok, img = self.load_image(filename)
4950
if not img_ok:
50-
Exception("Error loading image: " + filename )
51+
print("Error loading image: " + filename )
52+
raise Exception("Error loading image: " + filename )
5153

5254
data["img_blob"] = img
5355
if self.format_given:

aperturedb/ParallelLoader.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,30 @@ def worker(self, thid, generator, start, end):
5050

5151
db = self.db.create_new_connection()
5252

53-
data_for_query = []
54-
5553
if thid == 0 and self.stats:
5654
pb = ProgressBar.ProgressBar(self.loader_filename)
5755

58-
for i in range(start, end):
56+
total_batches = (end - start) // self.batchsize
5957

60-
data_for_query.append(generator[i])
58+
if (end - start) % self.batchsize > 0:
59+
total_batches += 1
6160

62-
if len(data_for_query) >= self.batchsize:
63-
self.do_batch(db, data_for_query)
64-
data_for_query = []
65-
if thid == 0 and self.stats:
66-
pb.update((i - start) / (end - start))
61+
for i in range(total_batches):
6762

68-
if len(data_for_query) > 0:
69-
self.do_batch(db, data_for_query)
70-
data_for_query = []
63+
batch_start = start + i * self.batchsize
64+
batch_end = min(batch_start + self.batchsize, end)
7165

72-
if thid == 0 and self.stats:
73-
pb.update(1)
66+
try:
67+
# This can be done with slices instead of list comprehension.
68+
# but required support from generator.
69+
data_for_query = [ generator[idx]
70+
for idx in range(batch_start, batch_end) ]
71+
self.do_batch(db, data_for_query)
72+
except:
73+
self.error_counter += 1
74+
75+
if thid == 0 and self.stats:
76+
pb.update((i + 1) / total_batches)
7477

7578
def ingest(self, generator, batchsize=1, numthreads=1, stats=False):
7679

aperturedb/VideoLoader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __getitem__(self, idx):
4545
video_ok, video = self.load_video(filename)
4646
if not video_ok:
4747
print("Error loading video: " + filename )
48-
return data
48+
raise Exception("Error loading video: " + filename )
4949

5050
data["video_blob"] = video
5151

setup.py

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

66
setuptools.setup(
77
name="aperturedb",
8-
version="0.0.11",
8+
version="0.0.12",
99
description="ApertureDB Client Module",
1010
install_requires=['vdms', 'scikit-image', 'image',
1111
'opencv-python', 'numpy', 'matplotlib', 'pandas'],

0 commit comments

Comments
 (0)