martin-ueding / geo-activity-playground

Data analysis and visualization based on GPS tracked outdoor activities.
https://martin-ueding.github.io/geo-activity-playground/
MIT License
35 stars 14 forks source link

Strava Checkout Import fails for activities without GPS data #144

Closed martin-ueding closed 3 months ago

martin-ueding commented 3 months ago

I was able to find one condition that crashes the import: Any activity that has no actual GPS data such as Pool Swimming. These activities have distance as a string (e.g. "2,000" for 2 km) and throw the following error message when importing:

Detect deleted activities: 0it [00:00, ?it/s]
Parse activity metadata: 0it [00:00, ?it/s]
Collate activity metadata: 0it [00:00, ?it/s]
Import from Strava export: 100%|███████████████████████████████████████████████████████| 23/23 [00:08<00:00,  2.80it/s]
Enrich new activity data:  35%|███████████████████▊                                     | 8/23 [00:00<00:00, 20.82it/s]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 116, in <module>
    main()
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 92, in main
    options.func(options)
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 66, in <lambda>
    *make_activity_repository(options.basedir, options.skip_strava),
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 110, in make_activity_repository
    scan_for_activities(repository, tile_visit_accessor, config, skip_strava)
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\webui\upload\controller.py", line 105, in scan_for_activities
    enrich_activities(config.get("kind", {}))
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\core\enrichment.py", line 60, in enrich_activities
    time_series = pd.read_parquet(extracted_time_series_path)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\io\parquet.py", line 667, in read_parquet
    return impl.read(
           ^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\io\parquet.py", line 267, in read
    path_or_handle, handles, filesystem = _get_path_or_handle(
                                          ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\io\parquet.py", line 140, in _get_path_or_handle
    handles = get_handle(
              ^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\io\common.py", line 882, in get_handle
    handle = open(handle, ioargs.mode)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'Cache\\Activity\\Extracted\\Time Series\\12037268733.parquet'

D:\Dokumente\GeoPlayground>pause
Drücken Sie eine beliebige Taste . . .

Originally posted by @eifelkiwi in https://github.com/martin-ueding/geo-activity-playground/issues/112#issuecomment-2275988965

martin-ueding commented 3 months ago

The distance string is not the problem. The issue is that I store the metadata before I check whether a time series exist. That used to be different, hence it is a bug now. I've fixed it in two ways: The metadata is saved only when a time series exists, that already rules out these activities. In the enrichment phase it will remove the intermediate metadata file if no matching time series is found. So it should cure the inconsistent state that you have and prevent it from happening again.