dataforgoodfr / 12_bloom

23 stars 11 forks source link

[ETL] fix clean_positions #280

Open marthevienne opened 22 hours ago

marthevienne commented 22 hours ago

Hello, J'ai l'erreur suivante : (.venv) (base) ➜ 12_bloom git:(main) python3 -m bloom.tasks.clean_positions [bloom INFO @ 14:03:04] DEBUT - Nettoyage des positions [bloom INFO @ 14:03:04] Lecture des nouvelles positions de Spire en base [bloom INFO @ 14:03:05] Traitement des positions entre le 2024-11-21 10:15:02.810009+00:00 et le 2024-11-21 13:00:03.247710+00:00 [bloom INFO @ 14:03:05] 16038 nouvelles positions de Spire [bloom ERROR @ 14:03:16] Session rollback because of exception Traceback (most recent call last): File "/Users/marthevienne/12_bloom/backend/bloom/infra/database/database_manager.py", line 32, in session yield session File "/Users/marthevienne/12_bloom/backend/bloom/tasks/clean_positions.py", line 89, in run last_segment = segment_repository.get_last_vessel_id_segments(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/bloom/infra/repositories/repository_segment.py", line 160, in get_last_vessel_id_segments df = pd.DataFrame(q, columns=["vessel_id", "excursion_id", "end_position", "timestamp_end", 'heading_at_end', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 867, in init mgr = ndarray_to_mgr( ^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/internals/construction.py", line 336, in ndarray_to_mgr _check_values_indices_shape_match(values, index, columns) File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/internals/construction.py", line 420, in _check_values_indices_shape_match raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}") ValueError: Shape of passed values is (1496, 1), indices imply (1496, 8) Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/Users/marthevienne/12_bloom/backend/bloom/tasks/clean_positions.py", line 182, in run(args.batch_time) File "/Users/marthevienne/12_bloom/backend/bloom/tasks/clean_positions.py", line 89, in run last_segment = segment_repository.get_last_vessel_id_segments(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/bloom/infra/repositories/repository_segment.py", line 160, in get_last_vessel_id_segments df = pd.DataFrame(q, columns=["vessel_id", "excursion_id", "end_position", "timestamp_end", 'heading_at_end', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 867, in init mgr = ndarray_to_mgr( ^^^^^^^^^^^^^^^ File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/internals/construction.py", line 336, in ndarray_to_mgr _check_values_indices_shape_match(values, index, columns) File "/Users/marthevienne/12_bloom/backend/.venv/lib/python3.11/site-packages/pandas/core/internals/construction.py", line 420, in _check_values_indices_shape_match raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}") ValueError: Shape of passed values is (1496, 1), indices imply (1496, 8)

marthevienne commented 22 hours ago

dans get_last_vessel_id_segments, il y a que la première colonne dans les résultats de la requête (sql_model.Vessel.id).

marthevienne commented 21 hours ago

C'est ici qu'il y a un problème dans main (à droite)

Capture d’écran 2024-11-21 à 2 32 25 PM