vikrant06
(vikrant )
April 27, 2021, 11:35am
1
I used this code to run the app from python but it giving me errors:
prodigy.serve("textcat.manual",
"esg_tagged_test",
"en_core_web_lg",
"./ESG_classifications_analystA.jsonl",
None,
["ESG", "Not_ESG", "Confused"],
True,
None,
port=9000)
it's giving the following error:
\lib\site-packages\prodigy\recipes\textcat.py in manual(dataset, spacy_model, source, api, loader, label, exclusive, exclude)
127 log("RECIPE: Loaded model {}".format(spacy_model))
128 labels = label
--> 129 has_options = len(labels) > 1
130 log("RECIPE: Annotating with {} labels".format(len(labels)), labels)
131 stream = get_stream(
TypeError: object of type 'bool' has no len()
Can anyone tell me what's the correct syntax. I am using prodigy v'1.8.3'
SofieVL
(Sofie)
April 27, 2021, 8:41pm
2
Hi!
If I match the arguments to the textcat.manual
method, it looks like you've forgotten the argument for api
or for loader
. Right now, True
is being parsed as the argument for label
(instead of your intended list) so this seems to be where the error comes from.
Does it work if you call
prodigy.serve("textcat.manual",
"esg_tagged_test",
"en_core_web_lg",
"./ESG_classifications_analystA.jsonl",
None,
None,
["ESG", "Not_ESG", "Confused"],
True,
None,
port=9000)
instead?
2 Likes
@SofieVL . Recently my organization has upgraded to version 1.9.9. Can you please tell me the syntax for this version. I tried the below mentioned snippet but it didn't work.
prodigy.serve("textcat.manual",
"esg_tagged_test",
"./ESG_classifications_analystA.jsonl",
None,
None,
["ESG", "Not_ESG", "Confused"],
True,
None,
port=9000)
SofieVL
(Sofie)
May 10, 2021, 10:01am
5
Hm, that looks correct to me at first sight, for 1.9.9. Could you paste the error you're getting?
here is the error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-60f300f246d3> in <module>
18 True,
19 None,
---> 20 port=port, show_stats = True)
c:\users\45131968\scratchpad\.venv\lib\site-packages\prodigy\__init__.py in serve(command, *recipe_args, **config)
42 if not loaded_recipe:
43 msg.fail(f"Can't find recipe '{recipe_name}'", exits=1)
---> 44 controller = loaded_recipe(*recipe_args)
45 controller.config.update(config)
46 server(controller, controller.config)
cython_src\prodigy\core.pyx in prodigy.core.recipe.recipe_decorator.recipe_proxy()
c:\users\45131968\scratchpad\.venv\lib\site-packages\prodigy\recipes\textcat.py in manual(dataset, source, _, api, loader, label, exclusive, exclude)
134 if not labels:
135 msg.fail("textcat.manual requires at least one --label", exits=1)
--> 136 has_options = len(labels) > 1
137 log(f"RECIPE: Annotating with {len(labels)} labels", labels)
138 stream = get_stream(source, api, loader, rehash=True, dedup=True, input_key="text")
TypeError: object of type 'bool' has no len()
SofieVL
(Sofie)
May 11, 2021, 9:25am
7
Thanks. Could you try again with
prodigy.serve("textcat.manual",
"esg_tagged_test",
"./ESG_classifications_analystA.jsonl",
None,
None,
None,
["ESG", "Not_ESG", "Confused"],
True,
None,
port=9000)
(i.e. one more None
to fill the place for the deprecated variable _
in the function call)
@SofieVL Thanks it worked but with a bug. When I run the above lines of code, the app starts on the given port but with an error.
Starting the web server at http://localhost:9002 ...
Open the app in your browser and start annotating!
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-7d901ce6f128> in <module>
19 True,
20 None,
---> 21 port=port)
22
c:\users\45131968\scratchpad\.venv\lib\site-packages\prodigy\__init__.py in serve(command, *recipe_args, **config)
44 controller = loaded_recipe(*recipe_args)
45 controller.config.update(config)
---> 46 server(controller, controller.config)
c:\users\45131968\scratchpad\.venv\lib\site-packages\prodigy\app.py in server(controller, config)
510 port=int(port),
511 log_level=get_log_level(),
--> 512 log_config=_uvicorn_log_config,
513 )
514 controller.save()
c:\users\45131968\scratchpad\.venv\lib\site-packages\uvicorn\main.py in run(app, **kwargs)
352 supervisor.run()
353 else:
--> 354 server.run()
355
356
c:\users\45131968\scratchpad\.venv\lib\site-packages\uvicorn\main.py in run(self, sockets)
380 self.config.setup_event_loop()
381 loop = asyncio.get_event_loop()
--> 382 loop.run_until_complete(self.serve(sockets=sockets))
383
384 async def serve(self, sockets=None):
C:\ProgramData\Anaconda3\lib\asyncio\base_events.py in run_until_complete(self, future)
452 future.add_done_callback(_run_until_complete_cb)
453 try:
--> 454 self.run_forever()
455 except:
456 if new_task and future.done() and not future.cancelled():
C:\ProgramData\Anaconda3\lib\asyncio\base_events.py in run_forever(self)
406 self._check_closed()
407 if self.is_running():
--> 408 raise RuntimeError('This event loop is already running')
409 if events._get_running_loop() is not None:
410 raise RuntimeError(
RuntimeError: This event loop is already running
I checked the port, no event was running on it prior to running the above script.
SofieVL
(Sofie)
May 13, 2021, 1:00pm
9
Hm, I'm not really sure what that last error means, especially if you say you checked the port.
Are you able to reboot and/or try again in a fresh environment? Perhaps you've ended up in some inconsistent state after upgrading?
1 Like