ImportError: cannot import name 'ModelField' from 'pydantic.fields

Hi

I am trying to run DeepPavlov from github source:

branch: dev
Python: 3.7.3

I run it inside an “env” as described in the README.

The first problem was a missing dependency, but I could fix this by running

pip install aio-pika

but now I receive the following Import error when running

python -m deeppavlov train deeppavlov/configs/faq/tfidf_logreg_en_faq.json

File “/Users/foobar/src/DeepPavlov/deeppavlov/utils/server/init.py”, line 1, in
from .server import get_server_params, get_ssl_params, redirect_root_to_docs, start_model_server
File “/Users/foobar/src/DeepPavlov/deeppavlov/utils/server/server.py”, line 26, in
from pydantic.fields import Field, ModelField
ImportError: cannot import name ‘ModelField’ from ‘pydantic.fields’ (/Users/foobar/src//DeepPavlov/env/lib/python3.7/site-packages/pydantic/fields.py)

Any idea what I might be doing wrong?

I am not a python programmer, so any help is very much appreciated :slight_smile:

Thanks

Michael

If I understand correctly

pip install deeppavlov

is installing

env/lib/python3.7/site-packages/pydantic-0.32.2.dist-info

which does not contain ModelField yet, but only later versions of pydantic contain ModelField.

Is my interpretation correct? If so, how do I make sure, that the versions according to requirements.txt are being installed?

Thanks

Michael

I have got it running with

and then train and interact works :slight_smile:

python -m deeppavlov train deeppavlov/configs/faq/tfidf_logreg_en_faq.json
python -m deeppavlov interact deeppavlov/configs/faq/tfidf_logreg_en_faq.json

but the riseapi still does not work :frowning:

python -m deeppavlov riseapi deeppavlov/configs/faq/tfidf_logreg_en_faq.json

whereas I receive the following error

File “/Users/foobar/src//DeepPavlov/env/lib/python3.7/site-packages/uvicorn/main.py”, line 262, in run
config = Config(app, **kwargs)
TypeError: init() got an unexpected keyword argument ‘log_config’

Any idea how to fix this?

Thanks

Michael

Running pip install -e . from the repository root should fix this.
When you’re doing pip install deeppavlov, you’re installing the latest master version with its requirements but in dev branch some of them were updated.

Thanks for your feedback!

The following sequence works:

Is this how it is supposed to be in order to test the “dev” branch?

Thanks

Michael

Is this how it is supposed to be in order to test the “dev” branch?

Yes.
You can also run

python -m deeppavlov install deeppavlov/configs/faq/tfidf_logreg_en_faq.json

instead of installing spacy and en_core_web_sm. The install command should install all the requirements needed to run a configuration.

Thanks very much for this hint!

Two more questions:

If I want to start developing myself and change code, what is the recommended command line sequence to develop and test my local changes?

I have found the following guide re contributing

http://docs.deeppavlov.ai/en/master/devguides/contribution_guide.html

but it does not tell how to develop.

And the second questions not directly related…when I run “riseapi”, then I see two endpoints

  • /model
  • /api

but according to the following web page there should be more

http://docs.deeppavlov.ai/en/master/integrations/rest_api.html

Is this web page outdated?

Thanks

Michael

what is the recommended command line sequence to develop and test my local changes?

If you’ve installed deeppavlov with -e from a local directory python will look for the library code in that directory, so you can change your code and see the changes.
I would advise you to fork the repository first and work with you own version of it so that you could push your changes to github and mayber send us a pull request with your changes later.

I see two endpoints

All the endpoinds are there:

  • /docs endpoint is where you see /model and /api documentation
  • /probe is there but not documented in /docs, you can send a POST request on /probe using other tools, such as curl, requests python library, or Postman.

Hi @yoptar

Thanks for the additional hint! The following sequence works very well:

git clone https://github.com/deepmipt/DeepPavlov.git
git checkout dev
python3 -m venv env
source ./env/bin/activate
pip install -e .
python -m deeppavlov install deeppavlov/configs/faq/tfidf_logreg_en_faq.json
python -m deeppavlov train deeppavlov/configs/faq/tfidf_logreg_en_faq.json
python -m deeppavlov riseapi deeppavlov/configs/faq/tfidf_logreg_en_faq.json
http://0.0.0.0:5000 

Regarding endpoints, got it now :slight_smile:

Just sent curl -X POST “http://0.0.0.0:5000/probe” and received

{“detail”:[{“loc”:[“body”,“item”],“msg”:“field required”,“type”:“value_error.missing”}]}

Thanks

Michael

Hii @yoptar

I have created a fork and a branch where I have started the implementation of a REST interface to retrain the model. It is working, but the implementation could be improved and maybe you could have a quick look at it and check whether the general implementation makes sense.
In particular I am not quite sure what is best to reload/rebuild the model

Thanks

Michael

Hi @michaelwechner,

There is no need to use the argparser module, I feel.
To rewrite the model variable only once inside a nested function you can use the nonlocal keyword.

Hi @yoptar

You mean that I somehow reuse the args variable from deeppavlov/deep.py def main() ?

Or maybe you can post some code regarding what you mean exactly?

Thanks

Michael