Skip to content

Commit 576ca4b

Browse files
committed
Auto call warm_up
1 parent 800ddca commit 576ca4b

4 files changed

Lines changed: 3 additions & 10 deletions

File tree

integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_document_embedder.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,12 @@ def run(self, documents: list[Document]) -> dict[str, list[Document]]:
200200
A list of Documents to embed.
201201
:returns:
202202
The updated Documents with their embeddings.
203-
:raises RuntimeError:
204-
If the component was not initialized.
205203
:raises TypeError:
206204
If the input is not a list of Documents.
207205
"""
208206
if not self._initialized:
209-
msg = "The embedding model has not been loaded. Please call warm_up() before running."
210-
raise RuntimeError(msg)
207+
self.warm_up()
208+
211209
if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)):
212210
msg = (
213211
"OptimumDocumentEmbedder expects a list of Documents as input."

integrations/optimum/src/haystack_integrations/components/embedders/optimum/optimum_text_embedder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,11 @@ def run(self, text: str) -> dict[str, list[float]]:
162162
The text to embed.
163163
:returns:
164164
The embeddings of the text.
165-
:raises RuntimeError:
166-
If the component was not initialized.
167165
:raises TypeError:
168166
If the input is not a string.
169167
"""
170168
if not self._initialized:
171-
msg = "The embedding model has not been loaded. Please call warm_up() before running."
172-
raise RuntimeError(msg)
169+
self.warm_up()
173170

174171
if not isinstance(text, str):
175172
msg = (

integrations/optimum/tests/test_optimum_document_embedder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ def test_run(self, opt_config, quant_config):
371371
optimizer_settings=opt_config,
372372
quantizer_settings=quant_config,
373373
)
374-
embedder.warm_up()
375374

376375
result = embedder.run(documents=docs)
377376
_ = [embedder.run([d]) for d in docs_copy]

integrations/optimum/tests/test_optimum_text_embedder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def test_run(self):
252252
suffix=" suffix",
253253
pooling_mode=pooling_mode,
254254
)
255-
embedder.warm_up()
256255

257256
result = embedder.run(text="The food was delicious")
258257

0 commit comments

Comments
 (0)