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

Wiring does improper import #320

rmk135 opened this issue Nov 5, 2020 · 1 comment

Wiring does improper import #320

rmk135 opened this issue Nov 5, 2020 · 1 comment


Copy link

rmk135 commented Nov 5, 2020

Module wiring does improper import of modules when looks for injection markers using packages=[] option. This caused multiple imports of the same module.

Here is user's comment on this:

Hi @rmk135, thank u so much for support.
I've another issue. QA's class constructor requires a string:

class QA():
    def __init__(self, model=Provide[]):
        self.model = model

if I create a new QA object in main method everything goes fine, but using 'BotDependencyFactory' they return this error that is like config wasn't wired:

INFO:root:configuration completed
INFO:root:Configuration container wired successfully
INFO:root:Initializing model...
INFO:root:model: <dependency_injector.wiring.Provide object at 0x00000235228E4250>
Traceback (most recent call last):
  File "c:/Users/Federico/Desktop/DeepCleverBot/bot/", line 24, in <module>
    bot = Bot()
  File "C:\Users\Federico\anaconda3\envs\deepcleverbot\lib\site-packages\dependency_injector\", line 319, in _patched
    to_inject[injection] = provider()
  File "src/dependency_injector/providers.pyx", line 160, in dependency_injector.providers.Provider.__call__
  File "src/dependency_injector/providers.pyx", line 2130, in dependency_injector.providers.Singleton._provide
  File "src/dependency_injector/providers.pxd", line 450, in dependency_injector.providers.__factory_call
  File "src/dependency_injector/providers.pxd", line 436, in dependency_injector.providers.__callable_call
  File "src/dependency_injector/providers.pxd", line 432, in dependency_injector.providers.__call
  File "c:\Users\Federico\Desktop\DeepCleverBot\bot\src\QA\", line 13, in __init__
  File "c:\Users\Federico\Desktop\DeepCleverBot\bot\src\QA\", line 18, in init_model
    self.tokenizer = BertTokenizer.from_pretrained(self.model, return_token_type_ids = True)
  File "C:\Users\Federico\anaconda3\envs\deepcleverbot\lib\site-packages\transformers\", line 1516, in from_pretrained
    if os.path.isfile(pretrained_model_name_or_path) or is_remote_url(pretrained_model_name_or_path):
  File "C:\Users\Federico\anaconda3\envs\deepcleverbot\lib\", line 30, in isfile
    st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not Provide

Originally posted by @iskorini in #313 (comment)

@rmk135 rmk135 self-assigned this Nov 5, 2020
@rmk135 rmk135 added the bug label Nov 5, 2020
rmk135 added a commit that referenced this issue Nov 5, 2020
Copy link
Member Author

rmk135 commented Nov 5, 2020

The issue is fixed in 4.3.5. The release is on PyPI.

@iskorini, thanks for reporting the issue. You're welcome to upgrade to a patched version.

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

No branches or pull requests

1 participant