Skip to content

Commit e4ba6be

Browse files
committed
refactor: clean up imports and improve code readability across multiple files
1 parent b0941d3 commit e4ba6be

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/vresto/services/sentinel_stream.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
from __future__ import annotations
99

1010
import contextlib
11-
import hashlib
1211
import os
1312
import re
1413
import threading
1514
from pathlib import Path
16-
from typing import List, Optional, Tuple
15+
from typing import Optional
1716

18-
import numpy as np
1917
from loguru import logger
2018

2119
CDSE_S3_BUCKET = "eodata"
@@ -141,8 +139,6 @@ def get_quicklook_url(self, product_name: str) -> Optional[str]:
141139
"""
142140
# CDSE OData quicklook endpoint
143141
clean_name = product_name.replace(".SAFE", "")
144-
url = f"https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Name eq '{clean_name}.SAFE'&$expand=Assets"
145-
# For direct quicklook, use the standard pattern
146142
quicklook_url = f"https://catalogue.dataspace.copernicus.eu/odata/v1/Assets('{clean_name}.SAFE')/quicklook"
147143
return quicklook_url
148144

@@ -194,6 +190,7 @@ def find_tci_path_in_product(self, s3_path: str, tile_code: str) -> Optional[str
194190
"""
195191
try:
196192
import boto3
193+
197194
from vresto.api.config import CopernicusConfig
198195

199196
config = CopernicusConfig()

src/vresto/services/tiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _create_client(
229229

230230
def _shutdown_client_obj(self, name: str, client) -> None:
231231
"""Shut down a single client object (caller must have already removed from _clients)."""
232-
url = self._urls.pop(name, None)
232+
self._urls.pop(name, None)
233233
vrt = self._vrts.pop(name, None)
234234

235235
if client:

src/vresto/ui/widgets/map_search_tab.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
COLLECTION_PRODUCT_LEVELS,
1313
get_product_capabilities,
1414
)
15-
from vresto.services.mgrs_grid import compute_visible_tiles_geojson, is_available as mgrs_available
15+
from vresto.services.mgrs_grid import compute_visible_tiles_geojson
16+
from vresto.services.mgrs_grid import is_available as mgrs_available
1617
from vresto.services.sentinel_stream import sentinel_stream_service
1718
from vresto.services.tiles import tile_pool
1819
from vresto.ui.widgets.activity_log import ActivityLogWidget
@@ -245,7 +246,6 @@ async def _stream_tile(self, tile_code: str):
245246
if thumb_url and thumb_url.startswith("https://"):
246247
# Add as image overlay (approximation — use tile layer for now)
247248
self._add_message(f"🖼️ Loading quicklook for {tile_code}...")
248-
quicklook_shown = True
249249

250250
# Step 2: Stream full TCI in background
251251
self._add_message(f"📡 Streaming TCI for {tile_code} ({product.sensing_date})...")
@@ -329,9 +329,10 @@ async def _search_product_for_tile(self, tile_code: str) -> Optional[ProductInfo
329329
search_code = tile_code if tile_code.startswith("T") else f"T{tile_code}"
330330

331331
def _query():
332-
from vresto.api.auth import CopernicusAuth
333332
import requests
334333

334+
from vresto.api.auth import CopernicusAuth
335+
335336
config = CopernicusConfig()
336337
auth = CopernicusAuth(config=config)
337338
headers = auth.get_headers()

tests/test_services/test_tiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
22
import tempfile
3-
from unittest.mock import MagicMock, patch
3+
from unittest.mock import patch
44

55
import pytest
66
import rasterio
77

8-
from vresto.services.tiles import TileManager, TilePool, tile_pool
8+
from vresto.services.tiles import TileManager, TilePool
99

1010

1111
@pytest.fixture

0 commit comments

Comments
 (0)