Skip to content

Conversation

@sgugger
Copy link
Collaborator

@sgugger sgugger commented Dec 8, 2022

What does this PR do?

Fixes #20671

As reported in #20671, calling AutoModel.from_config on a model with a missing specific soft dependency does not raise the appropriate error. This is because this method ends up calling ModelClass._from_config and the DummyObject class does not raise the error on all private attributes (basically because we need the __xxx__ attribute to stay the same). This PR whitelists _from_config to fix the issue.

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

(do you think it's even fine for us to call super().__getattribute__(key) whenever super has key as its attribute? i.e. not to check _ or a whitelist, but just check if super has that attr)

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 8, 2022

The documentation is not available anymore as the PR was closed or merged.

@sgugger
Copy link
Collaborator Author

sgugger commented Dec 8, 2022

You can't do that kind of check without triggerring recursion errors (cause it calls methods like __getattribute__ inside that method ;-) ).

@sgugger sgugger merged commit 69038ce into main Dec 8, 2022
@sgugger sgugger deleted the dummy_fix branch December 8, 2022 16:19
mpierrau pushed a commit to mpierrau/transformers that referenced this pull request Dec 15, 2022
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

Successfully merging this pull request may close these issues.

Calling AutoModel.from_config() method for a model requiring timm does not raise ImportError although it should

4 participants