Skip to content

Conversation

@zymap
Copy link
Member

@zymap zymap commented May 30, 2022

Motivation

The CPP ci test always failed by the python function tests

ERROR: test_python_instance (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_python_instance
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/pulsar/pulsar-functions/instance/target/python-instance/tests/test_python_instance.py", line 28, in <module>
    from python_instance import InstanceConfig
  File "/pulsar/pulsar-functions/instance/target/python-instance/python_instance.py", line 37, in <module>
    import Function_pb2
  File "/pulsar/pulsar-functions/instance/target/python-instance/Function_pb2.py", line 51, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.8/dist-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Modification

Regenerate the proto file for the python instance

…nction

---

**Motivation**

The CPP ci test always failed by the python function tests

```
ERROR: test_python_instance (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_python_instance
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/pulsar/pulsar-functions/instance/target/python-instance/tests/test_python_instance.py", line 28, in <module>
    from python_instance import InstanceConfig
  File "/pulsar/pulsar-functions/instance/target/python-instance/python_instance.py", line 37, in <module>
    import Function_pb2
  File "/pulsar/pulsar-functions/instance/target/python-instance/Function_pb2.py", line 51, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.8/dist-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
```

**Modification**

Regenerate the proto file for python instance
@zymap zymap added area/test area/function doc-not-needed Your PR changes do not impact docs area/ci labels May 30, 2022
@zymap zymap self-assigned this May 30, 2022
@zymap zymap changed the title [fix][python-function] Fix the failed CPP test CI caused by python fu… [fix][python-function] Fix the failed CPP test CI caused by python function May 30, 2022
@zymap
Copy link
Member Author

zymap commented May 30, 2022

Looks like that because we upgraded the python version in this PR

@zymap
Copy link
Member Author

zymap commented May 30, 2022

Something wrong with bookkeeper client:

======================================================================
ERROR: test_python_instance (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_python_instance
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/pulsar/pulsar-functions/instance/target/python-instance/tests/test_python_instance.py", line 28, in <module>
    from python_instance import InstanceConfig
  File "/pulsar/pulsar-functions/instance/target/python-instance/python_instance.py", line 43, in <module>
    import state_context
  File "/pulsar/pulsar-functions/instance/target/python-instance/state_context.py", line 25, in <module>
    from bookkeeper import admin, kv
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/admin/__init__.py", line 15, in <module>
    from bookkeeper.admin.client import Client
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/admin/client.py", line 20, in <module>
    from bookkeeper import types
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/types.py", line 22, in <module>
    from bookkeeper.proto import common_pb2
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/proto/common_pb2.py", line 35, in <module>
    _descriptor.FieldDescriptor(
  File "/usr/local/lib/python3.8/dist-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

@lhotari
Copy link
Member

lhotari commented May 30, 2022

Protobuf was upgraded in #15344 . Is protobuf 3.20.0 compatible with the bookkeeper python client?

@zymap
Copy link
Member Author

zymap commented May 30, 2022

If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.

@lhotari But we need to upgrade the bookkeeper Protobuf to the 3.19.0+ then regenerate the code?

@lhotari
Copy link
Member

lhotari commented May 30, 2022

If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.

@lhotari But we need to upgrade the bookkeeper Protobuf to the 3.19.0+ then regenerate the code?

@zymap I guess so, but that would first require the change in Bookkeeper. I wonder if it would be able to downgrade Protobuf on Pulsar side so that we wouldn't have to depend on a Bookkeeper upgrade.

@zymap
Copy link
Member Author

zymap commented May 31, 2022

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

@lhotari I used this workaround, and the python function tests passed 23cd61b

And downgrade Protobuf doesn't work, and I have tested it here zymap#37.

@zymap
Copy link
Member Author

zymap commented May 31, 2022

CPP flaky test:

FAILED TESTS (3/295):
     637 ms: ./main AuthPluginTest.testAthenz (try #1)
     514 ms: ./main AuthPluginTest.testAuthFactoryAthenz (try #1)
     331 ms: ./main AuthPluginTest.testAuthFactoryAthenz (try #2)

@zymap
Copy link
Member Author

zymap commented May 31, 2022

The function tests failed by the same reason:

2022-05-31T03:31:15,772+0000 [function-timer-thread-82-1] INFO  org.apache.pulsar.functions.runtime.process.ProcessRuntime - Started process successfully
Traceback (most recent call last):
  File "/pulsar/instances/python-instance/python_instance_main.py", line 41, in <module>
    import python_instance
  File "/pulsar/instances/python-instance/python_instance.py", line 43, in <module>
    import state_context
  File "/pulsar/instances/python-instance/state_context.py", line 25, in <module>
    from bookkeeper import admin, kv
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/admin/__init__.py", line 15, in <module>
    from bookkeeper.admin.client import Client
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/admin/client.py", line 20, in <module>
    from bookkeeper import types
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/types.py", line 22, in <module>
    from bookkeeper.proto import common_pb2
  File "/usr/local/lib/python3.8/dist-packages/bookkeeper/proto/common_pb2.py", line 35, in <module>
    _descriptor.FieldDescriptor(
  File "/usr/local/lib/python3.8/dist-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.

(cherry picked from commit 437388a)
Comment on lines +60 to +61
// skip this tests and fix it later
// @Test(groups = {"python_state", "state", "function", "python_function"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also required with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The function tests using python runtime will meet the same exception. I added the variable in the docker, and I will revert this change.

@lhotari
Copy link
Member

lhotari commented May 31, 2022

And downgrade Protobuf doesn't work, and I have tested it here zymap#37.

@zymap I wonder if downgrading would have required installing a fixed version of the protobuf package with pip?
@cbornet used pip3 install protobuf==3.20.1 --user in #15846

@lhotari
Copy link
Member

lhotari commented May 31, 2022

@zymap FYI , #15846 (comment) . The PR will fix the dependencies in the Pulsar's Python client so that Protobuf package version is limited to 3.20.* .

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Jul 1, 2022
@zymap zymap closed this Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants