Skip to content

Commit b3050b1

Browse files
gsaluja9bovlbdrewaoglegithub-actions[bot]
authored
Release 0.4.31 (#457)
* Colab logging (#455) * Trying setting log level to minumum * test * fix * Update aperturedb/__init__.py Co-authored-by: Drew Ogle <[email protected]> * fmt * Fix for Kaggle issue --------- Co-authored-by: Drew Ogle <[email protected]> * expand protobuf support to 4.x (#456) * expand protobuf support to 4.x * add shim file * try to make it performant * make queryMessage wrap ParseFromString * Version bump: 0.4.30 to 0.4.31 --------- Co-authored-by: bovlb <[email protected]> Co-authored-by: Drew Ogle <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 6832586 commit b3050b1

File tree

7 files changed

+85
-15
lines changed

7 files changed

+85
-15
lines changed

aperturedb/Connector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# THE SOFTWARE.
2626
#
2727
from __future__ import annotations
28-
from . import queryMessage_pb2
28+
from . import queryMessage
2929
import sys
3030
import os
3131
import socket
@@ -359,7 +359,7 @@ def _query(self, query, blob_array = [], try_resume=True):
359359
else:
360360
query_str = query
361361

362-
query_msg = queryMessage_pb2.queryMessage()
362+
query_msg = queryMessage.queryMessage()
363363
# query has .json and .blobs
364364
query_msg.json = query_str
365365

@@ -380,8 +380,8 @@ def _query(self, query, blob_array = [], try_resume=True):
380380
if self._send_msg(data):
381381
response = self._recv_msg()
382382
if response is not None:
383-
querRes = queryMessage_pb2.queryMessage()
384-
querRes.ParseFromString(response)
383+
querRes = queryMessage.queryMessage()
384+
queryMessage.ParseFromString(querRes, response)
385385
response_blob_array = [b for b in querRes.blobs]
386386
self.last_response = json.loads(querRes.json)
387387
break

aperturedb/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,23 @@
99

1010
logger = logging.getLogger(__name__)
1111

12-
__version__ = "0.4.30"
12+
__version__ = "0.4.31"
1313

1414
# set log level
15-
logger.setLevel(logging.DEBUG)
16-
formatter = logging.Formatter(
15+
formatter = logging.Formatter(
1716
"%(asctime)s : %(levelname)s : %(name)s : %(thread)d : %(lineno)d : %(message)s")
1817

1918
log_file_level = logging.getLevelName(os.getenv("LOG_FILE_LEVEL", "WARN"))
2019
log_console_level = logging.getLevelName(
2120
os.getenv("LOG_CONSOLE_LEVEL", "ERROR"))
2221

22+
# Set the logger filter to the minimum (more chatty) of the two handler levels
23+
# This reduces problems if the environment adds a root handler (e.g. Google Colab)
24+
logger_level = min(log_file_level, log_console_level)
25+
if any(log_control in os.environ
26+
for log_control in ["LOG_CONSOLE_LEVEL", "LOG_FILE_LEVEL"]):
27+
logger.setLevel(logger_level)
28+
2329
# define file handler and set formatter
2430
error_file_name = "error.${now}.log"
2531

aperturedb/queryMessage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# queryMessage.py - wraps protobuf versions
2+
import google.protobuf
3+
4+
if google.protobuf.__version__.split(".")[0] == "3":
5+
from . import queryMessage3_pb2
6+
7+
def queryMessage():
8+
return queryMessage3_pb2.queryMessage()
9+
10+
def ParseFromString(msg, data):
11+
return msg.ParseFromString(data)
12+
elif google.protobuf.__version__.split(".")[0] == "4":
13+
from . import queryMessage4_pb2
14+
15+
def queryMessage():
16+
return queryMessage4_pb2.queryMessage()
17+
18+
def ParseFromString(msg, data):
19+
# because of https://github.com/protocolbuffers/protobuf/issues/10774
20+
return msg.ParseFromString(memoryview(data).tobytes())
21+
else:
22+
raise Exception(
23+
f"aperturedb not compatible with {google.protobuf.__version__}")

aperturedb/queryMessage_pb2.py renamed to aperturedb/queryMessage3_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aperturedb/queryMessage4_pb2.py

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.protobuf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ApertureDB python library supports version 3 and 4 of protobuf.
2+
3+
These are incompatable implementations in that the proto file that protoc
4+
compiles into python code will not work between versions.
5+
6+
To solve this we have added a thin wrapper which selects the backend
7+
implementation based on the system installed version.
8+
9+
This is done because customers use packages alongside aperturedb which require
10+
python protobuf packages from both the 3.x line and the 4.x line.
11+
12+
To regenerate the files, simply take the queryMessage.proto file, and make
13+
copies which append the version at the end, then use the matching protoc to
14+
compile them. Finally place them in this repo.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ authors = [
1616
dependencies = [
1717
# Pin to the bridge version.
1818
# https://github.com/tensorflow/tensorflow/issues/60320
19-
'protobuf==3.20.3',
19+
'protobuf >=3.20.3,<5.0.0',
2020
#Folllowing is needed parallel loaders, and basic things for
2121
# making the notebooks.
2222
'scikit-image', 'image', 'requests', 'boto3',
23-
'numpy<2', 'matplotlib', 'pandas', 'kaggle', 'google-cloud-storage',
23+
# https://github.com/Kaggle/kaggle-api/issues/611
24+
'numpy<2', 'matplotlib', 'pandas', 'kaggle!=1.6.15', 'google-cloud-storage',
2425
'ipython', 'dask[complete]', 'ipywidgets', 'pydantic', 'devtools', 'typer[all]',
2526
"opencv-python-headless",
2627
# Pinning this to be able to install google-cloud-bigquery

0 commit comments

Comments
 (0)