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
31 stars 13 forks source link

Summary page throws "KeyError: 'calories'" after migration to 0.24 #127

Closed ray66 closed 1 month ago

ray66 commented 2 months ago

After migration to 0.24.1everything seem working except http://localhost:5000/summary/ which shows a blank page and the following message in the terminal:

[2024-07-28 09:40:09,394] ERROR in app: Exception on /summary/ [GET]
Traceback (most recent call last):
  File "/home/user/.local/pipx/venvs/geo-activity-playground/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'calories'

I suspect this due to the fact that I have calories nowhere in ma activities.

ray66 commented 2 months ago

This error happens when metadata["calories"] and/or metadata["steps"] never get assigned a value. When I set both to 0 by default in core/activity_parsers.py::read_activity the summary page displays well.

martin-ueding commented 2 months ago

I think I what the issue is, I've set up a fix for 0.24.2.

antonmosich commented 2 months ago

The same problem also appears while generating the sharepics on the activity pages. https://github.com/martin-ueding/geo-activity-playground/blob/f893407be0fb33f5d006471f6c6ad750e5d13474/geo_activity_playground/webui/activity/controller.py#L457 This line is where it fails for me with a key error. Summary page works fine for me after the release of 0.24.2.

martin-ueding commented 1 month ago

Oh yes, I see the issue. I've fixed it and will upload it with the next release.