Skip to content

Commit 8bbaedc

Browse files
authored
Merge pull request #162 from ColinMaudry/hotfix/2.6.3
Hotfix/2.6.3
2 parents 7b21aa6 + f2fcab9 commit 8bbaedc

5 files changed

Lines changed: 18 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 2.6.3 2025-12-16
2+
3+
- Téléchargement des ressources plus résilient aux erreurs ([tenacity](https://tenacity.readthedocs.io/en/latest/))
4+
- Téléchargement des données établissements plus résilient aux erreurs ([tenacity](https://tenacity.readthedocs.io/en/latest/))
5+
16
### 2.6.2 2025-12-15
27

38
- Réduction du nombre de tâches prefect pour réduire la charge sur la BDD et la latence

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DECP processing
22

3-
> version 2.6.2 ([notes de version](https://github.com/ColinMaudry/decp-processing/blob/main/CHANGELOG.md))
3+
> version 2.6.3 ([notes de version](https://github.com/ColinMaudry/decp-processing/blob/main/CHANGELOG.md))
44
55
Projet de traitement et de publication de meilleures données sur les marchés publics attribués en France. Vous pouvez consulter, filtrer et télécharger
66
ces données sur le site [decp.info](https://decp.info). Enfin la section [À propos](https://decp.info/a-propos) décrit les objectifs du projet et regroupe toutes les informations clés.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "decp-processing"
33
description = "Traitement des données des marchés publics français."
4-
version = "2.6.2"
4+
version = "2.6.3"
55
requires-python = ">= 3.9"
66
authors = [
77
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
File renamed without changes.

src/tasks/get.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
import ijson
1010
import orjson
1111
import polars as pl
12-
from httpx import Client, HTTPStatusError, TimeoutException, get
12+
from httpx import Client, get
1313
from lxml import etree, html
1414
from prefect.transactions import transaction
1515
from tenacity import (
1616
retry,
17-
retry_if_exception_type,
1817
stop_after_attempt,
1918
wait_exponential,
2019
)
@@ -44,16 +43,12 @@
4443
)
4544

4645

47-
@retry(
48-
stop=stop_after_attempt(3),
49-
wait=wait_exponential(multiplier=1, min=1, max=10),
50-
retry=retry_if_exception_type(httpx.HTTPError), # On ne retry que sur erreur http
51-
)
46+
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=1, max=20))
5247
def stream_get(url: str, chunk_size=1024**2): # chunk_size en octets (1 Mo par défaut)
5348
if url.startswith("http"):
5449
try:
5550
with HTTP_CLIENT.stream(
56-
"GET", url, headers=HTTP_HEADERS, follow_redirects=True
51+
"GET", url, headers=HTTP_HEADERS, follow_redirects=True, timeout=20
5752
) as response:
5853
yield from response.iter_bytes(chunk_size)
5954
except httpx.TooManyRedirects:
@@ -397,22 +392,19 @@ def get_etablissements() -> pl.LazyFrame:
397392
hrefs.append(base_url + href)
398393

399394
# Fonction de traitement pour un fichier
395+
@retry(
396+
stop=stop_after_attempt(4), wait=wait_exponential(multiplier=1, min=1, max=20)
397+
)
400398
def get_process_file(_href: str):
401-
print(_href.split("/")[-1])
402-
try:
403-
response = http_client.get(
404-
_href, headers=HTTP_HEADERS, timeout=20
405-
).raise_for_status()
406-
except (HTTPStatusError, TimeoutException) as err:
407-
print(err)
408-
print("Nouvel essai...")
409-
response = http_client.get(
410-
_href, headers=HTTP_HEADERS, timeout=20
411-
).raise_for_status()
399+
response = http_client.get(
400+
_href, headers=HTTP_HEADERS, timeout=30
401+
).raise_for_status()
412402

413403
content = response.content
414404
lff = pl.scan_csv(content, schema_overrides=schema)
415405
lff = lff.select(columns)
406+
print(_href.split("/")[-1], "OK")
407+
416408
return lff
417409

418410
# Traitement en parrallèle avec 8 threads

0 commit comments

Comments
 (0)