FreeAndFair / OpenRLA

Free & Fair's open source RLA support software.
Other
4 stars 3 forks source link

Test statistic not changing, error: Prelude.foldr1: empty list #61

Closed nealmcb closed 7 years ago

nealmcb commented 7 years ago

No idea what this means. I think I defined everything right, but while auditing, I see no progress in the Test statistic (which remains "1"), and see this for most every ballot audited in the stdout:

Prelude.foldr1: empty list

e.g.

GET /audit/active
  Accept: */*
  Status: 200 OK 0.000368s
Prelude.foldr1: empty list
GET /audit/active
  Accept: */*
  Status: 200 OK 0.001233s
Prelude.foldr1: empty list
GET /audit/active
  Accept: */*
  Status: 200 OK 0.000332s
Prelude.foldr1: empty list
POST /audit/1/marks
  Request Body: {"ballotId":7723,"marks":[{"contestId":1006,"candidateId":51},{"contestId":1008,"candidateId":55}]}
  Accept: */*
  Status: 200 OK 0.951436s
GET /audit/1/marks
  Accept: */*
  Status: 200 OK 0.000378s
GET /audit/1/sample
  Accept: */*
  Status: 200 OK 0.000715s
GET /audit/active
  Accept: */*
  Status: 200 OK 0.001902s
Prelude.foldr1: empty list
ranweiler commented 7 years ago

@nealmcb, what do you see if you do (with jq in your path):

curl -XGET "http://localhost:8080/election/1/outcome" 2>/dev/null | jq

Incidentally, this is a useful little script for poking at backend URLs:

#!/usr/bin/env bash
path="${1}"
shift
curl -XGET "http://localhost:8080${path}" 2>/dev/null | jq "${@}"

If it is in your path as e.g. rla-get, then you can do: rla-get /election/1/outcome.

nealmcb commented 7 years ago

Ahh - nice script! Now I just need to know the API for the server!

$ rla-get /election/1/outcome
[
  {
    "shares": [
      {
        "id": 51,
        "share": 0.8
      },
      {
        "id": 52,
        "share": 0.2
      }
    ],
    "id": 1006
  },
  {
    "shares": [
      {
        "id": 53,
        "share": 0.2
      },
      {
        "id": 54,
        "share": 0.8
      }
    ],
    "id": 1007
  }
]
nealmcb commented 7 years ago

Oh, and I think you want a "." after jq in your script.

ranweiler commented 7 years ago

@nealmcb just added issue #62 for backend API documentation. In the meantime, you can at least see what all the routes are in this file: https://github.com/FreeAndFair/OpenRLA/blob/workflow-assistant/openrla-assistant/backend/src/OpenRLA.hs

(re the script, I'm not assuming a filter, but intentionally passing all the remaining args to jq so you can give it other opt args, e.g. rla-get /election/1/outcome '.[0]' -c)

ranweiler commented 7 years ago

@nealmcb hm, your JSON response looks right. I'm suspecting some sort of upload error. If you want to send me the application database out of band, I'll poke around some more!

ranweiler commented 7 years ago

Closing this unless it occurs again and we can repro. The need for better error handling overall is filed in #6.

nealmcb commented 7 years ago

Makes sense. For future reference, can you document here the best way to "send me the application database out of band"? Exactly what files are needed? Should we perhaps provide a make target for collecting that and any other evidence or logs?

ranweiler commented 7 years ago

You bet!

In this case, all I would've wanted is the underlying SQLite database. This lives in the application "data directory". Currently, that is just a subdirectory of the executable's directory. Concretely, when you run make run, the file will be called openrla.db. If $BACKEND is the backend subdirectory of the repo on your machine, then the path will be something like (on my system):

${BACKEND}/.stack-work/install/x86_64-osx/lts-7.16/8.0.1/bin/data

To figure this out programmatically, if you are in the backend dir of the repo, you can compute the data dir and backend database path like so:

DATA_DIR="$(stack path --local-install-root)/bin/data"
DB_PATH="${DATA_DIR}/openrla.db"