Skip to content

Commit 1474e03

Browse files
feat: add requests and types-requests dependencies; refactor code for clarity
1 parent 717cdd9 commit 1474e03

File tree

8 files changed

+30
-14
lines changed

8 files changed

+30
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repos:
1313
exclude: ^(tests/.*|examples/.*|notebooks/.*)$
1414
additional_dependencies:
1515
- types-boto3
16+
- types-requests
1617
- pystac>=1.10.0
1718
- httpx>=0.27.0
1819

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ dependencies = [
3636
"morecantile>=5.0.0",
3737
"cf-xarray>=0.9.0",
3838
"eopf-geozarr @ git+https://github.com/EOPF-Explorer/data-model.git@new_s2",
39-
39+
"requests",
40+
4041
]
4142

4243
[dependency-groups]
@@ -45,6 +46,7 @@ dev = [
4546
"mypy>=1.11.0",
4647
"pre-commit>=3.7.0",
4748
"types-boto3>=1.0.2",
49+
"types-requests",
4850
]
4951
test = [
5052
"pytest>=9.0.1",

scripts/convert_v1_s2.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ def run_conversion(
113113
except Exception as e:
114114
logger.warning(f" ⚠️ Cleanup warning: {e}")
115115

116-
dask_client = setup_dask_cluster(
117-
enable_dask=use_dask_cluster, verbose=True
118-
)
116+
setup_dask_cluster(enable_dask=use_dask_cluster, verbose=True)
119117

120118
# Load input dataset
121119
logger.info(f"{' 📥 Loading input dataset '}{zarr_url}")

scripts/register_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def consolidate_reflectance_assets(item: Item, geozarr_url: str, s3_endpoint: st
294294
# Gather all reflectance bands from old-style assets
295295
for key, asset in list(item.assets.items()):
296296
# Extract band info from individual band assets (e.g., B01_20m, B02_10m)
297-
if key.startswith("B") and "_" in key and "reflectance" in asset.roles:
297+
if key.startswith("B") and "_" in key and asset.roles and "reflectance" in asset.roles:
298298
# Parse resolution from key (e.g., B01_20m -> 20m)
299299
parts = key.split("_")
300300
if len(parts) == 2:
@@ -386,7 +386,7 @@ def consolidate_reflectance_assets(item: Item, geozarr_url: str, s3_endpoint: st
386386
}
387387

388388
# Add extent if proj:bbox is available (assuming it's in projected coordinates)
389-
if len(proj_bbox) >= 4 and isinstance(proj_bbox[0], (int, float)):
389+
if len(proj_bbox) >= 4 and isinstance(proj_bbox[0], int | float):
390390
# proj:bbox might be in lat/lon, need to check if we have projected bbox
391391
# For now, we'll use proj:transform and proj:shape to compute extent
392392
proj_transform = item.properties.get("proj:transform")

submit_stac_items_notebook.ipynb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@
3838
"import json\n",
3939
"import os\n",
4040
"from pathlib import Path\n",
41-
"import requests\n",
42-
"\n",
4341
"\n",
4442
"import pandas as pd\n",
45-
"import pika\n",
43+
"import requests\n",
4644
"from pystac_client import Client\n",
4745
"\n",
4846
"# Try to load .env file if available\n",
@@ -428,7 +426,7 @@
428426
"search = catalog.search(\n",
429427
" collections=[source_collection],\n",
430428
" bbox=aoi_bbox,\n",
431-
" datetime=f\"{start_date}/{end_date}\" # Adjust as needed\n",
429+
" datetime=f\"{start_date}/{end_date}\", # Adjust as needed\n",
432430
")\n",
433431
"\n",
434432
"# Collect items paginated results\n",
@@ -491,7 +489,7 @@
491489
"\n",
492490
" # Publish message with simple http post request to localhost:12000/samples\n",
493491
" message = json.dumps(payload)\n",
494-
" response = requests.post(\n",
492+
" requests.post(\n",
495493
" \"http://localhost:12000/samples\",\n",
496494
" data=message,\n",
497495
" headers={\"Content-Type\": \"application/json\"},\n",

submit_test_workflow_wh.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python3
22
import json
3+
34
import requests
45

56
# Test item that was failing (same as before)
67
payload = {
78
"source_url": "https://stac.core.eopf.eodc.eu/collections/sentinel-2-l2a/items/S2C_MSIL2A_20251117T090251_N0511_R007_T35SMA_20251117T124014",
89
"collection": "sentinel-2-l2a-dp-test",
9-
"action": "convert-v1-s2-hp", # specify the action to use the S2 high-priority trigger
10+
"action": "convert-v1-s2-hp", # specify the action to use the S2 high-priority trigger
1011
}
1112

1213
# credentials = pika.PlainCredentials("user", os.getenv("RABBITMQ_PASSWORD"))

tests/test_consolidate_reflectance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def has_old_format_assets(item: Item) -> bool:
3838
and "_" in key
3939
and any(key.endswith(f"_{res}") for res in ["10m", "20m", "60m"])
4040
)
41-
for key in item.assets.keys()
41+
for key in item.assets
4242
)
4343

4444

@@ -78,7 +78,7 @@ def test_after_consolidation_no_old_format_assets(self, stac_item):
7878
)
7979

8080
# Verify no old-format assets remain
81-
for key in stac_item.assets.keys():
81+
for key in stac_item.assets:
8282
assert not key.startswith("SR_"), f"SR_ asset {key} should be removed"
8383
assert not (
8484
key.startswith("B")

uv.lock

Lines changed: 16 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)