adamkewley / jobson

A platform for transforming command-line applications into a job service.
Apache License 2.0
256 stars 20 forks source link

Support for arbitrary file uploads #60

Closed adamkewley closed 4 years ago

adamkewley commented 4 years ago

Asked for via email by a software developer who wants to use jobson to make a web interface for a bioinformatics tool.

Things needed (+ engineering considerations):

Rough Tasklist

adamkewley commented 4 years ago

Alright, so the first step of this feature is now in this PR. Video of it in action here:

https://youtu.be/3FsZkDN-OJs

Needs documenting, hardening, etc., but it seems to mostly be working. I can ship this intermediate product as an undocumented (and, therefore, not "officially" supported - yet) feature, because shipping new versions of Jobson is quite easy (usually automated by travis).

adamkewley commented 4 years ago

Jobson 1.0.9 now includes the file support as an undocumented-but-working feature:

https://github.com/adamkewley/jobson/releases

adamkewley commented 4 years ago

This PR now houses implementing file[] support, which I've mostly done in the backend now, but it needs a relevant renderer in the UI (if you try it now, the UI will complain that it doesn't know what a file[] is).

adamkewley commented 4 years ago

The latest commit now has both backend and UI support for the file[] type. This implementation is a bit rough-and-ready (time constraints) but does work, mostly. Key points:

{
    "spec": "specId",
    "inputs": {
        "inputId": [
            { "filename": "somefile.txt", "data": "<base64 string>" },
            { "filename": "someotherfile", "data": "<base 64 string>" }
        ]
    }
}

Backend accepts the JSON request and converts it (internally) back into a byte array + filename. Developers can then use toDir to put all of the files in into a single dir (duplicates are renamed accordingly):

# spec.yml

name: somespec
expectedInputs:
- id: filearray
  type: file[]
execution:
  application: echo
  arguments:
  - "${toDir(inputs.filearray)}"
  - "${inputs.filearray}"  # coerces into 'toDir(inputs.filearray)'

Which will give the runtime application a directory that it can then scan (e.g. with whatever directory listing function their language provides) to grab all inputs.

Things Missing

adamkewley commented 4 years ago

Even with those problems/limitations in mind, I still think it would be a good idea to ship this as an undocumented feature. It's probably better to try this out and get the ball rolling than me spending weeks dealing with all this extra stuff. For developers using Jobson in smaller, closed deployments (e.g. research groups). They'll appreciate a somewhat-working feature today more than a perfect feature in acouple of months' time.