Call to progress() missing session and total arguments

In my custom recipe, I have implemented a progress function as described in the PRODIGY_README.html with the arguments session and total.

However, these arguments are not actually passed in by Prodigy it seems:

Task exception was never retrieved
future: <Task finished coro=<RequestResponseCycle.run_asgi() done, defined at /usr/local/miniconda3/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py:383> exception=TypeError("progress() missing 2 required positional arguments: 'session' and 'total'")>
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 388, in run_asgi
    self.logger.error(msg, exc_info=exc)
File "/usr/local/miniconda3/lib/python3.7/logging/__init__.py", line 1412, in error
    self._log(ERROR, msg, args, **kwargs)
File "/usr/local/miniconda3/lib/python3.7/logging/__init__.py", line 1519, in _log
    self.handle(record)
File "/usr/local/miniconda3/lib/python3.7/logging/__init__.py", line 1528, in handle
    if (not self.disabled) and self.filter(record):
File "/usr/local/miniconda3/lib/python3.7/logging/__init__.py", line 762, in filter
    result = f.filter(record)
File "cython_src/prodigy/util.pyx", line 120, in prodigy.util.ServerErrorFilter.filter
File "/usr/local/miniconda3/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 385, in run_asgi
    result = await app(self.scope, self.receive, self.send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/fastapi/applications.py", line 140, in __call__
    await super().__call__(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/applications.py", line 134, in __call__
    await self.error_middleware(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/middleware/errors.py", line 178, in __call__
    raise exc from None
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/middleware/errors.py", line 156, in __call__
    await self.app(scope, receive, _send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/middleware/cors.py", line 84, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/middleware/cors.py", line 140, in simple_response
    await self.app(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/exceptions.py", line 73, in __call__
    raise exc from None
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/exceptions.py", line 62, in __call__
    await self.app(scope, receive, sender)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/routing.py", line 590, in __call__
    await route(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/routing.py", line 208, in __call__
    await self.app(scope, receive, send)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
File "/usr/local/miniconda3/lib/python3.7/site-packages/fastapi/routing.py", line 129, in app
    raw_response = await run_in_threadpool(dependant.call, **values)
File "/usr/local/miniconda3/lib/python3.7/site-packages/starlette/concurrency.py", line 25, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
File "/usr/local/miniconda3/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
File "/usr/local/miniconda3/lib/python3.7/site-packages/prodigy/app.py", line 418, in give_answers
    controller.receive_answers(answers, session_id=session_id)
File "cython_src/prodigy/core.pyx", line 147, in prodigy.core.Controller.receive_answers
TypeError: progress() missing 2 required positional arguments: 'session' and 'total'

Instead, there was an unexpected keyword argument loss?

I'm using Prodigy 1.9.0.

Sorry if this is a bit confusing at the moment – it's mostly because we need to preserve backwards compatibility.

If your recipe provides an update callback, the progress function receives the return value of that callback as the loss keyword argument. This is typically used in active learning recipes where you'd calculate the progress based on the loss. Otherwise, it receives the session and total values. I've also updated this in the docs to make it a bit more clear.

Btw, the PRODIGY_README.html is deprecated as of v1.9 and the latest state of the API docs is now available on the website: Prodigy 101 – everything you need to know · Prodigy · An annotation tool for AI, Machine Learning & NLP

I see, that’s unfortunate. I do provide the update function but want a custom progress based on counts not loss :frowning: Why not include the counts alongside loss as arguments in that case?

On a side note, the new documentation looks great but I find it very hard to find what I need in there. It is definitely lacking a search functionality. The good thing about the old readme was that it was all on one page, so you could easily find things using the browser’s built-in search.

It's not super elegant but you could just fetch the total number of examples when the recipe starts and then keep your own counts in update.

I guess it's a reasonable enough change that'd justify a backwards incompatibility. It's not the most common use case anyways and maybe we could use inspect to check that the progress function accepts the right arguments :thinking:

IF we change it anyways, I'd want to make it take the controller instance and maybe a more generic update_return_value (needs better naming) argument. The controller gives you the counts, but also various other stuff if you need it. And the update_return_value would default to None.

Ah, yes, I've been meaning to add Algolia DocSearch!

Also, if it's not too tricky to do, I want to try compiling a minimalist single-page version of the docs, basically in the same style as the previous readme. Then people could also save that for offline use etc.

1 Like