# Running CLI modules on a remote server

**URL:** <https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328>\
**Category:** Development\
**Created:** [May 16, 2017, 5:44pm UTC](https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328 "2017-05-16T17:44:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirclem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mirclem/32/3356_2.png) [@mirclem](https://discourse.slicer.org/u/mirclem)\
**Post date:** [May 16, 2017, 5:44pm UTC](https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328/1 "2017-05-16T17:44:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 16, 2017, 6:14pm UTC](https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328/2 "2017-05-16T18:14:00Z")

</div>

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](https://www.na-mic.org/Wiki/index.php/2013_Project_Week:Slicer_Personal_Cloud) did something similar. See more information about it on [this page](https://www.slicer.org/wiki/Developer_Meetings/20130212) (_regarding remote execution of modules_). Probably @pieper and/or Jim Miller (GE Corporate Research) can give you more details.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [May 16, 2017, 9:18pm UTC](https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328/3 "2017-05-16T21:18:16Z")

</div>

Hi Clement,

If you would like to execute CLI remotely, you could have a look at [https://github.com/girder/slicer\_cli\_web](https://github.com/girder/slicer_cli_web)

The easiest would be to ask your questions on [https://gitter.im/girder/girder](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

---

<div class="post-metadata">

**Author:** ![cdeepakroy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cdeepakroy/32/196_2.png) [@cdeepakroy](https://discourse.slicer.org/u/cdeepakroy)\
**Post date:** [May 16, 2017, 9:36pm UTC](https://discourse.slicer.org/t/running-cli-modules-on-a-remote-server/328/4 "2017-05-16T21:36:12Z")

</div>

Adding onto what @jcfr said, take a look at this repo – [https://github.com/cdeepakroy/slicer\_cli\_web\_plugin](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](https://github.com/cdeepakroy/slicer_cli_web_plugin/blob/master/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](http://girder.readthedocs.io/en/latest/plugins.html#automatic-configuration-of-item-tasks-via-docker) of girder.
