Skip to content

Commit 50f0015

Browse files
committed
feat: use obstore
1 parent 6df3f4c commit 50f0015

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies = [
88
"attr>=0.3.2",
99
"fastapi>=0.115.8",
1010
"geojson-pydantic>=1.2.0",
11+
"obstore>=0.6.0",
1112
"pydantic>=2.10.4",
1213
"pystac>=1.13.0",
1314
"rustac==0.7.0b3",

src/stac_fastapi/geoparquet/api.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import json
2+
import urllib.parse
23
from collections import defaultdict
34
from contextlib import asynccontextmanager
5+
from pathlib import Path
46
from typing import Any, AsyncIterator, TypedDict
57

8+
import obstore.store
69
import pystac.utils
710
from fastapi import FastAPI, HTTPException
811
from rustac import Collection, DuckdbClient
@@ -91,8 +94,16 @@ def create(
9194
)
9295

9396
if settings.stac_fastapi_collections_href:
94-
with open(settings.stac_fastapi_collections_href, "rb") as f:
95-
collections = json.load(f)
97+
if urllib.parse.urlparse(settings.stac_fastapi_collections_href).scheme:
98+
href = settings.stac_fastapi_collections_href
99+
else:
100+
href = "file://" + str(
101+
Path(settings.stac_fastapi_collections_href).absolute()
102+
)
103+
prefix, file_name = href.rsplit("/", 1)
104+
store = obstore.store.from_url(prefix)
105+
result = store.get(file_name)
106+
collections = json.loads(bytes(result.bytes()))
96107
else:
97108
collections = []
98109

uv.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)