Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 65e0f4c5f0 | |||
| bc7652f336 | |||
| 188383a882 | |||
| 7f3a0bcb21 | |||
| 3270abb7f6 | |||
| 2eb984a95f | |||
| 776126a481 | |||
| 59abf35a12 | |||
| a40eb64245 | |||
| acae1517cb | |||
| 9a9decde6e | |||
| a1ae962c73 | |||
| 0404aa0973 | |||
| effe01dedf | |||
| 816d0de324 | |||
| 90e9bc3c8c |
@@ -0,0 +1,29 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Sequence of patterns matched against refs/tags
|
||||||
|
tags:
|
||||||
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
|
name: Auto-release d'un tag
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: auto-release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Get tag message
|
||||||
|
run: echo "TAG_MESSAGE=`git show ${{ github.ref_name }} | grep '^\- '`" >> "$GITHUB_ENV"
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||||
|
TAG_MESSAGE: ${{ env.TAG_MESSAGE }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: ${{ github.ref_name }}
|
||||||
|
body: ${{ env.TAG_MESSAGE }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# decp.info
|
# decp.info
|
||||||
|
|
||||||
> v2.1.2
|
> v2.1.4
|
||||||
|
|
||||||
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
||||||
|
|
||||||
@@ -38,6 +38,21 @@ Ne pas oublier de mettre à jour les fichier .env.
|
|||||||
|
|
||||||
## Notes de version
|
## Notes de version
|
||||||
|
|
||||||
|
##### 2.1.5 (10 octobre 2025)
|
||||||
|
|
||||||
|
- réparation des filtres (notamment < > sur les montants)
|
||||||
|
- remplacement des valeurs "null" dans les tableaux par des cellules vides
|
||||||
|
|
||||||
|
##### 2.1.4 (8 octobre 2025)
|
||||||
|
|
||||||
|
- possibilité de filtrer sur le champ "Source"
|
||||||
|
- création automatique d'une release Github quand je push un tag
|
||||||
|
|
||||||
|
##### 2.1.3 (4 octobre 2025)
|
||||||
|
|
||||||
|
- tentative d'auto-release à chaque création de tag git
|
||||||
|
- adaptation au format TableSchema
|
||||||
|
|
||||||
##### 2.1.2 (3 octobre 2025)
|
##### 2.1.2 (3 octobre 2025)
|
||||||
|
|
||||||
- dataframe global plutôt que lazyframe, pour plus de résilience et charger toutes les données en mémoire
|
- dataframe global plutôt que lazyframe, pour plus de résilience et charger toutes les données en mémoire
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "decp.info"
|
name = "decp.info"
|
||||||
description = "Interface d'exploration et d'analyse des marchés publics français."
|
description = "Interface d'exploration et d'analyse des marchés publics français."
|
||||||
version = "2.1.2"
|
version = "2.1.5"
|
||||||
requires-python = ">= 3.10"
|
requires-python = ">= 3.10"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
|
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 333 KiB |
@@ -175,7 +175,6 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
|
|||||||
acheteur_siret = url.split("/")[-1]
|
acheteur_siret = url.split("/")[-1]
|
||||||
lff = df.lazy()
|
lff = df.lazy()
|
||||||
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||||
lff = lff.fill_null("")
|
|
||||||
lff = lff.select(
|
lff = lff.select(
|
||||||
"id",
|
"id",
|
||||||
"uid",
|
"uid",
|
||||||
@@ -204,6 +203,8 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
|
|||||||
)
|
)
|
||||||
def get_last_marches_table(data) -> html.Div:
|
def get_last_marches_table(data) -> html.Div:
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
dff = dff.fill_null("")
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
columns, tooltip = setup_table_columns(
|
columns, tooltip = setup_table_columns(
|
||||||
dff,
|
dff,
|
||||||
|
|||||||
+2
-1
@@ -93,7 +93,8 @@ def get_marche_data(url) -> tuple[dict, list]:
|
|||||||
def update_marche_info(marche, titulaires):
|
def update_marche_info(marche, titulaires):
|
||||||
def make_parameter(col):
|
def make_parameter(col):
|
||||||
column_object = data_schema.get(col)
|
column_object = data_schema.get(col)
|
||||||
column_name = column_object.get("friendly_name") if column_object else col
|
print(column_object)
|
||||||
|
column_name = column_object.get("title") if column_object else col
|
||||||
|
|
||||||
if marche[col]:
|
if marche[col]:
|
||||||
if col == "acheteur_nom":
|
if col == "acheteur_nom":
|
||||||
|
|||||||
@@ -182,9 +182,6 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
if len(sort_by) > 0:
|
if len(sort_by) > 0:
|
||||||
lff = sort_table_data(lff, sort_by)
|
lff = sort_table_data(lff, sort_by)
|
||||||
|
|
||||||
# Remplace les strings null par "", mais pas les numeric null
|
|
||||||
lff = lff.fill_null("")
|
|
||||||
|
|
||||||
# Matérialisation des filtres
|
# Matérialisation des filtres
|
||||||
dff: pl.DataFrame = lff.collect()
|
dff: pl.DataFrame = lff.collect()
|
||||||
|
|
||||||
@@ -196,6 +193,12 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
# end_row = (page_current + 1) * page_size
|
# end_row = (page_current + 1) * page_size
|
||||||
dff = dff.slice(start_row, page_size)
|
dff = dff.slice(start_row, page_size)
|
||||||
|
|
||||||
|
# Tout devient string
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
|
||||||
|
# Remplace les strings null par "", mais pas les numeric null
|
||||||
|
dff = dff.fill_null("")
|
||||||
|
|
||||||
# Ajout des liens vers l'annuaire des entreprises
|
# Ajout des liens vers l'annuaire des entreprises
|
||||||
dff = add_links(dff)
|
dff = add_links(dff)
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ def get_titulaire_marches_data(url, titulaire_year: str) -> list[dict]:
|
|||||||
(pl.col("titulaire_id") == titulaire_siret)
|
(pl.col("titulaire_id") == titulaire_siret)
|
||||||
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
||||||
)
|
)
|
||||||
lff = lff.fill_null("")
|
|
||||||
lff = lff.select(
|
lff = lff.select(
|
||||||
"id",
|
"id",
|
||||||
"uid",
|
"uid",
|
||||||
@@ -218,6 +217,8 @@ def get_last_marches_table(data) -> html.Div:
|
|||||||
]
|
]
|
||||||
|
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
dff = dff.fill_null("")
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
columns, tooltip = setup_table_columns(
|
columns, tooltip = setup_table_columns(
|
||||||
dff, hideable=False, exclude=["acheteur_id", "id"]
|
dff, hideable=False, exclude=["acheteur_id", "id"]
|
||||||
|
|||||||
+67
-31
@@ -43,9 +43,9 @@ def add_resource_link(dff: pl.DataFrame) -> pl.DataFrame:
|
|||||||
dff = dff.with_columns(
|
dff = dff.with_columns(
|
||||||
(
|
(
|
||||||
'<a href="' + pl.col("sourceFile") + '">' + pl.col("sourceDataset") + "</a>"
|
'<a href="' + pl.col("sourceFile") + '">' + pl.col("sourceDataset") + "</a>"
|
||||||
).alias("source")
|
).alias("sourceDataset")
|
||||||
)
|
)
|
||||||
dff = dff.drop(["sourceFile", "sourceDataset"])
|
dff = dff.drop(["sourceFile"])
|
||||||
return dff
|
return dff
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ def format_number(number) -> str:
|
|||||||
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
||||||
def format_function(expr, scale=None):
|
def format_function(expr, scale=None):
|
||||||
# https://stackoverflow.com/a/78636786
|
# https://stackoverflow.com/a/78636786
|
||||||
expr = expr.cast(pl.String).str.splitn(".", 2)
|
expr = expr.str.splitn(".", 2)
|
||||||
|
|
||||||
num = expr.struct[0]
|
num = expr.struct[0]
|
||||||
frac = expr.struct[1]
|
frac = expr.struct[1]
|
||||||
@@ -145,7 +145,13 @@ def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
|||||||
.otherwise(pl.lit(""))
|
.otherwise(pl.lit(""))
|
||||||
)
|
)
|
||||||
|
|
||||||
return num + frac + pl.lit(" €")
|
montant: pl.Expr = (
|
||||||
|
pl.when((num + frac) == pl.lit(""))
|
||||||
|
.then(pl.lit(""))
|
||||||
|
.otherwise(num + frac + pl.lit(" €"))
|
||||||
|
)
|
||||||
|
|
||||||
|
return montant
|
||||||
|
|
||||||
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
|
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
|
||||||
return dff
|
return dff
|
||||||
@@ -215,16 +221,26 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
|||||||
if debug:
|
if debug:
|
||||||
print("filter_value:", filter_value)
|
print("filter_value:", filter_value)
|
||||||
print("filter_value_type:", type(filter_value))
|
print("filter_value_type:", type(filter_value))
|
||||||
|
print("operator:", operator)
|
||||||
print("col_type:", col_type)
|
print("col_type:", col_type)
|
||||||
|
|
||||||
if col_type == "Date":
|
lff = lff.filter(pl.col(col_name).is_not_null())
|
||||||
# Convertir la colonne en chaînes de caractères
|
|
||||||
lff = dates_to_strings(lff, col_name)
|
|
||||||
|
|
||||||
if operator in ("<", "<=", ">", ">="):
|
if col_type == "Date":
|
||||||
lff = lff.filter(
|
# Convertir la colonne date en chaînes de caractères
|
||||||
pl.col(col_name).is_not_null() & (pl.col(col_name) != pl.lit(""))
|
lff = dates_to_strings(lff, col_name)
|
||||||
)
|
col_type = "String"
|
||||||
|
if col_type == "String":
|
||||||
|
lff = lff.filter(pl.col(col_name) != pl.lit(""))
|
||||||
|
|
||||||
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
|
try:
|
||||||
|
filter_value = int(filter_value)
|
||||||
|
except ValueError:
|
||||||
|
logger.error(f"Invalid numeric filter value: {filter_value}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if operator in ("contains", "<", "<=", ">", ">="):
|
||||||
if operator == "<":
|
if operator == "<":
|
||||||
lff = lff.filter(pl.col(col_name) < filter_value)
|
lff = lff.filter(pl.col(col_name) < filter_value)
|
||||||
elif operator == ">":
|
elif operator == ">":
|
||||||
@@ -233,17 +249,17 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
|||||||
lff = lff.filter(pl.col(col_name) >= filter_value)
|
lff = lff.filter(pl.col(col_name) >= filter_value)
|
||||||
elif operator == "<=":
|
elif operator == "<=":
|
||||||
lff = lff.filter(pl.col(col_name) <= filter_value)
|
lff = lff.filter(pl.col(col_name) <= filter_value)
|
||||||
|
elif operator == "contains":
|
||||||
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
if col_type in ["String", "Date"]:
|
||||||
try:
|
lff = lff.filter(
|
||||||
filter_value = int(filter_value)
|
pl.col(col_name).str.contains("(?i)" + filter_value)
|
||||||
except ValueError:
|
)
|
||||||
logger.error(f"Invalid numeric filter value: {filter_value}")
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
continue
|
lff = lff.filter(pl.col(col_name) == filter_value)
|
||||||
lff = lff.filter(pl.col(col_name) == filter_value)
|
else:
|
||||||
|
logger.error(f"Invalid column type: {col_type}")
|
||||||
elif operator == "contains" and col_type in ["String", "Date"]:
|
else:
|
||||||
lff = lff.filter(pl.col(col_name).str.contains("(?i)" + filter_value))
|
logger.error(f"Invalid operator: {operator}")
|
||||||
|
|
||||||
# elif operator == 'datestartswith':
|
# elif operator == 'datestartswith':
|
||||||
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
||||||
@@ -270,7 +286,7 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
continue
|
continue
|
||||||
column_object = data_schema.get(column_id)
|
column_object = data_schema.get(column_id)
|
||||||
if column_object:
|
if column_object:
|
||||||
column_name = column_object.get("friendly_name", column_id)
|
column_name = column_object.get("title", column_id)
|
||||||
else:
|
else:
|
||||||
column_name = column_id
|
column_name = column_id
|
||||||
|
|
||||||
@@ -286,7 +302,7 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
|
|
||||||
if column_object:
|
if column_object:
|
||||||
tooltip[column_id] = {
|
tooltip[column_id] = {
|
||||||
"value": f"""**{column_object.get("friendly_name")}** ({column_id})
|
"value": f"""**{column_object.get("title")}** ({column_id})
|
||||||
|
|
||||||
"""
|
"""
|
||||||
+ column_object["description"],
|
+ column_object["description"],
|
||||||
@@ -295,6 +311,32 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
return columns, tooltip
|
return columns, tooltip
|
||||||
|
|
||||||
|
|
||||||
|
def get_data_schema() -> dict:
|
||||||
|
# Récupération du schéma des données tabulaires
|
||||||
|
path = os.getenv("DATA_SCHEMA_PATH")
|
||||||
|
if path.startswith("http"):
|
||||||
|
original_schema: dict = get(
|
||||||
|
os.getenv("DATA_SCHEMA_PATH"), follow_redirects=True
|
||||||
|
).json()
|
||||||
|
elif os.path.exists(path):
|
||||||
|
with open(path) as f:
|
||||||
|
original_schema: dict = json.load(f)
|
||||||
|
else:
|
||||||
|
raise Exception(f"Chemin vers le schéma invalide: {path}")
|
||||||
|
|
||||||
|
new_schema = {}
|
||||||
|
|
||||||
|
for col in original_schema["fields"]:
|
||||||
|
new_schema[col["name"]] = col
|
||||||
|
|
||||||
|
new_schema["sourceDataset"] = {
|
||||||
|
"description": "Code de la source des données, avec un lien vers le fichier Open Data dont proviennent les données de ce marché public.",
|
||||||
|
"title": "Source des données",
|
||||||
|
"short_name": "Source",
|
||||||
|
}
|
||||||
|
return new_schema
|
||||||
|
|
||||||
|
|
||||||
df: pl.DataFrame = get_decp_data()
|
df: pl.DataFrame = get_decp_data()
|
||||||
departements = get_departements()
|
departements = get_departements()
|
||||||
domain_name = (
|
domain_name = (
|
||||||
@@ -308,10 +350,4 @@ meta_content = {
|
|||||||
"Pour une commande publique accessible à toutes et tous."
|
"Pour une commande publique accessible à toutes et tous."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
data_schema = get_data_schema()
|
||||||
# Récupération du schéma des données tabulaires
|
|
||||||
data_schema: dict = get(os.getenv("DATA_SCHEMA_PATH"), follow_redirects=True).json()
|
|
||||||
data_schema["source"] = {
|
|
||||||
"description": "Code de la source des données, avec un lien vers le fichier Open Data dont proviennent les données de ce marché public.",
|
|
||||||
"friendly_name": "Source des données",
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user