Skip to main content

(Python) client for the ChRIS API

Project description

A python client for the ChRIS API.

https://travis-ci.org/FNNDSC/python-chrisclient.svg?branch=master

Quick Overview

This repository contains various python scripts and modules that provide a rich client experience for interacting with a CUBE backend instance. Interaction is typically either via the command line interface (CLI) or directly in python using relevant modules.

Overview

At time of writing (early 2021), two scripts/modules are in production:

  • a plugin search utility

  • a plugin run schedule utility

Note that in the instructions below, the details of a CUBE instance are passed in a JSON structure using the --onCUBE flag. In many cases you might only want to pass the address of a CUBE instance. For this purpose, the --onCUBEaddress can be used that will only set the address and keep other default information intact.

Installation

Use the PyPI, Luke!

pip install -U python-chrisclient

Run

Plugins can be run/scheduled on a CUBE instance using the chrispl-run script. The CLI parameters are broadly similar to chrispl-search with some semantic changes more pertinent to the run call – the for search is fixed to the plugin id and the search --pluginSpec becomes the --using CLI.

Run Examples

Run an FS plugin, pl-mri10yr06mo01da_normal

chrispl-run --plugin name=pl-mri10yr06mo01da_normal \
            --onCUBE '{
                "protocol":     "http",
                "port":         "8000",
                "address":      "%HOSTIP",
                "user":         "chris",
                "password":     "chris1234"}'

This plugin does not require any specific CLI args when run in the default state. Once posted to CUBE, a string is returned to the shell:

(name=pl-mri10yr06mo01da_normal) id 14

Indicating that the plugin instance ID of the plugin in CUBE is 14 (for example).

For convenience, let’s set:

CUBE='{
    "protocol":     "http",
    "port":         "8000",
    "address":      "%HOSTIP",
    "user":         "chris",
    "password":     "chris1234"
}'

This return construct lends itself easily to scripting:

ROOTNODE=$(./chrispl-run --plugin name=pl-mri10yr06mo01da_normal --onCUBE "$CUBE" | awk '{print $3}')

or with some formatting:

ROOTNODE=$(
    chrispl-run --plugin name=pl-mri10yr06mo01da_normal     \
                --onCUBE="$CUBE"                            |
                     awk '{print $3}'
)

Run a DS plugin, pl-freesurfer_pp, that builds on the previous node

In this manner, a workflow can be constructed. First construct the arguments for the next plugin:

ARGS="                              \
--ageSpec=10-06-01;                 \
--copySpec=sag,cor,tra,stats,3D;    \
--previous_id=$ROOTNODE             \
"

and now schedule the run:

chrispl-run --plugin name="pl-freesurfer_pp"    \
            --args="$ARGS"                      \
            --onCUBE="$CUBE"

which will return:

(name=pl-freesurfer_pp)        id 19

As before, this can be captured and used for subsequent chaining:

FSNODE=$(
    chrispl-run --plugin name=pl-freesurfer_pp  \
                --args="$ARGS"                  \
                --onCUBE="$CUBE"                |
                     awk '{print $3}'
)

Additional Reading

Consult the ChRIS_docs workflow directory for examples of workflows built using these tools.

-30-

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-chrisclient-2.2.6.tar.gz (24.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page