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

Import from Strava export fails on manual activities #133

Closed p3dda closed 3 months ago

p3dda commented 3 months ago

On manual recorded activities (without .gpx / .fit file), the import from API fails with an exception, because "Filename" is not set in the activities.csv. In this case, row["Filename"] is type float and value NaN.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/geo_activity_playground/__main__.py", line 118, in <module>
    main()
  File "/app/geo_activity_playground/__main__.py", line 93, in main
    options.func(options)
  File "/app/geo_activity_playground/__main__.py", line 67, in <lambda>
    *make_activity_repository(options.basedir, options.skip_strava),
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/geo_activity_playground/__main__.py", line 112, in make_activity_repository
    scan_for_activities(repository, tile_visit_accessor, config, skip_strava)
  File "/app/geo_activity_playground/webui/upload/controller.py", line 103, in scan_for_activities
    import_from_strava_checkout(repository)
  File "/app/geo_activity_playground/importers/strava_checkout.py", line 169, in import_from_strava_checkout
    activity_file = checkout_path / row["Filename"]
                    ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'PosixPath' and 'float'

This would suggest to check this and skip the import of this activity.

if row["Filename"] is np.nan:
    logger.debug(f"Skipping activity {activity_id} without file.")
    continue
martin-ueding commented 3 months ago

Sounds like a good fix, I've added it. Thanks!