Skip to content

Commit 8bf7314

Browse files
Merge pull request #28 from developmentseed/feature/new-range-parsing-logic
new log parsing logic
2 parents c689310 + 66b2b07 commit 8bf7314

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.16.0 (2025-04-30)
2+
3+
* new Range request parsing logic to make sure it works with S3 and HTTPS files
4+
15
## 0.15.0 (2025-02-27)
26

37
* add support for `VSIFile` backend (https://github.com/developmentseed/tilebench/pull/27)

tests/test_tilebench.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Test profiler with S3 and HTTPS files.
2+
3+
NOTE: while not in GDAL>=3.10 the number of GET/Head requests might not be right
4+
see: https://github.com/vincentsarago/vsifile/issues/13#issuecomment-2683310594
5+
6+
"""
7+
8+
import pytest
9+
from rio_tiler.io import Reader
10+
11+
from tilebench import profile as profiler
12+
13+
14+
@pytest.mark.parametrize(
15+
"src_path,head,get",
16+
[
17+
(
18+
"s3://sentinel-cogs/sentinel-s2-l2a-cogs/15/T/VK/2023/10/S2B_15TVK_20231008_0_L2A/TCI.tif",
19+
0,
20+
3,
21+
),
22+
(
23+
"https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/15/T/VK/2023/10/S2B_15TVK_20231008_0_L2A/TCI.tif",
24+
1,
25+
3,
26+
),
27+
],
28+
)
29+
@pytest.mark.xfail
30+
def test_profiler(src_path, head, get):
31+
"""Test profiler."""
32+
config = {
33+
"AWS_NO_SIGN_REQUEST": True,
34+
"AWS_DEFAULT_REGION": "us-west-2",
35+
"GDAL_DISABLE_READDIR_ON_OPEN": "EMPTY_DIR",
36+
}
37+
38+
@profiler(
39+
quiet=True,
40+
add_to_return=True,
41+
config=config,
42+
)
43+
def _read_tile(src_path: str, x: int, y: int, z: int, tilesize: int = 256):
44+
with Reader(src_path) as cog:
45+
return cog.tile(x, y, z, tilesize=tilesize)
46+
47+
(_, _), stats = _read_tile(src_path, 121, 185, 9)
48+
assert stats["HEAD"]["count"] == head
49+
assert stats["GET"]["count"] == get
50+
assert stats["GET"]["bytes"] == 386677

tilebench/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ def parse_rasterio_io_logs(logs: List[str]) -> Dict[str, Any]:
3030
# GET
3131
all_get_requests = len([line for line in logs if "CURL_INFO_HEADER_OUT: GET" in line])
3232

33-
get_requests = [line for line in logs if ": Downloading" in line]
33+
get_requests = [
34+
line for line in logs if "CURL_INFO_HEADER_IN: Content-Range: bytes" in line
35+
]
3436
get_values = [
35-
list(map(int, get.split(" Downloading ")[1].split(" ")[0].split("-")))
37+
list(
38+
map(
39+
int,
40+
get.split("CURL_INFO_HEADER_IN: Content-Range: bytes ")[1]
41+
.split("/")[0]
42+
.split("-"),
43+
)
44+
)
3645
for get in get_requests
3746
]
3847
get_values_str = [f"{start}-{end}" for (start, end) in get_values]

0 commit comments

Comments
 (0)