Skip to content

Commit 7f46fe8

Browse files
fix mypy union-attr and address reviewer comments
1 parent deb7b9d commit 7f46fe8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

integrations/supabase/src/haystack_integrations/components/downloaders/supabase/supabase_bucket_downloader.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import mimetypes
66
from pathlib import Path
7-
from typing import Any
7+
from typing import Any, cast
88

99
from haystack import component, default_from_dict, default_to_dict, logging
1010
from haystack.dataclasses import ByteStream
@@ -64,7 +64,7 @@ def __init__(
6464
self._client: Client | None = None
6565

6666
def warm_up(self) -> None:
67-
"""Initialize the Supabase client. Called once before the first run."""
67+
"""Initializes the Supabase client. Called automatically on the first run(), or can be called explicitly in a pipeline."""
6868
if self._client is None:
6969
key = self.supabase_key.resolve_value()
7070
if not key:
@@ -85,9 +85,7 @@ def run(self, sources: list[str]) -> dict[str, list[ByteStream]]:
8585
"""
8686
if self._client is None:
8787
self.warm_up()
88-
if self._client is None:
89-
msg = "Supabase client is not initialized. Call warm_up() before run()."
90-
raise RuntimeError(msg)
88+
client = cast(Client, self._client)
9189
streams = []
9290

9391
for path in sources:
@@ -98,7 +96,7 @@ def run(self, sources: list[str]) -> dict[str, list[ByteStream]]:
9896
continue
9997

10098
try:
101-
data = self._client.storage.from_(self.bucket_name).download(path)
99+
data = client.storage.from_(self.bucket_name).download(path)
102100
except Exception as e:
103101
logger.warning(
104102
"Failed to download {path} from bucket {bucket}: {error}",

integrations/supabase/tests/test_supabase_bucket_downloader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,5 @@ def test_run_integration(self):
186186
result = downloader.run(sources=["test-file.txt"])
187187
assert len(result["streams"]) > 0
188188
assert isinstance(result["streams"][0], ByteStream)
189+
assert result["streams"][0].meta["file_path"] == "test-file.txt"
190+
assert result["streams"][0].meta["bucket_name"] == os.environ.get("SUPABASE_BUCKET_NAME", "test-bucket")

0 commit comments

Comments
 (0)