robinhood / faust

Python Stream Processing
Other
6.75k stars 534 forks source link

Faust not working with Python 3.7 #277

Closed arel closed 5 years ago

arel commented 5 years ago

Checklist

Steps to reproduce

Using the sample code from the docs:

import faust

class Greeting(faust.Record):
    from_name: str
    to_name: str

app = faust.App('hello-app', broker='kafka://localhost')
topic = app.topic('hello-topic', value_type=Greeting)

@app.agent(topic)
async def hello(greetings):
    async for greeting in greetings:
        print(f'Hello from {greeting.from_name} to {greeting.to_name}')

@app.timer(interval=1.0)
async def example_sender(app):
    await hello.send(
        value=Greeting(from_name='Faust', to_name='you'),
    )

if __name__ == '__main__':
    app.main()

In new virtualenv with Python 3.7:

pip install faust
python greeting.py worker -l info

Causes exception:

  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/transport/drivers/aiokafka.py", line 61, in <module>
    'Please install robinhood-aiokafka, not aiokafka')
RuntimeError: Please install robinhood-aiokafka, not aiokafka

But, robinhood-aiokafka is installed:

pip freeze | grep kafka
robinhood-aiokafka==0.5.0
robinhood-kafka-python==1.4.3

Expected behavior

I would expect faust to work with Python 3.6+ (as stated in the docs).

Actual behavior

Faust does not start up. (It does work as expected with Python 3.6)

Full traceback

  File "greeting.py", line 22, in <module>
    app.main()
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/app/base.py", line 650, in main
    cli(app=self)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/cli/base.py", line 463, in _inner
    return cmd()
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/cli/base.py", line 538, in __call__
    self.run_using_worker(*args, **kwargs)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/cli/base.py", line 546, in run_using_worker
    self.on_worker_created(worker)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/cli/worker.py", line 53, in on_worker_created
    self.say(self.banner(worker))
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/cli/worker.py", line 106, in banner
    transport_v=app.transport.driver_version,
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/app/base.py", line 1450, in transport
    self._transport = self._new_transport()
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/app/base.py", line 1321, in _new_transport
    return transport.by_url(self.conf.broker[0])(
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/mode/utils/imports.py", line 97, in by_url
    return self.by_name(URL(url).scheme)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/mode/utils/imports.py", line 102, in by_name
    return symbol_by_name(name, aliases=self.aliases)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/mode/utils/imports.py", line 202, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ubuntu/.local/share/virtualenvs/c-eMGTbQpQ/lib/python3.7/site-packages/faust/transport/drivers/aiokafka.py", line 61, in <module>
    'Please install robinhood-aiokafka, not aiokafka')
RuntimeError: Please install robinhood-aiokafka, not aiokafka

Versions

etos commented 5 years ago

Experiencing the same:

Looks as though the problematic code was removed a day ago in https://github.com/robinhood/faust/commit/d9d77ebaa7dad123951537b04cef568374612d23 by @ask however it appears we require a new GH Release (v1.4.3 ?) and pushing to PyPi :)

brobusta commented 5 years ago

It seems that they have pushed the wrong version to PyPi, I tried to use an old version of faust (1.4.1) but the error still existed.

ask commented 5 years ago

Thanks!

I uploaded robinhood-aiokafka 0.5.1 to PyPI that fixes this issue!

Seems our version requirement for robinhood-aiokafka was <1.0, but please be advised that the version we currently use in production is robinhood-aiokafka 0.4.19

ask commented 5 years ago

I just released Faust 1.4.3 to PyPI: this version will require robinhood-aiokafka<0.5.0