If I install MedCAT 1.0.40, I get the error below when calling the MedCAT Service. This error is fixed by installing medcat-1.0.39.
Error:
ValueError: [E966] `nlp.add_pipe` now takes the string name of the registered component factory, not a callable component. Expected string, but got functools.partial(<function tag_skip_and_punct at 0x7ff0b0e12cb0>, config=<medcat.config.Config object at 0x7ff16c125350>) (name: 'tag_skip_and_punct').
- If you created your component with `nlp.create_pipe('name')`: remove nlp.create_pipe and call `nlp.add_pipe('name')` instead.
- If you passed in a component like `TextCategorizer()`: call `nlp.add_pipe` with the string name instead, e.g. `nlp.add_pipe('textcat')`.
- If you're using a custom component: Add the decorator `@Language.component` (for function components) or `@Language.factory` (for class components / factories) to your custom component and assign it a name, e.g. `@Language.component('your_name')`. You can then run `nlp.add_pipe('your_name')` to add it to the pipeline.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
medcat 1.0.40 requires spacy==2.3.4, but you have spacy 3.0.7 which is incompatible.
Successfully installed catalogue-2.0.6 en-core-sci-md-0.4.0 pathy-0.6.0 pydantic-1.8.2 spacy-3.0.7 spacy-legacy-3.0.8 srsly-2.4.1 thinc-8.0.8 typer-0.3.2
. start-service-prod.sh curl -XPOST http://localhost:5000/api/process -H 'Content-Type: application/json' -d '{"content":{"text":"The patient was diagnosed with leukemia."}}’
Receive the following error:
[2021-08-25 21:41:19,751] [ERROR] medcat_service.app.app: Exception on /api/process [POST]
Traceback (most recent call last):
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/__init__.py", line 804, in get
return self._context[key]
KeyError: <class 'medcat_service.nlp_service.nlp_service.NlpService'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 804, in get
return self._context[key]
KeyError: <class 'medcat_service.nlp_processor.medcat_processor.MedCatProcessor'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask_injector/init.py", line 95, in wrapper
return injector.call_with_injection(callable=fun, args=args, kwargs=kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1024, in call_with_injection
ownerkey=self.class if self_ is not None else callable.module,
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper
return function(*args, kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1069, in args_to_inject
instance = self.get(interface) # type: Any
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 963, in get
result = scope_instance.get(interface, binding.provider).get(self)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper
return function(*args, *kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 806, in get
provider = InstanceProvider(provider.get(self.injector))
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 291, in get
return injector.create_object(self._cls)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 990, in create_object
self.call_withinjection(cls.init, self=instance, kwargs=additional_kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1024, in call_with_injection
ownerkey=self.class if self_ is not None else callable.module,
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper
return function(args, kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1069, in args_to_inject
instance = self.get(interface) # type: Any
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 963, in get
result = scope_instance.get(interface, binding.provider).get(self)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper
return function(*args, *kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 806, in get
provider = InstanceProvider(provider.get(self.injector))
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 291, in get
return injector.create_object(self._cls)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 990, in create_object
self.call_withinjection(cls.init, self=instance, kwargs=additional_kwargs)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1030, in call_with_injection
return callable(full_args, **dependencies)
File "/home/elisa/MedCATservice/medcat_service/nlp_processor/medcat_processor.py", line 63, in init
self.cat = self._create_cat()
File "/home/elisa/MedCATservice/medcat_service/nlp_processor/medcat_processor.py", line 234, in _create_cat
return CAT(cdb=cdb, config=conf, vocab=vocab, meta_cats=meta_models)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/medcat/cat.py", line 75, in init
additional_fields=['is_punct'])
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/medcat/pipe.py", line 38, in add_tagger
self.nlp.addpipe(tagger, name='tag' + name, first=True)
File "/opt/conda/envs/medcat/lib/python3.7/site-packages/spacy/language.py", line 755, in add_pipe
raise ValueError(err)
ValueError: [E966] nlp.add_pipe now takes the string name of the registered component factory, not a callable component. Expected string, but got functools.partial(<function tag_skip_and_punct at 0x7ff0b0e12cb0>, config=<medcat.config.Config object at 0x7ff16c125350>) (name: 'tag_skip_and_punct').
If you created your component with nlp.create_pipe('name'): remove nlp.create_pipe and call nlp.add_pipe('name') instead.
If you passed in a component like TextCategorizer(): call nlp.add_pipe with the string name instead, e.g. nlp.add_pipe('textcat').
If you're using a custom component: Add the decorator @Language.component (for function components) or @Language.factory (for class components / factories) to your custom component and assign it a name, e.g. @Language.component('your_name'). You can then run nlp.add_pipe('your_name') to add it to the pipeline.
[25/Aug/2021:21:41:19 +0000] [ACCESSS] 127.0.0.1 "POST /api/process HTTP/1.1" 500 "-" "curl/7.52.1"
If I install MedCAT 1.0.40, I get the error below when calling the MedCAT Service. This error is fixed by installing medcat-1.0.39.
Error:
Steps to reproduce:
pip install -r medcat_service/requirements.txt
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_core_sci_md-0.4.0.tar.gz
Which generates dependency error at bottom:
. start-service-prod.sh
curl -XPOST http://localhost:5000/api/process -H 'Content-Type: application/json' -d '{"content":{"text":"The patient was diagnosed with leukemia."}}’
Receive the following error:
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 804, in get return self._context[key] KeyError: <class 'medcat_service.nlp_processor.medcat_processor.MedCatProcessor'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/opt/conda/envs/medcat/lib/python3.7/site-packages/flask_injector/init.py", line 95, in wrapper return injector.call_with_injection(callable=fun, args=args, kwargs=kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1024, in call_with_injection ownerkey=self.class if self_ is not None else callable.module, File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper return function(*args, kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1069, in args_to_inject instance = self.get(interface) # type: Any File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 963, in get result = scope_instance.get(interface, binding.provider).get(self) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper return function(*args, *kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 806, in get provider = InstanceProvider(provider.get(self.injector)) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 291, in get return injector.create_object(self._cls) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 990, in create_object self.call_withinjection(cls.init, self=instance, kwargs=additional_kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1024, in call_with_injection ownerkey=self.class if self_ is not None else callable.module, File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper return function(args, kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1069, in args_to_inject instance = self.get(interface) # type: Any File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 963, in get result = scope_instance.get(interface, binding.provider).get(self) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 111, in wrapper return function(*args, *kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 806, in get provider = InstanceProvider(provider.get(self.injector)) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 291, in get return injector.create_object(self._cls) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 990, in create_object self.call_withinjection(cls.init, self=instance, kwargs=additional_kwargs) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/injector/init.py", line 1030, in call_with_injection return callable(full_args, **dependencies) File "/home/elisa/MedCATservice/medcat_service/nlp_processor/medcat_processor.py", line 63, in init self.cat = self._create_cat() File "/home/elisa/MedCATservice/medcat_service/nlp_processor/medcat_processor.py", line 234, in _create_cat return CAT(cdb=cdb, config=conf, vocab=vocab, meta_cats=meta_models) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/medcat/cat.py", line 75, in init additional_fields=['is_punct']) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/medcat/pipe.py", line 38, in add_tagger self.nlp.addpipe(tagger, name='tag' + name, first=True) File "/opt/conda/envs/medcat/lib/python3.7/site-packages/spacy/language.py", line 755, in add_pipe raise ValueError(err) ValueError: [E966]
nlp.add_pipe
now takes the string name of the registered component factory, not a callable component. Expected string, but got functools.partial(<function tag_skip_and_punct at 0x7ff0b0e12cb0>, config=<medcat.config.Config object at 0x7ff16c125350>) (name: 'tag_skip_and_punct').If you created your component with
nlp.create_pipe('name')
: remove nlp.create_pipe and callnlp.add_pipe('name')
instead.If you passed in a component like
TextCategorizer()
: callnlp.add_pipe
with the string name instead, e.g.nlp.add_pipe('textcat')
.If you're using a custom component: Add the decorator
@Language.component
(for function components) or@Language.factory
(for class components / factories) to your custom component and assign it a name, e.g.@Language.component('your_name')
. You can then runnlp.add_pipe('your_name')
to add it to the pipeline. [25/Aug/2021:21:41:19 +0000] [ACCESSS] 127.0.0.1 "POST /api/process HTTP/1.1" 500 "-" "curl/7.52.1"