Skip to content

autotune fails if any day in a range has no readings #1454

@Jackenmen

Description

@Jackenmen

Describe the bug
When trying to run on a date range with one of the days not having any readings, autotune crashes on that day:

Query: https://ns.fly.dev entries/sgv.json find%5Bdate%5D%5B%24gte%5D=1689213600000&find%5Bdate%5D%5B%24lte%5D=1689300000000&count=1500
-rw-rw-r-- 1 ubuntu ubuntu 3 Aug 12 06:46 ns-entries.2023-07-13.json
Query: https://ns.fly.dev treatments.json find%5Bcreated_at%5D%5B%24gte%5D=2023-07-12T06:00+02:00&find%5Bcreated_at%5D%5B%24lte%5D=2023-07-14T18:00+02:00
-rw-rw-r-- 1 ubuntu ubuntu 45422 Aug 12 06:46 ns-treatments.2023-07-13.json
oref0-autotune-prep   ns-treatments.2023-07-13.json profile.json ns-entries.2023-07-13.json profile.pump.json > autotune.2023-07-13.json
undefined:1
undefined
^

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at categorizeBGDatums (/home/ubuntu/.npm-packages/lib/node_modules/oref0/lib/autotune-prep/categorize.js:75:28)
    at generate (/home/ubuntu/.npm-packages/lib/node_modules/oref0/lib/autotune-prep/index.js:23:30)
    at Object.<anonymous> (/home/ubuntu/.npm-packages/lib/node_modules/oref0/bin/oref0-autotune-prep.js:135:27)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47
Could not run oref0-autotune-prep ns-treatments.2023-07-13.json profile.json ns-entries.2023-07-13.json

To Reproduce

  1. Find a date in NS during which you had no sensor readings. If you don't have any, perhaps try a date before you started using Nightscout?
  2. Run autotune per the "Run via a cloud-based virtual machine" instructions from https://openaps.readthedocs.io/en/latest/docs/Customize-Iterate/autotune.html#phase-c-running-autotune-for-suggested-adjustments-without-an-openaps-rig
    • More specifically, I ran (with different secret and URL):
      API_SECRET=secret LC_ALL=en_US.UTF-8 oref0-autotune --dir=~/work/openaps-autotune --ns-host=https://ns.fly.dev/ --start-date=2023-07-03
      

Expected behavior
I would expect no errors and autotune just adding that day to the "Days Missing" column.

Setup Information (please complete the following information):

  • oref0 version (e.g. oref0 0.6.2 master, or 0.7.0-dev): oref0@0.7.1 installed from npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions