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

Closed
rmk135 opened this issue Nov 5, 2020 · 1 comment
Closed

Wiring does improper import #320

rmk135 opened this issue Nov 5, 2020 · 1 comment
Assignees
Labels

Comments

@rmk135
Copy link
Member

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[ConfigContainer.config.model.name]):
        self.model = model
        self.init_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/app.py", line 24, in <module>
    bot = Bot()
  File "C:\Users\Federico\anaconda3\envs\deepcleverbot\lib\site-packages\dependency_injector\wiring.py", 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\QA.py", line 13, in __init__
    self.init_model()
  File "c:\Users\Federico\Desktop\DeepCleverBot\bot\src\QA\QA.py", 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\tokenization_utils_base.py", 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\genericpath.py", 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
@rmk135
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
Labels
Projects
None yet
Development

No branches or pull requests

1 participant