Skip to content

Commit 001be4a

Browse files
Fix broken async reference file system _cat_file method (#1734)
Co-authored-by: Martin Durant <[email protected]>
1 parent 199ee82 commit 001be4a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

fsspec/implementations/reference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ async def _cat_file(self, path, start=None, end=None, **kwargs):
806806
return part_or_url[start:end]
807807
protocol, _ = split_protocol(part_or_url)
808808
try:
809-
await self.fss[protocol]._cat_file(part_or_url, start=start, end=end)
809+
return await self.fss[protocol]._cat_file(
810+
part_or_url, start=start0, end=end0
811+
)
810812
except Exception as e:
811813
raise ReferenceNotReachable(path, part_or_url) from e
812814

fsspec/implementations/tests/test_reference.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,35 @@ def test_cat_file_ranges(m):
513513
assert fs.cat_file("d", 1, -3) == other[4:10][1:-3]
514514

515515

516+
@pytest.mark.asyncio
517+
async def test_async_cat_file_ranges():
518+
fsspec.get_filesystem_class("http").clear_instance_cache()
519+
fss = fsspec.filesystem("https", asynchronous=True)
520+
session = await fss.set_session()
521+
522+
fs = fsspec.filesystem(
523+
"reference",
524+
fo={
525+
"version": 1,
526+
"refs": {
527+
"reference_time/0": [
528+
"https://noaa-nwm-retro-v2-0-pds.s3.amazonaws.com/full_physics/2017/201704010000.CHRTOUT_DOMAIN1.comp",
529+
39783,
530+
12,
531+
],
532+
},
533+
},
534+
fs={"https": fss},
535+
remote_protocol="https",
536+
asynchronous=True,
537+
)
538+
539+
assert (
540+
await fs._cat_file("reference_time/0") == b"x^K0\xa9d\x04\x00\x03\x13\x01\x0f"
541+
)
542+
await session.close()
543+
544+
516545
@pytest.mark.parametrize(
517546
"fo",
518547
[

0 commit comments

Comments
 (0)