Skip to content

Commit 0e8100b

Browse files
authored
Broaden pystac requirement and fix blob enumeration on empty path (#362)
* broaden pystac version * Fix blob enumeration * Try out noaa-hrrr * Revert "Try out noaa-hrrr" This reverts commit 191f9a3.
1 parent 006ab3c commit 0e8100b

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

pctasks/core/pctasks/core/storage/blob.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,20 @@ def _get_prefix_content(
515515
logger.info("Listing prefix=%s", full_prefix)
516516
folders = []
517517
files = []
518+
prefix_len = len(full_prefix) if full_prefix else 0
518519
for item in client.container.walk_blobs(name_starts_with=full_prefix):
519520
item_name: str = cast(str, item.name)
520-
name = os.path.relpath(item_name, full_prefix)
521+
# Use string slicing instead of os.path.relpath to extract
522+
# the name relative to the current prefix. walk_blobs
523+
# guarantees results start with full_prefix, so simple
524+
# slicing is correct and avoids os.path.relpath mis-handling
525+
# blob names that start with "/" (which produces "../../.."
526+
# relative paths on the filesystem).
527+
name = item_name[prefix_len:]
521528
if isinstance(item, BlobPrefix):
522-
folders.append(name.strip("/"))
529+
folder_name = name.strip("/")
530+
if folder_name:
531+
folders.append(folder_name)
523532
else:
524533
if item.size == 0:
525534
# ADLS Gen 2 creates empty files as directory placeholders.

pctasks/core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies = [
3737
"opencensus-ext-logging>=0.1.1",
3838
"orjson>=3.0.0,<4",
3939
"planetary-computer==1.0.0",
40-
"pystac==1.10.1",
40+
"pystac>=1.10.1",
4141
"pydantic>=2.0.0",
4242
"pydantic-settings>=2.0.0",
4343
"python-dateutil>=2.8.2,<2.9",

pctasks/ingest_task/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = [
3030
"pctasks.task @ {root:parent:uri}/task",
3131
"plpygis>=0.5.0",
3232
"pypgstac[psycopg]==0.9.6",
33-
"pystac==1.10.1",
33+
"pystac>=1.10.1",
3434
]
3535

3636
[project.optional-dependencies]

0 commit comments

Comments
 (0)