diff --git a/fsspec/implementations/reference.py b/fsspec/implementations/reference.py index 3d22ddc40..79bff141a 100644 --- a/fsspec/implementations/reference.py +++ b/fsspec/implementations/reference.py @@ -806,7 +806,9 @@ async def _cat_file(self, path, start=None, end=None, **kwargs): return part_or_url[start:end] protocol, _ = split_protocol(part_or_url) try: - await self.fss[protocol]._cat_file(part_or_url, start=start, end=end) + return await self.fss[protocol]._cat_file( + part_or_url, start=start0, end=end0 + ) except Exception as e: raise ReferenceNotReachable(path, part_or_url) from e diff --git a/fsspec/implementations/tests/test_reference.py b/fsspec/implementations/tests/test_reference.py index fefdd6024..0063d11b0 100644 --- a/fsspec/implementations/tests/test_reference.py +++ b/fsspec/implementations/tests/test_reference.py @@ -513,6 +513,35 @@ def test_cat_file_ranges(m): assert fs.cat_file("d", 1, -3) == other[4:10][1:-3] +@pytest.mark.asyncio +async def test_async_cat_file_ranges(): + fsspec.get_filesystem_class("http").clear_instance_cache() + fss = fsspec.filesystem("https", asynchronous=True) + session = await fss.set_session() + + fs = fsspec.filesystem( + "reference", + fo={ + "version": 1, + "refs": { + "reference_time/0": [ + "https://noaa-nwm-retro-v2-0-pds.s3.amazonaws.com/full_physics/2017/201704010000.CHRTOUT_DOMAIN1.comp", + 39783, + 12, + ], + }, + }, + fs={"https": fss}, + remote_protocol="https", + asynchronous=True, + ) + + assert ( + await fs._cat_file("reference_time/0") == b"x^K0\xa9d\x04\x00\x03\x13\x01\x0f" + ) + await session.close() + + @pytest.mark.parametrize( "fo", [