Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write the component without cloning and patching the whole DeepPavlov repo? #159

Closed
sld opened this issue Apr 2, 2018 · 4 comments

Comments

@sld
Copy link

sld commented Apr 2, 2018

Hi!

I'd like to write my own component in my private project.

It seems like I should clone the repo then patch it:

  1. By writing write my own dataset readers, iterators,... and putting them into DeepPavlov folder.
  2. Then I should put necessary imports into https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/__init__.py.
  3. In the end I should write my config.json and run python -m deeppavlov...

Can I write separate component independently without patching source code of DeepPavlov?

@seliverstov
Copy link
Contributor

The only reason we write the imports in the __init__ file is to ensure that all standard components are registered through the decorator @register.

@register('ner')
class NER(TFModel):

It is not necessary to put your component import in this __init__ file, you only need to ensure that the appropriate decorator is called before the component is used through it code name in pipeline.

@sld
Copy link
Author

sld commented Apr 4, 2018

I am running next command:
python -m deeppavlov.deep interact deeppavlov/configs/custom_config_component.json

How can I register custom component's dataset readers, iterators, model without putting to __init__.py of DeepPavlov repo?

It seems that I should write my own fork of deeppavlov.deep interact module.

@seliverstov
Copy link
Contributor

deeppavlov.deep interact module is pretty simple. You can write two line of code to interact with your model directly in your own python script:

from deeppavlov.core.commands.infer import interact_model
interact_model(pipeline_config_path)

or train your model:

from deeppavlov.core.commands.train import train_model_from_config
train_model_from_config(pipeline_config_path)

@yoptar yoptar closed this as completed Apr 25, 2018
@sshivaji
Copy link

This should be in the FAQ as its a very common need!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants