Repository navigation
Commit 4b3a3d7
authored
pipelines: defer eager model imports in text_to_audio and token_classification (#50001)
pipelines: defer eager model imports to avoid spurious test dependencies
`token_classification.py` imported `BasicTokenizer` at module level, and
`text_to_audio.py` imported `SpeechT5HifiGan` inside the
`if is_torch_available()` block — both at import time, unconditionally.
This caused every test file that loads any pipeline (via PipelineTesterMixin
→ test_pipeline_mixin.py → pipeline source files) to record a transitive
dependency on `modeling_bert_legacy` and `modeling_speecht5`, even when
those models are completely unrelated to the test being run.
Move both imports to the call site where they are first needed (`__init__`
for `BasicTokenizer`, the spectrogram-model branch of `__init__` for
`SpeechT5HifiGan`), so they are only executed when the relevant pipeline
class is actually instantiated.
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>1 parent 3fe9133 commit 4b3a3d7
2 files changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
138 | 137 | | |
139 | 138 | | |
140 | 139 | | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
0 commit comments