diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/downloaders/s3/s3_downloader.py b/integrations/amazon_bedrock/src/haystack_integrations/components/downloaders/s3/s3_downloader.py index e790a51d8b..7ad228057b 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/downloaders/s3/s3_downloader.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/downloaders/s3/s3_downloader.py @@ -142,8 +142,7 @@ def run( """ if self._storage is None: - msg = f"The component {self.__class__.__name__} was not warmed up. Call 'warm_up()' before calling run()." - raise RuntimeError(msg) + self.warm_up() filtered_documents = self._filter_documents_by_extensions(documents) if self.file_extensions else documents diff --git a/integrations/amazon_bedrock/tests/test_s3_downloader.py b/integrations/amazon_bedrock/tests/test_s3_downloader.py index 71f231f81a..d1692b3c4a 100644 --- a/integrations/amazon_bedrock/tests/test_s3_downloader.py +++ b/integrations/amazon_bedrock/tests/test_s3_downloader.py @@ -129,7 +129,6 @@ def test_to_dict_with_parameters(self, tmp_path): def test_run(self, tmp_path, mock_s3_storage, mock_boto3_session): d = S3Downloader(file_root_path=str(tmp_path)) - S3Downloader.warm_up(d) d._storage = mock_s3_storage docs = [ @@ -141,7 +140,6 @@ def test_run(self, tmp_path, mock_s3_storage, mock_boto3_session): def test_run_with_extensions(self, tmp_path, mock_s3_storage, mock_boto3_session): d = S3Downloader(file_root_path=str(tmp_path), file_extensions=[".txt"]) - S3Downloader.warm_up(d) d._storage = mock_s3_storage docs = [ @@ -155,12 +153,9 @@ def test_run_with_extensions(self, tmp_path, mock_s3_storage, mock_boto3_session def test_run_with_input_file_meta_key(self, tmp_path, mock_s3_storage, mock_boto3_session): d = S3Downloader(file_root_path=str(tmp_path), file_name_meta_key="custom_file_key") - S3Downloader.warm_up(d) d._storage = mock_s3_storage - docs = [ - Document(meta={"file_id": str(uuid4()), "custom_file_key": "a.txt"}), - ] + docs = [Document(meta={"file_id": str(uuid4()), "custom_file_key": "a.txt"})] out = d.run(documents=docs) assert len(out["documents"]) == 1 @@ -168,12 +163,9 @@ def test_run_with_input_file_meta_key(self, tmp_path, mock_s3_storage, mock_boto def test_run_with_s3_key_generation_function(self, tmp_path, mock_s3_storage, mock_boto3_session): d = S3Downloader(file_root_path=str(tmp_path), s3_key_generation_function=s3_key_generation_function) - S3Downloader.warm_up(d) d._storage = mock_s3_storage - docs = [ - Document(meta={"file_id": str(uuid4()), "file_name": "a.txt"}), - ] + docs = [Document(meta={"file_id": str(uuid4()), "file_name": "a.txt"})] out = d.run(documents=docs) assert len(out["documents"]) == 1 assert out["documents"][0].meta["file_name"] == "a.txt" @@ -189,7 +181,6 @@ def test_run_with_s3_key_generation_function_and_file_extensions( s3_key_generation_function=s3_key_generation_function, file_extensions=[".txt"], ) - S3Downloader.warm_up(d) d._storage = mock_s3_storage docs = [ @@ -210,8 +201,6 @@ def test_run_with_s3_key_generation_function_and_file_extensions( def test_live_run(self, tmp_path, monkeypatch): d = S3Downloader(file_root_path=str(tmp_path)) monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "") - S3Downloader.warm_up(d) - docs = [ Document(meta={"file_id": str(uuid4()), "file_name": "text-sample.txt"}), Document(meta={"file_id": str(uuid4()), "file_name": "document-sample.pdf"}), @@ -229,9 +218,7 @@ def test_live_run(self, tmp_path, monkeypatch): ) def test_live_run_with_no_documents(self, tmp_path): d = S3Downloader(file_root_path=str(tmp_path)) - S3Downloader.warm_up(d) - docs = [] - out = d.run(documents=docs) + out = d.run(documents=[]) assert len(out["documents"]) == 0 @pytest.mark.integration @@ -247,10 +234,8 @@ def test_live_run_with_no_documents(self, tmp_path): def test_live_run_with_custom_meta_key(self, tmp_path, monkeypatch): d = S3Downloader(file_root_path=str(tmp_path), file_name_meta_key="custom_name") monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "") - S3Downloader.warm_up(d) - docs = [ - Document(meta={"custom_name": "text-sample.txt"}), - ] + d.warm_up() + docs = [Document(meta={"custom_name": "text-sample.txt"})] out = d.run(documents=docs) assert len(out["documents"]) == 1 assert out["documents"][0].meta["custom_name"] == "text-sample.txt" @@ -263,11 +248,8 @@ def test_live_run_with_custom_meta_key(self, tmp_path, monkeypatch): def test_live_run_with_prefix(self, tmp_path, monkeypatch): d = S3Downloader(file_root_path=str(tmp_path)) monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "subfolder/") - - S3Downloader.warm_up(d) - docs = [ - Document(meta={"file_name": "employees.json"}), - ] + d.warm_up() + docs = [Document(meta={"file_name": "employees.json"})] out = d.run(documents=docs) assert len(out["documents"]) == 1 assert out["documents"][0].meta["file_name"] == "employees.json" @@ -286,10 +268,8 @@ def test_live_run_with_s3_key_generation_function_and_file_extensions(self, tmp_ file_name_meta_key="file_name", s3_key_generation_function=s3_key_generation_function, ) - S3Downloader.warm_up(d) - docs = [ - Document(meta={"file_name": "dog.jpg"}), - ] + d.warm_up() + docs = [Document(meta={"file_name": "dog.jpg"})] out = d.run(documents=docs) assert len(out["documents"]) == 1 assert out["documents"][0].meta["file_name"] == "dog.jpg"