Skip to content

Commit cfece05

Browse files
authored
Merge pull request #173 from aperture-data/release-0.3.5
Release 0.3.5
2 parents a01ebfb + de2891b commit cfece05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3829
-336
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ kaggleds/
144144
examples/*/kaggleds/
145145
docs/*/*.svg
146146
test/aperturedb/logs
147+
adb-python/*
148+
docker/notebook/aperturedata/*

aperturedb/BBoxDataCSV.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def __init__(self, filename, df=None, use_dask=False):
6262
super().__init__(filename, df=df, use_dask=use_dask)
6363
if not use_dask:
6464
self.props_keys = [x for x in self.header[5:]
65-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX)]
65+
if not x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
6666
self.constraints_keys = [x for x in self.header[5:]
67-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
67+
if x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
6868

6969
self.img_key = self.header[0]
7070
self.command = "AddBoundingBox"

aperturedb/BBoxLoader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def __init__(self, filename):
4646
super().__init__(filename)
4747

4848
self.props_keys = [x for x in self.header[5:]
49-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX)]
49+
if not x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
5050
self.constraints_keys = [x for x in self.header[5:]
51-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
51+
if x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
5252

5353
self.img_key = self.header[0]
5454

aperturedb/BlobDataCSV.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def __init__(self, filename, df=None, use_dask=False):
5252
super().__init__(filename, df=df, use_dask=use_dask)
5353
if not use_dask:
5454
self.props_keys = [x for x in self.header[1:]
55-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX) and x != BLOB_PATH]
55+
if not x.startswith(CSVParser.CONSTRAINTS_PREFIX) and x != BLOB_PATH]
5656
self.constraints_keys = [x for x in self.header[1:]
57-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
57+
if x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
5858
self.command = "AddBlob"
5959

6060
def getitem(self, idx):

aperturedb/BlobLoader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def __init__(self, filename):
4040
super().__init__(filename)
4141

4242
self.props_keys = [x for x in self.header[1:]
43-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX)]
43+
if not x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
4444
self.props_keys = [x for x in self.props_keys if x != BLOB_PATH]
4545
self.constraints_keys = [x for x in self.header[1:]
46-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
46+
if x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
4747

4848
def getitem(self, idx):
4949

aperturedb/Blobs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import annotations
2+
from typing import Dict
3+
4+
from aperturedb.Connector import Connector
5+
from aperturedb.Entities import Entities
6+
from aperturedb.Query import Query
7+
8+
9+
class Blobs(Entities):
10+
db_object = "_Blob"
11+
12+
@classmethod
13+
def retrieve(cls,
14+
db: Connector,
15+
spec: Query,
16+
with_adjacent: Dict[str, Query] = None) -> Blobs:
17+
spec.with_class = cls.db_object
18+
19+
results = Entities.retrieve(
20+
db=db, spec=spec, with_adjacent=with_adjacent)
21+
22+
blobs = results[-1]
23+
return blobs

aperturedb/BoundingBoxes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import annotations
2+
from typing import Dict
3+
4+
from aperturedb.Connector import Connector
5+
from aperturedb.Entities import Entities
6+
from aperturedb.Query import Query
7+
8+
9+
class BoundingBoxes(Entities):
10+
db_object = "_BoundingBox"
11+
12+
@classmethod
13+
def retrieve(cls,
14+
db: Connector,
15+
spec: Query,
16+
with_adjacent: Dict[str, Query] = None) -> BoundingBoxes:
17+
spec.with_class = cls.db_object
18+
19+
results = Entities.retrieve(
20+
db=db, spec=spec, with_adjacent=with_adjacent)
21+
22+
bboxes = results[-1]
23+
return bboxes

aperturedb/CSVParser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
logger = logging.getLogger(__name__)
1010

1111
ENTITY_CLASS = "EntityClass"
12-
CONTRAINTS_PREFIX = "constraint_"
12+
CONSTRAINTS_PREFIX = "constraint_"
1313
PROPERTIES = "properties"
1414
CONSTRAINTS = "constraints"
1515

@@ -86,7 +86,7 @@ def parse_constraints(self, df, idx):
8686
constraints[prop] = [
8787
"==", {"_date": self.df.loc[idx, key]}]
8888
else:
89-
prop = key[len(CONTRAINTS_PREFIX):] # remove "prefix
89+
prop = key[len(CONSTRAINTS_PREFIX):] # remove "prefix
9090
constraints[prop] = ["==", self.df.loc[idx, key]]
9191

9292
return constraints

aperturedb/ConnectionDataCSV.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
2-
from aperturedb import CSVParser
2+
from aperturedb.CSVParser import CSVParser, CONSTRAINTS_PREFIX
3+
from aperturedb.Query import QueryBuilder
34

45
logger = logging.getLogger(__name__)
56

@@ -8,7 +9,7 @@
89
CONSTRAINTS = "constraints"
910

1011

11-
class ConnectionDataCSV(CSVParser.CSVParser):
12+
class ConnectionDataCSV(CSVParser):
1213
"""**ApertureDB Connection Data.**
1314
1415
This class loads the Connection Data which is present in a csv file,
@@ -57,10 +58,10 @@ def __init__(self, filename, df=None, use_dask=False):
5758
super().__init__(filename, df=df, use_dask=use_dask)
5859
if not use_dask:
5960
self.props_keys = [x for x in self.header[3:]
60-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX)]
61+
if not x.startswith(CONSTRAINTS_PREFIX)]
6162

6263
self.constraints_keys = [x for x in self.header[3:]
63-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
64+
if x.startswith(CONSTRAINTS_PREFIX)]
6465

6566
self.src_class = self.header[1].split("@")[0]
6667
self.src_key = self.header[1].split("@")[1]
@@ -77,34 +78,25 @@ def getitem(self, idx):
7778
q = []
7879

7980
try:
80-
8181
ref_src = (2 * idx) % 100000 + 1
82-
fe_a = {
83-
"FindEntity": {
84-
"_ref": ref_src,
85-
"with_class": self.src_class,
86-
"unique": True,
82+
cmd_params = {
83+
"_ref": ref_src,
84+
"unique": True,
85+
"constraints": {
86+
self.src_key: ["==", src_value]
8787
}
8888
}
89-
90-
fe_a["FindEntity"]["constraints"] = {}
91-
fe_a["FindEntity"]["constraints"][self.src_key] = [
92-
"==", src_value]
93-
q.append(fe_a)
89+
q.append(QueryBuilder.find_command(self.src_class, cmd_params))
9490

9591
ref_dst = ref_src + 1
96-
fe_b = {
97-
"FindEntity": {
98-
"_ref": ref_dst,
99-
"with_class": self.dst_class,
100-
"unique": True,
92+
cmd_params = {
93+
"_ref": ref_dst,
94+
"unique": True,
95+
"constraints": {
96+
self.dst_key: ["==", dst_value]
10197
}
10298
}
103-
104-
fe_b["FindEntity"]["constraints"] = {}
105-
fe_b["FindEntity"]["constraints"][self.dst_key] = [
106-
"==", dst_value]
107-
q.append(fe_b)
99+
q.append(QueryBuilder.find_command(self.dst_class, cmd_params))
108100

109101
ae = self._basic_command(idx,
110102
custom_fields={

aperturedb/ConnectionLoader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def __init__(self, filename):
4141
super().__init__(filename)
4242

4343
self.props_keys = [x for x in self.header[3:]
44-
if not x.startswith(CSVParser.CONTRAINTS_PREFIX)]
44+
if not x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
4545

4646
self.constraints_keys = [x for x in self.header[3:]
47-
if x.startswith(CSVParser.CONTRAINTS_PREFIX)]
47+
if x.startswith(CSVParser.CONSTRAINTS_PREFIX)]
4848

4949
self.src_class = self.header[1].split("@")[0]
5050
self.src_key = self.header[1].split("@")[1]

0 commit comments

Comments
 (0)