Skip to content

Conversation

@HichTala
Copy link
Contributor

What does this PR do?

This pull request updates the get_imports function in src/transformers/dynamic_module_utils.py to improve how conditional imports are handled. The most important change introduces a check for functions in transformers.utils.import_utils to ensure imports in specific conditional blocks are ignored.

Enhancements to conditional import handling:

  • src/transformers/dynamic_module_utils.py: Added a reference to transformers.utils and updated the logic in the recursive_look_for_imports function to ignore imports in conditional blocks that use functions from transformers.utils.import_utils, in addition to the existing check for is_flash_attn functions.

Fixes # (issue)

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?

@Rocketknight1

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.

@github-actions github-actions bot marked this pull request as draft April 28, 2025 09:20
@github-actions
Copy link
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@HichTala HichTala marked this pull request as ready for review April 28, 2025 09:58
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1
Copy link
Member

Hi @HichTala. thanks for the updates. This looks good now, so I'm going to merge!

@Rocketknight1 Rocketknight1 merged commit aa6b79d into huggingface:main Apr 29, 2025
20 checks passed
@HichTala
Copy link
Contributor Author

My pleasure

@HichTala
Copy link
Contributor Author

I think, yesterday one of the test didn't pass, I'm not sure of want changed, can you enlighten me ? 😅

@HichTala HichTala deleted the fix-unecessary-check-import-issue-37626 branch April 29, 2025 13:30
@Rocketknight1
Copy link
Member

hi @HichTala, that was probably just a flaky test! I reran the tests and it passed afterwards. We're working on making the CI more robust so that stops happening

@HichTala
Copy link
Contributor Author

Hi @Rocketknight1, ok notted thank you 👍

zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
…ce#37825)

* Fix check of unecessary packages (issue huggingface#37626)

* Reformat using ruff

* And a condition to avoind the risk of matching a random object in `import_utils`

* Reformat
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.

3 participants