Running CLI modules on a remote server

I developed a tool to get all the CLI modules loaded into a local Slicer, use them as you were used to. But, when you click on apply it generates the command, saves it in a json file and uploads the json file to a database.
Then, a remote Slicer has a connection with the database, it checks if there is a command in the database, runs it remotely and then uploads back the outputs.

Thanks to the nice documentation and people here on Discourse, I have been able to parse CLI node parameters, get their values (nodes) and run some CLIs remotely.
The only exception I have is about colormaps. When I generate the CLI command in the local Slicer, the colormap parameter is empty and so the remote Slicer returns an error with missing parameter.

Slicer does some processing before running a CLI: export data to files, resolve dependencies (such as colormaps); and after running a CLI (displays results, applies a referenced transform, etc). I would suggest to intercept the CLI execution at a lower level so that you don’t have to reimplement all these pre/post CLI actions.

Slicer personal cloud did something similar. See more information about it on this page (regarding remote execution of modules). Probably @pieper and/or Jim Miller (GE Corporate Research) can give you more details.

1 Like

Hi Clement,

If you would like to execute CLI remotely, you could have a look at https://github.com/girder/slicer_cli_web

The easiest would be to ask your questions on https://gitter.im/girder/girder

In a nutshell, it provides infrastructure to execute your CLI available in docker containers:

  • Input and results are automatically downloaded/uploaded from a girder instance
  • API endpoint to allow remote execution are generated for each CLI
  • WebUI is also generated for you based on the XML description
  • Both Cpp and Python based CLIs are supported
  • Execution is distributed to available worker nodes. Note that database, webserver and worker nodes can all “live” on the same server
1 Like

Adding onto what @jcfr said, take a look at this repo – https://github.com/cdeepakroy/slicer_cli_web_plugin – that demonstrates how to package a bunch of slicer CLIs to be accessed over the web through slicer_cli_web.

It contains one python and one c++ sample CLI (see Applications folder). Developers need to write a slicer_cli_list.json (see Applications folder) file listing the CLIs to be exposed and write the Dockerfile with commands to install/build all pre-requisites and libraries needed by the CLIs.

All the functionality within slicer_cli_web is being integrated into the item tasks plugin of girder.

1 Like