Task error in custom recipe for image labelling


I am trying to implement a custom image annotation recipe which is not going well. The recipe.py file has the following code:

# AUTOGENERATED! DO NOT EDIT! File to edit: recipe.ipynb.

# %% auto 0
__all__ = ['data_review_recipe']

# %% recipe.ipynb 1
import prodigy
from prodigy.components.loaders import Images

# %% recipe.ipynb 3
def data_review_recipe(dataset, images_path):    

    stream = Images(images_path),
    return {
        "view_id": "image",
        "dataset": dataset,
		"stream": stream,

I use the following command at the terminal to start the server:

prodigy data-review-recipe datareview ../train_images/clip_000000 -F recipe.py

The server starts fine without errors as shown in the image below:
Screenshot from 2022-08-15 14-20-19

But when I use the URL in the browser, I get the following error in the interface:
Screenshot from 2022-08-15 13-38-47

The error log shows the following error, complaining about generator has no get attribute:

Task exception was never retrieved
future: <Task finished name='Task-22' coro=<RequestResponseCycle.run_asgi() done, defined at /home/bilal/mambaforge/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py:394> exception=AttributeError("'generator' object has no attribute 'get'")>
Traceback (most recent call last):
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 399, in run_asgi
    self.logger.error(msg, exc_info=exc)
  File "/home/bilal/mambaforge/lib/python3.9/logging/__init__.py", line 1475, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/home/bilal/mambaforge/lib/python3.9/logging/__init__.py", line 1589, in _log
  File "/home/bilal/mambaforge/lib/python3.9/logging/__init__.py", line 1598, in handle
    if (not self.disabled) and self.filter(record):
  File "/home/bilal/mambaforge/lib/python3.9/logging/__init__.py", line 806, in filter
    result = f.filter(record)
  File "cython_src/prodigy/util.pyx", line 145, in prodigy.util.ServerErrorFilter.filter
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/fastapi/applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/cors.py", line 86, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/cors.py", line 142, in simple_response
    await self.app(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/base.py", line 25, in __call__
    response = await self.dispatch_func(request, self.call_next)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/prodigy/app.py", line 205, in reset_db_middleware
    response = await call_next(request)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/base.py", line 45, in call_next
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/middleware/base.py", line 38, in coro
    await self.app(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/routing.py", line 580, in __call__
    await route.handle(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/routing.py", line 241, in handle
    await self.app(scope, receive, send)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/routing.py", line 52, in app
    response = await func(request)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/fastapi/routing.py", line 226, in app
    raw_response = await run_endpoint_function(
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/home/bilal/mambaforge/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/prodigy/app.py", line 434, in get_session_questions
    return _shared_get_questions(req.session_id, excludes=req.excludes)
  File "/home/bilal/mambaforge/lib/python3.9/site-packages/prodigy/app.py", line 399, in _shared_get_questions
    tasks = controller.get_questions(session_id=session_id, excludes=excludes)
  File "cython_src/prodigy/core.pyx", line 221, in prodigy.core.Controller.get_questions
  File "cython_src/prodigy/core.pyx", line 222, in prodigy.core.Controller.get_questions
  File "cython_src/prodigy/components/feeds.pyx", line 379, in prodigy.components.feeds.Feed.get_batch
  File "cython_src/prodigy/components/feeds.pyx", line 323, in prodigy.components.feeds.Feed._enqueue_tasks
  File "cython_src/prodigy/components/stream.pyx", line 170, in prodigy.components.stream.Stream.__next__
  File "cython_src/prodigy/components/stream.pyx", line 174, in prodigy.components.stream.Stream.__next__
  File "cython_src/prodigy/components/filters.pyx", line 93, in filter_tasks
AttributeError: 'generator' object has no attribute 'get'

Any idea what am I doing wrong? I check the data of images at the folder which is there but somehow it is not getting read.

Any guidance will be much appreciated.

Many thanks and

Kind regards,

Hi @Bilal,
thank you for your question.
I was able to reproduce the error using the recipe you provided. It seems that you have inserted a comma after Images(images_path). If you delete this comma, the error should be fixed and the recipe should work as expected.

I hope this small fix solves your problem. Please let me know if you encounter any further issues.

Hi @Jette16, this is a very naive mistake. My bad. I should have reviewed it properly. I expect Prodigy should raise meaningful errors for such mistakes. The error log was not useful at all. But anyway, thanks for picking this up. This has been fixed now.