jwoglom / tconnectsync

Syncs data from Tandem Source (formerly t:connect) to Nightscout for the t:slim X2 and Mobi insulin pumps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

arrow.parser.ParserError: Could not match input '' to any of the following formats: ...

HockeyTrafalgar opened this issue · comments

2022-12-24 11:43:27 INFO     Enabled features: BASAL, BOLUS
Processing data between 2022-12-23 11:43:27.390603 and 2022-12-24 11:43:27.390603
2022-12-24 11:43:27 INFO     Downloading t:connect ControlIQ data
2022-12-24 11:43:27 INFO     Logging in to ControlIQApi...
2022-12-24 11:43:28 INFO     Reported tconnect software version: t:connect 7.14.0.1
2022-12-24 11:43:30 INFO     Logged in to ControlIQApi successfully (expiration: 2022-12-24T15:43:28.671Z, in 7 hours, 59 minutes)
2022-12-24 11:43:31 INFO     Downloading t:connect therapy_events
2022-12-24 11:43:33 INFO     Last CGM reading from t:connect CIQ: 2022-12-24T11:33:41+04:00 (9 minutes ago)
2022-12-24 11:43:33 INFO     Last bolus from t:connect CIQ: 2022-12-24T10:47:59 (in 3 hours, 4 minutes)
2022-12-24 11:43:34 INFO     Last basal event from CIQ: {'time': '2022-12-24 11:14:15+04:00', 'delivery_type': 'algorithmDelivery', 'duration_mins': 19.95, 'basal_rate': 0.55}
2022-12-24 11:43:34 INFO     Last Nightscout basal upload: 2022-12-24T06:49:16+00:00
2022-12-24 11:43:34 INFO       Processing basal: {'time': '2022-12-24 10:49:16+04:00', 'delivery_type': 'algorithmDelivery (control-iq suspension)', 'duration_mins': 19.983333333333334, 'basal_rate': 0.0} entry: {'eventType': 'Temp Basal', 'reason': 'algorithmDelivery (control-iq suspension)', 'duration': 19.983333333333334, 'absolute': 0.0, 'rate': 0.0, 'created_at': '2022-12-24 10:49:16+04:00', 'carbs': None, 'insulin': None, 'enteredBy': 'Pump (tconnectsync)'}
2022-12-24 11:43:34 INFO     Replacing last uploaded entry: {'_id': '63a6a172e9d972f0723eed1d', 'eventType': 'Temp Basal', 'reason': 'algorithmDelivery (control-iq suspension)', 'duration': 0, 'absolute': 0, 'rate': 0, 'created_at': '2022-12-24T06:49:16.000Z', 'enteredBy': 'Pump (tconnectsync)', 'utcOffset': 240, 'carbs': None, 'insulin': None}
2022-12-24 11:43:34 INFO       Processing basal: {'time': '2022-12-24 11:09:15+04:00', 'delivery_type': 'algorithmDelivery', 'duration_mins': 5.0, 'basal_rate': 0.11} entry: {'eventType': 'Temp Basal', 'reason': 'algorithmDelivery', 'duration': 5.0, 'absolute': 0.11, 'rate': 0.11, 'created_at': '2022-12-24 11:09:15+04:00', 'carbs': None, 'insulin': None, 'enteredBy': 'Pump (tconnectsync)'}
2022-12-24 11:43:34 INFO       Processing basal: {'time': '2022-12-24 11:14:15+04:00', 'delivery_type': 'algorithmDelivery', 'duration_mins': 19.95, 'basal_rate': 0.55} entry: {'eventType': 'Temp Basal', 'reason': 'algorithmDelivery', 'duration': 19.95, 'absolute': 0.55, 'rate': 0.55, 'created_at': '2022-12-24 11:14:15+04:00', 'carbs': None, 'insulin': None, 'enteredBy': 'Pump (tconnectsync)'}
2022-12-24 11:43:34 INFO     Processing ciqBolusData (18 entries)
Traceback (most recent call last):
  File "main.py", line 5, in <module>
    main()
  File "/home/ubuntu/tconnectsync/tconnectsync/__init__.py", line 91, in main
    added = process_time_range(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features)
  File "/home/ubuntu/tconnectsync/tconnectsync/process.py", line 167, in process_time_range
    bolusEvents = process_bolus_events(ciqBolusData, source="ciq")
  File "/home/ubuntu/tconnectsync/tconnectsync/sync/bolus.py", line 44, in process_bolus_events
    bolusEvents.sort(key=lambda event: arrow.get(event.request_time if not event.is_extended_bolus else event.bolex_start_time))
  File "/home/ubuntu/tconnectsync/tconnectsync/sync/bolus.py", line 44, in <lambda>
    bolusEvents.sort(key=lambda event: arrow.get(event.request_time if not event.is_extended_bolus else event.bolex_start_time))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/arrow/api.py", line 91, in get
    return _factory.get(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/arrow/factory.py", line 254, in get
    dt = parser.DateTimeParser(locale).parse_iso(arg, normalize_whitespace)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/arrow/parser.py", line 298, in parse_iso
    return self._parse_multiformat(datetime_string, formats)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/arrow/parser.py", line 727, in _parse_multiformat
    raise ParserError(
arrow.parser.ParserError: Could not match input '' to any of the following formats: YYYY-MM-DD, YYYY-M-DD, YYYY-M-D, YYYY/MM/DD, YYYY/M/DD, YYYY/M/D, YYYY.MM.DD, YYYY.M.DD, YYYY.M.D, YYYYMMDD, YYYY-DDDD, YYYYDDDD, YYYY-MM, YYYY/MM, YYYY.MM, YYYY, W.

I think the problem is I yesterday entered extended bolus and then cancelled it, so bolex_completion_time='', bolex_start_time=''. Here's what I see in the debugger:

(Pdb) l
 39  	            requested_at = parsed.request_time if not parsed.extended_bolus else parsed.bolex_start_time
 40  	            parsed.bg_type = guess_bolus_bg_type(parsed.bg, requested_at, cgmEvents)
 41
 42  	        bolusEvents.append(parsed)
 43
 44  ->	    bolusEvents.sort(key=lambda event: arrow.get(event.request_time if not event.is_extended_bolus else event.bolex_start_time))
 45
 46  	    return bolusEvents
 47
 48  	"""
 49  	Determine whether the given BG specified in the bolus is identical to the
(Pdb) print(event)
Bolus(description='Extended 50.00%/0.67 (User Aborted: requested 0 units)', complete='0', completion='User Aborted', request_time='2022-12-23 21:26:45+04:00', completion_time='2022-12-23 21:27:15+04:00', insulin='0.07', requested_insulin='0', carbs='10', bg='139', user_override='0', extended_bolus='1', bolex_completion_time='', bolex_start_time='')
(Pdb)


Thanks for the detailed report!

By any chance could you provide the raw data from tconnect so I can write a test case to cover this? That would be the variable b inside the loop through bolusdata in process_bolus_events in the same context as the print(event) you provided.

I released v0.8.9 with a prototype fix.