Error when running Prodigy 1.9.1 ner.manual with --patterns argument

Script: prodigy ner.manual SENSITIVE en_core_web_lg notes.jsonl --label Drug --patterns .\tmp\patterns_drugs-DRUG.jsonl

Server crashes.

Top of error log: Task exception was never retrieved
*future: <Task finished coro=<RequestResponseCycle.run_asgi() done, defined at C:\Users\RonT\AppData*
Local\Programs\Python\Python37\lib\site-packages\uvicorn\protocols\http\h11_impl.py:383> exception=K
eyError('meta')>

Last lines of error log: File "C:\Users\RonT\AppData\Local\Programs\Python\Python37\lib\site-packages\prodigy\recipes\ner.p
y", line 154, in
** stream = (eg for _, eg in pattern_matcher(stream))**
** File "cython_src\prodigy\models\matcher.pyx", line 200, in call**
KeyError: 'meta'

Patterns file is from prodigy-recipes/example-patterns/ patterns_drugs-DRUG.jsonl

Server launches properly WITHOUT the --patterns argument.

Happy to supply more data as you request. Hope you find it to be my cockpit error.

Thank you.

Thanks for the report – and sorry about that! The pattern matcher writes the matched pattern info to the task's "meta" so it's displayed in the bottom right corner of the annotation part. And it didn't correctly make sure the dict is created if it doesn't exist. I've already fixed this internally and we'll push another patch release with the fix.

In the meantime, the easiest workaround would be to add "meta": {} to each example:

import srsly
examples = srsly.read_jsonl("./notes.jsonl")
for eg in examples:
    eg["meta"] = {}
srsly.write_jsonl("./notes_updated.jsonl")

Edit: Just released v1.9.2, which fixes the underlying problem :slightly_smiling_face:

Thank you kindly, Ines! 1.92 Installed in a few seconds. new.manual . . . --patterns now works per the new docs.

1 Like