daisy / pipeline-ui

A user interface for the DAISY Pipeline 2
MIT License
6 stars 2 forks source link

Optional inputs are not supported #48

Closed bertfrees closed 1 year ago

bertfrees commented 1 year ago

An optional input is an input that is defined in XProc as a <p:input sequence="false"> but with a default inline binding, e.g.:

<p:input port="tts-config" px:media-type="application/vnd.pipeline.tts-config+xml">
  <p:inline><d:config/></p:inline>
</p:input>

The "DTBook to EPUB 3" script has such an input.

This is how the web service presents the input:

<input desc="Configuration file for the text-to-speech. [...]"
       mediaType="application/vnd.pipeline.tts-config+xml"
       name="tts-config"
       nicename="Text-to-speech configuration file"
       required="false"
       sequence="false"/>
marisademeglio commented 1 year ago

What do you see and what do you expect instead? I see this, which gives me an input field for the TTS config file:

Screenshot 2022-12-13 at 09 11 48
bertfrees commented 1 year ago

The problem becomes clear when you submit a job with all the options left unchanged (so the TTS configuration field is empty). The engine will choke.

bertfrees commented 1 year ago

Perhaps all inputs are specified in the job request XML, also those that are not required and not specified in the UI?

marisademeglio commented 1 year ago

So the problem happens after the job has been submitted?

Does the web service handle blank inputs gracefully or does it just try to process everything?

bertfrees commented 1 year ago

It might try to process everything, also blank inputs. However that doesn't seem to be the problem here. This is the XML that is sent by the UI:

<jobRequest xmlns="http://www.daisy.org/ns/pipeline/data">
    <nicename>DTBook to DAISY 3</nicename>
    <priority>medium</priority>
    <script href="http://127.0.0.1:49152/ws/scripts/dtbook-to-daisy3"/>
    <input name="tts-config">
      <item value="null"/>
   </input>
   <input name="source">
      <item value="file:///Users/bert/src/github/daisy/pipeline-samples/dtbook/hauy_valid.xml"/>
   </input>
    <option name="include-tts-log">false</option>
   <option name="publisher">null</option>
   <option name="audio">false</option>
   <option name="with-text">true</option>
   <option name="word-detection">true</option>
  </jobRequest>

(Notice the null.)

So this issue seems very related to https://github.com/daisy/pipeline-ui/issues/47.

marisademeglio commented 1 year ago

Ok I'm finding that job requests with 'null' or blank values cause the engine to choke, e.g. this gets immediately rejected as a bad request:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <jobRequest xmlns="http://www.daisy.org/ns/pipeline/data">
    <nicename>DTBook to EPUB 3</nicename>
    <priority>medium</priority>
    <script href="http://127.0.0.1:49152/ws/scripts/dtbook-to-epub3"/>
    <input name="tts-config">
        <item value=""/>
    </input>
    <input name="source">
          <item value="file:///Users/marisa/dev/accessible-books-in-browsers/experiments/content-from-bangladesh/AmarBanglaBoiClass5DaisyMultimedia/dtbook.xml"/>
    </input>
    <option name="language"></option>
    <option name="assert-valid">true</option>
    <option name="chunk-size">-1</option>
    <option name="audio">false</option>
  </jobRequest>

The engine accepts this though, where the empty/null values have been pre-filtered out:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <jobRequest xmlns="http://www.daisy.org/ns/pipeline/data">
    <nicename>DTBook to EPUB 3</nicename>
    <priority>medium</priority>
    <script href="http://127.0.0.1:49152/ws/scripts/dtbook-to-epub3"/>
    <input name="source">
     <item value="file:///Users/marisa/dev/accessible-books-in-browsers/experiments/content-from-bangladesh/AmarBanglaBoiClass5DaisyMultimedia/dtbook.xml"/>
    </input>
    <option name="assert-valid">true</option>
    <option name="chunk-size">-1</option>
    <option name="audio">false</option>
  </jobRequest>
bertfrees commented 1 year ago

Right. This is the expected behavior. Including an input item means adding a document to the sequence. Including an option means binding a value to the option. Non-required inputs/options may have 0 or 1 values. A string value may also be "null" and even "" (blank). A file value may also be the file "null".

The API could be made more forgiving when it comes to files: file names can never be empty so these could automatically be filtered out.