Skip to content

Commit 4073d47

Browse files
committed
address commnets
1 parent 13d13de commit 4073d47

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/databricks/sql/cloudfetch/downloader.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class DownloadableResultSettings:
5151
link_expiry_buffer_secs (int): Time in seconds to prevent download of a link before it expires. Default 0 secs.
5252
download_timeout (int): Timeout for download requests. Default 60 secs.
5353
max_consecutive_file_download_retries (int): Number of consecutive download retries before shutting down.
54-
speed_warning_threshold_mbps (float): Threshold in MB/s below which to log warning. Default 0.1 MB/s.
54+
min_cloudfetch_download_speed (float): Threshold in MB/s below which to log warning. Default 0.1 MB/s.
5555
"""
5656

5757
is_lz4_compressed: bool
5858
link_expiry_buffer_secs: int = 0
5959
download_timeout: int = 60
6060
max_consecutive_file_download_retries: int = 0
61-
speed_warning_threshold_mbps: float = 0.1
61+
min_cloudfetch_download_speed: float = 0.1
6262

6363

6464
class ResultSetDownloadHandler:
@@ -143,24 +143,26 @@ def _log_download_metrics(
143143
self, url: str, bytes_downloaded: int, duration_seconds: float
144144
):
145145
"""Log download speed metrics at INFO/WARN levels."""
146-
if duration_seconds <= 0:
147-
return
148-
149146
# Calculate speed in MB/s (ensure float division for precision)
150147
speed_mbps = (float(bytes_downloaded) / (1024 * 1024)) / duration_seconds
151148

152149
urlEndpoint = url.split("?")[0]
153150
# INFO level logging
154151
logger.info(
155-
f"CloudFetch download completed: {speed_mbps:.4f} MB/s, "
156-
f"{bytes_downloaded} bytes in {duration_seconds:.3f}s from {urlEndpoint}"
152+
"CloudFetch download completed: %.4f MB/s, %d bytes in %.3fs from %s",
153+
speed_mbps,
154+
bytes_downloaded,
155+
duration_seconds,
156+
urlEndpoint,
157157
)
158158

159159
# WARN level logging if below threshold
160-
if speed_mbps < self.settings.speed_warning_threshold_mbps:
160+
if speed_mbps < self.settings.min_cloudfetch_download_speed:
161161
logger.warning(
162-
f"CloudFetch download slower than threshold: {speed_mbps:.4f} MB/s "
163-
f"(threshold: {self.settings.speed_warning_threshold_mbps:.1f} MB/s) from {url}"
162+
"CloudFetch download slower than threshold: %.4f MB/s (threshold: %.1f MB/s) from %s",
163+
speed_mbps,
164+
self.settings.min_cloudfetch_download_speed,
165+
url,
164166
)
165167

166168
@staticmethod

0 commit comments

Comments
 (0)