Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicdmt committed Jan 29, 2025
1 parent 8242764 commit e38dfa0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
with:
python-version: "3.10"
cache: "pip"
- name: Install GDAL
run: sudo apt-get update && sudo apt install postgresql-14 postgresql-14-postgis-3 postgresql-server-dev-14 python3-psycopg binutils libproj-dev gdal-bin
- name: Install python dependencies
run: pip install -r back/requirements.txt
- name: Install front js dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
load_geodataframe_from_db,
select_city,
)
from tqdm import tqdm


def compute_indice(tiles_id) -> None:
Expand Down Expand Up @@ -62,19 +63,23 @@ def compute_normalized_indice() -> None:
]

# Fetch in batches to avoid OOM issues
batch_size = 1e5
batch_size = int(1e5)
offset = 0
qs = Tile.objects.all()
while True:
print(f"Batch: {offset+1}")
tiles_batch = qs[offset : offset + batch_size]
if not tiles_batch:
break
Tile.objects.filter(id__in=[tile.id for tile in tiles_batch]).update(
plantability_normalized_indice=(F("plantability_indice") - min_indice)
/ (max_indice - min_indice)
)
offset += 1
total_batches = (len(qs) + batch_size - 1) // batch_size
with tqdm(total=total_batches, desc="Processing Batches") as pbar:
while True:
tiles_batch = qs[offset : offset + batch_size]
if not tiles_batch:
break
Tile.objects.filter(id__in=[tile.id for tile in tiles_batch]).update(
plantability_normalized_indice=(
F("plantability_indice") - min_indice
)
/ (max_indice - min_indice)
)
offset += 1
pbar.update(1)


class Command(BaseCommand):
Expand Down
5 changes: 5 additions & 0 deletions front/tests/empty.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test, expect } from 'vitest';

test('empty test', () => {
expect(true).toBe(true);
});

0 comments on commit e38dfa0

Please sign in to comment.