-
Notifications
You must be signed in to change notification settings - Fork 51
Feature/collecte de plusieurs annees pour le dataset edc #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/collecte de plusieurs annees pour le dataset edc #9
Conversation
…ux_dataset_2024 to download_extract_insert_yearly_SISE_data
I've run the import over the several years without any issues. I understand your questions, particularly regarding resetting tables when launching with 'all' and the need to select the 'refresh_type' via CLI. Depending on what others think and your availability @moreaupascal56 , I could contribute to the few changes you suggested if needed. Nothing more to add from my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Pascal,
Merci pour ta contribution de qualité !
Je vais demander quelques changements, notamment sur le naming, autant faire des breaking changes tout de suite en début de projet.
- Renommons les tables... J'avais appelé ça SISE-Eaux, mais c'était trop approximatif. je te laisse lire le wiki/outline pour avoir tout le contexte, mais je pense que ce serait bien de nommer cette source "Eau distribuée par commune" et de préfixer le nom des tables par
edc_
. Je suis ouvert à d'autres propositions de nom/préfixe, mais ne gardons mon nom. - Renommons la colonne "annee_prelevement", c'est une colonne créée par nous data eng, pas par la source de donnée, on sait jamais, peut-être qu'il peut y avoir des relevés 2023 dans la source 2024... Donc nommons ça "partition" ou "pipeline_year_run" ou autre, ouvert encore une fois.
- Petit erreur de type sur
years_to_update = available_years[-1]
- Ca fail si on avait déjà build la database sur la version précédente. Peut-être qu'on corrige pas...
- Tu soulèves les limitations actuelles de ton travail, mais ça me gêne pas de merge tel quel. Peux-tu lister de nouvelles tâches pour plus tard ? (update cli to allow passing a param, really dropping the tables when full refresh). On va rajouter ces tâches dans notre backlog. Si tu veux le faire dans NocoDB directement, je peux te créer un accès (écris moi sur slack), sinon liste ça en commentaire et je ferrai un copier-coller.
ducoup dans les nouveaux changements:
J'ai créer deux tickets dans le Kanban pour améliorer ce script: build_database.py/ Ajouter une option pour faire un drop des tables |
Hello, top le code Pascal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo on filename and file is empty, add code or remove the notebook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @NicolasDuchenne,
Je me demande si peut être on devrait créer un folder pour le dataset edc, ce qui donnerait: tasks car Pour le README.md si ça va a tout le monde je l'updaterais (sic :p) une fois que le code sera prêt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est ok pour moi, on pourra restructurer le code avec des sous dossier si on ajoute des sources dans le futur
"communes": { | ||
"file_name_prefix": "DIS_COM_UDI_", | ||
"file_extension": ".txt", | ||
"table_name": "edc_communes", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comme tu renomme les tables, le notebook de test ne va plus fonctionner (analytics/notebooks/exemple.ipynb). Il faut mettre a jour le nom des tables dans le notebook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix dans le commit 5e901f8
5e901f8
* add fct get_yearly_dataset_infos * parametrize process_sise_eaux_dataset_2024 * recreate cache folder by default in clear_cache() * add check_table_existence function * parametrize process_sise_eaux_dataset_2024() * format _common.py * add process_sise_eaux_dataset() controller and rename process_sise_eaux_dataset_2024 to download_extract_insert_yearly_SISE_data * upd docstrings, formatting * upd logs and add a clear_cache() in process_sise_eaux_dataset * reorganize file * add notebook to preview data * fix Incompatible types in assignment * rename SISE to EDC * rename annee_prelevement to de_partition * catch and raise error if refresh_type not in the allowed values * format * fix typo * add _config_edc.py and use it accordingly * add de_ingestion_date * make refresh_type="last" as default * fix example notebooks with new sql table names * delete test_plusierus_annees.ipynb --------- Co-authored-by: Jeremy Greze <jereze@users.noreply.github.com>
Context
The original code was getting data only for the 2024 year, the goal is to get data from 2016 to 2024 and parametrize the year.
Changes
build_database.py
get_yearly_dataset_infos()
check_table_existence()
to check if a table exists in duckdb.process_sise_eaux_dataset_2024()
function (renamed todownload_extract_insert_yearly_SISE_data()
) in order to add a year parameter.To avoid duplicates I check if the table exists and if yes I insert data instead of create the table.
process_sise_eaux_dataset()
function as a controller ofdownload_extract_insert_yearly_SISE_data()
with refresh_type parameter._common.py
shutil.rmtree
drops the folder and all its children. Sometimes we just want to empty the folder.I will add explanations on the code below directly if needed.
Results
I have run this for the years 2016 to 2024:
I have run some checks:
Ideas
I have also some ideas but wants your opinion on them:
check_table_existence
to _common.pydownload_extract_insert_yearly_SISE_data
intodownload_extract_SISE_data
andinsert_SISE_data_to_duckdb
for a better readabilityrefresh_type = all
inprocess_sise_eaux_dataset()
should drop the tables entirely instead of deleting every year data.