-
Notifications
You must be signed in to change notification settings - Fork 100
5. ChRIS plugin geretrieve
This page describes interacting with the ChRIS Ultron Back End (CUBE) using pfurl
and running a DS
type plugin called pl-gererieve
. Essentially, pl-geretrieve
pulls data (in this case MRI image data) from the GE HealthCare Cloud.
Covered in this page are:
- Formulating a client-side request to run an instance of the plugin
- Checking on the result/status
- Checking on registered files
- Pulling a generated file to the client
The GE secrets key is not part of the repository. The plugin docker image needs to be built locally, with the key information manually added to the checked out source repository. See elsewhere for information on this.
You should set an environment variable, HOST_IP
to the IP of the actual host you are using. In Linux, this is
export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}')
At least one user with name/password combination as
-
chris
/chris1234
pfcon
pfioh
pman
Start CUBE from the repository source directory, running
*make*
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/ \
--quiet --jsonpprintindent 4
Look through the list for pl-geretrieve
. For example, let's say that this is located at
http://10.17.24.163:8000/api/v1/plugins/9/
we can call
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/9/ \
--quiet --jsonpprintindent 4
{
"collection": {
"href": "http://10.17.24.163:8000/api/v1/plugins/9/",
"links": [],
"version": "1.0",
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/9/",
"links": [
{
"rel": "parameters",
"href": "http://10.17.24.163:8000/api/v1/plugins/9/parameters/"
},
{
"rel": "instances",
"href": "http://10.17.24.163:8000/api/v1/plugins/9/instances/"
}
],
"data": [
{
"name": "name",
"value": "geretrieve"
},
{
"name": "dock_image",
"value": "local/pl-geretrieve"
},
{
"name": "type",
"value": "ds"
}
]
}
]
}
}
Follow the links provided to get information on the parameters for the plugin
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/9/parameters/ \
--quiet --jsonpprintindent 4
{
"collection": {
"href": "http://10.17.24.163:8000/api/v1/plugins/9/parameters/",
"links": [
{
"rel": "plugin",
"href": "http://10.17.24.163:8000/api/v1/plugins/9/"
}
],
"version": "1.0",
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/41/",
"links": [
{
"rel": "plugin",
"href": "http://10.17.24.163:8000/api/v1/plugins/9/"
}
],
"data": [
{
"name": "name",
"value": "prefix"
},
{
"name": "type",
"value": "string"
},
{
"name": "optional",
"value": true
},
{
"name": "default",
"value": ""
},
{
"name": "help",
"value": "retrieve directory/file with this prefix in ge"
}
]
}
]
}
}
Since this is a DS type plugin, it needs as a previous ID an already existing FS plugin generated Feed. For simplicity sake, we can just run a dummy pl-simplefsapp
plugin to generate a new blank feed.
pfurl --auth chris:chris1234 --verb POST \
--http ${HOST_IP}:8000/api/v1/plugins/1/instances/ \
--content-type application/vnd.collection+json --jsonwrapper 'template' \
--msg '{"data":
[{"name":"dir",
"value":"./"},
{"name":"previous",
"value":""}]
}' --quiet --jsonpprintindent 4
Wait until this plugin has finished and returns a finishedSuccessfully
status:
pfurl --auth chris:chris1234 \
--verb GET --http ${HOST_IP}:8000/api/v1/plugins/instances/1/ \
--content-type application/vnd.collection+json \
--quiet --jsonpprintindent 4
Now, assuming a successful FS call as above, and assuming this FS call was the first feed generated in the system, we can call the pl-geretrieve
plugin:
pfurl --auth chris:chris1234 --verb POST \
--http ${HOST_IP}:8000/api/v1/plugins/9/instances/ \
--content-type application/vnd.collection+json \
--jsonwrapper 'template' --msg '
{"data":
[{"name": "prefix", "value": "demo-upload/data/1033"},
{"name":"previous_id", "value":"1"} ]
}' --quiet --jsonpprintindent 4
{
"stdout": {
"collection": {
"href": "http://134.174.13.44:8000/api/v1/plugins/9/instances/",
"version": "1.0",
"links": [],
"items": [
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"data": [
{
"name": "id",
"value": 2
},
{
"name": "previous_id",
"value": 1
},
{
"name": "plugin_name",
"value": "geretrieve"
},
{
"name": "start_date",
"value": "2017-11-10T19:49:16.441820Z"
},
{
"name": "end_date",
"value": "2017-11-10T19:49:16.441865Z"
},
{
"name": "status",
"value": "started"
},
{
"name": "owner",
"value": "chris"
}
],
"links": [
{
"rel": "previous",
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/"
},
{
"rel": "plugin",
"href": "http://134.174.13.44:8000/api/v1/plugins/9/"
},
{
"rel": "string_param",
"href": "http://134.174.13.44:8000/api/v1/plugins/string-parameter/1/"
}
]
}
]
}
},
"msg": "push OK."
}
Examine the return JSON for the instance ID returned. In the above, we note that this is
{
"stdout": {
"collection": {
"version": "1.0",
"href": "http://10.17.24.163:8000/api/v1/plugins/4/instances/",
"links": [],
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
...
In other words, instance 2.
pfurl --auth chris:chris1234 \
--verb GET \
--http ${HOST_IP}:8000/api/v1/plugins/instances/2/ \
--content-type application/vnd.collection+json \
--quiet --jsonpprintindent 4
If the job is still running, we will receive a payload:
{
"collection": {
"links": [],
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"version": "1.0",
"items": [
{
"links": [
{
"rel": "previous",
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/"
},
{
"rel": "plugin",
"href": "http://134.174.13.44:8000/api/v1/plugins/9/"
},
{
"rel": "string_param",
"href": "http://134.174.13.44:8000/api/v1/plugins/string-parameter/1/"
}
],
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"data": [
{
"name": "id",
"value": 2
},
{
"name": "previous_id",
"value": 1
},
{
"name": "plugin_name",
"value": "geretrieve"
},
{
"name": "start_date",
"value": "2017-11-10T19:49:16.441820Z"
},
{
"name": "end_date",
"value": "2017-11-10T19:50:54.637311Z"
},
{
"name": "status",
"value": "finishedSuccessfully"
},
{
"name": "owner",
"value": "chris"
}
]
}
]
}
}
In which we see that the status is finishedSuccessfully. On first attempt at asking the status of a successfully completed job, CUBE might block for a second or two as it actually registers the files in its data base.
Finally, we can check the CUBE container space for the files returned from the query
dke chris_dev_backend
root@10bd34cb1dc2:/usr/src/chris_backend# cd /usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033/
root@10bd34cb1dc2:/usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033# ls
Axial_FLAIR-33_months-5 Axial_T2-33_months-4 Coronal_T2-33_months-6 Sagittal_T1-33_months-12
root@10bd34cb1dc2:/usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033#
where
dke ()
{
NAME=$1;
ID=$(dkl | grep $NAME | head -n 1 | awk '{print $1}');
docker exec -ti $ID /bin/bash
}
To access files from a client, determine the feed ID that is the root of this plugin. In this example case, this will be feed 1
assuming that the first action we ran was the pl-pacsquery
. In that status return call, we noted
{
"rel": "feed",
"href": "http://10.17.24.163:8000/api/v1/1/"
}
Access the references to registered files by calling http://10.17.24.163:8000/api/v1/1/ -- note that will return ALL the files down a plugin tree, paginated as indicated by the next
relationship:
pfurl --auth chris:chris1234 \
--verb GET \
--http ${HOST_IP}:8000/api/v1/1/files/ \
--content-type application/vnd.collection+json \
--quiet --jsonpprintindent 4
which should return
{
"collection": {
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/files/?limit=10&offset=10",
"rel": "next"
}
],
"href": "http://134.174.13.44:8000/api/v1/1/files/",
"items": [
{
"data": [
{
"name": "path",
"value": "/out.txt"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 1
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/1/out.txt",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/1/"
},
{
"data": [
{
"name": "path",
"value": "/input.meta.json"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 1
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/2/input.meta.json",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/2/"
},
{
"data": [
{
"name": "path",
"value": "/dummy.txt"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 1
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/3/dummy.txt",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/3/"
},
{
"data": [
{
"name": "path",
"value": "/output.meta.json"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 1
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/4/output.meta.json",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/4/"
},
{
"data": [
{
"name": "path",
"value": "/input.meta.json"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/5/input.meta.json",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/5/"
},
{
"data": [
{
"name": "path",
"value": "/output.meta.json"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/6/output.meta.json",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/6/"
},
{
"data": [
{
"name": "path",
"value": "/demo-upload/data/1033/Axial_T2-33_months-4/0018-1.2.840.113619.2.244.6945.200386.21925.1376394510.98.dcm"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/7/0018-1.2.840.113619.2.244.6945.200386.21925.1376394510.98.dcm",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/7/"
},
{
"data": [
{
"name": "path",
"value": "/demo-upload/data/1033/Axial_T2-33_months-4/0023-1.2.840.113619.2.244.6945.200386.21925.1376394510.103.dcm"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/8/0023-1.2.840.113619.2.244.6945.200386.21925.1376394510.103.dcm",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/8/"
},
{
"data": [
{
"name": "path",
"value": "/demo-upload/data/1033/Axial_T2-33_months-4/0022-1.2.840.113619.2.244.6945.200386.21925.1376394510.102.dcm"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/9/0022-1.2.840.113619.2.244.6945.200386.21925.1376394510.102.dcm",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/9/"
},
{
"data": [
{
"name": "path",
"value": "/demo-upload/data/1033/Axial_T2-33_months-4/0026-1.2.840.113619.2.244.6945.200386.21925.1376394510.106.dcm"
},
{
"name": "feed_id",
"value": 1
},
{
"name": "plugin_inst_id",
"value": 2
}
],
"links": [
{
"href": "http://134.174.13.44:8000/api/v1/files/10/0026-1.2.840.113619.2.244.6945.200386.21925.1376394510.106.dcm",
"rel": "file_resource"
},
{
"href": "http://134.174.13.44:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://134.174.13.44:8000/api/v1/plugins/instances/2/",
"rel": "plugin_inst"
}
],
"href": "http://134.174.13.44:8000/api/v1/files/10/"
}
],
"version": "1.0"
}
}
Use httpie to pull an actual file, using an href from the above return:
http -a chris:chris1234 --download http://134.174.13.44:8000/api/v1/files/10/0026-1.2.840.113619.2.244.6945.200386.21925.1376394510.106.dcm
--30--