KSvend Claude Happy commited on
Commit ·
0dfd092
1
Parent(s): d75edf9
fix: resolve Python deprecation warnings in database and openeo_client
Browse filesReplace datetime.utcnow() with datetime.now(UTC) and bitwise ~bool
with == 0 comparison to silence warnings ahead of Python 3.16.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- app/database.py +5 -5
- app/openeo_client.py +4 -4
app/database.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
import json
|
| 4 |
import uuid
|
| 5 |
-
from datetime import datetime
|
| 6 |
|
| 7 |
import aiosqlite
|
| 8 |
|
|
@@ -48,7 +48,7 @@ class Database:
|
|
| 48 |
async def create_job(self, request: JobRequest) -> str:
|
| 49 |
await self._ensure_init()
|
| 50 |
job_id = uuid.uuid4().hex[:12]
|
| 51 |
-
now = datetime.
|
| 52 |
async with aiosqlite.connect(self.db_path) as db:
|
| 53 |
await db.execute(
|
| 54 |
"INSERT INTO jobs (id, request_json, status, created_at, updated_at, email) VALUES (?, ?, ?, ?, ?, ?)",
|
|
@@ -71,7 +71,7 @@ class Database:
|
|
| 71 |
self, job_id: str, status: JobStatus, error: str | None = None
|
| 72 |
) -> None:
|
| 73 |
await self._ensure_init()
|
| 74 |
-
now = datetime.
|
| 75 |
async with aiosqlite.connect(self.db_path) as db:
|
| 76 |
await db.execute(
|
| 77 |
"UPDATE jobs SET status = ?, error = ?, updated_at = ? WHERE id = ?",
|
|
@@ -83,7 +83,7 @@ class Database:
|
|
| 83 |
self, job_id: str, indicator_id: str, indicator_status: str
|
| 84 |
) -> None:
|
| 85 |
await self._ensure_init()
|
| 86 |
-
now = datetime.
|
| 87 |
async with aiosqlite.connect(self.db_path) as db:
|
| 88 |
cursor = await db.execute(
|
| 89 |
"SELECT progress_json FROM jobs WHERE id = ?", (job_id,)
|
|
@@ -99,7 +99,7 @@ class Database:
|
|
| 99 |
|
| 100 |
async def save_job_result(self, job_id: str, result: IndicatorResult) -> None:
|
| 101 |
await self._ensure_init()
|
| 102 |
-
now = datetime.
|
| 103 |
async with aiosqlite.connect(self.db_path) as db:
|
| 104 |
cursor = await db.execute(
|
| 105 |
"SELECT results_json FROM jobs WHERE id = ?", (job_id,)
|
|
|
|
| 2 |
|
| 3 |
import json
|
| 4 |
import uuid
|
| 5 |
+
from datetime import datetime, UTC
|
| 6 |
|
| 7 |
import aiosqlite
|
| 8 |
|
|
|
|
| 48 |
async def create_job(self, request: JobRequest) -> str:
|
| 49 |
await self._ensure_init()
|
| 50 |
job_id = uuid.uuid4().hex[:12]
|
| 51 |
+
now = datetime.now(UTC).isoformat()
|
| 52 |
async with aiosqlite.connect(self.db_path) as db:
|
| 53 |
await db.execute(
|
| 54 |
"INSERT INTO jobs (id, request_json, status, created_at, updated_at, email) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
|
| 71 |
self, job_id: str, status: JobStatus, error: str | None = None
|
| 72 |
) -> None:
|
| 73 |
await self._ensure_init()
|
| 74 |
+
now = datetime.now(UTC).isoformat()
|
| 75 |
async with aiosqlite.connect(self.db_path) as db:
|
| 76 |
await db.execute(
|
| 77 |
"UPDATE jobs SET status = ?, error = ?, updated_at = ? WHERE id = ?",
|
|
|
|
| 83 |
self, job_id: str, indicator_id: str, indicator_status: str
|
| 84 |
) -> None:
|
| 85 |
await self._ensure_init()
|
| 86 |
+
now = datetime.now(UTC).isoformat()
|
| 87 |
async with aiosqlite.connect(self.db_path) as db:
|
| 88 |
cursor = await db.execute(
|
| 89 |
"SELECT progress_json FROM jobs WHERE id = ?", (job_id,)
|
|
|
|
| 99 |
|
| 100 |
async def save_job_result(self, job_id: str, result: IndicatorResult) -> None:
|
| 101 |
await self._ensure_init()
|
| 102 |
+
now = datetime.now(UTC).isoformat()
|
| 103 |
async with aiosqlite.connect(self.db_path) as db:
|
| 104 |
cursor = await db.execute(
|
| 105 |
"SELECT results_json FROM jobs WHERE id = ?", (job_id,)
|
app/openeo_client.py
CHANGED
|
@@ -102,7 +102,7 @@ def build_ndvi_graph(
|
|
| 102 |
# Cloud mask: keep only vegetation, bare soil, water (SCL classes 4,5,6)
|
| 103 |
scl = cube.band("SCL")
|
| 104 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 105 |
-
cube = cube.mask(
|
| 106 |
|
| 107 |
# NDVI
|
| 108 |
b08 = cube.band("B08")
|
|
@@ -143,7 +143,7 @@ def build_true_color_graph(
|
|
| 143 |
# Cloud mask
|
| 144 |
scl = cube.band("SCL")
|
| 145 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 146 |
-
cube = cube.mask(
|
| 147 |
|
| 148 |
# Drop SCL, keep RGB
|
| 149 |
rgb = cube.filter_bands(["B02", "B03", "B04"])
|
|
@@ -179,7 +179,7 @@ def build_mndwi_graph(
|
|
| 179 |
|
| 180 |
scl = cube.band("SCL")
|
| 181 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 182 |
-
cube = cube.mask(
|
| 183 |
|
| 184 |
b03 = cube.band("B03")
|
| 185 |
b11 = cube.band("B11")
|
|
@@ -279,7 +279,7 @@ def build_buildup_graph(
|
|
| 279 |
# Cloud mask: keep only vegetation, bare soil, water (SCL classes 4,5,6)
|
| 280 |
scl = cube.band("SCL")
|
| 281 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 282 |
-
cube = cube.mask(
|
| 283 |
|
| 284 |
# NDBI = (SWIR - NIR) / (SWIR + NIR)
|
| 285 |
b11 = cube.band("B11")
|
|
|
|
| 102 |
# Cloud mask: keep only vegetation, bare soil, water (SCL classes 4,5,6)
|
| 103 |
scl = cube.band("SCL")
|
| 104 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 105 |
+
cube = cube.mask(cloud_mask == 0)
|
| 106 |
|
| 107 |
# NDVI
|
| 108 |
b08 = cube.band("B08")
|
|
|
|
| 143 |
# Cloud mask
|
| 144 |
scl = cube.band("SCL")
|
| 145 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 146 |
+
cube = cube.mask(cloud_mask == 0)
|
| 147 |
|
| 148 |
# Drop SCL, keep RGB
|
| 149 |
rgb = cube.filter_bands(["B02", "B03", "B04"])
|
|
|
|
| 179 |
|
| 180 |
scl = cube.band("SCL")
|
| 181 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 182 |
+
cube = cube.mask(cloud_mask == 0)
|
| 183 |
|
| 184 |
b03 = cube.band("B03")
|
| 185 |
b11 = cube.band("B11")
|
|
|
|
| 279 |
# Cloud mask: keep only vegetation, bare soil, water (SCL classes 4,5,6)
|
| 280 |
scl = cube.band("SCL")
|
| 281 |
cloud_mask = (scl == 4) | (scl == 5) | (scl == 6)
|
| 282 |
+
cube = cube.mask(cloud_mask == 0)
|
| 283 |
|
| 284 |
# NDBI = (SWIR - NIR) / (SWIR + NIR)
|
| 285 |
b11 = cube.band("B11")
|