Unrecognized method, property, or field for generated protobuf message

Hi all,
We have a project where we communicate with a device using gRPC. On the computer, we run Python in a virtual enviornment. We load that environment in matlab using pyenv. We use MATLAB 2023b (23.2.0.2599560 (R2023b) Update 8) and Python 3.10.11.
Connecting with the device and querying some device information works in both, Python and MATLAB. However, since 2-3 months, we are unable to access members of protobuf messages. Below is an example of the code we execute in Python and the equivalent code executed in MATLAB:
Python:
% C:\work\data\kingfisher-py\.venv\Scripts\python.exe "..."
import kingfisher_py.lib as kgfLib
scn = kgfLib.device.Scanner('10.10.1.1', '8081')
device_info = scn.device_info.get_info()
device_info.sw_rev
items {
key: "mcu"
value: "v1.0.1"
}
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
items {
key: "kingfisher"
value: "5.2.0-cam-cal-third-party-rc.1-5-gd6f7161"
}
% response continues...
MATLAB:
>> kgfLib = py.importlib.import_module('kingfisher_py.lib');
>> scn = kgfLib.device.Scanner('10.10.1.1', '8081');
>> deviceInfo = scn.device_info.get_info();
>> deviceInfo.HasField('sw_rev')
ans =
logical
1
>> deviceInfo.sw_rev
Unrecognized method, property, or field 'sw_rev' for class 'py.kf.api.messages.system_pb2.GetDeviceInfoResponse'.
>> deviceInfo
deviceInfo =
Python GetDeviceInfoResponse with properties:
DESCRIPTOR: [1×1 py.google._upb._message.Descriptor]
manufact_rev {
device_name: "BLK360-2060047"
serial_number: "2060047"
}
sw_rev {
items {
key: "mcu"
value: "v1.0.1"
}
items {
key: "kingfisher"
value: "5.2.0-cam-cal-third-party-rc.1-5-gd6f7161"
}
% response continues...
Note that the same virtual environment is active. MATLAB even says that the field sw_rev exists, but still cannot access it. Also, we checked different versions and combinations of MATLAB and Python. Specifically:
  • Matlab 9.10.0.2198249 (R2021a) Update 8 + Python 3.8.10
  • Matlab 9.13.0.2193358 (R2022b) Update 5 + Python 3.8.10
  • Matlab 9.13.0.2193358 (R2022b) Update 5 + Python 3.10.11
  • Matlab 23.2.0.2599560 (R2023b) Update 8 + Python 3.10.11
The behaviour is the same with all versions. As the whole communication with the device is set up using protobuf, there is not much we can do with the device at this point as we run into this problem all accorss our MATLAB code base.
Is this a known issue, e.g. with a newer protobuf version? As mentioned, we did not have any issues like this until 2-3 months ago.
Hope to get some help or at least an explanation. Thank you :-)

댓글 수: 1

Joel Buesser
Joel Buesser 2024년 8월 12일
편집: Joel Buesser 2024년 8월 12일
Update: It is dependent on the protobuf version.
  • protobuf 3.20.1 works
  • protobuf 4.25.2 doesn't work
  • protobuf 5.27.1 doens't work

댓글을 달려면 로그인하십시오.

 채택된 답변

Joel Buesser
Joel Buesser 2024년 8월 12일

1 개 추천

I reached out to Customer Support (thank you for the quick assistance!).
It is a bug that for some new versions of libraries, properties/methods cannot be called anymore using library.method although the method is found when searched for.
As a workaround, I downgraded to protobuf 3.20.1 in my case. Alternatively, the property above could be accessed using py.getattr(deviceInfo, 'sw_rev').

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

릴리스

R2023b

질문:

2024년 8월 12일

답변:

2024년 8월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by