View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002039 | Slicer4 | Core: CLI infrastructure | public | 2012-05-14 12:59 | 2017-06-07 23:27 |
Reporter | domibel | Assigned To | jcfr | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | |||||
Target Version | Slicer 4.3.0 | Fixed in Version | Slicer 4.3.0 | ||
Summary | 0002039: Support self-describing CLI | ||||
Description | Implementing CLIs in python is not supported. From Dominique - May 14, 2010: I am trying to implement a CLI module for Slicer4 written in python. Here is a minimalistic example: $ cat ~/Slicer4-SuperBuild-Debug/Slicer-build/lib/Slicer-4.1/cli-modules/minicli.py print '<?xml version="1.0" encoding="utf-8"?>' It always fails with: $ ./Slicer | ||||
Tags | No tags attached. | ||||
Within Slicer, the associated XML used to be displayed using "print" statement. In Slicer4, instead we should probably keep the description of such module in its own separate XML file and assume its available in the same directory. This will be consistent with how module data are specified. |
|
Please support self-describing CLIs e.g.
will returns a valid xml document which defines how to call the CLI. |
|
+1 to the request to preserve self-describing CLI modules written in any language. It is klunky to require a second .xml file IMO. |
|
Just to clarify, there are two concepts here: The intent of this issue (0002039) is to address "self-describing" module. Best practice could be discussed independently :) |
|
Hi Dominique - I took a look - I think the reason this didn't work for you is that slicer4 is looking at the .py extension and trying to load this as a scripted module. Removing the extension and fixing up the xml results in a python script that looks to slicer like a cli. I'll put more notes in the bug report. Best, |
|
2012-05-15 09:46
|
|
If you make the attached file 'mini' executable and put it in the module path then slicer will recognize it as a cli. I made this with something like: ./lib/Slicer4.1/CLIModuleTest --xml > mini and then editing the result to be a python script (I may have the name of the source module wrong). To make this work on windows we should be able to pick another extension, say .cli, and bind that to be opened with the python interpreter but I have not tried that -- I'm guessing that Dominique's use case is on Debian anyway ;) |
|
Thanks, but this didn't work on my side. Can you send me your working 'mini' script. Here is what I did: ./lib/Slicer-4.1/cli-modules/CLIModule4Test --xml > mini Error output is Error(s):
Fail to instantiate module "mini" |
|
Hi Dominique - See the file 'mini' attached to this report - sorry I wasn't clear about that. -Steve |
|
2012-05-16 05:20
|
|
Ah - I see now I attached your original file as 'mini'. See the newly attached file 'minicli' for a corrected version. |
|
Hi Steve, I tried this again with your example, but I am still getting the same error. Are you able to load your example cli into Slicer4? Where in the module list does it appear? We have to be careful with that example, there is another 'Add Scalar Volumes' module with the same name in the list. But even after changing the name the new module doesn't show up in the module list. -Dominique |
|
Hi Dominique - Yes, it works for me - did you put the file in the cli-modules directory? It's acting as an executable not as a script. You'll know when it's loaded because it defines a custom category: <category>PYTHON TEST CLI</category> You can also try the --verbose-module-discovery option to see what's going on with it. -Steve |
|
This is what I get: ./Slicer-build/Slicer --verbose-module-discovery [...]
Fail to instantiate module "minicli" This is similar to http://na-mic.org/Bug/view.php?id=1848 I used Ubuntu 12.04 for this test. I guess I have to switch to a different version. What is considered as Slicer's reference OS? |
|
Hi Dominique - Can you run minicli at a regular terminal? I believe it should be using standard python startup conventions. It runs fine on my ubuntu 10.10 machine (although I understand that I'm a dinosaur for still running that version). -Steve |
|
Hi Steve, minicli's permissions are set to 755. I will try to test it on Debian testing and on Ubuntu 10.04 (and maybe 10.10) over the weekend. Thanks |
|
Add support for CLI having ".bat" extension. |
|
Thanks for adding the note Jc - you are too fast for me :) Also note that with this extra output helps with debugging modules: http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21663 |
|
The following process worked for me to make a python cli that works on both windows and mac - this could used for developers who want to make a python wrapper around their matlab code. First, I made a .bat file run the python with the following contents: "c:\Program Files\Slicer 4.2.0-2012-11-30\Slicer.exe" --no-main-window --disable-cli-modules --disable-loadable-modules --disable-scripted-modules --python-script minicli Remarks: Then I made the actual python script (minicli in this case) be executable (chmod a+x minicli) so it will be runable on linux/mac, but without the .py extension so it won't be treated as a loadable scripted module. For now, this just exits, but it could parse the passed arguments and invoke matlab with them. The contents of minicli are: #!/usr/bin/env python print(xml) |
|
A solution is available now, so the issue can be closed. See details below. I confirm that the solution suggested above (0007815) works most of the time. When it fails it is due to the slow starting of Slicer.exe and the 5sec timeout in the CLI engine. I ended up using a .bat file to return the xml file contents immediately: @set MODULE_NAME=test Similar launcher can be used on linux/mac (this script has not been tested): #!/bin/sh If this proxy is called with the --xml parameter then just return the module decriptor XML file,otherwise run the associated module script.MODULE_NAME="test" |
|
Closing resolved issues that have not been updated in more than 3 months |
|
Slicer: 2145-support-for-installing-extension-from-file 705aee4f 2013-02-04 17:16:23 Details Diff |
ENH: allow .bat files to be used as command line modules (issue 0002039) This way people can write simple wrapper scripts on windows for other executable types, such as matlab scripts. git-svn-id: http://svn.slicer.org/Slicer4/trunk@21662 3bd1e089-480b-0410-8dfb-8563597acbee |
||
mod - Base/QTCore/qSlicerUtils.cxx | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-05-14 12:59 | jcfr | New Issue | |
2012-05-14 12:59 | jcfr | Reporter | jcfr => domibel |
2012-05-14 12:59 | jcfr | Description Updated | |
2012-05-14 12:59 | jcfr | Note Added: 0004383 | |
2012-05-14 13:00 | jcfr | Description Updated | |
2012-05-14 13:01 | jcfr | Note Edited: 0004383 | |
2012-05-14 15:21 | domibel | Note Added: 0004385 | |
2012-05-14 15:51 | jcfr | Assigned To | => jcfr |
2012-05-14 15:51 | jcfr | Status | new => assigned |
2012-05-14 15:51 | jcfr | Summary | Support scripted CLI => Support self-describing CLI |
2012-05-14 15:52 | jcfr | Target Version | => Slicer 4.3.0 |
2012-05-15 03:48 | pieper | Note Added: 0004392 | |
2012-05-15 03:58 | jcfr | Note Added: 0004393 | |
2012-05-15 09:46 | pieper | Note Added: 0004403 | |
2012-05-15 09:46 | pieper | File Added: mini | |
2012-05-15 09:49 | pieper | Note Added: 0004404 | |
2012-05-15 16:12 | domibel | Note Added: 0004424 | |
2012-05-16 05:05 | pieper | Note Added: 0004431 | |
2012-05-16 05:20 | pieper | File Added: minicli | |
2012-05-16 05:20 | pieper | Note Added: 0004432 | |
2012-05-16 19:56 | domibel | Note Added: 0004449 | |
2012-05-17 02:38 | pieper | Note Added: 0004450 | |
2012-05-18 19:30 | domibel | Note Added: 0004507 | |
2012-05-18 19:46 | pieper | Note Added: 0004508 | |
2012-05-18 19:52 | domibel | Note Added: 0004509 | |
2013-02-04 12:28 | jcfr | Note Added: 0007813 | |
2013-02-04 12:29 | jcfr | Note Edited: 0007813 | |
2013-02-04 13:17 | pieper | Note Added: 0007814 | |
2013-02-04 13:24 | pieper | Note Added: 0007815 | |
2013-02-04 13:39 | jcfr | Note Edited: 0007815 | |
2013-02-04 13:40 | jcfr | Note Edited: 0007815 | |
2013-02-04 13:41 | jcfr | Note Edited: 0007815 | |
2013-02-04 13:45 | jcfr | Note Edited: 0007815 | |
2013-06-27 07:34 | lassoan | Note Added: 0008812 | |
2013-06-27 07:34 | lassoan | Status | assigned => resolved |
2013-06-27 07:34 | lassoan | Resolution | open => fixed |
2013-07-23 21:02 | jcfr | Fixed in Version | => Slicer 4.3.0 |
2014-03-06 04:56 | jcfr | Note Added: 0010815 | |
2014-03-06 04:58 | jcfr | Status | resolved => closed |
2017-06-07 23:27 | pieper | Changeset attached | => Slicer 2145-support-for-installing-extension-from-file 705aee4f |