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

Replace assert by ValueError of src/transformers/models/electra/modeling_{electra,tf_electra}.py and all other models that had copies #13955

Conversation

AkechiShiro
Copy link
Contributor

@AkechiShiro AkechiShiro commented Oct 10, 2021

What does this PR do?

Related to issue: #12789

I've had to change others files in order that the code_check_quality tests passes, if there is any change that should be removed please feel free to let me know.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

I'm tagging @LysandreJik because I have modified the albert and bert models as well as other that had to be changed in order for the code_quality_check to pass.

@AkechiShiro AkechiShiro force-pushed the replace-assert-models-modeling-electra-by-exception branch from f183373 to 3860118 Compare October 10, 2021 19:49
@AkechiShiro AkechiShiro force-pushed the replace-assert-models-modeling-electra-by-exception branch from 7c726b3 to a6fc239 Compare October 10, 2021 20:50
* Change multiples models assertion to ValueError in order to validate
  check_code_style test and models template test.
@AkechiShiro AkechiShiro changed the title Replace assert by ValueError in src/transformers/models/electra/modeling_{electra,tf_electra}.py Replace assert by ValueError of src/transformers/models/electra/modeling_{electra,tf_electra}.py and all other models that were copies Oct 10, 2021
@AkechiShiro AkechiShiro changed the title Replace assert by ValueError of src/transformers/models/electra/modeling_{electra,tf_electra}.py and all other models that were copies Replace assert by ValueError of src/transformers/models/electra/modeling_{electra,tf_electra}.py and all other models that had copies Oct 10, 2021
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks a lot for fixing those, added a few comments :-)

src/transformers/models/albert/modeling_tf_albert.py Outdated Show resolved Hide resolved
src/transformers/models/albert/modeling_albert.py Outdated Show resolved Hide resolved
src/transformers/models/bert/modeling_bert.py Outdated Show resolved Hide resolved
src/transformers/models/bert/modeling_tf_bert.py Outdated Show resolved Hide resolved
src/transformers/models/convbert/modeling_tf_convbert.py Outdated Show resolved Hide resolved
src/transformers/models/electra/modeling_electra.py Outdated Show resolved Hide resolved
src/transformers/models/electra/modeling_tf_electra.py Outdated Show resolved Hide resolved
src/transformers/models/rembert/modeling_rembert.py Outdated Show resolved Hide resolved
src/transformers/models/tapas/modeling_tapas.py Outdated Show resolved Hide resolved
AkechiShiro and others added 9 commits October 11, 2021 19:42
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
…rt.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
@AkechiShiro
Copy link
Contributor Author

Thank you for your suggestion about the ValueError message and the simplification made to the logic to improve readability, I think this PR is ready to merge.

@sgugger
Copy link
Collaborator

sgugger commented Oct 11, 2021

Thanks a lot for adapting!

@sgugger sgugger merged commit 3499728 into huggingface:master Oct 11, 2021
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
…ing_{electra,tf_electra}.py and all other models that had copies (huggingface#13955)

* Replace all assert by ValueError in src/transformers/models/electra

* Reformat with black to pass check_code_quality test

* Change some assert to ValueError of modeling_bert & modeling_tf_albert

* Change some assert in multiples models

* Change multiples models assertion to ValueError in order to validate
  check_code_style test and models template test.

* Black reformat

* Change some more asserts in multiples models

* Change assert to ValueError in modeling_layoutlm.py to fix copy error in code_style_check

* Add proper message to ValueError in modeling_tf_albert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Simplify logic in models/bert/modeling_bert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Add ValueError message to models/convbert/modeling_tf_convbert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Add error message for ValueError to modeling_tf_electra.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Simplify logic in models/tapas/modeling_tapas.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Simplify logic in models/electra/modeling_electra.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Add ValueError message in src/transformers/models/bert/modeling_tf_bert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Simplify logic in src/transformers/models/rembert/modeling_rembert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Simplify logic in src/transformers/models/albert/modeling_albert.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
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.

2 participants