-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: put HFTokenStreamingHandler
in a lazy_import block
#7403
Conversation
@@ -222,8 +222,7 @@ def check_generation_params(kwargs: Optional[Dict[str, Any]], additional_accepte | |||
with LazyImport(message="Run 'pip install transformers[torch]'") as torch_and_transformers_import: | |||
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast, StoppingCriteria, TextStreamer | |||
|
|||
transformers_import.check() | |||
torch_import.check() | |||
torch_and_transformers_import.check() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated
Pull Request Test Coverage Report for Build 8386643773Details
💛 - Coveralls |
Yes, this is on me - apologies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have a small issue regarding this HFTokenStreamingHandler File "/code/haystack_api/pipeline/custom_pipelines.py", line 27, in <module>
2024-03-22T13:27:51.948291417Z from haystack.components.generators.utils import print_streaming_chunk
2024-03-22T13:27:51.948294052Z File "/usr/local/lib/python3.11/site-packages/haystack/components/generators/__init__.py", line 5, in <module>
2024-03-22T13:27:51.948297138Z from haystack.components.generators.hugging_face_local import HuggingFaceLocalGenerator
2024-03-22T13:27:51.948301586Z File "/usr/local/lib/python3.11/site-packages/haystack/components/generators/hugging_face_local.py", line 13, in <module>
2024-03-22T13:27:51.948308570Z from haystack.utils.hf import deserialize_hf_model_kwargs, serialize_hf_model_kwargs
2024-03-22T13:27:51.948311495Z File "/usr/local/lib/python3.11/site-packages/haystack/utils/hf.py", line 227, in <module>
2024-03-22T13:27:51.948314561Z class StopWordsCriteria(StoppingCriteria):
2024-03-22T13:27:51.948324500Z File "/usr/local/lib/python3.11/site-packages/haystack/utils/hf.py", line 243, in StopWordsCriteria
2024-03-22T13:27:51.948327546Z device: Union[str, torch.device] = "cpu",
2024-03-22T13:27:51.948330792Z ^^^^^
2024-03-22T13:27:51.948333477Z NameError: name 'torch' is not defined I don't use Huggingface at all so torch is not installed. |
Related Issues
Several core-integrations tests with Haytstack main are failing after #7377
See for example https://github.com/deepset-ai/haystack-core-integrations/actions/runs/8383450235/job/22959180165
This happens because
HFTokenStreamingHandler
import in HFLocalGenerator is not inside a lazy_import block,even if the class needs
transformers
Proposed Changes:
put
HFTokenStreamingHandler
in a lazy_import blockHow did you test it?
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.