FNNDSC / ChRIS_ui

UI for ChRIS
MIT License
53 stars 115 forks source link

Export pipeline as JSON feature #267

Open jennydaman opened 3 years ago

jennydaman commented 3 years ago

Feed view should have a button "Export" which creates a JSON representation of the selected DS plugins as part of a reproducible workflow, aka pipeline. This JSON file can be uploaded to the ChRIS store via POST request. Example:

https://github.com/FNNDSC/CHRIS_docs/blob/master/pipelines/fetal_brain_reconstruction.sh

A corresponding feature in ChRIS_store_ui is supporting import of these JSON representations of pipelines. https://github.com/FNNDSC/ChRIS_store_ui/issues/224

There should already exist an API endpoint which, given a plugin instance ID, saves a snapshot of the plugin instance and its children as a pipeline. Essentially we just need to connect this endpoint to a button.

jennydaman commented 3 years ago

Ideas for iteration: MVP: select one plugin, it and all its children are saved as a plugin.

Reach goal: allow selection of multiple plugins, assert selections represent a DAG, and save that.

alsoarpit commented 2 years ago

@sonylomo still you are working on this if not can you pass this issue to me @jennydaman

jennydaman commented 2 years ago

@arpit-maurya glad to see you're willing to take this up!

The original issue proposed an export to JSON feature. If you would like to take it above-and-beyond, try YAML output instead. Schema: https://github.com/FNNDSC/CHRIS_docs/blob/master/rfcs/2-pipeline_yaml.adoc

I'm sure you'll have questions about the spec, so please message me on Matrix.

Anirudh4583 commented 2 years ago

@arpit-maurya can I assist with this issue in any way, please let me know.

oryxwhite commented 2 years ago

Hello @jennydaman, I'm an Outreachy intern candidate and was wondering if this would be a good issue to work on for my initial contribution.

jennydaman commented 2 years ago

@oryxwhite this would be a great issue, I have assigned you.

oryxwhite commented 2 years ago

@jennydaman could you point me towards the endpoint you mentioned that generates a snapshot of the plugin and its children? I've been looking through the API and haven't been able to find it.

jennydaman commented 2 years ago

@oryxwhite

POST /api/v1/pipelines/ HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate, br
Authorization: Basic Y2hyaXM6Y2hyaXMxMjM0
Connection: keep-alive
Content-Length: 36
Content-Type: application/json
Host: localhost:8000
User-Agent: xh/0.17.0

{
    "plugin_inst_id": "2",
    "name": "lol1"
}

HTTP/1.1 201 Created
Allow: GET, POST
Connection: Keep-Alive
Content-Length: 600
Content-Type: application/json
Cross-Origin-Opener-Policy: same-origin
Date: Thu, 17 Nov 2022 06:04:41 GMT
Keep-Alive: timeout=2, max=100
Location: http://localhost:8000/api/v1/pipelines/2/
Referrer-Policy: same-origin
Server: Apache
Vary: Accept,Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "url": "http://localhost:8000/api/v1/pipelines/2/",
    "id": 2,
    "name": "lol1",
    "locked": true,
    "authors": "",
    "category": "",
    "description": "",
    "owner_username": "chris",
    "creation_date": "2022-11-17T01:04:41.295425-05:00",
    "modification_date": "2022-11-17T01:04:41.295439-05:00",
    "plugins": "http://localhost:8000/api/v1/pipelines/2/plugins/",
    "plugin_pipings": "http://localhost:8000/api/v1/pipelines/2/pipings/",
    "default_parameters": "http://localhost:8000/api/v1/pipelines/2/parameters/",
    "instances": "http://localhost:8000/api/v1/pipelines/2/instances/",
    "workflows": "http://localhost:8000/api/v1/pipelines/2/workflows/"
}