# prodigy v1.8 start the web app from Python for recipe textcat.manual

**URL:** <https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178>\
**Category:** Uncategorized\
**Tags:** usage, textcat, solved\
**Created:** [April 27, 2021, 11:35am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178 "2021-04-27T11:35:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikrant06](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vikrant06](https://support.prodi.gy/u/vikrant06)\
**Post date:** [April 27, 2021, 11:35am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/1 "2021-04-27T11:35:34Z")

</div>

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'

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [April 27, 2021, 8:41pm UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/2 "2021-04-27T20:41:16Z")

</div>

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

```python
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?

---

<div class="post-metadata">

**Author:** ![vikrant06](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vikrant06](https://support.prodi.gy/u/vikrant06)\
**Post date:** [April 28, 2021, 6:24am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/3 "2021-04-28T06:24:37Z")

</div>

Thanks this worked.

---

<div class="post-metadata">

**Author:** ![vikrant06](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vikrant06](https://support.prodi.gy/u/vikrant06)\
**Post date:** [May 10, 2021, 7:01am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/4 "2021-05-10T07:01:24Z")

</div>

@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)
```

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [May 10, 2021, 10:01am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/5 "2021-05-10T10:01:19Z")

</div>

Hm, that looks correct to me at first sight, for 1.9.9. Could you paste the error you're getting?

---

<div class="post-metadata">

**Author:** ![vikrant06](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vikrant06](https://support.prodi.gy/u/vikrant06)\
**Post date:** [May 11, 2021, 9:13am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/6 "2021-05-11T09:13:39Z")

</div>

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()
```

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [May 11, 2021, 9:25am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/7 "2021-05-11T09:25:17Z")

</div>

Thanks. Could you try again with

```python
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)

---

<div class="post-metadata">

**Author:** ![vikrant06](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vikrant06](https://support.prodi.gy/u/vikrant06)\
**Post date:** [May 12, 2021, 7:50am UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/8 "2021-05-12T07:50:57Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [May 13, 2021, 1:00pm UTC](https://support.prodi.gy/t/prodigy-v1-8-start-the-web-app-from-python-for-recipe-textcat-manual/4178/9 "2021-05-13T13:00:16Z")

</div>

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?
