tcgoetz / GarminDB

Download and parse data from Garmin Connect or a Garmin watch, FitBit CSV, and MS Health CSV files into and analyze data in Sqlite serverless databases with Jupyter notebooks.
GNU General Public License v2.0
1.18k stars 142 forks source link

numerical error when generating graphs #44

Closed laurentperrinet closed 4 years ago

laurentperrinet commented 4 years ago

Hi,

love the possibility to generate graphs. I had the following error:

$ make graphs
/usr/local/bin/python3 graphs.py --all
(...)
  File "/Users/laurentperrinet/quantic/Documents/outdoor/GarminDB/HealthDB/summary_base.py", line 82, in intensity_time_goal_percent
    return (conversions.time_to_secs(self.intensity_time) * 100) / conversions.time_to_secs(self.intensity_time_goal)
ZeroDivisionError: division by zero
make: *** [graphs] Error 1

any idea? would be glad to test. cheers, Laurent

tcgoetz commented 4 years ago

Look's like you had no intensity time goal in your database. Update to latest and try again.

laurentperrinet commented 4 years ago

Still the same problem after doing

make update
make create_dbs

Should I create this "intensity time goal" somewhere?

tcgoetz commented 4 years ago

Can you post the error. I changed the code and the error should not look the same.

laurentperrinet commented 4 years ago

The error message goes like this:

$ make graphs
/usr/local/bin/python3 graphs.py --all
All:
2020-01-05 17:47:45.984 Python[14292:7006755] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "graphs.py", line 308, in <module>
    main(sys.argv[1:])
  File "graphs.py", line 295, in main
    graph.graph_activity('itime', itime_period, days)
  File "graphs.py", line 183, in graph_activity
    graph_func(time, data, period)
  File "graphs.py", line 155, in _graph_itime
    itime_goal_percent = [entry.intensity_time_goal_percent for entry in data]
  File "graphs.py", line 155, in <listcomp>
    itime_goal_percent = [entry.intensity_time_goal_percent for entry in data]
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/ext/hybrid.py", line 895, in __get__
    return self.fget(instance)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/HealthDB/summary_base.py", line 82, in intensity_time_goal_percent
    return (conversions.time_to_secs(self.intensity_time) * 100) / conversions.time_to_secs(self.intensity_time_goal)
ZeroDivisionError: division by zero
make: *** [graphs] Error 1

(I stand at commit d026a6562abc9cd677c1ebe4677c157ddd731bc1 )

laurentperrinet commented 4 years ago

I can now get to the secod graph but then with this error:

$ make graphs
/usr/local/bin/python3 graphs.py --all
All:
2020-01-07 23:07:41.460 Python[1822:177801] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "graphs.py", line 342, in <module>
    main(sys.argv[1:])
  File "graphs.py", line 332, in main
    graph.graph_activity('steps', steps_period, days)
  File "graphs.py", line 208, in graph_activity
    graph_func(time, data, period)
  File "graphs.py", line 170, in _graph_steps
    yrange_list = [(0, max(steps) * 1.1), (0, max(steps_goal_percent) * 2)]
TypeError: '>' not supported between instances of 'NoneType' and 'NoneType'
make: *** [graphs] Error 1

with an update producing this eror:

$ make
(...)
raceback (most recent call last):
  File "garmin.py", line 387, in <module>
    main(sys.argv[1:])
  File "garmin.py", line 377, in main
    import_data(debug, latest, weight, monitoring, sleep, rhr, activities, test)
  File "garmin.py", line 218, in import_data
    gfd.process_files(db_params_dict)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_data.py", line 54, in process_files
    fp.write_file(fit_file)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_file_processor.py", line 83, in write_file
    self.__write_message_types(fit_file, fit_file.message_types())
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_file_processor.py", line 71, in __write_message_types
    self.__write_message_type(fit_file, message_type)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_file_processor.py", line 57, in __write_message_type
    function(fit_file, message_type, messages)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_file_processor.py", line 46, in __write_generic
    function(fit_file, message_dict)
  File "/Users/lolo/quantic/Documents/outdoor/GarminDB/fit_file_processor.py", line 299, in _write_session_entry
    current.update_from_dict(activity, ignore_none=True, ignore_zero=True)
TypeError: update_from_dict() got an unexpected keyword argument 'ignore_zero'
       53.86 real        14.30 user         0.38 sys
make: *** [update_garmin] Error 1

(sorry I could not look more closely at this but just report)

tcgoetz commented 4 years ago

TypeError: update_from_dict() got an unexpected keyword argument 'ignore_zero'

Means that your utilities submodule is out of date. The top level repo is referencing code in utilities that you don't have yet.

What did you do to update your tree? Did you run make update?

tcgoetz commented 4 years ago

Do you have a intensity minutes goal on Garmin Connect? If you look at your DBs: garmin db table daily_summary does the column intensity_time_goal have data in it? Is it all Null? Is any of Null?

laurentperrinet commented 4 years ago

Works very fine with the latest ``make update'', thanks!