Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d646442
Stream hf:// files from the CDN to avoid Hub rate limits (#664)
tristan-deep Oct 26, 2026
62e40e6
Validate ZEA_MAX_CONCURRENT_REQUESTS and keep the retry log off the e…
tristan-deep Oct 26, 2026
bde3508
Redact signed URLs in fsspec's HTTP debug log
tristan-deep Oct 26, 2026
1f4122d
fixed potential burst of requests on ttl expiry
Louisvh Oct 29, 2026
4bb3aee
Merge branch 'main' into feature/hf-cdn-streaming
tristan-deep Nov 2, 2026
d3b0c59
improve fetching of small chunks
tristan-deep Nov 2, 2026
e465a91
Keep large chunks on the merged path and make read_at thread-safe
tristan-deep Nov 2, 2026
d378820
Merge remote-tracking branch 'origin/main' into feature/hf-cdn-streaming
tristan-deep Nov 4, 2026
cd2bcb6
Drop cached CDN URLs on upload and reuse branch URLs only as long as …
tristan-deep Nov 4, 2026
206600e
Ask the Hub at most once per cooldown when a URL refresh gives nothin…
tristan-deep Nov 4, 2026
9e9954e
Keep using the current URL when its early refresh fails
tristan-deep Nov 4, 2026
a138178
Redact signed URLs in the errors of failed range requests
tristan-deep Nov 4, 2026
0a2ba87
Draw no progress bar for reads below MIN_BYTES
tristan-deep Nov 4, 2026
68c62c7
Check the chunk cache with a stat in pending_bytes
tristan-deep Nov 4, 2026
7b3d0ec
Fetch the blocks of a small read concurrently
tristan-deep Nov 4, 2026
3f43635
Merge ranges only while a request downloads no more gap bytes than ch…
tristan-deep Nov 4, 2026
afcc0ef
Keep one block cache per streamed file instead of two
tristan-deep Nov 4, 2026
dca16d0
Ask the stream whether it keeps the blocks it reads
tristan-deep Nov 4, 2026
dcd792d
Share the on-disk cache helpers of the Hub listing and the CDN URLs
tristan-deep Nov 4, 2026
3fcd16b
Merge branch 'main' into feature/hf-cdn-streaming
tristan-deep Nov 4, 2026
08f275f
Merge branch 'main' into feature/hf-cdn-streaming
swpenninga Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Redact signed URLs in fsspec's HTTP debug log
fsspec logs every URL it requests on the fsspec.http logger, so enabling debug
logging printed the full signed CDN URL, signature included. Add a logging
filter to that logger that strips query strings from logged URLs. Requests
still use the complete URL.
  • Loading branch information
tristan-deep committed Oct 26, 2026
commit bde3508a320ea1da0fb0f7b8bf917ea0124b0cd2
17 changes: 17 additions & 0 deletions tests/data/test_chunk_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import http.server
import inspect
import logging
import os
import socketserver
import threading
Expand Down Expand Up @@ -1102,6 +1103,22 @@ def refresh(self, stale_url):
server.close()


def test_fsspec_debug_log_redacts_signed_urls(structured_file, caplog):
"""fsspec logs every URL it requests; the signature must not end up in the log."""
server = _CountingServer(structured_file.parent, latency=0)
try:
url = server.url + structured_file.name + "?Policy=abc&Signature=secret"
fetcher = HTTPFetcher(url) # the test server ignores the query string
with caplog.at_level(logging.DEBUG, logger="fsspec.http"):
data = fetcher.fetch([(0, 16)])
assert data[0] == structured_file.read_bytes()[:16] # requested with the full URL
logged = [r.getMessage() for r in caplog.records if r.name == "fsspec.http"]
assert any(structured_file.name in m for m in logged)
assert not any("secret" in m or "Policy" in m for m in logged)
finally:
server.close()


class TestIsTransient:
@pytest.mark.parametrize("status", sorted(chunk_reader.RETRY_STATUS))
def test_transient_statuses(self, status):
Expand Down
27 changes: 27 additions & 0 deletions zea/data/chunk_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@

import asyncio
import functools
import logging
import os
import random
import re
import threading
import warnings
import zlib
Expand Down Expand Up @@ -186,6 +188,30 @@ def current(self) -> tuple[str, dict[str, str]]: ...
def refresh(self, stale_url: str) -> bool: ...


class _RedactQueryStrings(logging.Filter):
"""Strip query strings from URLs in log records: they carry the signature of a CDN URL."""

_url = re.compile(r"(https?://[^\s?]+)\?\S*")

def filter(self, record: logging.LogRecord) -> bool:
message = record.getMessage()
redacted = self._url.sub(r"\1?<redacted>", message)
if redacted != message:
record.msg, record.args = redacted, ()
return True


_redaction_lock = threading.Lock()


def _redact_fsspec_http_logs() -> None:
"""Keep signed URLs out of fsspec's HTTP debug log, which logs every requested URL."""
logger = logging.getLogger("fsspec.http")
with _redaction_lock:
if not any(isinstance(f, _RedactQueryStrings) for f in logger.filters):
logger.addFilter(_RedactQueryStrings())


class _FixedURL:
"""A plain URL that is never refreshed."""

Expand Down Expand Up @@ -374,6 +400,7 @@ def __init__(self, url: "str | SignedURL", token: str | None = None, cache=None)
self.location = url
self.cache = cache # zea.data.chunk_cache.ChunkCache, or None
self._fs = fsspec.filesystem("http")
_redact_fsspec_http_logs()

@property
def url(self) -> str:
Expand Down
Loading