Skip to content

Forward kwargs from cat_ranges to cat_file (#2016)#2044

Merged
martindurant merged 1 commit into
fsspec:masterfrom
assinscreedFC:fix/2016-cat-ranges-kwargs
Jun 8, 2026
Merged

Forward kwargs from cat_ranges to cat_file (#2016)#2044
martindurant merged 1 commit into
fsspec:masterfrom
assinscreedFC:fix/2016-cat-ranges-kwargs

Conversation

@assinscreedFC

Copy link
Copy Markdown
Contributor

Summary

Fixes #2016.

AbstractFileSystem.cat_ranges accepts **kwargs but did not forward them when calling cat_file:

out.append(self.cat_file(p, s, e))   # kwargs silently dropped

As reported, this means parameters such as a cache's block_size are lost, so cat_ranges bypasses an on-disk cache and goes out to the underlying (remote) filesystem on every call. The async AsyncFileSystem._cat_ranges already forwards **kwargs to _cat_file, so this just brings the sync path in line.

@martindurant confirmed in the issue: "I'd be happy to see kwargs passed through as you suggest for part 1 of this issue." This PR is scoped to that part 1.

Change

out.append(self.cat_file(p, s, e, **kwargs))

Test plan

  • Added test_cat_ranges_forwards_kwargs in fsspec/tests/test_spec.py (a recording filesystem asserts the kwarg reaches cat_file).
  • pytest fsspec/tests/test_spec.py — 120 passed.
  • ruff check / ruff format --check — clean.

AbstractFileSystem.cat_ranges accepts **kwargs but dropped them when
calling cat_file, so parameters such as a cache's block_size were
silently ignored and every range read bypassed the cache. The async
AsyncFileSystem._cat_ranges already forwards them.

Pass **kwargs through to cat_file, matching the async implementation.

Fixes fsspec#2016
@martindurant martindurant merged commit 073aac8 into fsspec:master Jun 8, 2026
11 checks passed
@martindurant

Copy link
Copy Markdown
Member

Thank you!

@bnlawrence

Copy link
Copy Markdown

Thanks from me too!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cat_ranges doesn't pass kwargs to cat_file which generates block size mismatches which result in no cache usage

3 participants