hotg-ai / rune

Rune provides containers to encapsulate and deploy edgeML pipelines and applications
Apache License 2.0
136 stars 15 forks source link

Improve the quality of error messages displayed #294

Open Mohit0928 opened 3 years ago

Mohit0928 commented 3 years ago

I wrote a yml file for YAMNet (a deep net that predicts 521 audio events), but it is throwing this error.

Error: Unable to parse the Runefile

Caused by:
    data did not match any variant of untagged enum Stage

I got this error because I made an error in the "audio_float" section of the Runefile.yml. By mistake, I wrote "proc-model" instead of "proc-block". It would be better if we could improve the quality of errors displayed. It could have at least pointed to the section where I have made the error. It would help in tracing the error faster.

Model info:

Inputs:
        waveform: Float32[1]
Outputs:
        Identity: Float32[1, 521]
        Identity_1: Float32[1, 1024]
        Identity_2: Float32[1, 64]

Input: We can pass any variable size audio file as input. To keep it simple, I have decided to pass only 1-sec audio as input. Outputs: There will be 3 outputs. I only need 1st for my use case. Below is the Runefile.yml file that I wrote for this.

version: 1
image: runicos/base

pipeline:
  audio:
    capability: SOUND
    outputs:
      - type: I16
        dimensions: [1,16000]
    args:
      hz: 16000
      sample_duration_ms: 1000
  audio_float:
    proc-model: "hotg-ai/rune#proc-blocks/audio_float_conversion"
    inputs:
      - audio
    outputs:
      - type: F32
        dimensions: [1,16000]
  yamnet:
    model: "./model.tflite"
    inputs:
      - audio_float
    outputs:
      - type: F32
        dimensions: [1,521]
      - type: F32
        dimensions: [1,1024]
      - type: F32
        dimensions: [1,64]
  most_confident_index:
    proc-block: "hotg-ai/rune#proc-blocks/most_confident_indices"
    inputs:
      - yamnet.0
    outputs:
      - type: U32
        dimensions: [3]
    args:
      count: 3
  label:
    proc-block: "hotg-ai/rune#proc-blocks/label"
    inputs:
      - most_confident_index
    outputs:
      - type: UTF8
        dimensions: [3]
    args:
      labels:
        -  Speech
        -  Child speech, kid speaking
        -  Conversation
        -  Narration, monologue
        -  Babbling
        -  Speech synthesizer
      ..................
  serial:
    out: SERIAL
    inputs:
      - label
Michael-F-Bryan commented 3 years ago

This could end up being a massive pain to handle properly... The underlying problem is we are using serde and serde_yaml for deserializing, and "data did not match any variant of untagged enum XXX" is the hard-coded error message when it tries to deserialize an enum and someone didn't provide a model, output, proc-block, or capability key.

To make things more annoying, serde_yaml doesn't provide any way to capture the "span" of an element, so after deserializing an item we don't know which line it was on and therefore can't provide nice error messages pointing at the line to blame. I made a PR to give serde_yaml the ability to capture span information way back in May (https://github.com/dtolnay/serde-yaml/pull/201), but it seems like nobody has responded to it.